3 static inline uint32_t rotl32(uint32_t x, int8_t r)
5 return (x << r) | (x >> (32 - r));
8 //-----------------------------------------------------------------------------
9 // Finalization mix - force all bits of a hash block to avalanche
11 static inline uint32_t fmix32(uint32_t h)
22 static uint32_t murmur3_tail(const uint8_t *data, const int nblocks,
23 uint32_t len, const uint32_t c1,
24 const uint32_t c2, uint32_t h1)
26 const uint8_t *tail = (const uint8_t *)(data + nblocks * 4);
42 return fmix32(h1 ^ len);
45 uint32_t murmurhash3(const void *key, uint32_t len, uint32_t seed)
47 const uint8_t *data = (const uint8_t *)key;
48 const int nblocks = len / 4;
50 const uint32_t c1 = 0xcc9e2d51;
51 const uint32_t c2 = 0x1b873593;
52 const uint32_t *blocks = (const uint32_t *)(data + nblocks * 4);
55 for (i = -nblocks; i; i++) {
56 uint32_t k1 = blocks[i];
64 h1 = h1 * 5 + 0xe6546b64;
67 return murmur3_tail(data, nblocks, len, c1, c2, h1);