aboutsummaryrefslogtreecommitdiffstats
path: root/lib/hash.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/hash.h')
-rw-r--r--lib/hash.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/hash.h b/lib/hash.h
index 8febb33f..3c173958 100644
--- a/lib/hash.h
+++ b/lib/hash.h
@@ -216,6 +216,14 @@ mem_hash_mix(u64 *h, const void *p, uint s)
}
static inline void
+mem_hash_mix_str(u64 *h, const char *s)
+{
+ const u64 multiplier = 0xb38bc09a61202731ULL;
+ while (s)
+ *h = *h * multiplier + *s++;
+}
+
+static inline void
mem_hash_mix_num(u64 *h, u64 val)
{
mem_hash_mix(h, &val, sizeof(val));
@@ -237,7 +245,7 @@ mem_hash(const void *p, uint s)
}
static inline uint
-ptr_hash(void *ptr)
+ptr_hash(const void *ptr)
{
uintptr_t p = (uintptr_t) ptr;
return p ^ (p << 8) ^ (p >> 16);