Zephyr Project API 4.0.0
A Scalable Open Source RTOS
|
Typedefs | |
typedef uint32_t(* | sys_hash_func32_t) (const void *str, size_t n) |
32-bit Hash function interface | |
Functions | |
static uint32_t | sys_hash32_identity (const void *str, size_t n) |
The naive identity hash function. | |
uint32_t | sys_hash32_djb2 (const void *str, size_t n) |
Daniel J. Bernstein's hash function. | |
uint32_t | sys_hash32_murmur3 (const void *str, size_t n) |
Murmur3 hash function. | |
static uint32_t | sys_hash32 (const void *str, size_t n) |
System default 32-bit hash function. | |
#include <include/zephyr/sys/hash_function.h>
32-bit Hash function interface
Hash functions are used to map data from an arbitrarily large space to a (typically smaller) fixed-size space. For a given input, a hash function will consistently generate the same, semi-unique numerical value. Even for marginally different data, a good hash function will distribute the entropy almost evenly over all bits in the hashed value when combined with modulo arithmetic over a finite-sized numeric field.
str | a string of input data |
n | the number of bytes in str |
str
#include <include/zephyr/sys/hash_function.h>
System default 32-bit hash function.
str | a string of input data |
n | the number of bytes in str |
str
#include <include/zephyr/sys/hash_function.h>
Daniel J. Bernstein's hash function.
Some notes:
str | a string of input data |
n | the number of bytes in str |
str
CONFIG_SYS_HASH_FUNC32_DJB2
#include <include/zephyr/sys/hash_function.h>
The naive identity hash function.
This hash function requires that n
is equal to the size of a primitive type, such as [u]int8_t
, [u]int16_t
, [u]int32_t
, [u]int64_t
, float
, double
, or void *
, and that the alignment of str
agrees with that of the respective native type.
str | a string of input data |
n | the number of bytes in str |
str
#include <include/zephyr/sys/hash_function.h>
Murmur3 hash function.
str | a string of input data |
n | the number of bytes in str |
str
CONFIG_SYS_HASH_FUNC32_MURMUR3