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);
44 return fmix32(h1 ^ len);
47 uint32_t murmurhash3(const void *key, uint32_t len, uint32_t seed)
49 const uint8_t *data = (const uint8_t *)key;
50 const int nblocks = len / 4;
52 const uint32_t c1 = 0xcc9e2d51;
53 const uint32_t c2 = 0x1b873593;
54 const uint32_t *blocks = (const uint32_t *)(data + nblocks * 4);
57 for (i = -nblocks; i; i++) {
58 uint32_t k1 = blocks[i];
66 h1 = h1 * 5 + 0xe6546b64;
69 return murmur3_tail(data, nblocks, len, c1, c2, h1);