OpenMPI  0.1.1
hash_string.h File Reference

Simple macros to quickly compute a hash value from a string. More...

Go to the source code of this file.

Macros

#define OPAL_HASH_STRLEN(str, hash, length)
 Compute the hash value and the string length simultaneously. More...
 
#define OPAL_HASH_STR(str, hash)
 Compute the hash value. More...
 

Detailed Description

Simple macros to quickly compute a hash value from a string.

Macro Definition Documentation

#define OPAL_HASH_STR (   str,
  hash 
)
Value:
do { \
register const char *_str = (str); \
register uint32_t _hash = 0; \
\
while( *_str ) { \
_hash += *_str++; \
_hash += (_hash << 10); \
_hash ^= (_hash >> 6); \
} \
\
_hash += (_hash << 3); \
_hash ^= (_hash >> 11); \
(hash) = (_hash + (_hash << 15)); \
} while(0)

Compute the hash value.

Parameters
str(IN) The string which will be parsed (char*)
hash(OUT) Where the hash value will be stored (uint32_t)
#define OPAL_HASH_STRLEN (   str,
  hash,
  length 
)
Value:
do { \
register const char *_str = (str); \
register uint32_t _hash = 0; \
register uint32_t _len = 0; \
\
while( *_str ) { \
_len++; \
_hash += *_str++; \
_hash += (_hash << 10); \
_hash ^= (_hash >> 6); \
} \
\
_hash += (_hash << 3); \
_hash ^= (_hash >> 11); \
(hash) = (_hash + (_hash << 15)); \
(length) = _len; \
} while(0)

Compute the hash value and the string length simultaneously.

Parameters
str(IN) The string which will be parsed (char*)
hash(OUT) Where the hash value will be stored (uint32_t)
length(OUT) The computed length of the string (uint32_t)