Line | Count | Source |
1 | | /* crc32_p.h -- Private inline functions and macros shared with |
2 | | * different computation of the CRC-32 checksum |
3 | | * of a data stream. |
4 | | * Copyright (C) 2026 Nathan Moinvaziri |
5 | | * For conditions of distribution and use, see copyright notice in zlib.h |
6 | | */ |
7 | | |
8 | | #ifndef CRC32_P_H |
9 | | #define CRC32_P_H |
10 | | |
11 | | #include "crc32_braid_tbl.h" |
12 | | |
13 | 0 | #define CRC_DO1(c, buf, i) c = crc_table[(c ^ buf[i]) & 0xff] ^ (c >> 8) |
14 | 0 | #define CRC_DO2(c, buf, i) {CRC_DO1(c, buf, i); CRC_DO1(c, buf, i+1);} |
15 | 0 | #define CRC_DO4(c, buf, i) {CRC_DO2(c, buf, i); CRC_DO2(c, buf, i+2);} |
16 | 0 | #define CRC_DO8(c, buf, i) {CRC_DO4(c, buf, i); CRC_DO4(c, buf, i+4);} |
17 | | |
18 | | Z_FORCEINLINE static uint32_t crc32_copy_small(uint32_t crc, uint8_t *dst, const uint8_t *buf, size_t len, |
19 | 0 | const int MAX_LEN, const int COPY) { |
20 | 0 | if (MAX_LEN >= 8) { |
21 | 0 | while (len >= 8) { |
22 | 0 | if (COPY) { |
23 | 0 | memcpy(dst, buf, 8); |
24 | 0 | dst += 8; |
25 | 0 | } |
26 | 0 | CRC_DO8(crc, buf, 0); |
27 | 0 | buf += 8; |
28 | 0 | len -= 8; |
29 | 0 | } |
30 | 0 | } |
31 | 0 | if (len & 4) { |
32 | 0 | if (COPY) { |
33 | 0 | memcpy(dst, buf, 4); |
34 | 0 | dst += 4; |
35 | 0 | } |
36 | 0 | CRC_DO4(crc, buf, 0); |
37 | 0 | buf += 4; |
38 | 0 | } |
39 | 0 | if (len & 2) { |
40 | 0 | if (COPY) { |
41 | 0 | memcpy(dst, buf, 2); |
42 | 0 | dst += 2; |
43 | 0 | } |
44 | 0 | CRC_DO2(crc, buf, 0); |
45 | 0 | buf += 2; |
46 | 0 | } |
47 | 0 | if (len & 1) { |
48 | 0 | if (COPY) |
49 | 0 | *dst = *buf; |
50 | 0 | CRC_DO1(crc, buf, 0); |
51 | 0 | } |
52 | |
|
53 | 0 | return crc; |
54 | 0 | } Unexecuted instantiation: crc32_pclmulqdq.c:crc32_copy_small Unexecuted instantiation: crc32_vpclmulqdq_avx2.c:crc32_copy_small Unexecuted instantiation: crc32_vpclmulqdq_avx512.c:crc32_copy_small Unexecuted instantiation: crc32_braid_c.c:crc32_copy_small Unexecuted instantiation: crc32.c:crc32_copy_small |
55 | | |
56 | | #endif /* CRC32_P_H */ |