Coverage Report

Created: 2025-12-28 06:36

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/zlib-ng/arch/x86/crc32_pclmulqdq.c
Line
Count
Source
1
/*
2
 * Compute the CRC32 using a parallelized folding approach with the PCLMULQDQ
3
 * instruction.
4
 *
5
 * A white paper describing this algorithm can be found at:
6
 *     doc/crc-pclmulqdq.pdf
7
 *
8
 * Copyright (C) 2013 Intel Corporation. All rights reserved.
9
 * Copyright (C) 2016 Marian Beermann (support for initial value)
10
 * Authors:
11
 *     Wajdi Feghali   <wajdi.k.feghali@intel.com>
12
 *     Jim Guilford    <james.guilford@intel.com>
13
 *     Vinodh Gopal    <vinodh.gopal@intel.com>
14
 *     Erdinc Ozturk   <erdinc.ozturk@intel.com>
15
 *     Jim Kukunas     <james.t.kukunas@linux.intel.com>
16
 *
17
 * For conditions of distribution and use, see copyright notice in zlib.h
18
 */
19
20
#ifdef X86_PCLMULQDQ_CRC
21
22
#include "crc32_fold_pclmulqdq_tpl.h"
23
24
16.7k
Z_INTERNAL uint32_t crc32_fold_pclmulqdq_reset(crc32_fold *crc) {
25
16.7k
    return crc32_fold_reset(crc);
26
16.7k
}
27
28
11.1k
Z_INTERNAL uint32_t crc32_fold_pclmulqdq_final(crc32_fold *crc) {
29
11.1k
    return crc32_fold_final(crc);
30
11.1k
}
31
32
7.45k
Z_INTERNAL void crc32_fold_pclmulqdq(crc32_fold *crc, const uint8_t *src, size_t len, uint32_t init_crc) {
33
7.45k
    crc32_fold_copy(crc, NULL, src, len, init_crc, 0);
34
7.45k
}
35
36
18.3k
Z_INTERNAL void crc32_fold_pclmulqdq_copy(crc32_fold *crc, uint8_t *dst, const uint8_t *src, size_t len) {
37
18.3k
    crc32_fold_copy(crc, dst, src, len, 0, 1);
38
18.3k
}
39
40
5.58k
Z_INTERNAL uint32_t crc32_pclmulqdq(uint32_t crc32, const uint8_t *buf, size_t len) {
41
    /* For lens smaller than ~12, crc32_small method is faster.
42
     * But there are also minimum requirements for the pclmul functions due to alignment */
43
5.58k
    if (len < 16)
44
5.58k
        return crc32_small(crc32, buf, len);
45
46
0
    crc32_fold ALIGNED_(16) crc_state;
47
0
    crc32_fold_reset(&crc_state);
48
    crc32_fold_copy(&crc_state, NULL, buf, len, crc32, 0);
49
0
    return crc32_fold_final(&crc_state);
50
5.58k
}
51
#endif