summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/hashmap.c19
-rw-r--r--src/shared/hashmap.h3
2 files changed, 22 insertions, 0 deletions
diff --git a/src/shared/hashmap.c b/src/shared/hashmap.c
index ef78070f4c..dcfbb67228 100644
--- a/src/shared/hashmap.c
+++ b/src/shared/hashmap.c
@@ -147,6 +147,25 @@ int trivial_compare_func(const void *a, const void *b) {
return a < b ? -1 : (a > b ? 1 : 0);
}
+unsigned uint64_hash_func(const void *p) {
+ uint64_t u;
+
+ assert_cc(sizeof(uint64_t) == 2*sizeof(unsigned));
+
+ u = *(const uint64_t*) p;
+
+ return (unsigned) ((u >> 32) ^ u);
+}
+
+int uint64_compare_func(const void *_a, const void *_b) {
+ uint64_t a, b;
+
+ a = *(const uint64_t*) _a;
+ b = *(const uint64_t*) _b;
+
+ return a < b ? -1 : (a > b ? 1 : 0);
+}
+
Hashmap *hashmap_new(hash_func_t hash_func, compare_func_t compare_func) {
bool b;
Hashmap *h;
diff --git a/src/shared/hashmap.h b/src/shared/hashmap.h
index 55dea0a692..6fd71cf519 100644
--- a/src/shared/hashmap.h
+++ b/src/shared/hashmap.h
@@ -44,6 +44,9 @@ int string_compare_func(const void *a, const void *b);
unsigned trivial_hash_func(const void *p);
int trivial_compare_func(const void *a, const void *b);
+unsigned uint64_hash_func(const void *p);
+int uint64_compare_func(const void *a, const void *b);
+
Hashmap *hashmap_new(hash_func_t hash_func, compare_func_t compare_func);
void hashmap_free(Hashmap *h);
void hashmap_free_free(Hashmap *h);