Commit Graph

103 Commits

Author SHA1 Message Date
Vladislav Shchapov
fe0a6407da Explicitly indicate functions are conditionally dispatched
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-03-06 23:32:15 +01:00
Hans Kristian Rosbach
0fddd5f125 Rename crc32_braid.c to crc32.c 2024-02-05 08:17:33 +01:00
Nathan Moinvaziri
a6155234a2 Speed up software CRC-32 computation by a factor of 1.5 to 3.
Use the interleaved method of Kadatch and Jenkins in order to make
use of pipelined instructions through multiple ALUs in a single
core. This also speeds up and simplifies the combination of CRCs,
and updates the functions to pre-calculate and use an operator for
CRC combination.

Co-authored-by: Nathan Moinvaziri <nathan@nathanm.com>
2022-05-25 12:04:35 +02:00
Nathan Moinvaziri
405f11bfbf Remove duplicate header includes. 2022-02-06 16:52:24 +01:00
Nathan Moinvaziri
346ec9c42c Merge crc32_little and crc32_big with preprocessor macros for each endian. Removed crc32_generic since it is not being used. 2022-01-15 12:29:57 +01:00
Hans Kristian Rosbach
839c4ec998 inttypes.h includes stdint.h, so only include one of them. 2021-12-19 15:40:19 +01:00
Nathan Moinvaziri
d802e8900f Move crc32 folding functions into functable. 2021-08-13 15:05:34 +02:00
Nathan Moinvaziri
db59b63676 Added CRC32_INITIAL_VALUE to prevent initial call to crc32 function. 2021-08-13 15:05:34 +02:00
Nathan Moinvaziri
f5d8abb47e Remove deflate_state dependency from crc_folding. 2021-06-26 08:37:19 +02:00
Nathan Moinvaziri
2eae5ba3f8 Separate crc32 and crc32_combine tables so the crc32_combine tables are not included when not used if statically linking. Reduces code size by 4k. 2020-11-22 20:33:54 +01:00
Nathan Moinvaziri
1f10aa4e29 Rename ZEXPORT and ZEXTERN for consistency. 2020-08-31 12:33:16 +02:00
Nathan Moinvaziri
7cffba4dd6 Rename ZLIB_INTERNAL to Z_INTERNAL for consistency. 2020-08-31 12:33:16 +02:00
Nathan Moinvaziri
b5a81501f2 Rename ZLIB_REGISTER to Z_REGISTER for consistency. 2020-08-31 12:33:16 +02:00
Nathan Moinvaziri
4490d52d0a Rename table headers with tbl suffix. 2020-08-27 19:19:30 +02:00
Mika Lindqvist
7b4e7f158a Style cleanup.
* Remove space between function name and opening parenthesis
* Remove space closing parenthesis of cast and variable name
2020-08-14 22:21:37 +02:00
Mika Lindqvist
e3fcf313af Fix signature of crc32_combine(), crc32_combine64() and crc32_z() in compat mode. 2020-08-14 22:21:37 +02:00
Nathan Moinvaziri
e1dbcc186a Added ZLIB_REGISTER to disable register keyword for C++.
Co-authored-by: pps83 <pps83@users.noreply.github.com>
2020-06-28 23:01:17 +02:00
Nathan Moinvaziri
6dcc7bf815 For gzseek, gzoffset, gzopen, adler32_combine, crc32_combine and crc32_combine_gen, export 32-bit and 64-bit versions for zlib-compatible api and only 64-bit version (without 64 suffix) for zlib-ng native api. 2020-06-08 21:14:07 +02:00
Nathan Moinvaziri
e09d131b5a Standardize fill_window implementations and abstract out slide_hash_neon for ARM. 2020-05-01 00:21:18 +02:00
Pavel P
762068fdc6 Remove cvs keywords 2020-03-17 15:26:47 +01:00
Nathan Moinvaziri
e0a711cdde Fixed formatting, 4 spaces for code intent, 2 spaces for preprocessor indent, initial function brace on the same line as definition, removed extraneous spaces and new lines. 2020-02-07 10:44:20 +01:00
Mika Lindqvist
3ea747396d Compatibility fix for crc32()
* Use "unsigned long" externally instead of "uint32_t" for crc
* Use "unsigned int" externally instead of "uint32_t" for len

Fixes #483
2019-11-26 15:43:47 +01:00
Hans Kristian Rosbach
bc29c36ea5 Add makecrct test and clean up makecrct.c code
Update crc32.h tables to match makecrct output.
2019-09-20 22:29:21 +02:00
Hans Kristian Rosbach
1e424d9bbf Split crc table generating code (MAKECRCH) out into separate tool makecrct. 2019-09-20 22:29:21 +02:00
Nathan Moinvaziri
c5e2ea1829 Rename gzendian to zendian since it is included in more than just the gzip library code. 2019-08-06 10:09:08 +02:00
Mika T. Lindqvist
e12905a0c2 Fix build when DYNAMIC_CRC_TABLE is defined. 2019-05-29 11:46:35 +02:00
Sebastian Pop
39e68648c7 cleanup: move code from arch/x86/crc_pclmulqdq.c to crc32.c 2019-01-31 13:56:00 +01:00
Hans Kristian Rosbach
18d2622939 Replace the UNROLL_LESS define with UNROLL_MORE, making UNROLL_LESS the default.
Performance benchmarks have so far not shown that any platform benefits from UNROLL_MORE,
although this might be beneficial on older compilers/cpus or for compiling without optimizations.

