summaryrefslogtreecommitdiff
path: root/libstd/bitset.myr
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2014-01-27 18:46:07 -0500
committerOri Bernstein <ori@eigenstate.org>2014-01-27 18:46:07 -0500
commitaa7e3e0a6facd876fea2235ccb6f1ee27e016d3a (patch)
tree5a83c1a1df81adbf31483b0f32b4b11c6e298583 /libstd/bitset.myr
parentb0b5a28b5fe1346d7957786b505219e2a0e28a4e (diff)
downloadmc-aa7e3e0a6facd876fea2235ccb6f1ee27e016d3a.tar.gz
Add missing symbols to bitset.
Diffstat (limited to 'libstd/bitset.myr')
-rw-r--r--libstd/bitset.myr24
1 files changed, 14 insertions, 10 deletions
diff --git a/libstd/bitset.myr b/libstd/bitset.myr
index 92ad648..fb7033e 100644
--- a/libstd/bitset.myr
+++ b/libstd/bitset.myr
@@ -1,7 +1,8 @@
use "alloc.use"
+use "extremum.use"
use "mk.use"
+use "slfill.use"
use "types.use"
-use "extremum.use"
pkg std =
type bitset = struct
@@ -27,8 +28,6 @@ pkg std =
const bsiter : (bs : bitset# -> bitset#)
;;
-const Szbits = 8*sizeof(size)
-
const mkbitset = {
-> zalloc()
}
@@ -42,12 +41,17 @@ const bsfree = {bs
free(bs)
}
+const bsclear = {bs
+ slfill(bs.bits, 0)
+ -> bs
+}
+
generic bsput = {bs, v
var idx
var off
- idx = (v castto(size)) / Szbits
- off = (v castto(size)) % Szbits
+ idx = (v castto(size)) / (8*sizeof(size))
+ off = (v castto(size)) % (8*sizeof(size))
ensurespace(bs, idx)
bs.bits[idx] |= (1 << off)
}
@@ -56,8 +60,8 @@ generic bsdel = {bs, v
var idx
var off
- idx = (v castto(size)) / Szbits
- off = (v castto(size)) % Szbits
+ idx = (v castto(size)) / (8*sizeof(size))
+ off = (v castto(size)) % (8*sizeof(size))
ensurespace(bs, idx)
bs.bits[idx] &= ~(1 << off)
}
@@ -66,8 +70,8 @@ generic bshas = {bs, v
var idx
var off
- idx = (v castto(size)) / Szbits
- off = (v castto(size)) % Szbits
+ idx = (v castto(size)) / (8*sizeof(size))
+ off = (v castto(size)) % (8*sizeof(size))
ensurespace(bs, idx)
-> (bs.bits[idx] & (1 << off)) != 0
}
@@ -124,7 +128,7 @@ const bseq = {a, b
}
const ensurespace = {bs, v
- if bs.bits.len*Szbits <= v
+ if bs.bits.len*(8*sizeof(size)) <= v
bs.bits = slzgrow(bs.bits, v + 1)
;;
}