add isl_hash_builtin
authorSven Verdoolaege <skimo@kotnet.org>
Sun, 4 Jul 2010 19:28:03 +0000 (21:28 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Sun, 4 Jul 2010 19:28:03 +0000 (21:28 +0200)
include/isl_hash.h
isl_hash.c

index 3c5ea3c..66c6c79 100644 (file)
@@ -10,6 +10,7 @@
 #ifndef ISL_HASH_H
 #define ISL_HASH_H
 
+#include <stdlib.h>
 #include <isl_stdint.h>
 
 #if defined(__cplusplus)
@@ -35,6 +36,9 @@ extern "C" {
              (((h) >> (bits)) ^ (h)) & (((uint32_t)1 << (bits)) - 1)
 
 uint32_t isl_hash_string(uint32_t hash, const char *s);
+uint32_t isl_hash_mem(uint32_t hash, const void *p, size_t len);
+
+#define isl_hash_builtin(h,l)  isl_hash_mem(h, &l, sizeof(l))
 
 struct isl_hash_table_entry
 {
index 15df05a..4f7e492 100644 (file)
@@ -18,6 +18,15 @@ uint32_t isl_hash_string(uint32_t hash, const char *s)
        return hash;
 }
 
+uint32_t isl_hash_mem(uint32_t hash, const void *p, size_t len)
+{
+       int i;
+       const char *s = p;
+       for (i = 0; i < len; ++i)
+               isl_hash_byte(hash, s[i]);
+       return hash;
+}
+
 static unsigned int round_up(unsigned int v)
 {
        int old_v = v;