Coverage Report

Created: 2026-08-13 06:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/zlib-ng/crc32_braid_comb.c
Line
Count
Source
1
/* crc32_braid_comb.c -- compute the CRC-32 of a data stream
2
 * Copyright (C) 1995-2022 Mark Adler
3
 * For conditions of distribution and use, see copyright notice in zlib.h
4
 *
5
 * This interleaved implementation of a CRC makes use of pipelined multiple
6
 * arithmetic-logic units, commonly found in modern CPU cores. It is due to
7
 * Kadatch and Jenkins (2010). See doc/crc-doc.1.0.pdf in this distribution.
8
 */
9
10
#include "zutil.h"
11
#include "crc32_braid_tbl.h"
12
#include "crc32_braid_comb_p.h"
13
14
/* ========================================================================= */
15
1.81k
static uint32_t crc32_combine_(uint32_t crc1, uint32_t crc2, z_off64_t len2) {
16
1.81k
    if (len2 < 0)
17
0
        return 0;
18
1.81k
    return multmodp(x2nmodp(len2, 3), crc1) ^ crc2;
19
1.81k
}
20
1.20k
static uint32_t crc32_combine_gen_(z_off64_t len2) {
21
1.20k
    if (len2 < 0)
22
0
        return 0;
23
1.20k
    return x2nmodp(len2, 3);
24
1.20k
}
25
1.56M
static uint32_t crc32_combine_op_(uint32_t crc1, uint32_t crc2, const uint32_t op) {
26
1.56M
    return multmodp(op, crc1) ^ crc2;
27
1.56M
}
28
29
/* ========================================================================= */
30
31
#ifdef ZLIB_COMPAT
32
unsigned long Z_EXPORT PREFIX(crc32_combine)(unsigned long crc1, unsigned long crc2, z_off_t len2) {
33
    return (unsigned long)crc32_combine_((uint32_t)crc1, (uint32_t)crc2, len2);
34
}
35
unsigned long Z_EXPORT PREFIX4(crc32_combine)(unsigned long crc1, unsigned long crc2, z_off64_t len2) {
36
    return (unsigned long)crc32_combine_((uint32_t)crc1, (uint32_t)crc2, len2);
37
}
38
unsigned long Z_EXPORT PREFIX(crc32_combine_gen)(z_off_t len2) {
39
    return crc32_combine_gen_(len2);
40
}
41
unsigned long Z_EXPORT PREFIX4(crc32_combine_gen)(z_off64_t len2) {
42
    return crc32_combine_gen_(len2);
43
}
44
unsigned long Z_EXPORT PREFIX(crc32_combine_op)(unsigned long crc1, unsigned long crc2, const unsigned long op) {
45
    return (unsigned long)crc32_combine_op_((uint32_t)crc1, (uint32_t)crc2, (uint32_t)op);
46
}
47
#else
48
1.81k
uint32_t Z_EXPORT PREFIX4(crc32_combine)(uint32_t crc1, uint32_t crc2, z_off64_t len2) {
49
1.81k
    return crc32_combine_(crc1, crc2, len2);
50
1.81k
}
51
1.20k
uint32_t Z_EXPORT PREFIX(crc32_combine_gen)(z_off64_t len2) {
52
1.20k
    return crc32_combine_gen_(len2);
53
1.20k
}
54
1.56M
uint32_t Z_EXPORT PREFIX(crc32_combine_op)(uint32_t crc1, uint32_t crc2, const uint32_t op) {
55
1.56M
    return crc32_combine_op_(crc1, crc2, op);
56
1.56M
}
57
#endif
58
59
/* ========================================================================= */