Coverage Report

Created: 2026-05-30 06:45

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/zlib-ng/crc32_p.h
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
15.3M
#define CRC_DO1(c, buf, i) c = crc_table[(c ^ buf[i]) & 0xff] ^ (c >> 8)
14
5.80M
#define CRC_DO2(c, buf, i) {CRC_DO1(c, buf, i); CRC_DO1(c, buf, i+1);}
15
1.63M
#define CRC_DO4(c, buf, i) {CRC_DO2(c, buf, i); CRC_DO2(c, buf, i+2);}
16
565k
#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
6.60M
                                               const int MAX_LEN, const int COPY) {
20
6.60M
    if (MAX_LEN >= 8) {
21
7.16M
        while (len >= 8) {
22
565k
            if (COPY) {
23
0
                memcpy(dst, buf, 8);
24
0
                dst += 8;
25
0
            }
26
565k
            CRC_DO8(crc, buf, 0);
27
565k
            buf += 8;
28
565k
            len -= 8;
29
565k
        }
30
6.60M
    }
31
6.60M
    if (len & 4) {
32
499k
        if (COPY) {
33
0
            memcpy(dst, buf, 4);
34
0
            dst += 4;
35
0
        }
36
499k
        CRC_DO4(crc, buf, 0);
37
499k
        buf += 4;
38
499k
    }
39
6.60M
    if (len & 2) {
40
2.54M
        if (COPY) {
41
0
            memcpy(dst, buf, 2);
42
0
            dst += 2;
43
0
        }
44
2.54M
        CRC_DO2(crc, buf, 0);
45
2.54M
        buf += 2;
46
2.54M
    }
47
6.60M
    if (len & 1) {
48
3.77M
        if (COPY)
49
0
            *dst = *buf;
50
3.77M
        CRC_DO1(crc, buf, 0);
51
3.77M
    }
52
53
6.60M
    return crc;
54
6.60M
}
Unexecuted instantiation: crc32.c:crc32_copy_small
crc32_pclmulqdq.c:crc32_copy_small
Line
Count
Source
19
6.60M
                                               const int MAX_LEN, const int COPY) {
20
6.60M
    if (MAX_LEN >= 8) {
21
7.16M
        while (len >= 8) {
22
565k
            if (COPY) {
23
0
                memcpy(dst, buf, 8);
24
0
                dst += 8;
25
0
            }
26
565k
            CRC_DO8(crc, buf, 0);
27
565k
            buf += 8;
28
565k
            len -= 8;
29
565k
        }
30
6.60M
    }
31
6.60M
    if (len & 4) {
32
499k
        if (COPY) {
33
0
            memcpy(dst, buf, 4);
34
0
            dst += 4;
35
0
        }
36
499k
        CRC_DO4(crc, buf, 0);
37
499k
        buf += 4;
38
499k
    }
39
6.60M
    if (len & 2) {
40
2.54M
        if (COPY) {
41
0
            memcpy(dst, buf, 2);
42
0
            dst += 2;
43
0
        }
44
2.54M
        CRC_DO2(crc, buf, 0);
45
2.54M
        buf += 2;
46
2.54M
    }
47
6.60M
    if (len & 1) {
48
3.77M
        if (COPY)
49
0
            *dst = *buf;
50
3.77M
        CRC_DO1(crc, buf, 0);
51
3.77M
    }
52
53
6.60M
    return crc;
54
6.60M
}
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
55
56
#endif /* CRC32_P_H */