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 | 9.48M | #define CRC_DO1(c, buf, i) c = crc_table[(c ^ buf[i]) & 0xff] ^ (c >> 8) |
12 | 3.01M | #define CRC_DO2(c, buf, i) {CRC_DO1(c, buf, i); CRC_DO1(c, buf, i+1);} |
13 | 1.38M | #define CRC_DO4(c, buf, i) {CRC_DO2(c, buf, i); CRC_DO2(c, buf, i+2);} |
14 | 466k | #define CRC_DO8(c, buf, i) {CRC_DO4(c, buf, i); CRC_DO4(c, buf, i+4);} |
15 | | |
16 | | Z_FORCEINLINE static uint32_t crc32_copy_small(uint32_t crc, uint8_t *dst, const uint8_t *buf, size_t len, |
17 | 3.98M | const int MAX_LEN, const int COPY) { |
18 | 3.98M | if (MAX_LEN >= 8) { |
19 | 4.45M | while (len >= 8) { |
20 | 466k | if (COPY) { |
21 | 0 | memcpy(dst, buf, 8); |
22 | 0 | dst += 8; |
23 | 0 | } |
24 | 466k | CRC_DO8(crc, buf, 0); |
25 | 466k | buf += 8; |
26 | 466k | len -= 8; |
27 | 466k | } |
28 | 3.98M | } |
29 | 3.98M | if (len & 4) { |
30 | 448k | if (COPY) { |
31 | 0 | memcpy(dst, buf, 4); |
32 | 0 | dst += 4; |
33 | 0 | } |
34 | 448k | CRC_DO4(crc, buf, 0); |
35 | 448k | buf += 4; |
36 | 448k | } |
37 | 3.98M | if (len & 2) { |
38 | 253k | if (COPY) { |
39 | 0 | memcpy(dst, buf, 2); |
40 | 0 | dst += 2; |
41 | 0 | } |
42 | 253k | CRC_DO2(crc, buf, 0); |
43 | 253k | buf += 2; |
44 | 253k | } |
45 | 3.98M | if (len & 1) { |
46 | 3.45M | if (COPY) |
47 | 0 | *dst = *buf; |
48 | 3.45M | CRC_DO1(crc, buf, 0); |
49 | 3.45M | } |
50 | | |
51 | 3.98M | return crc; |
52 | 3.98M | } crc32_pclmulqdq.c:crc32_copy_small Line | Count | Source | 17 | 3.98M | const int MAX_LEN, const int COPY) { | 18 | 3.98M | if (MAX_LEN >= 8) { | 19 | 4.45M | while (len >= 8) { | 20 | 466k | if (COPY) { | 21 | 0 | memcpy(dst, buf, 8); | 22 | 0 | dst += 8; | 23 | 0 | } | 24 | 466k | CRC_DO8(crc, buf, 0); | 25 | 466k | buf += 8; | 26 | 466k | len -= 8; | 27 | 466k | } | 28 | 3.98M | } | 29 | 3.98M | if (len & 4) { | 30 | 448k | if (COPY) { | 31 | 0 | memcpy(dst, buf, 4); | 32 | 0 | dst += 4; | 33 | 0 | } | 34 | 448k | CRC_DO4(crc, buf, 0); | 35 | 448k | buf += 4; | 36 | 448k | } | 37 | 3.98M | if (len & 2) { | 38 | 253k | if (COPY) { | 39 | 0 | memcpy(dst, buf, 2); | 40 | 0 | dst += 2; | 41 | 0 | } | 42 | 253k | CRC_DO2(crc, buf, 0); | 43 | 253k | buf += 2; | 44 | 253k | } | 45 | 3.98M | if (len & 1) { | 46 | 3.45M | if (COPY) | 47 | 0 | *dst = *buf; | 48 | 3.45M | CRC_DO1(crc, buf, 0); | 49 | 3.45M | } | 50 | | | 51 | 3.98M | return crc; | 52 | 3.98M | } |
Unexecuted instantiation: crc32_vpclmulqdq.c:crc32_copy_small Unexecuted instantiation: crc32_braid_c.c:crc32_copy_small |
53 | | |
54 | | #endif /* CRC32_P_H */ |