7#pragma clang attribute push( \
8 __attribute__((no_sanitize("integer"))), apply_to = function)
15static constexpr inline uint32_t rotl32(uint32_t x, int8_t r)
noexcept
17 return (x << r) | (x >> (32 - r));
20static constexpr inline uint64_t rotl64(uint64_t x, int8_t r)
noexcept
22 return (x << r) | (x >> (64 - r));
27static constexpr inline uint32_t fmix32(uint32_t h)
noexcept
40static constexpr inline uint64_t fmix64(uint64_t k)
noexcept
43 k *= 0xff51afd7ed558ccdULL;
45 k *= 0xc4ceb9fe1a85ec53ULL;
55 __attribute__((no_sanitize(
"undefined")))
58 murmur3_x86_32(
const void* key,
int len, uint32_t seed, uint32_t& out)
noexcept
60 const uint8_t* data = (
const uint8_t*)key;
61 const int nblocks = len / 4;
65 uint32_t c1 = 0xcc9e2d51;
66 uint32_t c2 = 0x1b873593;
71 const uint32_t* blocks = (
const uint32_t*)(data + nblocks * 4);
73 for(
int i = -nblocks; i; i++)
75 uint32_t k1 = blocks[i];
83 h1 = h1 * 5 + 0xe6546b64;
89 const uint8_t* tail = (
const uint8_t*)(data + nblocks * 4);
121constexpr void murmur3_x86_128(
122 const void* key,
const int len, uint32_t seed, uint32_t (&out)[4])
noexcept
124 const uint8_t* data = (
const uint8_t*)key;
125 const int nblocks = len / 16;
132 uint32_t c1 = 0x239b961b;
133 uint32_t c2 = 0xab0e9789;
134 uint32_t c3 = 0x38b34ae5;
135 uint32_t c4 = 0xa1e38b93;
140 const uint32_t* blocks = (
const uint32_t*)(data + nblocks * 16);
142 for(
int i = -nblocks; i; i++)
144 uint32_t k1 = blocks[i * 4 + 0];
145 uint32_t k2 = blocks[i * 4 + 1];
146 uint32_t k3 = blocks[i * 4 + 2];
147 uint32_t k4 = blocks[i * 4 + 3];
156 h1 = h1 * 5 + 0x561ccd1b;
165 h2 = h2 * 5 + 0x0bcaa747;
174 h3 = h3 * 5 + 0x96cd1c35;
183 h4 = h4 * 5 + 0x32ac3b17;
189 const uint8_t* tail = (
const uint8_t*)(data + nblocks * 16);
199 k4 ^= tail[14] << 16;
210 k3 ^= tail[11] << 24;
212 k3 ^= tail[10] << 16;
284constexpr void murmur3_x64_128(
285 const void* key,
const int len,
const uint32_t seed, uint64_t (&out)[2])
noexcept
287 const uint8_t* data = (
const uint8_t*)key;
288 const int nblocks = len / 16;
293 uint64_t c1 = 0x87c37b91114253d5ULL;
294 uint64_t c2 = 0x4cf5ad432745937fULL;
299 const uint64_t* blocks = (
const uint64_t*)(data);
301 for(
int i = 0; i < nblocks; i++)
303 uint64_t k1 = blocks[i * 2 + 0];
304 uint64_t k2 = blocks[i * 2 + 1];
313 h1 = h1 * 5 + 0x52dce729;
322 h2 = h2 * 5 + 0x38495ab5;
328 const uint8_t* tail = (
const uint8_t*)(data + nblocks * 16);
336 k2 ^= (uint64_t)(tail[14]) << 48;
338 k2 ^= (uint64_t)(tail[13]) << 40;
340 k2 ^= (uint64_t)(tail[12]) << 32;
342 k2 ^= (uint64_t)(tail[11]) << 24;
344 k2 ^= (uint64_t)(tail[10]) << 16;
346 k2 ^= (uint64_t)(tail[9]) << 8;
348 k2 ^= (uint64_t)(tail[8]) << 0;
355 k1 ^= (uint64_t)(tail[7]) << 56;
357 k1 ^= (uint64_t)(tail[6]) << 48;
359 k1 ^= (uint64_t)(tail[5]) << 40;
361 k1 ^= (uint64_t)(tail[4]) << 32;
363 k1 ^= (uint64_t)(tail[3]) << 24;
365 k1 ^= (uint64_t)(tail[2]) << 16;
367 k1 ^= (uint64_t)(tail[1]) << 8;
369 k1 ^= (uint64_t)(tail[0]) << 0;
397#pragma clang attribute pop