My Project
Loading...
Searching...
No Matches
hash_me.c File Reference
#include "hash_me.h"

Go to the source code of this file.

Macros

#define hashsize(n)
#define hashmask(n)
#define rot(x, k)
#define mix(a, b, c)
#define final(a, b, c)

Functions

uint32_t hashlittle (const void *key, size_t length)

Macro Definition Documentation

◆ final

#define final ( a,
b,
c )
Value:
{ \
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); \
}
CanonicalForm b
Definition cfModGcd.cc:4111
#define rot(x, k)
Definition hash_me.c:11

Definition at line 33 of file hash_me.c.

33#define final(a,b,c) \
34{ \
35 c ^= b; c -= rot(b,14); \
36 a ^= c; a -= rot(c,11); \
37 b ^= a; b -= rot(a,25); \
38 c ^= b; c -= rot(b,16); \
39 a ^= c; a -= rot(c,4); \
40 b ^= a; b -= rot(a,14); \
41 c ^= b; c -= rot(b,24); \
42}

◆ hashmask

#define hashmask ( n)
Value:
(hashsize(n)-1)
#define hashsize(n)
Definition hash_me.c:9

Definition at line 10 of file hash_me.c.

◆ hashsize

#define hashsize ( n)
Value:
((uint32_t)1<<(n))

Definition at line 9 of file hash_me.c.

◆ mix

#define mix ( a,
b,
c )
Value:
{ \
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; \
}

Definition at line 18 of file hash_me.c.

18#define mix(a,b,c) \
19{ \
20 a -= c; a ^= rot(c, 4); c += b; \
21 b -= a; b ^= rot(a, 6); a += c; \
22 c -= b; c ^= rot(b, 8); b += a; \
23 a -= c; a ^= rot(c,16); c += b; \
24 b -= a; b ^= rot(a,19); a += c; \
25 c -= b; c ^= rot(b, 4); b += a; \
26}

◆ rot

#define rot ( x,
k )
Value:
(((x)<<(k)) | ((x)>>(32-(k))))
int k
Definition cfEzgcd.cc:99
Variable x
Definition cfModGcd.cc:4090

Definition at line 11 of file hash_me.c.

Function Documentation

◆ hashlittle()

uint32_t hashlittle ( const void * key,
size_t length )

Definition at line 68 of file hash_me.c.

69{
70 uint32_t a,b,c; /* internal state */
71 union { const void *ptr; size_t i; } u; /* needed for Mac Powerbook G4 */
72
73 /* Set up the internal state */
74 a = b = c = 0xdeadbeef + ((uint32_t)length);
75
76 u.ptr = key;
77 {
78 const uint8_t *k = (const uint8_t *)key;
79
80 /*--------------- all but the last block: affect some 32 bits of (a,b,c) */
81 while (length > 12)
82 {
83 a += k[0];
84 a += ((uint32_t)k[1])<<8;
85 a += ((uint32_t)k[2])<<16;
86 a += ((uint32_t)k[3])<<24;
87 b += k[4];
88 b += ((uint32_t)k[5])<<8;
89 b += ((uint32_t)k[6])<<16;
90 b += ((uint32_t)k[7])<<24;
91 c += k[8];
92 c += ((uint32_t)k[9])<<8;
93 c += ((uint32_t)k[10])<<16;
94 c += ((uint32_t)k[11])<<24;
95 mix(a,b,c);
96 length -= 12;
97 k += 12;
98 }
99
100 /*-------------------------------- last block: affect all 32 bits of (c) */
101 switch(length) /* all the case statements fall through */
102 {
103 case 12: c+=((uint32_t)k[11])<<24;
104 case 11: c+=((uint32_t)k[10])<<16;
105 case 10: c+=((uint32_t)k[9])<<8;
106 case 9 : c+=k[8];
107 case 8 : b+=((uint32_t)k[7])<<24;
108 case 7 : b+=((uint32_t)k[6])<<16;
109 case 6 : b+=((uint32_t)k[5])<<8;
110 case 5 : b+=k[4];
111 case 4 : a+=((uint32_t)k[3])<<24;
112 case 3 : a+=((uint32_t)k[2])<<16;
113 case 2 : a+=((uint32_t)k[1])<<8;
114 case 1 : a+=k[0];
115 break;
116 case 0 : return c;
117 }
118 }
119
120 final(a,b,c);
121 return c;
122}
int i
Definition cfEzgcd.cc:132
#define mix(a, b, c)
Definition hash_me.c:18
static BOOLEAN length(leftv result, leftv arg)
Definition interval.cc:257