2 * Hyper-super-meta-alt-control-shift extra fast str_len() and hash_*()
5 * (c) 2002, Robert Spalek <robert@ucw.cz>
8 #ifndef _SHERLOCK_HASHFUNC_H
9 #define _SHERLOCK_HASHFUNC_H
13 /* An equivalent of the Intel's rol instruction. */
14 #define ROL(x, bits) (((x) << (bits)) | ((x) >> (sizeof(uns)*8 - (bits))))
16 /* The following functions need str to be aligned to uns. */
17 uns str_len_aligned(const byte *str) CONST;
18 uns hash_string_aligned(const byte *str) CONST;
19 uns hash_block_aligned(const byte *str, uns len) CONST;
21 #ifdef CPU_ALLOW_UNALIGNED
22 #define str_len(str) str_len_aligned(str)
23 #define hash_string(str) hash_string_aligned(str)
24 #define hash_block(str, len) hash_block_aligned(str, len)
26 uns str_len(const byte *str) CONST;
27 uns hash_string(const byte *str) CONST;
28 uns hash_block(const byte *str, uns len) CONST;
31 uns hash_string_nocase(const byte *str) CONST;
33 static inline uns hash_int(uns x) CONST;
34 static inline uns hash_int(uns x) { return 6442450967*x; }