return c;
}
+/* Returns the hash of the pair of aligned 32-bit words at 'p', starting from
+ * 'basis'. */
+uint32_t
+hash_2words(const uint32_t *p, uint32_t basis)
+{
+ uint32_t a, b, c;
+
+ a = b = c = 0xdeadbeef + (2 << 2) + basis;
+ b += p[1];
+ a += p[0];
+ HASH_FINAL(a, b, c);
+
+ return c;
+}
+
/* Returns the hash of the 'n' bytes at 'p', starting from 'basis'. */
uint32_t
hash_bytes(const void *p_, size_t n, uint32_t basis)
#include <stddef.h>
#include <stdint.h>
#include <string.h>
+#include "util.h"
/* This is the public domain lookup3 hash by Bob Jenkins from
* http://burtleburtle.net/bob/c/lookup3.c, modified for style. */
} while (0)
uint32_t hash_words(const uint32_t *, size_t n_word, uint32_t basis);
+uint32_t hash_2words(const uint32_t *, uint32_t basis);
uint32_t hash_bytes(const void *, size_t n_bytes, uint32_t basis);
static inline uint32_t hash_string(const char *s, uint32_t basis)
return x + basis;
}
+static inline uint32_t hash_double(double x, uint32_t basis)
+{
+ BUILD_ASSERT_DECL(sizeof x == 8);
+ return hash_2words((const uint32_t *) &x, basis);
+}
+
static inline uint32_t hash_pointer(const void *p, uint32_t basis)
{
/* Often pointers are hashed simply by casting to integer type, but that