| 97 | //----------------------------------------------------------------------------- |
| 98 | |
| 99 | void MurmurHash3_x86_32 ( const void * key, int len, |
| 100 | uint32_t seed, void * out ) |
| 101 | { |
| 102 | const uint8_t * data = (const uint8_t*)key; |
| 103 | const int nblocks = len / 4; |
| 104 | |
| 105 | uint32_t h1 = seed; |
| 106 | |
| 107 | const uint32_t c1 = 0xcc9e2d51; |
| 108 | const uint32_t c2 = 0x1b873593; |
| 109 | |
| 110 | //---------- |
| 111 | // body |
| 112 | |
| 113 | const uint32_t * blocks = (const uint32_t *)(data + nblocks*4); |
| 114 | |
| 115 | for(int i = -nblocks; i; i++) |
| 116 | { |
| 117 | uint32_t k1 = getblock(blocks,i); |
| 118 | |
| 119 | k1 *= c1; |
| 120 | k1 = ROTL32(k1,15); |
| 121 | k1 *= c2; |
| 122 | |
| 123 | h1 ^= k1; |
| 124 | h1 = ROTL32(h1,13); |
| 125 | h1 = h1*5+0xe6546b64; |
| 126 | } |
| 127 | |
| 128 | //---------- |
| 129 | // tail |
| 130 | |
| 131 | const uint8_t * tail = (const uint8_t*)(data + nblocks*4); |
| 132 | |
| 133 | uint32_t k1 = 0; |
| 134 | |
| 135 | switch(len & 3) |
| 136 | { |
| 137 | case 3: k1 ^= tail[2] << 16; |
| 138 | case 2: k1 ^= tail[1] << 8; |
| 139 | case 1: k1 ^= tail[0]; |
| 140 | k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1; |
| 141 | }; |
| 142 | |
| 143 | //---------- |
| 144 | // finalization |
| 145 | |
| 146 | h1 ^= len; |
| 147 | |
| 148 | h1 = fmix(h1); |
| 149 | |
| 150 | *(uint32_t*)out = h1; |
| 151 | } |
| 152 | |
| 153 | //----------------------------------------------------------------------------- |
| 154 |
nothing calls this directly
no test coverage detected