35 #define bitRotateLeft(x, nBits) (((x) << (nBits)) | ((x) >> (32 - (nBits))))
115 #define bitMixer(a, b, c) \
117 a -= c; a ^= bitRotateLeft(c, 4); c += b; \
118 b -= a; b ^= bitRotateLeft(a, 6); a += c; \
119 c -= b; c ^= bitRotateLeft(b, 8); b += a; \
120 a -= c; a ^= bitRotateLeft(c,16); c += b; \
121 b -= a; b ^= bitRotateLeft(a,19); a += c; \
122 c -= b; c ^= bitRotateLeft(b, 4); b += a; \
150 #define bitMixerFinal(a, b, c) \
152 c ^= b; c -= bitRotateLeft(b, 14); \
153 a ^= c; a -= bitRotateLeft(c, 11); \
154 b ^= a; b -= bitRotateLeft(a, 25); \
155 c ^= b; c -= bitRotateLeft(b, 16); \
156 a ^= c; a -= bitRotateLeft(c, 4); \
157 b ^= a; b -= bitRotateLeft(a, 14); \
158 c ^= b; c -= bitRotateLeft(b, 24); \
190 #ifdef WM_LITTLE_ENDIAN
191 static unsigned jenkins_hashlittle
199 union {
const void *ptr;
size_t i; } u;
202 a =
b =
c = 0xdeadbeef +
static_cast<uint32_t
>(length) + initval;
205 if ((u.i & 0x3) == 0)
208 const uint32_t *
k =
reinterpret_cast<const uint32_t*
>(key);
222 const uint8_t *k8 =
reinterpret_cast<const uint8_t*
>(
k);
225 case 12:
c +=
k[2];
b +=
k[1]; a +=
k[0];
break;
226 case 11:
c +=
static_cast<uint32_t
>(k8[10]) << 16; [[fallthrough]];
227 case 10:
c +=
static_cast<uint32_t
>(k8[9]) << 8; [[fallthrough]];
228 case 9 :
c += k8[8]; [[fallthrough]];
229 case 8 :
b +=
k[1]; a +=
k[0];
break;
230 case 7 :
b +=
static_cast<uint32_t
>(k8[6]) << 16; [[fallthrough]];
231 case 6 :
b +=
static_cast<uint32_t
>(k8[5]) << 8; [[fallthrough]];
232 case 5 :
b += k8[4]; [[fallthrough]];
233 case 4 : a +=
k[0];
break;
234 case 3 : a +=
static_cast<uint32_t
>(k8[2]) << 16; [[fallthrough]];
235 case 2 : a +=
static_cast<uint32_t
>(k8[1]) << 8; [[fallthrough]];
236 case 1 : a += k8[0];
break;
240 else if ((u.i & 0x1) == 0)
243 const uint16_t *
k =
reinterpret_cast<const uint16_t*
>(key);
248 a +=
k[0] + (
static_cast<uint32_t
>(
k[1]) << 16);
249 b +=
k[2] + (
static_cast<uint32_t
>(
k[3]) << 16);
250 c +=
k[4] + (
static_cast<uint32_t
>(
k[5]) << 16);
257 const uint8_t *k8 =
reinterpret_cast<const uint8_t*
>(
k);
261 c +=
k[4] + (
static_cast<uint32_t
>(
k[5]) << 16);
262 b +=
k[2] + (
static_cast<uint32_t
>(
k[3]) << 16);
263 a +=
k[0] + (
static_cast<uint32_t
>(
k[1]) << 16);
266 c +=
static_cast<uint32_t
>(k8[10]) << 16;
270 b +=
k[2] + (
static_cast<uint32_t
>(
k[3]) << 16);
271 a +=
k[0] + (
static_cast<uint32_t
>(
k[1]) << 16);
277 b +=
k[2] + (
static_cast<uint32_t
>(
k[3]) << 16);
278 a +=
k[0] + (
static_cast<uint32_t
>(
k[1]) << 16);
281 b +=
static_cast<uint32_t
>(k8[6]) << 16;
285 a +=
k[0] + (
static_cast<uint32_t
>(
k[1]) << 16);
291 a +=
k[0] + (
static_cast<uint32_t
>(
k[1]) << 16);
294 a +=
static_cast<uint32_t
>(k8[2]) << 16;
307 const uint8_t *
k =
reinterpret_cast<const uint8_t*
>(key);
313 a +=
static_cast<uint32_t
>(
k[1]) << 8;
314 a +=
static_cast<uint32_t
>(
k[2]) << 16;
315 a +=
static_cast<uint32_t
>(
k[3]) << 24;
317 b +=
static_cast<uint32_t
>(
k[5]) << 8;
318 b +=
static_cast<uint32_t
>(
k[6]) << 16;
319 b +=
static_cast<uint32_t
>(
k[7]) << 24;
321 c +=
static_cast<uint32_t
>(
k[9]) << 8;
322 c +=
static_cast<uint32_t
>(
k[10]) << 16;
323 c +=
static_cast<uint32_t
>(
k[11]) << 24;
333 case 12:
c +=
static_cast<uint32_t
>(
k[11]) << 24; [[fallthrough]];
334 case 11:
c +=
static_cast<uint32_t
>(
k[10]) << 16; [[fallthrough]];
335 case 10:
c +=
static_cast<uint32_t
>(
k[9]) << 8; [[fallthrough]];
336 case 9 :
c +=
k[8]; [[fallthrough]];
338 case 8 :
b +=
static_cast<uint32_t
>(
k[7]) << 24; [[fallthrough]];
339 case 7 :
b +=
static_cast<uint32_t
>(
k[6]) << 16; [[fallthrough]];
340 case 6 :
b +=
static_cast<uint32_t
>(
k[5]) << 8; [[fallthrough]];
341 case 5 :
b +=
k[4]; [[fallthrough]];
343 case 4 : a +=
static_cast<uint32_t
>(
k[3]) << 24; [[fallthrough]];
344 case 3 : a +=
static_cast<uint32_t
>(
k[2]) << 16; [[fallthrough]];
345 case 2 : a +=
static_cast<uint32_t
>(
k[1]) << 8; [[fallthrough]];
367 static unsigned jenkins_hashbig
375 union {
const void *ptr;
size_t i; } u;
378 a =
b =
c = 0xdeadbeef +
static_cast<uint32_t
>(length) + initval;
381 if ((u.i & 0x3) == 0)
384 const uint32_t *
k =
reinterpret_cast<const uint32_t*
>(key);
398 const uint8_t *k8 =
reinterpret_cast<const uint8_t*
>(
k);
402 case 12:
c +=
k[2];
b +=
k[1]; a +=
k[0];
break;
403 case 11:
c +=
static_cast<uint32_t
>(k8[10]) << 8; [[fallthrough]];
404 case 10:
c +=
static_cast<uint32_t
>(k8[9]) << 16; [[fallthrough]];
405 case 9 :
c +=
static_cast<uint32_t
>(k8[8]) << 24; [[fallthrough]];
406 case 8 :
b +=
k[1]; a +=
k[0];
break;
407 case 7 :
b +=
static_cast<uint32_t
>(k8[6]) << 8; [[fallthrough]];
408 case 6 :
b +=
static_cast<uint32_t
>(k8[5]) << 16; [[fallthrough]];
409 case 5 :
b +=
static_cast<uint32_t
>(k8[4]) << 24; [[fallthrough]];
410 case 4 : a +=
k[0];
break;
411 case 3 : a +=
static_cast<uint32_t
>(k8[2]) << 8; [[fallthrough]];
412 case 2 : a +=
static_cast<uint32_t
>(k8[1]) << 16; [[fallthrough]];
413 case 1 : a +=
static_cast<uint32_t
>(k8[0]) << 24;
break;
420 const uint8_t *
k =
reinterpret_cast<const uint8_t*
>(key);
425 a +=
static_cast<uint32_t
>(
k[0]) << 24;
426 a +=
static_cast<uint32_t
>(
k[1]) << 16;
427 a +=
static_cast<uint32_t
>(
k[2]) << 8;
428 a +=
static_cast<uint32_t
>(
k[3]);
429 b +=
static_cast<uint32_t
>(
k[4]) << 24;
430 b +=
static_cast<uint32_t
>(
k[5]) << 16;
431 b +=
static_cast<uint32_t
>(
k[6]) << 8;
432 b +=
static_cast<uint32_t
>(
k[7]);
433 c +=
static_cast<uint32_t
>(
k[8]) << 24;
434 c +=
static_cast<uint32_t
>(
k[9]) << 16;
435 c +=
static_cast<uint32_t
>(
k[10]) << 8;
436 c +=
static_cast<uint32_t
>(
k[11]);
446 case 12:
c +=
k[11]; [[fallthrough]];
447 case 11:
c +=
static_cast<uint32_t
>(
k[10]) << 8; [[fallthrough]];
448 case 10:
c +=
static_cast<uint32_t
>(
k[9]) << 16; [[fallthrough]];
449 case 9 :
c +=
static_cast<uint32_t
>(
k[8]) << 24; [[fallthrough]];
450 case 8 :
b +=
k[7]; [[fallthrough]];
451 case 7 :
b +=
static_cast<uint32_t
>(
k[6]) << 8; [[fallthrough]];
452 case 6 :
b +=
static_cast<uint32_t
>(
k[5]) << 16; [[fallthrough]];
453 case 5 :
b +=
static_cast<uint32_t
>(
k[4]) << 24; [[fallthrough]];
454 case 4 : a +=
k[3]; [[fallthrough]];
455 case 3 : a +=
static_cast<uint32_t
>(
k[2]) << 8; [[fallthrough]];
456 case 2 : a +=
static_cast<uint32_t
>(
k[1]) << 16; [[fallthrough]];
457 case 1 : a +=
static_cast<uint32_t
>(
k[0]) << 24; [[fallthrough]];
479 #if defined (WM_BIG_ENDIAN)
480 return jenkins_hashbig(key, length, initval);
481 #elif defined (WM_LITTLE_ENDIAN)
482 return jenkins_hashlittle(key, length, initval);
484 #error "Cannot determine WM_BIG_ENDIAN or WM_LITTLE_ENDIAN."
510 a =
b =
c = 0xdeadbeef + (
static_cast<uint32_t
>(length) << 2) + seed;
526 case 3 :
c +=
k[2]; [[fallthrough]];
527 case 2 :
b +=
k[1]; [[fallthrough]];
556 a =
b =
c = 0xdeadbeef + (
static_cast<uint32_t
>(length) << 2) + hash1;
573 case 3 :
c +=
k[2]; [[fallthrough]];
574 case 2 :
b +=
k[1]; [[fallthrough]];