5a70b84cb66fb8c7a3fce0e3f2e4b61e0b2ea9d4Simo Sorce/* This file is based on the public domain MurmurHash3 from Austin Appleby:
5a70b84cb66fb8c7a3fce0e3f2e4b61e0b2ea9d4Simo Sorce * http://code.google.com/p/smhasher/source/browse/trunk/MurmurHash3.cpp
5a70b84cb66fb8c7a3fce0e3f2e4b61e0b2ea9d4Simo Sorce * We use only the 32 bit variant because the 2 produce different result while
5a70b84cb66fb8c7a3fce0e3f2e4b61e0b2ea9d4Simo Sorce * we need to produce the same result regardless of the architecture as
5a70b84cb66fb8c7a3fce0e3f2e4b61e0b2ea9d4Simo Sorce * clients can be both 64 or 32 bit at the same time.
5a70b84cb66fb8c7a3fce0e3f2e4b61e0b2ea9d4Simo Sorce return (x << r) | (x >> (32 - r));
5a70b84cb66fb8c7a3fce0e3f2e4b61e0b2ea9d4Simo Sorce/* slower than original but is endian neutral and handles platforms that
5a70b84cb66fb8c7a3fce0e3f2e4b61e0b2ea9d4Simo Sorce * do only aligned reads */
f34e96625d745c8fd13bf31107e0c66f1fbf1a65Stephen Gallagherstatic inline uint32_t getblock(const uint8_t *p, int i)
5a70b84cb66fb8c7a3fce0e3f2e4b61e0b2ea9d4Simo Sorce * Finalization mix - force all bits of a hash block to avalanche
5a70b84cb66fb8c7a3fce0e3f2e4b61e0b2ea9d4Simo Sorce h ^= h >> 16;
5a70b84cb66fb8c7a3fce0e3f2e4b61e0b2ea9d4Simo Sorce h *= 0x85ebca6b;
5a70b84cb66fb8c7a3fce0e3f2e4b61e0b2ea9d4Simo Sorce h ^= h >> 13;
5a70b84cb66fb8c7a3fce0e3f2e4b61e0b2ea9d4Simo Sorce h *= 0xc2b2ae35;
5a70b84cb66fb8c7a3fce0e3f2e4b61e0b2ea9d4Simo Sorce h ^= h >> 16;
5a70b84cb66fb8c7a3fce0e3f2e4b61e0b2ea9d4Simo Sorceuint32_t murmurhash3(const char *key, int len, uint32_t seed)
5a70b84cb66fb8c7a3fce0e3f2e4b61e0b2ea9d4Simo Sorce for (i = 0; i < nblocks; i++) {
5a70b84cb66fb8c7a3fce0e3f2e4b61e0b2ea9d4Simo Sorce /* finalization */