
為了找到給定緩衝區的雜湊值,我使用了arch_fast_hash
Linux 核心 v3.16 中聲明include/linux/hash.h
和定義的函數linux/lib/hash.c
。
但在 Linux 核心 v3.19 中,該功能消失了。幾乎沒有新函數和宏,但沒有適當的文檔。
任何人都可以幫助我使用適當的哈希技術或arch_fast_hash
v3.19 中的替代方案嗎?
還有比哈希更快的替代方案嗎?
連結
Linux 核心 v3.16 中的 include/linux/hash.h
Linux 核心 v3.19 中的 include/linux/hash.h
答案1
嘗試:
#include <linux/jhash.h>
並使用這個函數:
/*
* jhash - hash an arbitrary key
* @k: sequence of bytes as key
* @length: the length of the key
* @initval: the previous hash, or an arbitray value
*
* The generic version, hashes an arbitrary sequence of bytes.
* No alignment or length assumptions are made about the input key.
* Returns the hash value of the key. The result depends on endianness.
*/
u32 jhash(const void *key, u32 length, u32 initval);