Coverage Report

Created: 2025-10-28 06:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/zlib-ng/crc32_braid_comb_p.h
Line
Count
Source
1
#ifndef CRC32_BRAID_COMB_P_H_
2
#define CRC32_BRAID_COMB_P_H_
3
4
/*
5
  Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial,
6
  reflected. For speed, this requires that a not be zero.
7
 */
8
671k
static uint32_t multmodp(uint32_t a, uint32_t b) {
9
671k
    uint32_t m, p;
10
11
671k
    m = (uint32_t)1 << 31;
12
671k
    p = 0;
13
17.2M
    for (;;) {
14
17.2M
        if (a & m) {
15
9.38M
            p ^= b;
16
9.38M
            if ((a & (m - 1)) == 0)
17
671k
                break;
18
9.38M
        }
19
16.5M
        m >>= 1;
20
16.5M
        b = b & 1 ? (b >> 1) ^ POLY : b >> 1;
21
16.5M
    }
22
671k
    return p;
23
671k
}
24
25
/*
26
  Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been
27
  initialized.
28
 */
29
3.26k
static uint32_t x2nmodp(z_off64_t n, unsigned k) {
30
3.26k
    uint32_t p;
31
32
3.26k
    p = (uint32_t)1 << 31;           /* x^0 == 1 */
33
30.5k
    while (n) {
34
27.3k
        if (n & 1)
35
13.5k
            p = multmodp(x2n_table[k & 31], p);
36
27.3k
        n >>= 1;
37
27.3k
        k++;
38
27.3k
    }
39
3.26k
    return p;
40
3.26k
}
41
42
#endif /* CRC32_BRAID_COMB_P_H_ */