hashhash32hash32_bufhash32_strhash32_strnhash32_strehash32_strne
- general kernel hashing functions
SYNOPSIS
#include <sys/hash.h> uint32_t
hash32_buf (const void *buf size_t len uint32_t hash); uint32_t
hash32_str (const void *buf uint32_t hash); uint32_t
hash32_strn (const void *buf size_t len uint32_t hash); uint32_t
hash32_stre (const void *buf int end const char **ep uint32_t hash); uint32_t
hash32_strne (const void *buf size_t len int end const char **ep uint32_t hash);
DESCRIPTION
The
hash32 ();
functions are used to give a consistent and general interface to
a decent hashing algorithm within the kernel.
These functions can be used to hash
ASCIINUL
terminated strings, as well as blocks of memory.
The
hash32_buf ();
function is used as a general buffer hashing function.
The argument
Fa buf
is used to pass in the location, and
Fa len
is the length of the buffer.
The argument
Fa hash
is used to extend an existing hash, or is passed the initial value
HASHINIT
to start a new hash.
The
hash32_str ();
function is used to hash a
NUL
terminated string passed in
Fa buf
with initial hash value given in
Fa hash .
The
hash32_strn ();
function is like the
hash32_str ();
function, except it also takes a
Fa len
argument, which is the maximal length of the expected string.
The
hash32_stre ();
and
hash32_strne ();
functions are helper functions used by the kernel to hash pathname
components.
These functions have the additional termination condition
of terminating when they find a character given by
Fa end
in the string to be hashed.
If the argument
Fa ep
is not
NULL
it is set to the point in the buffer at which the hash function
terminated hashing.
RETURN VALUES
The
hash32 ();
functions return a 32 bit hash value of the buffer or string.
The
hash32 ();
functions are only 32 bit functions.
They will prove to give poor 64 bit performance, especially for the
top 32 bits.
At the current time, this is not seen as a great limitation, as these
hash values are usually used to index into an array.
Should these hash values be used for other means, this limitation should
be revisited.
HISTORY
The
functions were first committed to
Nx 1.6 .
The
Ox versions were written and massaged for
Ox 2.3
by Tobias Weingartner,
and finally committed for
Ox 3.2 .