summaryrefslogtreecommitdiff
path: root/neozip/crc32_chorba_p.h
blob: 95f92af9131b1b0d97369378e5a6d701a1b87ed1 (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
/* crc32_chorba_p.h -- crc32 chorba interface
 * Copyright (C) 2021 Nathan Moinvaziri
 * For conditions of distribution and use, see copyright notice in zlib.h
 */

#ifndef CRC32_CHORBA_P_H_
#define CRC32_CHORBA_P_H_

#include "zendian.h"

/* Size thresholds for Chorba algorithm variants */

#define CHORBA_LARGE_THRESHOLD (sizeof(chorba_word_t) * 64 * 1024)
#define CHORBA_MEDIUM_UPPER_THRESHOLD 32768
#define CHORBA_MEDIUM_LOWER_THRESHOLD 8192
#define CHORBA_SMALL_THRESHOLD_64BIT 72
#ifdef ARCH_64BIT
#  define CHORBA_SMALL_THRESHOLD 72
#  define CHORBA_W 8
#  define CHORBA_WORD_FROM_LE(word) Z_U64_FROM_LE(word)
    typedef uint64_t chorba_word_t;
#else
#  define CHORBA_SMALL_THRESHOLD 80
#  define CHORBA_W 4
#  define CHORBA_WORD_FROM_LE(word) Z_U32_FROM_LE(word)
    typedef uint32_t chorba_word_t;
#endif

Z_INTERNAL uint32_t crc32_chorba_118960_nondestructive(uint32_t crc, const uint8_t *buf, size_t len);
Z_INTERNAL uint32_t crc32_chorba_32768_nondestructive(uint32_t crc, const uint8_t *buf, size_t len);
Z_INTERNAL uint32_t crc32_chorba_small_nondestructive(uint32_t crc, const uint8_t *buf, size_t len);
Z_INTERNAL uint32_t crc32_chorba_small_nondestructive_32bit(uint32_t crc, const uint8_t *buf, size_t len);

#endif /* CRC32_CHORBA_P_H_ */