更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
los_hash.h 文件参考

浏览源代码.

函数

LITE_OS_SEC_ALW_INLINE STATIC INLINE UINT32 LOS_HashFNV32aBuf (const VOID *buf, size_t len, UINT32 hval)
 
LITE_OS_SEC_ALW_INLINE STATIC INLINE UINT32 LOS_HashFNV32aStr (CHAR *str, UINT32 hval)
 

函数说明

◆ LOS_HashFNV32aBuf()

LITE_OS_SEC_ALW_INLINE STATIC INLINE UINT32 LOS_HashFNV32aBuf ( const VOID *  buf,
size_t  len,
UINT32  hval 
)

在文件 los_hash.h79 行定义.

80{
81 const UINT8 *hashbuf = (const UINT8 *)buf;
82
83 /*
84 * FNV-1a hash each octet in the buffer
85 */
86 while (len-- != 0) {
87 /* xor the bottom with the current octet */
88 hval ^= (UINT32)*hashbuf++;
89
90 /* multiply by the 32 bit FNV magic prime mod 2^32 */
91 hval *= FNV_32_PRIME;
92 }
93
94 /* return our new hash value */
95 return hval;
96}
unsigned char UINT8
Definition: los_typedef.h:55
unsigned int UINT32
Definition: los_typedef.h:57
这是这个函数的调用关系图:

◆ LOS_HashFNV32aStr()

LITE_OS_SEC_ALW_INLINE STATIC INLINE UINT32 LOS_HashFNV32aStr ( CHAR str,
UINT32  hval 
)

在文件 los_hash.h98 行定义.

99{
100 UINT8 *s = (UINT8 *)str;
101
102 /*
103 * FNV-1a hash each octet in the buffer
104 */
105 while (*s) {
106 /* xor the bottom with the current octet */
107 hval ^= (UINT32)*s++;
108
109 /* multiply by the 32 bit FNV magic prime mod 2^32 */
110 hval *= FNV_32_PRIME;
111 }
112
113 /* return our new hash value */
114 return hval;
115}