Coverage Report

Created: 2026-01-10 06:46

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/zlib-ng/adler32_p.h
Line
Count
Source
1
/* adler32_p.h -- Private inline functions and macros shared with
2
 *                different computation of the Adler-32 checksum
3
 *                of a data stream.
4
 * Copyright (C) 1995-2011, 2016 Mark Adler
5
 * For conditions of distribution and use, see copyright notice in zlib.h
6
 */
7
8
#ifndef ADLER32_P_H
9
#define ADLER32_P_H
10
11
655k
#define BASE 65521U     /* largest prime smaller than 65536 */
12
14.0k
#define NMAX 5552
13
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
14
15
0
#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
16
0
#define ADLER_DO2(sum1, sum2, buf, i)  {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
17
0
#define ADLER_DO4(sum1, sum2, buf, i)  {ADLER_DO2(sum1, sum2, buf, i); ADLER_DO2(sum1, sum2, buf, i+2);}
18
0
#define ADLER_DO8(sum1, sum2, buf, i)  {ADLER_DO4(sum1, sum2, buf, i); ADLER_DO4(sum1, sum2, buf, i+4);}
19
#define ADLER_DO16(sum1, sum2, buf)    {ADLER_DO8(sum1, sum2, buf, 0); ADLER_DO8(sum1, sum2, buf, 8);}
20
21
0
static inline uint32_t adler32_copy_len_1(uint32_t adler, uint8_t *dst, const uint8_t *buf, uint32_t sum2, const int COPY) {
22
0
    uint8_t c = *buf;
23
0
    if (COPY) {
24
0
        *dst = c;
25
0
    }
26
0
    adler += c;
27
0
    adler %= BASE;
28
0
    sum2 += adler;
29
0
    sum2 %= BASE;
30
0
    return adler | (sum2 << 16);
31
0
}
Unexecuted instantiation: adler32_ssse3.c:adler32_copy_len_1
Unexecuted instantiation: adler32_sse42.c:adler32_copy_len_1
Unexecuted instantiation: adler32_avx2.c:adler32_copy_len_1
Unexecuted instantiation: adler32_avx512.c:adler32_copy_len_1
Unexecuted instantiation: adler32_avx512_vnni.c:adler32_copy_len_1
Unexecuted instantiation: adler32_c.c:adler32_copy_len_1
32
33
30.2k
static inline uint32_t adler32_copy_len_16(uint32_t adler, uint8_t *dst, const uint8_t *buf, size_t len, uint32_t sum2, const int COPY) {
34
264k
    while (len--) {
35
234k
        uint8_t c = *buf++;
36
234k
        if (COPY) {
37
118k
            *dst++ = c;
38
118k
        }
39
234k
        adler += c;
40
234k
        sum2 += adler;
41
234k
    }
42
30.2k
    adler %= BASE;
43
30.2k
    sum2 %= BASE;            /* only added so many BASE's */
44
    /* return recombined sums */
45
30.2k
    return adler | (sum2 << 16);
46
30.2k
}
adler32_ssse3.c:adler32_copy_len_16
Line
Count
Source
33
7.03k
static inline uint32_t adler32_copy_len_16(uint32_t adler, uint8_t *dst, const uint8_t *buf, size_t len, uint32_t sum2, const int COPY) {
34
59.9k
    while (len--) {
35
52.9k
        uint8_t c = *buf++;
36
52.9k
        if (COPY) {
37
0
            *dst++ = c;
38
0
        }
39
52.9k
        adler += c;
40
52.9k
        sum2 += adler;
41
52.9k
    }
42
7.03k
    adler %= BASE;
43
7.03k
    sum2 %= BASE;            /* only added so many BASE's */
44
    /* return recombined sums */
45
7.03k
    return adler | (sum2 << 16);
46
7.03k
}
adler32_sse42.c:adler32_copy_len_16
Line
Count
Source
33
6.70k
static inline uint32_t adler32_copy_len_16(uint32_t adler, uint8_t *dst, const uint8_t *buf, size_t len, uint32_t sum2, const int COPY) {
34
60.7k
    while (len--) {
35
54.0k
        uint8_t c = *buf++;
36
54.0k
        if (COPY) {
37
54.0k
            *dst++ = c;
38
54.0k
        }
39
54.0k
        adler += c;
40
54.0k
        sum2 += adler;
41
54.0k
    }
42
6.70k
    adler %= BASE;
43
6.70k
    sum2 %= BASE;            /* only added so many BASE's */
44
    /* return recombined sums */
45
6.70k
    return adler | (sum2 << 16);
46
6.70k
}
adler32_avx2.c:adler32_copy_len_16
Line
Count
Source
33
16.4k
static inline uint32_t adler32_copy_len_16(uint32_t adler, uint8_t *dst, const uint8_t *buf, size_t len, uint32_t sum2, const int COPY) {
34
144k
    while (len--) {
35
127k
        uint8_t c = *buf++;
36
127k
        if (COPY) {
37
64.4k
            *dst++ = c;
38
64.4k
        }
39
127k
        adler += c;
40
127k
        sum2 += adler;
41
127k
    }
42
16.4k
    adler %= BASE;
43
16.4k
    sum2 %= BASE;            /* only added so many BASE's */
44
    /* return recombined sums */
45
16.4k
    return adler | (sum2 << 16);
46
16.4k
}
Unexecuted instantiation: adler32_avx512.c:adler32_copy_len_16
Unexecuted instantiation: adler32_avx512_vnni.c:adler32_copy_len_16
Unexecuted instantiation: adler32_c.c:adler32_copy_len_16
47
48
0
static inline uint32_t adler32_copy_len_64(uint32_t adler, uint8_t *dst, const uint8_t *buf, size_t len, uint32_t sum2, const int COPY) {
49
0
    const uint8_t *src = buf;
50
0
    const size_t src_len = len;
51
#ifdef UNROLL_MORE
52
    while (len >= 16) {
53
        len -= 16;
54
        ADLER_DO16(adler, sum2, buf);
55
        buf += 16;
56
#else
57
0
    while (len >= 8) {
58
0
        len -= 8;
59
0
        ADLER_DO8(adler, sum2, buf, 0);
60
0
        buf += 8;
61
0
#endif
62
0
    }
63
    /* Process tail (len < 16).  */
64
0
    adler = adler32_copy_len_16(adler, NULL, buf, len, sum2, 0);
65
0
    if (COPY) {
66
0
        memcpy(dst, src, src_len);
67
0
    }
68
0
    return adler;
69
0
}
Unexecuted instantiation: adler32_ssse3.c:adler32_copy_len_64
Unexecuted instantiation: adler32_sse42.c:adler32_copy_len_64
Unexecuted instantiation: adler32_avx2.c:adler32_copy_len_64
Unexecuted instantiation: adler32_avx512.c:adler32_copy_len_64
Unexecuted instantiation: adler32_avx512_vnni.c:adler32_copy_len_64
Unexecuted instantiation: adler32_c.c:adler32_copy_len_64
70
71
#endif /* ADLER32_P_H */