1 /* SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0+ */ 2 #ifndef __EROFS_LIB_XXHASH_H 3 #define __EROFS_LIB_XXHASH_H 4 5 #ifdef __cplusplus 6 extern "C" 7 { 8 #endif 9 10 #include <stdint.h> 11 12 /* 13 * xxh32() - calculate the 32-bit hash of the input with a given seed. 14 * 15 * @input: The data to hash. 16 * @length: The length of the data to hash. 17 * @seed: The seed can be used to alter the result predictably. 18 * 19 * Return: The 32-bit hash of the data. 20 */ 21 uint32_t xxh32(const void *input, size_t length, uint32_t seed); 22 23 /* 24 * xxh64() - calculate the 64-bit hash of the input with a given seed. 25 * 26 * @input: The data to hash. 27 * @length: The length of the data to hash. 28 * @seed: The seed can be used to alter the result predictably. 29 * 30 * This function runs 2x faster on 64-bit systems, but slower on 32-bit systems. 31 * 32 * Return: The 64-bit hash of the data. 33 */ 34 uint64_t xxh64(const void *input, const size_t len, const uint64_t seed); 35 36 #ifdef __cplusplus 37 } 38 #endif 39 40 #endif 41