56 #define _rotl(x,r) ((x << r) | (x >> (32 - r)))
58 #define PRIME1 2654435761U
59 #define PRIME2 2246822519U
60 #define PRIME3 3266489917U
61 #define PRIME4 668265263U
62 #define PRIME5 0x165667b1
64 void hash_xxfast_init() {
67 uint32_t hash_xxfast_buffer(uint8_t * buffer, uint16_t length)
70 uint8_t * bEnd = p + length;
71 uint8_t * limit = bEnd - 4;
72 uint32_t idx = PRIME1;
73 uint32_t crc = PRIME5;
77 crc += ((*(uint32_t *)p) + idx++);
78 crc += _rotl(crc, 17) * PRIME4;
85 crc += ((*p) + idx++);
101 uint32_t hash_xxfast_convenience(uint32_t one, uint32_t two, uint32_t three, uint32_t four, uint32_t five)
105 memcpy(buffer + 0, &one,
sizeof(uint32_t));
106 memcpy(buffer + 4, &two,
sizeof(uint32_t));
107 memcpy(buffer + 8, &three,
sizeof(uint32_t));
108 memcpy(buffer + 12, &four,
sizeof(uint32_t));
109 memcpy(buffer + 16, &five,
sizeof(uint32_t));
111 return hash_xxfast_buffer(buffer, 16);
114 uint32_t hash_xxfast_convenience_ptr(uint32_t * one, uint32_t * two, uint32_t * three, uint32_t * four, uint32_t * five)
118 memcpy(buffer + 0, one,
sizeof(uint32_t));
119 memcpy(buffer + 4, two,
sizeof(uint32_t));
120 memcpy(buffer + 8, three,
sizeof(uint32_t));
121 memcpy(buffer + 12, four,
sizeof(uint32_t));
122 memcpy(buffer + 16, five,
sizeof(uint32_t));
124 return hash_xxfast_buffer(buffer, 16);
130 hash_xxfast_convenience,
131 hash_xxfast_convenience_ptr,