summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-07-15 00:36:08 -0700
committerOri Bernstein <ori@eigenstate.org>2017-07-15 00:36:42 -0700
commit357f87c1117edfdf77411781ebfae221a406c454 (patch)
tree5e70ba66596b8ee13ceb46e2c9268fe12101f17a /util
parent15b5fb5c0f9fee25b01a245229efcef21c103bdc (diff)
downloadmc-357f87c1117edfdf77411781ebfae221a406c454.tar.gz
Type binding refactoring now compiles.
Still a bit sloppy on a few things, needs some dedup work, but it's working.
Diffstat (limited to 'util')
-rw-r--r--util/bitset.c9
-rw-r--r--util/htab.c4
-rw-r--r--util/util.h2
3 files changed, 12 insertions, 3 deletions
diff --git a/util/bitset.c b/util/bitset.c
index 6aa9344..6109f9e 100644
--- a/util/bitset.c
+++ b/util/bitset.c
@@ -225,6 +225,15 @@ bsintersect(Bitset *a, Bitset *b)
a->chunks[i] &= b->chunks[i];
}
+ulong
+bshash(Bitset *bs)
+{
+ if (!bs)
+ return 14247517;
+ else
+ return murmurhash2(bs->chunks, bs->nchunks * sizeof(size_t));
+}
+
void
bsdiff(Bitset *a, Bitset *b)
{
diff --git a/util/htab.c b/util/htab.c
index 8894579..7ba6291 100644
--- a/util/htab.c
+++ b/util/htab.c
@@ -11,8 +11,6 @@
#define Initsz 16
#define Seed 2928213749
-static ulong murmurhash2(void *key, size_t len);
-
/* Creates a new empty hash table, using 'hash' as the
* hash funciton, and 'cmp' to verify that there are no
* hash collisions. */
@@ -294,7 +292,7 @@ ptreq(void *a, void *b)
return a == b;
}
-static ulong
+ulong
murmurhash2 (void *ptr, size_t len)
{
uint32_t m = 0x5bd1e995;
diff --git a/util/util.h b/util/util.h
index 49f10d6..be09dfc 100644
--- a/util/util.h
+++ b/util/util.h
@@ -67,6 +67,7 @@ void sbputs(Strbuf *sb, char *s);
void sbputb(Strbuf *sb, char b);
/* bit sets */
+ulong bshash(Bitset *bs);
Bitset *mkbs(void);
void bsfree(Bitset *bs);
Bitset *bsdup(Bitset *bs);
@@ -113,6 +114,7 @@ ulong ptrhash(void *key);
int ptreq(void *a, void *b);
ulong inthash(uint64_t key);
int inteq(uint64_t a, uint64_t b);
+ulong murmurhash2(void *buf, size_t sz);
/* util functions */
void *zalloc(size_t size);