Coverage Report

Created: 2026-11-12 06:21

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
10.2M
#define CRC_DO1(c, buf, i) c = crc_table[(c ^ buf[i]) & 0xff] ^ (c >> 8)
14
3.50M
#define CRC_DO2(c, buf, i) {CRC_DO1(c, buf, i); CRC_DO1(c, buf, i+1);}
15
1.33M
#define CRC_DO4(c, buf, i) {CRC_DO2(c, buf, i); CRC_DO2(c, buf, i+2);}
16
458k
#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
4.06M
                                               const int MAX_LEN, const int COPY) {
20
4.06M
    if (MAX_LEN >= 8) {
21
4.52M
        while (len >= 8) {
22
458k
            if (COPY) {
23
0
                memcpy(dst, buf, 8);
24
0
                dst += 8;
25
0
            }
26
458k
            CRC_DO8(crc, buf, 0);
27
458k
            buf += 8;
28
458k
            len -= 8;
29
458k
        }
30
4.06M
    }
31
4.06M
    if (len & 4) {
32
422k
        if (COPY) {
33
0
            memcpy(dst, buf, 4);
34
0
            dst += 4;
35
0
        }
36
422k
        CRC_DO4(crc, buf, 0);
37
422k
        buf += 4;
38
422k
    }
39
4.06M
    if (len & 2) {
40
829k
        if (COPY) {
41
0
            memcpy(dst, buf, 2);
42
0
            dst += 2;
43
0
        }
44
829k
        CRC_DO2(crc, buf, 0);
45
829k
        buf += 2;
46
829k
    }
47
4.06M
    if (len & 1) {
48
3.23M
        if (COPY)
49
0
            *dst = *buf;
50
3.23M
        CRC_DO1(crc, buf, 0);
51
3.23M
    }
52
53
4.06M
    return crc;
54
4.06M
}
Unexecuted instantiation: crc32.c:crc32_copy_small
Unexecuted instantiation: crc32_chorba_sse2.c:crc32_copy_small
Unexecuted instantiation: crc32_chorba_sse41.c:crc32_copy_small
crc32_pclmulqdq.c:crc32_copy_small
Line
Count
Source
19
4.06M
                                               const int MAX_LEN, const int COPY) {
20
4.06M
    if (MAX_LEN >= 8) {
21
4.52M
        while (len >= 8) {
22
458k
            if (COPY) {
23
0
                memcpy(dst, buf, 8);
24
0
                dst += 8;
25
0
            }
26
458k
            CRC_DO8(crc, buf, 0);
27
458k
            buf += 8;
28
458k
            len -= 8;
29
458k
        }
30
4.06M
    }
31
4.06M
    if (len & 4) {
32
422k
        if (COPY) {
33
0
            memcpy(dst, buf, 4);
34
0
            dst += 4;
35
0
        }
36
422k
        CRC_DO4(crc, buf, 0);
37
422k
        buf += 4;
38
422k
    }
39
4.06M
    if (len & 2) {
40
829k
        if (COPY) {
41
0
            memcpy(dst, buf, 2);
42
0
            dst += 2;
43
0
        }
44
829k
        CRC_DO2(crc, buf, 0);
45
829k
        buf += 2;
46
829k
    }
47
4.06M
    if (len & 1) {
48
3.23M
        if (COPY)
49
0
            *dst = *buf;
50
3.23M
        CRC_DO1(crc, buf, 0);
51
3.23M
    }
52
53
4.06M
    return crc;
54
4.06M
}
Unexecuted instantiation: crc32_vpclmulqdq_avx2.c:crc32_copy_small
Unexecuted instantiation: crc32_vpclmulqdq_avx512.c:crc32_copy_small
Unexecuted instantiation: crc32_chorba_c.c:crc32_copy_small
55
56
#endif /* CRC32_P_H */