My Project
Loading...
Searching...
No Matches
hash_me.h File Reference
#include <stdint.h>
#include <stddef.h>

Go to the source code of this file.

Functions

uint32_t hashlittle (const void *key, size_t length)

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
int k
Definition cfEzgcd.cc:99
CanonicalForm b
Definition cfModGcd.cc:4111
#define mix(a, b, c)
Definition hash_me.c:18
static BOOLEAN length(leftv result, leftv arg)
Definition interval.cc:257