|
NAMEhash , hash32 ,
hash32_buf , hash32_str ,
hash32_strn , hash32_stre ,
hash32_strne , jenkins_hash ,
jenkins_hash32 ,
murmur3_32_hash ,
murmur3_32_hash32 —
general kernel hashing functions
SYNOPSIS#include <sys/hash.h>
uint32_t
uint32_t
uint32_t
uint32_t
uint32_t
uint32_t
uint32_t
uint32_t
uint32_t
DESCRIPTIONThehash32 () 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 ASCII NUL terminated
strings, as well as blocks of memory.
A len argument is the length of the buffer in bytes. A count argument is the length of the buffer in 32-bit words. The The The The The The The RETURN VALUESThehash32 () functions return a 32 bit hash value of the
buffer or string.
EXAMPLESLIST_HEAD(head, cache) *hashtbl = NULL; u_long mask = 0; void sample_init(void) { hashtbl = hashinit(numwanted, type, flags, &mask); } void sample_use(char *str, int len) { uint32_t hash; hash = hash32_str(str, HASHINIT); hash = hash32_buf(&len, sizeof(len), hash); hashtbl[hash & mask] = len; } SEE ALSOfree(9), hashinit(9), malloc(9)LIMITATIONSThehash32 () 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.
HISTORYThehash functions first appeared in
NetBSD 1.6. The current implementation of
hash32 functions was first committed to
OpenBSD 3.2, and later imported to
FreeBSD 6.1. The jenkins_hash
functions were added in FreeBSD 10.0. The
murmur3_32_hash functions were added in
FreeBSD 10.1.
AUTHORSThehash32 functions were written by
Tobias Weingartner. The
jenkins_hash functions were written by
Bob Jenkins. The murmur3_32_hash
functions were written by
Dag-Erling Smørgrav <des@FreeBSD.org>.
Visit the GSP FreeBSD Man Page Interface. |