]> git.ipfire.org Git - thirdparty/ccache.git/blame - murmurhashneutral2.c
Improve description on how to fix bad object files in the cache
[thirdparty/ccache.git] / murmurhashneutral2.c
CommitLineData
e53af1a6
JR
1/*
2 * MurmurHashNeutral2, by Austin Appleby. Released to the public domain. See
3 * <http://murmurhash.googlepages.com>.
4 */
5
6#include "murmurhashneutral2.h"
7
530dfe7c
JR
8unsigned int
9murmurhashneutral2(const void *key, int len, unsigned int seed)
e53af1a6
JR
10{
11 const unsigned int m = 0x5bd1e995;
12 const int r = 24;
13
14 unsigned int h = seed ^ len;
15
16 const unsigned char *data = (const unsigned char *)key;
17
18 while (len >= 4) {
19 unsigned int k;
20
21 k = data[0];
22 k |= data[1] << 8;
23 k |= data[2] << 16;
24 k |= data[3] << 24;
25
26 k *= m;
27 k ^= k >> r;
28 k *= m;
29
30 h *= m;
31 h ^= k;
32
33 data += 4;
34 len -= 4;
35 }
36
37 switch (len)
38 {
39 case 3: h ^= data[2] << 16;
40 case 2: h ^= data[1] << 8;
41 case 1: h ^= data[0];
42 h *= m;
43 };
44
45 h ^= h >> 13;
46 h *= m;
47 h ^= h >> 15;
48
49 return h;
50}