mirror of
https://github.com/versity/scoutfs.git
synced 2026-02-08 03:30:46 +00:00
Add a quick header which calculates 64bit hashes by calculating the crc of the two halves of a byte region. Signed-off-by: Zach Brown <zab@versity.com>
16 lines
335 B
C
16 lines
335 B
C
#ifndef _SCOUTFS_HASH_H_
|
|
#define _SCOUTFS_HASH_H_
|
|
|
|
#include <linux/crc32c.h>
|
|
|
|
/* XXX replace with xxhash */
|
|
static inline u64 scoutfs_hash64(const void *data, unsigned int len)
|
|
{
|
|
unsigned int half = (len + 1) / 2;
|
|
|
|
return crc32c(~0, data, half) |
|
|
((u64)crc32c(~0, data + len - half, half) << 32);
|
|
}
|
|
|
|
#endif
|