- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
#define mix(a,b,c) \
{ \
a -= c; a ^= rot(c, 4); c += b; \
b -= a; b ^= rot(a, 6); a += c; \
c -= b; c ^= rot(b, 8); b += a; \
a -= c; a ^= rot(c,16); c += b; \
b -= a; b ^= rot(a,19); a += c; \
c -= b; c ^= rot(b, 4); b += a; \
}
#define final(a,b,c) \
{ \
c ^= b; c -= rot(b,14); \
a ^= c; a -= rot(c,11); \
b ^= a; b -= rot(a,25); \
c ^= b; c -= rot(b,16); \
a ^= c; a -= rot(c,4); \
b ^= a; b -= rot(a,14); \
c ^= b; c -= rot(b,24); \
}
unsigned int lookup3(const void *key, size_t length, unsigned int initval)
{
unsigned int a, b, c;
const unsigned char *k;
const unsigned int *data32Bit;
data32Bit = (unsigned int *)key;
a = b = c = 0xdeadbeef + (((unsigned int)length) << 2) + initval;
while (length > 12) {
a += *(data32Bit++);
b += *(data32Bit++);
c += *(data32Bit++);
mix(a, b, c);
length -= 12;
}
k = (const unsigned char *)data32Bit;
switch (length) {
case 12: c += ((unsigned int)k[11]) << 24;
case 11: c += ((unsigned int)k[10]) << 16;
case 10: c += ((unsigned int)k[9]) << 8;
case 9: c += k[8];
case 8: b += ((unsigned int)k[7]) << 24;
case 7: b += ((unsigned int)k[6]) << 16;
case 6: b += ((unsigned int)k[5]) << 8;
case 5: b += k[4];
case 4: a += ((unsigned int)k[3]) << 24;
case 3: a += ((unsigned int)k[2]) << 16;
case 2: a += ((unsigned int)k[1]) << 8;
case 1: a += k[0];
break;
case 0: return c;
}
final(a, b, c);
return c;
}
Що это за хуйня и как ей пользоваться? Декларируется 3 раза в проекте