2 #include "../compiler/compiler.h"
4 static inline uint32_t rotl32(uint32_t x, int8_t r)
6 return (x << r) | (x >> (32 - r));
9 //-----------------------------------------------------------------------------
10 // Finalization mix - force all bits of a hash block to avalanche
12 static inline uint32_t fmix32(uint32_t h)
23 static uint32_t murmur3_tail(const uint8_t *data, const int nblocks,
24 uint32_t len, const uint32_t c1,
25 const uint32_t c2, uint32_t h1)
27 const uint8_t *tail = (const uint8_t *)(data + nblocks * 4);
45 return fmix32(h1 ^ len);
48 uint32_t murmurhash3(const void *key, uint32_t len, uint32_t seed)
50 const uint8_t *data = (const uint8_t *)key;
51 const int nblocks = len / 4;
53 const uint32_t c1 = 0xcc9e2d51;
54 const uint32_t c2 = 0x1b873593;
55 const uint32_t *blocks = (const uint32_t *)(data + nblocks * 4);
58 for (i = -nblocks; i; i++) {
59 uint32_t k1 = blocks[i];
67 h1 = h1 * 5 + 0xe6546b64;
70 return murmur3_tail(data, nblocks, len, c1, c2, h1);