xref: /aosp_15_r20/external/lzma/C/Xxh64.h (revision f6dc9357d832569d4d1f5d24eacdb3935a1ae8e6)
1 /* Xxh64.h -- XXH64 hash calculation interfaces
2 2023-08-18 : Igor Pavlov : Public domain */
3 
4 #ifndef ZIP7_INC_XXH64_H
5 #define ZIP7_INC_XXH64_H
6 
7 #include "7zTypes.h"
8 
9 EXTERN_C_BEGIN
10 
11 #define Z7_XXH64_BLOCK_SIZE  (4 * 8)
12 
13 typedef struct
14 {
15   UInt64 v[4];
16 } CXxh64State;
17 
18 void Xxh64State_Init(CXxh64State *p);
19 
20 // end != data && end == data + Z7_XXH64_BLOCK_SIZE * numBlocks
21 void Z7_FASTCALL Xxh64State_UpdateBlocks(CXxh64State *p, const void *data, const void *end);
22 
23 /*
24 Xxh64State_Digest():
25 data:
26   the function processes only
27     (totalCount & (Z7_XXH64_BLOCK_SIZE - 1)) bytes in (data): (smaller than 32 bytes).
28 totalCount: total size of hashed stream:
29   it includes total size of data processed by previous Xxh64State_UpdateBlocks() calls,
30   and it also includes current processed size in (data).
31 */
32 UInt64 Xxh64State_Digest(const CXxh64State *p, const void *data, UInt64 totalCount);
33 
34 
35 typedef struct
36 {
37   CXxh64State state;
38   UInt64 count;
39   UInt64 buf64[4];
40 } CXxh64;
41 
42 void Xxh64_Init(CXxh64 *p);
43 void Xxh64_Update(CXxh64 *p, const void *data, size_t size);
44 
45 #define Xxh64_Digest(p) \
46   Xxh64State_Digest(&(p)->state, (p)->buf64, (p)->count)
47 
48 EXTERN_C_END
49 
50 #endif
51