]> mj.ucw.cz Git - libucw.git/blob - lib/str_hash.h
after a long time of experimenting, added a support for unaligned parameters
[libucw.git] / lib / str_hash.h
1 /*
2  *      Hyper-super-meta-alt-control-shift extra fast str_len() and str_hash()
3  *      routines
4  *
5  *      (c) 2002, Robert Spalek <robert@ucw.cz>
6  */
7
8 #include "lib/lib.h"
9
10 /* An equivalent of the Intel's rol instruction.  */
11 #define ROL(x, bits)    (((x) << (bits)) | ((x) >> (sizeof(uns)*8 - (bits))))
12
13 /* The following functions need str to be aligned to uns.  */
14 uns str_len_aligned(const char *str) __attribute__((const));
15 uns str_hash_aligned(const char *str) __attribute__((const));
16
17 #ifdef  CPU_ALLOW_UNALIGNED
18 #define str_len(str)    str_len_aligned(str)
19 #define str_hash(str)   str_hash_aligned(str)
20 #else
21 uns str_len(const char *str) __attribute__((const));
22 uns str_hash(const char *str) __attribute__((const));
23 #endif