Add Linux's math64.h
[akaros.git] / kern / src / hashtable.c
index 5f24cc0..1465f2a 100644 (file)
@@ -14,6 +14,8 @@
 #include <string.h>
 #include <slab.h>
 #include <kmalloc.h>
+#include <hash.h>
+#include <arch/types.h>
 
 /*
 Credit for primes table: Aaron Krowne
@@ -39,17 +41,16 @@ struct kmem_cache *hentry_cache;
 /* Call this once on bootup, after initializing the slab allocator.  */
 void hashtable_init(void)
 {
-       hentry_cache = kmem_cache_create("hash_entry", sizeof(struct hash_entry),
-                                        __alignof__(struct hash_entry), 0, 0, 0);
+       hentry_cache = kmem_cache_create("hash_entry",
+                                        sizeof(struct hash_entry),
+                                        __alignof__(struct hash_entry), 0,
+                                        NULL, 0, 0, NULL);
 }
 
 /* Common hash/equals functions.  Don't call these directly. */
 size_t __generic_hash(void *k)
 {
-       /* 0x9e370001UL used by Linux (32 bit)
-        * (prime approx to the golden ratio to the max integer, IAW Knuth)
-        */
-       return (size_t)k * 0x9e370001UL;
+       return hash_long((unsigned long)k, BITS_PER_LONG);
 }
 
 ssize_t __generic_eq(void *k1, void *k2)