aboutsummaryrefslogtreecommitdiff
path: root/C/Xxh64.h
blob: efef65eb3df56cc6b95c2e4ce59e699d902c0af0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* Xxh64.h -- XXH64 hash calculation interfaces
2023-08-18 : Igor Pavlov : Public domain */

#ifndef ZIP7_INC_XXH64_H
#define ZIP7_INC_XXH64_H

#include "7zTypes.h"

EXTERN_C_BEGIN

#define Z7_XXH64_BLOCK_SIZE  (4 * 8)

typedef struct
{
  UInt64 v[4];
} CXxh64State;

void Xxh64State_Init(CXxh64State *p);

// end != data && end == data + Z7_XXH64_BLOCK_SIZE * numBlocks
void Z7_FASTCALL Xxh64State_UpdateBlocks(CXxh64State *p, const void *data, const void *end);

/*
Xxh64State_Digest():
data:
  the function processes only
    (totalCount & (Z7_XXH64_BLOCK_SIZE - 1)) bytes in (data): (smaller than 32 bytes).
totalCount: total size of hashed stream:
  it includes total size of data processed by previous Xxh64State_UpdateBlocks() calls,
  and it also includes current processed size in (data).
*/
UInt64 Xxh64State_Digest(const CXxh64State *p, const void *data, UInt64 totalCount);


typedef struct
{
  CXxh64State state;
  UInt64 count;
  UInt64 buf64[4];
} CXxh64;

void Xxh64_Init(CXxh64 *p);
void Xxh64_Update(CXxh64 *p, const void *data, size_t size);

#define Xxh64_Digest(p) \
  Xxh64State_Digest(&(p)->state, (p)->buf64, (p)->count)

EXTERN_C_END

#endif