The extra UNROLL_MORE code should be considered for removal since it is never enabled by us
and will likely only serve to confuse and contribute to bitrot.
2019-01-21 10:25:50 +01:00
Mark Adler
cc36e352ba Add crc32_combine_gen() and crc32_combine_op() for fast combines.
When the same len2 is used repeatedly, it is faster to use
crc32_combine_gen() to generate an operator, that is then used to
combine CRCs with crc32_combine_op().
2018-12-08 12:36:30 +01:00
Mark Adler
9a143bb48f Add tables for crc32_combine(), to speed it up by a factor of 200. 2018-12-08 12:36:30 +01:00
Mika Lindqvist
df1fd1567f Move private defines from zconf.h and zconf-ng.h to zbuild.h
* move definition of z_size_t to zbuild.h
2018-03-22 10:18:27 +01:00
Daniel Black
9ec0d91a01 wrap crc32 in functable (#145)
* wrap crc32 in functable
* change internal crc32 api to use uint64_t rather than size_t for length
2018-02-16 11:41:44 +01:00
Mika Lindqvist
aff0fc6e3c Adapt code to support PREFIX macros and update build scripts 2018-01-31 10:45:29 +01:00
Hans Kristian Rosbach
f5e888a6a6 Add function prefix (zng_) to all exported functions to allow zlib-ng
to co-exist in an application that has been linked to something that
depends on stock zlib. Previously, that would cause random problems
since there is no way to guarantee what zlib version is being used
for each dynamically linked function.

Add the corresponding zlib-ng.h.

Tests, example and minigzip will not compile before they have been
adapted to use the correct functions as well.
Either duplicate them, so we have minigzip-ng.c for example, or add
compile-time detection in the source code.
2018-01-31 10:45:29 +01:00
Mika Lindqvist
d74b5dbe3d Add initial support for AARCH64. 2017-03-24 23:55:59 +02:00
Mika Lindqvist
02f5b0b9c6 Add support for ARM ACLE instructions. 2017-03-24 23:55:58 +02:00
Mika Lindqvist
15ae16292c
Replace remaining Z_NULL instances with NULL. 2017-02-13 18:17:37 +02:00
Mika Lindqvist
debd37a1c0
Move instruction set specific crc32 code to arch directories. 2017-02-13 13:18:43 +02:00
Mark Adler
2a51c84f6c zlib 1.2.9 2017-02-09 11:39:40 +01:00
Mark Adler
73ba5ea69e Add crc32_z() and adler32_z() functions with size_t lengths. 2017-02-09 11:21:35 +01:00
Mark Adler
52380f5b44 Note the violation of the strict aliasing rule in crc32.c.
See the comment for more details. This is in response to an issue
raised as a result of a security audit of the zlib code by Trail
of Bits and TrustInSoft, in support of the Mozilla Foundation.
2017-01-31 11:09:18 +01:00
Mark Adler
2234eb9f0a Avoid pre-decrement of pointer in big-endian CRC calculation.
There was a small optimization for PowerPCs to pre-increment a
pointer when accessing a word, instead of post-incrementing. This
required prefacing the loop with a decrement of the pointer,
possibly pointing before the object passed. This is not compliant
with the C standard, for which decrementing a pointer before its
allocated memory is undefined. When tested on a modern PowerPC
with a modern compiler, the optimization no longer has any effect.
Due to all that, and per the recommendation of a security audit of
the zlib code by Trail of Bits and TrustInSoft, in support of the
Mozilla Foundation, this "optimization" was removed, in order to
avoid the possibility of undefined behavior.
2017-01-31 11:09:01 +01:00
Mika Lindqvist
602531cf3d Replace Z_NULL with NULL. Fix incorrect uses of NULL/Z_NULL. 2017-01-31 10:53:22 +01:00
Evan Nemerson
8348a181e6 Fix endianness-detection code on Solaris 11.
Solaris doesn't have sys/endian.h or endian.h, it has sys/byteorder.h,
which doesn't define BYTE_ORDER, it defines either _LITTLE_ENDIAN or
_BIG_ENDIAN.
2016-04-28 13:37:12 +02:00
Hans Kristian Rosbach
1d227a260f Fix spelling of __DragonFly__ in crc32.c, found by @nemequ 2016-04-28 13:37:04 +02:00
Mika Lindqvist
9c3a280877 Type cleanup. 2015-12-14 11:00:22 +02:00
Evan Nemerson
ca7d031dad Fix compilation on BSD
The endianness functions are in <sys/endian.h>, not <endian.h> as
they are in Linux.
2015-11-25 16:06:30 +01:00
René J.V. Bertin
9a7f5077d4 Allow building on OS X 2015-06-10 21:16:13 +02:00
Hans Kristian Rosbach
d9b63c782f Style cleanup for adler/crc code 2015-05-25 23:03:25 +02:00
Hans Kristian Rosbach
f533fd6e9b Update remaining function prototypes to ANSI C standard 2015-05-23 21:14:45 +02:00