Line | Count | Source (jump to first uncovered line) |
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_braid_tbl.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 | | #ifdef ZLIB_COMPAT |
21 | | unsigned long Z_EXPORT PREFIX(crc32_z)(unsigned long crc, const unsigned char *buf, size_t len) { |
22 | | if (buf == NULL) return 0; |
23 | | |
24 | | return (unsigned long)FUNCTABLE_CALL(crc32)((uint32_t)crc, buf, len); |
25 | | } |
26 | | #else |
27 | 0 | uint32_t Z_EXPORT PREFIX(crc32_z)(uint32_t crc, const unsigned char *buf, size_t len) { |
28 | 0 | if (buf == NULL) return 0; |
29 | | |
30 | 0 | return FUNCTABLE_CALL(crc32)(crc, buf, len); |
31 | 0 | } |
32 | | #endif |
33 | | |
34 | | #ifdef ZLIB_COMPAT |
35 | | unsigned long Z_EXPORT PREFIX(crc32)(unsigned long crc, const unsigned char *buf, unsigned int len) { |
36 | | return (unsigned long)PREFIX(crc32_z)((uint32_t)crc, buf, len); |
37 | | } |
38 | | #else |
39 | 0 | uint32_t Z_EXPORT PREFIX(crc32)(uint32_t crc, const unsigned char *buf, uint32_t len) { |
40 | 0 | return PREFIX(crc32_z)(crc, buf, len); |
41 | 0 | } |
42 | | #endif |