| 153 | //----------------------------------------------------------------------------- |
| 154 | |
| 155 | void MurmurHash3_x86_128 ( const void * key, const int len, |
| 156 | uint32_t seed, void * out ) |
| 157 | { |
| 158 | const uint8_t * data = (const uint8_t*)key; |
| 159 | const int nblocks = len / 16; |
| 160 | |
| 161 | uint32_t h1 = seed; |
| 162 | uint32_t h2 = seed; |
| 163 | uint32_t h3 = seed; |
| 164 | uint32_t h4 = seed; |
| 165 | |
| 166 | const uint32_t c1 = 0x239b961b; |
| 167 | const uint32_t c2 = 0xab0e9789; |
| 168 | const uint32_t c3 = 0x38b34ae5; |
| 169 | const uint32_t c4 = 0xa1e38b93; |
| 170 | |
| 171 | //---------- |
| 172 | // body |
| 173 | |
| 174 | const uint32_t * blocks = (const uint32_t *)(data + nblocks*16); |
| 175 | |
| 176 | for(int i = -nblocks; i; i++) |
| 177 | { |
| 178 | uint32_t k1 = getblock(blocks,i*4+0); |
| 179 | uint32_t k2 = getblock(blocks,i*4+1); |
| 180 | uint32_t k3 = getblock(blocks,i*4+2); |
| 181 | uint32_t k4 = getblock(blocks,i*4+3); |
| 182 | |
| 183 | k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1; |
| 184 | |
| 185 | h1 = ROTL32(h1,19); h1 += h2; h1 = h1*5+0x561ccd1b; |
| 186 | |
| 187 | k2 *= c2; k2 = ROTL32(k2,16); k2 *= c3; h2 ^= k2; |
| 188 | |
| 189 | h2 = ROTL32(h2,17); h2 += h3; h2 = h2*5+0x0bcaa747; |
| 190 | |
| 191 | k3 *= c3; k3 = ROTL32(k3,17); k3 *= c4; h3 ^= k3; |
| 192 | |
| 193 | h3 = ROTL32(h3,15); h3 += h4; h3 = h3*5+0x96cd1c35; |
| 194 | |
| 195 | k4 *= c4; k4 = ROTL32(k4,18); k4 *= c1; h4 ^= k4; |
| 196 | |
| 197 | h4 = ROTL32(h4,13); h4 += h1; h4 = h4*5+0x32ac3b17; |
| 198 | } |
| 199 | |
| 200 | //---------- |
| 201 | // tail |
| 202 | |
| 203 | const uint8_t * tail = (const uint8_t*)(data + nblocks*16); |
| 204 | |
| 205 | uint32_t k1 = 0; |
| 206 | uint32_t k2 = 0; |
| 207 | uint32_t k3 = 0; |
| 208 | uint32_t k4 = 0; |
| 209 | |
| 210 | switch(len & 15) |
| 211 | { |
| 212 | case 15: k4 ^= tail[14] << 16; |
nothing calls this directly
no test coverage detected