util: move fnv1a hash implementation into its own header
[mesa.git] / src / util / hash_table.h
index 87b1409c4574b0a6b790131767400864e405501d..e2cd889f6da59f86a042b07d247951dd72711f63 100644 (file)
@@ -32,6 +32,7 @@
 #include <inttypes.h>
 #include <stdbool.h>
 #include "c99_compat.h"
+#include "fnv1a.h"
 #include "macros.h"
 
 #ifdef __cplusplus
@@ -126,27 +127,6 @@ static inline uint32_t _mesa_hash_pointer(const void *pointer)
 struct hash_table *
 _mesa_pointer_hash_table_create(void *mem_ctx);
 
-enum {
-   _mesa_fnv32_1a_offset_bias = 2166136261u,
-};
-
-static inline uint32_t
-_mesa_fnv32_1a_accumulate_block(uint32_t hash, const void *data, size_t size)
-{
-   const uint8_t *bytes = (const uint8_t *)data;
-
-   while (size-- != 0) {
-      hash ^= *bytes;
-      hash = hash * 0x01000193;
-      bytes++;
-   }
-
-   return hash;
-}
-
-#define _mesa_fnv32_1a_accumulate(hash, expr) \
-   _mesa_fnv32_1a_accumulate_block(hash, &(expr), sizeof(expr))
-
 /**
  * This foreach function is safe against deletion (which just replaces
  * an entry's data with the deleted marker), but not against insertion