summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-01-15 00:25:13 -0800
committerOri Bernstein <ori@eigenstate.org>2017-01-15 00:25:13 -0800
commit0893bfe6bde2b9498a32354894b003adc13a9ea9 (patch)
tree698b857da3be2cf802b147f9deb60d1060cc57de /util
parent4078198dee11c72b6e735e704d21a2c0f39cb575 (diff)
downloadmc-0893bfe6bde2b9498a32354894b003adc13a9ea9.tar.gz
Back to a 9front C subset.
Diffstat (limited to 'util')
-rw-r--r--util/bitset.c5
-rw-r--r--util/htab.c6
2 files changed, 8 insertions, 3 deletions
diff --git a/util/bitset.c b/util/bitset.c
index 31049bf..c69269a 100644
--- a/util/bitset.c
+++ b/util/bitset.c
@@ -109,6 +109,9 @@ size_t bscount(Bitset *bs)
inline static int firstbit(size_t b)
{
int n;
+ static const char bits[] = {
+ 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0
+ };
n = 0;
if (!(b & 0xffffffff)) {
@@ -127,7 +130,7 @@ inline static int firstbit(size_t b)
n += 4;
b >>= 4;
}
- n += (char[16]){4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0}[b & 0xf];
+ n += bits[b & 0xf];
return n;
}
diff --git a/util/htab.c b/util/htab.c
index e9bc15f..60571d7 100644
--- a/util/htab.c
+++ b/util/htab.c
@@ -279,11 +279,13 @@ ulong murmurhash2 (void *ptr, size_t len)
uint32_t m = 0x5bd1e995;
uint32_t r = 24;
uint32_t h, k, n;
- uint8_t *p;
+ uint8_t *p, *end;
h = Seed ^ len;
n = len & ~0x3ull;
- for (p = ptr; p != ptr + n; p += 4) {
+ end = ptr;
+ end += n;
+ for (p = ptr; p != end; p += 4) {
k = (p[0] << 0) |
(p[1] << 8) |
(p[2] << 16) |