Coverage Report

Created: 2026-02-24 06:17

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