Commit Graph

52 Commits

Author SHA1 Message Date
Mark Adler e9d5486e66 Remove K&R function definitions from zlib.
C2X has removed K&R definitions from the C function syntax.
Though the standard has not yet been approved, some high-profile
compilers are now issuing warnings when such definitions are
encountered.
2023-04-15 21:17:31 -07:00
Mark Adler 888b3da8de Provide missing function prototypes in CRC-32 code. [fredgan] 2022-10-06 20:43:18 -07:00
Mark Adler 5752b171fd Fix some typos.
No code changes.
2022-08-23 15:35:13 -07:00
Mark Adler 7ecf7c7458 Fix odd error in Visual C compiler preventing automatic promotion. 2022-06-04 15:02:40 -07:00
Mark Adler 6c532a8e8a Fix missing ZEXPORT for crc32_combine_op(). 2022-06-04 12:52:13 -07:00
Mark Adler ec3df00224 Correct incorrect inputs provided to the CRC functions.
The previous releases of zlib were not sensitive to incorrect CRC
inputs with bits set above the low 32. This commit restores that
behavior, so that applications with such bugs will continue to
operate as before.
2022-03-30 11:14:53 -07:00
Mark Adler 21767c654d zlib 1.2.12 2022-03-27 16:05:02 -07:00
Mark Adler 296967c7b7 Fix crc32.c to compile local functions only if used. 2022-03-27 13:48:19 -07:00
Mark Adler d71dc66fa8 Fix error in comment on the polynomial representation of a byte. 2019-07-09 08:55:13 -07:00
Mark Adler deb44b5742 Use ARM crc32 instructions if the ARM architecture has them.
The ARM crc32 instructions will be used only if an architecture is
explicitly specified at compile time that has those instructions.
For example, -march=armv8.1-a or -march=armv8-a+crc, or if the
machine being compiled on has the instructions, -march=native.
2019-02-17 20:49:29 -08:00
Mark Adler 52fc78baf2 Add use of the ARMv8 crc32 instructions when requested.
Define the macro Z_ARM_CRC32 at compile time to use the ARMv8
(aarch64) crc32x and crc32b instructions. This code does not check
for the presence of the crc32 instructions. Those instructions are
optional for ARMv8.0, though mandatory for ARMv8.1 and later. The
use of the crc32 instructions is about ten times as fast as the
software braided calculation of the CRC-32. This can noticeably
speed up the decompression of gzip streams.
2019-02-17 19:48:57 -08:00
Mark Adler aec89faa2e Correct comment in crc32.c. 2019-02-03 19:54:46 -08:00
Mark Adler 7c0c75e990 Use atomic test and set, if available, for dynamic CRC tables. 2018-12-26 13:50:27 -08:00
Mark Adler f8719f5ae5 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.
2018-12-26 12:26:52 -08:00
Mark Adler 41d86c73b2 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-11-04 10:31:46 -08:00
Mark Adler 47cb412957 Add tables for crc32_combine(), to speed it up by a factor of 200. 2018-11-03 19:45:22 -07:00
Mark Adler 3c46f5ddb5 Avoid the use of ptrdiff_t.
This isn't the right type anyway to assure that it contains a
pointer. That type would be intptr_t or uintptr_t. However the C99
standard says that those types are optional, so their use would not
be portable. This commit simply uses size_t or whatever configure
decided to use for size_t. That would be the same length as
ptrdiff_t, and so will work just as well. The code checks to see if
the length of the type used is the same as the length of a void
pointer, so there is already protection against the use of the
wrong type. The use of size_t (or ptrdiff_t) will almost always
work, as all modern architectures have an array size that is the
same as the pointer size. Only old segmented architectures would
have to fall back to the slower CRC-32 calculation, where the
amount of memory that can be accessed is larger than the maximum
array size.
2017-06-03 09:53:33 -07:00
Mark Adler 2fa463bacf zlib 1.2.9 2016-12-31 23:37:10 -08:00
Mark Adler b9ae6f0079 Add crc32_z() and adler32_z() functions with size_t lengths. 2016-12-31 17:50:52 -08:00
Mark Adler bedea2483b Clean up and comment the use of local for static. 2016-10-26 10:25:10 -07:00
Mark Adler e08118c401 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.
2016-10-03 22:33:26 -07:00
Mark Adler d1d577490c 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.
2016-09-28 20:48:38 -07:00
Mark Adler 6c9bd474aa Fix type mismatch between get_crc_table() and crc_table.
crc_table is made using a four-byte integer (when that can be
determined).  However get_crc_table() returned a pointer to an
unsigned long, which could be eight bytes.  This fixes that by
creating a new z_crc_t type for the crc_table.

