1 /* jhash.h: Jenkins hash support.
3 * Copyright (C) 2006. Bob Jenkins (bob_jenkins@burtleburtle.net)
5 * http://burtleburtle.net/bob/hash/
7 * These are the credits from Bob's sources:
9 * lookup3.c, by Bob Jenkins, May 2006, Public Domain.
11 * These are functions for producing 32-bit hashes for hash table lookup.
12 * hashword(), hashlittle(), hashlittle2(), hashbig(), mix(), and final()
13 * are externally useful functions. Routines to test the hash are included
14 * if SELF_TEST is defined. You can use this free for any purpose. It's in
15 * the public domain. It has no warranty.
17 * Copyright (C) 2009-2010 Jozsef Kadlecsik (kadlec@blackhole.kfki.hu)
19 * I've modified Bob's hash to be useful in the Linux kernel, and
20 * any bugs present are my fault.
27 #include "qemu/bitops.h"
30 * hashtable relation copy from linux kernel jhash
33 /* __jhash_mix -- mix 3 32-bit values reversibly. */
34 #define __jhash_mix(a, b, c) \
36 a -= c; a ^= rol32(c, 4); c += b; \
37 b -= a; b ^= rol32(a, 6); a += c; \
38 c -= b; c ^= rol32(b, 8); b += a; \
39 a -= c; a ^= rol32(c, 16); c += b; \
40 b -= a; b ^= rol32(a, 19); a += c; \
41 c -= b; c ^= rol32(b, 4); b += a; \
44 /* __jhash_final - final mixing of 3 32-bit values (a,b,c) into c */
45 #define __jhash_final(a, b, c) \
47 c ^= b; c -= rol32(b, 14); \
48 a ^= c; a -= rol32(c, 11); \
49 b ^= a; b -= rol32(a, 25); \
50 c ^= b; c -= rol32(b, 16); \
51 a ^= c; a -= rol32(c, 4); \
52 b ^= a; b -= rol32(a, 14); \
53 c ^= b; c -= rol32(b, 24); \
56 /* An arbitrary initial parameter */
57 #define JHASH_INITVAL 0xdeadbeef
59 #endif /* QEMU_JHASH_H */