RTEMS
5.0.0
|
RTEMS File Systems Directory Hash function. More...
#include <rtems/rfs/rtems-rfs-dir-hash.h>
Macros | |
#define | HASH_LITTLE_ENDIAN 0 |
#define | HASH_BIG_ENDIAN 0 |
#define | hashsize(n) ((uint32_t)1<<(n)) |
#define | hashmask(n) (hashsize(n)-1) |
#define | rot(x, k) (((x)<<(k)) | ((x)>>(32-(k)))) |
#define | mix(a, b, c) |
#define | final(a, b, c) |
#define | initval (20010928) |
Functions | |
uint32_t | rtems_rfs_dir_hash (const void *key, size_t length) |
RTEMS File Systems Directory Hash function.
#define final | ( | a, | |
b, | |||
c | |||
) |
#define initval (20010928) |
The follow is the documentation from Bob Jenkin's hash function:
http://burtleburtle.net/bob/hash/doobs.html
The function hashlittle() has been renamed.
hashlittle() – hash a variable-length key into a 32-bit value
k : the key (the unaligned variable-length array of bytes) length : the length of the key, counting by bytes initval : can be any 4-byte value
Returns a 32-bit value. Every bit of the key affects every bit of the return value. Two keys differing by one or two bits will have totally different hash values.
The best hash table sizes are powers of 2. There is no need to do mod a prime (mod is sooo slow!). If you need less than 32 bits, use a bitmask. For example, if you need only 10 bits, do h = (h & hashmask(10)); In which case, the hash table should have hashsize(10) elements.
If you are hashing n strings (uint8_t **)k, do it like this: for (i=0, h=0; i<n; ++i) h = hashlittle( k[i], len[i], h);
By Bob Jenkins, 2006. bob_j. You may use this code any way you wish, private, educational, or commercial. It's free. enki ns@bu rtle burtl e.ne t
Use for hash table lookup, or anything where one collision in 2^^32 is acceptable. Do NOT use for cryptographic purposes.
#define mix | ( | a, | |
b, | |||
c | |||
) |
uint32_t rtems_rfs_dir_hash | ( | const void * | key, |
size_t | length | ||
) |
Compute a hash of the key over the length of string.
[in] | key | is a pointer to the key to calculate the hash of. |
[in] | length | is the length of the key in bytes. |
hash | The computed uint32_t hash. |