Lines Matching +full:a +full:- +full:b
14 * These are functions for producing 32-bit hashes for hash table lookup.
20 * Copyright (C) 2009-2010 Jozsef Kadlecsik (kadlec@netfilter.org)
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()
81 b += __get_unaligned_cpu32(k + 4); in jhash()
83 __jhash_mix(a, b, c); in jhash()
84 length -= 12; in jhash()
93 case 8: b += (u32)k[7]<<24; fallthrough; in jhash()
94 case 7: b += (u32)k[6]<<16; fallthrough; in jhash()
95 case 6: b += (u32)k[5]<<8; fallthrough; in jhash()
96 case 5: b += k[4]; fallthrough; in jhash()
97 case 4: a += (u32)k[3]<<24; fallthrough; in jhash()
98 case 3: a += (u32)k[2]<<16; fallthrough; in jhash()
99 case 2: a += (u32)k[1]<<8; fallthrough; in jhash()
100 case 1: a += k[0]; in jhash()
101 __jhash_final(a, b, 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()
127 b += k[1]; in jhash2()
129 __jhash_mix(a, b, c); in jhash2()
130 length -= 3; in jhash2()
137 case 2: b += k[1]; fallthrough; in jhash2()
138 case 1: a += k[0]; in jhash2()
139 __jhash_final(a, b, c); in jhash2()
149 /* __jhash_nwords - hash exactly 3, 2 or 1 word(s) */
150 static inline u32 __jhash_nwords(u32 a, u32 b, u32 c, u32 initval) in __jhash_nwords() argument
152 a += initval; in __jhash_nwords()
153 b += initval; in __jhash_nwords()
156 __jhash_final(a, b, c); in __jhash_nwords()
161 static inline u32 jhash_3words(u32 a, u32 b, u32 c, u32 initval) in jhash_3words() argument
163 return __jhash_nwords(a, b, c, initval + JHASH_INITVAL + (3 << 2)); in jhash_3words()
166 static inline u32 jhash_2words(u32 a, u32 b, u32 initval) in jhash_2words() argument
168 return __jhash_nwords(a, b, 0, initval + JHASH_INITVAL + (2 << 2)); in jhash_2words()
171 static inline u32 jhash_1word(u32 a, u32 initval) in jhash_1word() argument
173 return __jhash_nwords(a, 0, 0, initval + JHASH_INITVAL + (1 << 2)); in jhash_1word()