Coverage Report

Created: 2026-05-30 06:45

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/zlib-ng/crc32.c
Line
Count
Source
1
/* crc32.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 "zbuild.h"
11
#include "functable.h"
12
#include "crc32_p.h"
13
14
/* ========================================================================= */
15
16
0
const uint32_t * Z_EXPORT PREFIX(get_crc_table)(void) {
17
0
    return (const uint32_t *)crc_table;
18
0
}
19
20
/* crc32 function meant for short buffers like gzip headers */
21
0
Z_INTERNAL uint32_t crc32_small(uint32_t crc, const uint8_t *buf, size_t len) {
22
0
    if (UNLIKELY(len >= 32)){
23
0
        return FUNCTABLE_CALL(crc32)(crc, buf, len);
24
0
    }
25
26
0
    return ~crc32_copy_small(~crc, NULL, buf, len, 32, 0);
27
0
}
28
29
#ifdef ZLIB_COMPAT
30
unsigned long Z_EXPORT PREFIX(crc32_z)(unsigned long crc, const unsigned char *buf, size_t len) {
31
    if (buf == NULL)
32
        return CRC32_INITIAL_VALUE;
33
    return (unsigned long)FUNCTABLE_CALL(crc32)((uint32_t)crc, buf, len);
34
}
35
#else
36
7.02M
uint32_t Z_EXPORT PREFIX(crc32_z)(uint32_t crc, const unsigned char *buf, size_t len) {
37
7.02M
    if (buf == NULL)
38
0
        return CRC32_INITIAL_VALUE;
39
7.02M
    return FUNCTABLE_CALL(crc32)(crc, buf, len);
40
7.02M
}
41
#endif
42
43
#ifdef ZLIB_COMPAT
44
unsigned long Z_EXPORT PREFIX(crc32)(unsigned long crc, const unsigned char *buf, unsigned int len) {
45
    if (buf == NULL)
46
        return CRC32_INITIAL_VALUE;
47
    return (unsigned long)FUNCTABLE_CALL(crc32)((uint32_t)crc, buf, len);
48
}
49
#else
50
624
uint32_t Z_EXPORT PREFIX(crc32)(uint32_t crc, const unsigned char *buf, uint32_t len) {
51
624
    if (buf == NULL)
52
624
        return CRC32_INITIAL_VALUE;
53
0
    return FUNCTABLE_CALL(crc32)(crc, buf, len);
54
624
}
55
#endif