Lines Matching +full:a +full:- +full:c

6  * Copyright (C) 2006. Bob Jenkins (bob_jenkins@burtleburtle.net)
12 * lookup3.c, by Bob Jenkins, May 2006, Public Domain.
14 * These are functions for producing 32-bit hashes for hash table lookup.
20 * Copyright (C) 2009-2010 Jozsef Kadlecsik (kadlec@blackhole.kfki.hu)
32 #define jhash_mask(n) (jhash_size(n)-1)
34 /* __jhash_mix -- mix 3 32-bit values reversibly. */
35 #define __jhash_mix(a, b, c) \ argument
37 a -= c; a ^= rol32(c, 4); c += b; \
38 b -= a; b ^= rol32(a, 6); a += c; \
39 c -= b; c ^= rol32(b, 8); b += a; \
40 a -= c; a ^= rol32(c, 16); c += b; \
41 b -= a; b ^= rol32(a, 19); a += c; \
42 c -= b; c ^= rol32(b, 4); b += a; \
45 /* __jhash_final - final mixing of 3 32-bit values (a,b,c) into c */
46 #define __jhash_final(a, b, c) \ argument
48 c ^= b; c -= rol32(b, 14); \
49 a ^= c; a -= rol32(c, 11); \
50 b ^= a; b -= rol32(a, 25); \
51 c ^= b; c -= rol32(b, 16); \
52 a ^= c; a -= rol32(c, 4); \
53 b ^= a; b -= rol32(a, 14); \
54 c ^= b; c -= rol32(b, 24); \
60 /* jhash - hash an arbitrary key
72 u32 a, b, c; in jhash() local
76 a = b = c = JHASH_INITVAL + length + initval; in jhash()
78 /* All but the last block: affect some 32 bits of (a,b,c) */ in jhash()
80 a += __get_unaligned_cpu32(k); in jhash()
82 c += __get_unaligned_cpu32(k + 8); in jhash()
83 __jhash_mix(a, b, c); in jhash()
84 length -= 12; in jhash()
87 /* Last block: affect all 32 bits of (c) */ in jhash()
90 case 12: c += (u32)k[11]<<24; in jhash()
91 case 11: c += (u32)k[10]<<16; in jhash()
92 case 10: c += (u32)k[9]<<8; in jhash()
93 case 9: c += k[8]; in jhash()
98 case 4: a += (u32)k[3]<<24; in jhash()
99 case 3: a += (u32)k[2]<<16; in jhash()
100 case 2: a += (u32)k[1]<<8; in jhash()
101 case 1: a += k[0]; in jhash()
102 __jhash_final(a, b, c); in jhash()
107 return c; in jhash()
110 /* jhash2 - hash an array of u32's
119 u32 a, b, c; in jhash2() local
122 a = b = c = JHASH_INITVAL + (length<<2) + initval; in jhash2()
126 a += k[0]; in jhash2()
128 c += k[2]; in jhash2()
129 __jhash_mix(a, b, c); in jhash2()
130 length -= 3; in jhash2()
136 case 3: c += k[2]; in jhash2()
138 case 1: a += k[0]; in jhash2()
139 __jhash_final(a, b, c); in jhash2()
144 return c; in jhash2()
148 /* __jhash_nwords - hash exactly 3, 2 or 1 word(s) */
149 static inline u32 __jhash_nwords(u32 a, u32 b, u32 c, u32 initval) in __jhash_nwords() argument
151 a += initval; in __jhash_nwords()
153 c += initval; in __jhash_nwords()
155 __jhash_final(a, b, c); in __jhash_nwords()
157 return c; in __jhash_nwords()
160 static inline u32 jhash_3words(u32 a, u32 b, u32 c, u32 initval) in jhash_3words() argument
162 return __jhash_nwords(a, b, c, initval + JHASH_INITVAL + (3 << 2)); in jhash_3words()
165 static inline u32 jhash_2words(u32 a, u32 b, u32 initval) in jhash_2words() argument
167 return __jhash_nwords(a, b, 0, initval + JHASH_INITVAL + (2 << 2)); in jhash_2words()
170 static inline u32 jhash_1word(u32 a, u32 initval) in jhash_1word() argument
172 return __jhash_nwords(a, 0, 0, initval + JHASH_INITVAL + (1 << 2)); in jhash_1word()