1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2016, Olivier MATZ <zer0@droids-corp.org>
7 #include <ecoli_murmurhash.h>
9 uint32_t ec_murmurhash3(const void *key, int len, uint32_t seed)
11 const uint8_t *data = (const uint8_t *)key;
13 const int nblocks = len / 4;
16 const uint32_t *blocks = (const uint32_t *)(data + nblocks * 4);
19 for (i = -nblocks; i; i++) {
22 h1 = ec_murmurhash3_add32(h1, k1);
23 h1 = ec_murmurhash3_mix32(h1);
26 tail = (const uint8_t *)(data + nblocks * 4);
30 case 3: k1 ^= tail[2] << 16;
31 case 2: k1 ^= tail[1] << 8;
32 case 1: k1 ^= tail[0];
33 h1 = ec_murmurhash3_add32(h1, k1);
38 h1 = ec_murmurhash3_fmix32(h1);