1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #ifndef PMIX_HASH_STRING_H
19 #define PMIX_HASH_STRING_H
20
21
22
23
24
25
26
27
28 #define PMIX_HASH_STRLEN( str, hash, length ) \
29 do { \
30 register const char *_str = (str); \
31 register uint32_t _hash = 0; \
32 register uint32_t _len = 0; \
33 \
34 while( *_str ) { \
35 _len++; \
36 _hash += *_str++; \
37 _hash += (_hash << 10); \
38 _hash ^= (_hash >> 6); \
39 } \
40 \
41 _hash += (_hash << 3); \
42 _hash ^= (_hash >> 11); \
43 (hash) = (_hash + (_hash << 15)); \
44 (length) = _len; \
45 } while (0)
46
47
48
49
50
51
52
53 #define PMIX_HASH_STR( str, hash ) \
54 do { \
55 register const char *_str = (str); \
56 register uint32_t _hash = 0; \
57 \
58 while( *_str ) { \
59 _hash += *_str++; \
60 _hash += (_hash << 10); \
61 _hash ^= (_hash >> 6); \
62 } \
63 \
64 _hash += (_hash << 3); \
65 _hash ^= (_hash >> 11); \
66 (hash) = (_hash + (_hash << 15)); \
67 } while (0)
68
69 #endif