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
55.9k
#define CRC_DO1(c, buf, i) c = crc_table[(c ^ buf[i]) & 0xff] ^ (c >> 8)
14
26.3k
#define CRC_DO2(c, buf, i) {CRC_DO1(c, buf, i); CRC_DO1(c, buf, i+1);}
15
11.4k
#define CRC_DO4(c, buf, i) {CRC_DO2(c, buf, i); CRC_DO2(c, buf, i+2);}
16
3.86k
#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
7.07k
                                               const int MAX_LEN, const int COPY) {
20
7.07k
    if (MAX_LEN >= 8) {
21
10.9k
        while (len >= 8) {
22
3.86k
            if (COPY) {
23
2.20k
                memcpy(dst, buf, 8);
24
2.20k
                dst += 8;
25
2.20k
            }
26
3.86k
            CRC_DO8(crc, buf, 0);
27
3.86k
            buf += 8;
28
3.86k
            len -= 8;
29
3.86k
        }
30
7.07k
    }
31
7.07k
    if (len & 4) {
32
3.72k
        if (COPY) {
33
2.20k
            memcpy(dst, buf, 4);
34
2.20k
            dst += 4;
35
2.20k
        }
36
3.72k
        CRC_DO4(crc, buf, 0);
37
3.72k
        buf += 4;
38
3.72k
    }
39
7.07k
    if (len & 2) {
40
3.38k
        if (COPY) {
41
2.01k
            memcpy(dst, buf, 2);
42
2.01k
            dst += 2;
43
2.01k
        }
44
3.38k
        CRC_DO2(crc, buf, 0);
45
3.38k
        buf += 2;
46
3.38k
    }
47
7.07k
    if (len & 1) {
48
3.34k
        if (COPY)
49
1.94k
            *dst = *buf;
50
3.34k
        CRC_DO1(crc, buf, 0);
51
3.34k
    }
52
53
7.07k
    return crc;
54
7.07k
}
crc32_pclmulqdq.c:crc32_copy_small
Line
Count
Source
19
7.07k
                                               const int MAX_LEN, const int COPY) {
20
7.07k
    if (MAX_LEN >= 8) {
21
10.9k
        while (len >= 8) {
22
3.86k
            if (COPY) {
23
2.20k
                memcpy(dst, buf, 8);
24
2.20k
                dst += 8;
25
2.20k
            }
26
3.86k
            CRC_DO8(crc, buf, 0);
27
3.86k
            buf += 8;
28
3.86k
            len -= 8;
29
3.86k
        }
30
7.07k
    }
31
7.07k
    if (len & 4) {
32
3.72k
        if (COPY) {
33
2.20k
            memcpy(dst, buf, 4);
34
2.20k
            dst += 4;
35
2.20k
        }
36
3.72k
        CRC_DO4(crc, buf, 0);
37
3.72k
        buf += 4;
38
3.72k
    }
39
7.07k
    if (len & 2) {
40
3.38k
        if (COPY) {
41
2.01k
            memcpy(dst, buf, 2);
42
2.01k
            dst += 2;
43
2.01k
        }
44
3.38k
        CRC_DO2(crc, buf, 0);
45
3.38k
        buf += 2;
46
3.38k
    }
47
7.07k
    if (len & 1) {
48
3.34k
        if (COPY)
49
1.94k
            *dst = *buf;
50
3.34k
        CRC_DO1(crc, buf, 0);
51
3.34k
    }
52
53
7.07k
    return crc;
54
7.07k
}
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 */