This type is also used for the BYFOUR crc calculations that depend
on a four-byte type.  The four-byte type can now be determined by
./configure, which also solves a problem where ./configure --solo
would never use BYFOUR.  No the Z_U4 #define indicates that four-
byte integer was found either by ./configure or by zconf.h.
2012-04-29 16:18:12 -07:00
Mark Adler 94acb3c1a0 zlib 1.2.6.1 2012-02-12 14:20:33 -08:00
Mark Adler 7d45cf5a1d Use optimized byte swap operations for Microsoft and GNU [Snyder]. 2012-02-11 00:26:38 -08:00
Mark Adler f9e4edc996 Avoid library header include in crc32.c for Z_SOLO.
crc32.c was #including limits.h in order to find a four-byte integer
type.  It was doing this even if Z_SOLO were defined, violating the
intent of Z_SOLO, which is to include no library headers and require
no library functions.  Now crc32.c obeys the intent of Z_SOLO, but
with the downside that crc32() will be slower than when not compiled
with Z_SOLO.  This can be remedied manually by typedefing u4 to a
known four-byte unsigned integer type, and #defining BYFOUR in
crc32.c.
2012-02-01 23:55:29 -08:00
Mark Adler 10daf0d4d7 zlib 1.2.5.1 2011-09-11 11:04:49 -07:00
Mark Adler 9712272c78 zlib 1.2.5 2011-09-09 23:35:10 -07:00
Mark Adler 05d47d2627 zlib 1.2.4.1 2011-09-09 23:34:22 -07:00
Mark Adler f6194ef39a zlib 1.2.3.4 2011-09-09 23:26:40 -07:00
Mark Adler 639be99788 zlib 1.2.3.3 2011-09-09 23:26:29 -07:00
Mark Adler 9c3a583021 zlib 1.2.2.4 2011-09-09 23:24:52 -07:00
Mark Adler 6b8233bfe0 zlib 1.2.2.3 2011-09-09 23:24:43 -07:00
Mark Adler 0484693e17 zlib 1.2.2.2 2011-09-09 23:24:33 -07:00
Mark Adler 9811b53dd9 zlib 1.2.2.1 2011-09-09 23:24:24 -07:00
Mark Adler 79fbcdc939 zlib 1.2.2 2011-09-09 23:24:02 -07:00
Mark Adler 7a6955760b zlib 1.2.1.2 2011-09-09 23:23:45 -07:00
Mark Adler 4b5a43a219 zlib 1.2.0.5 2011-09-09 23:22:37 -07:00
Mark Adler 086e982175 zlib 1.2.0.4 2011-09-09 23:22:30 -07:00
Mark Adler 8e34b3a802 zlib 1.2.0.2 2011-09-09 23:22:10 -07:00
Mark Adler 7c2a874e50 zlib 1.2.0 2011-09-09 23:21:47 -07:00
Mark Adler a383133c4e zlib 1.1.4 2011-09-09 23:20:42 -07:00
Mark Adler b8c9ecb076 zlib 1.0.9 2011-09-09 23:19:21 -07:00
Mark Adler 6759211ad8 zlib 1.0.8 2011-09-09 23:18:57 -07:00
Mark Adler 7850e4e406 zlib 1.0.7 2011-09-09 23:17:33 -07:00
Mark Adler 423eb40306 zlib 1.0.1 2011-09-09 23:14:39 -07:00
Mark Adler 8a2acbffc8 zlib 1.0-pre 2011-09-09 23:13:27 -07:00
Mark Adler 56bcb184fa zlib 0.99 2011-09-09 23:11:37 -07:00
Mark Adler 23c69f1069 zlib 0.94 2011-09-09 23:09:18 -07:00
Mark Adler 6b834a58bd zlib 0.93 2011-09-09 23:08:28 -07:00