25 #ifndef FIRM_ADT_HASHPTR_H
26 #define FIRM_ADT_HASHPTR_H
39 #define _FIRM_FNV_OFFSET_BASIS 2166136261U
40 #define _FIRM_FNV_FNV_PRIME 16777619U
43 #define _FIRM_FNV_TIMES_PRIME(x) ((x) * _FIRM_FNV_FNV_PRIME)
50 static inline unsigned hash_data(
const unsigned char *data,
size_t bytes)
53 unsigned hash = _FIRM_FNV_OFFSET_BASIS;
55 for(i = 0; i < bytes; ++i) {
56 hash = _FIRM_FNV_TIMES_PRIME(hash);
68 static inline unsigned hash_str(
const char *str)
71 unsigned hash = _FIRM_FNV_OFFSET_BASIS;
73 for(i = 0; str[i] !=
'\0'; ++i) {
74 hash = _FIRM_FNV_TIMES_PRIME(hash);
86 static inline unsigned hash_ptr(
const void *ptr)
88 return ((
unsigned)(((
char *) (ptr) - (
char *)0) >> 3));
99 unsigned hash = _FIRM_FNV_TIMES_PRIME(_FIRM_FNV_OFFSET_BASIS);
101 hash = _FIRM_FNV_TIMES_PRIME(hash);