zlib replacement with optimizations for "next generation" systems.
Go to file
Hans Kristian Rosbach 033b4dd92c Import default codecfactor.io .shellcheckrc file.
Disable codefactor complaints about using $? for retval checking (SC2181).
2020-03-09 14:13:36 +01:00
.github/workflows Attempt to run codecov again if it fails. 2020-03-09 14:13:36 +01:00
arch Add cpuidex. 2020-02-12 20:32:08 +01:00
cmake 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
doc zlib 1.2.5.1 2011-09-11 11:04:49 -07:00
test Change deflate_state's bi_buf from 16-bit to 32-bit. 2020-02-08 13:53:43 +01:00
tools Attempt to run codecov again if it fails. 2020-03-09 14:13:36 +01:00
win32 Add initial AVX2 support. 2020-02-07 20:49:52 +01:00
.gitattributes Add a.exe to cleanup list. 2017-01-30 10:36:53 +01:00
.gitignore travis.yml changes: 2019-09-26 20:42:49 +02:00
.shellcheckrc Import default codecfactor.io .shellcheckrc file. 2020-03-09 14:13:36 +01:00
adler32_p.h cleanup arm/adler32_neon.c code 2019-04-04 10:13:26 +02:00
adler32.c cleanup arm/adler32_neon.c code 2019-04-04 10:13:26 +02:00
CMakeLists.txt Don't enable debug when building with code coverage. 2020-03-09 14:13:36 +01:00
compress.c 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
configure Add initial AVX2 support. 2020-02-07 20:49:52 +01:00
crc32_p.h Add makecrct test and clean up makecrct.c code 2019-09-20 22:29:21 +02:00
crc32.c 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
crc32.h Add makecrct test and clean up makecrct.c code 2019-09-20 22:29:21 +02:00
deflate_fast.c Add zng_ prefix to internal functions to avoid linking conflicts with zlib. (#363) 2019-07-18 13:21:13 +02:00
deflate_medium.c Removed MAX_DIST2 which is incompatible with zlib when compiled with INFLATE_STRICT. It also fixes the check for proper bounds in zng_tr_tally. 2020-02-07 17:48:05 +01:00
deflate_p.h 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
deflate_slow.c Clean up LIKELY/UNLIKELY definitions, making them upper-case to improve visibility. 2019-10-22 09:56:34 +02:00
deflate.c Change deflate_state's bi_buf from 16-bit to 32-bit. 2020-02-08 13:53:43 +01:00
deflate.h Fixed missing compressed_len count in deflate_quick when ZLIB_DEBUG defined. Put most likely condition in send_bits first. 2020-02-08 13:53:43 +01:00
fallback_builtins.h 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
FAQ.zlib zlib 1.2.11 2017-02-13 10:16:17 +01:00
functable.c 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
functable.h Add slide_hash to functable, and enable the sse2-optimized version. 2019-09-04 08:53:36 +02:00
gzclose.c Move private defines from zconf.h and zconf-ng.h to zbuild.h 2018-03-22 10:18:27 +01:00
gzguts.h 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
gzlib.c Avoid adding empty gzip member after gzflush with Z_FINISH. 2019-10-22 09:55:41 +02:00
gzread.c 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
gzwrite.c Avoid adding empty gzip member after gzflush with Z_FINISH. 2019-10-22 09:55:41 +02:00
INDEX Fixed formatting converting tabs to spaces. 2019-10-24 09:18:29 +02:00
infback.c 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
inffast.c 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
inffast.h Add zng_ prefix to internal functions to avoid linking conflicts with zlib. (#363) 2019-07-18 13:21:13 +02:00
inffixed.h Get inffixed.h and MAKEFIXED result to match. 2011-10-05 20:32:32 -07:00
inflate_p.h Fixed compiler warning when using BITS macro. 2020-02-07 18:42:03 +01:00
inflate.c 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
inflate.h Don't bother computing check value after successful inflateSync(). 2019-10-22 09:57:38 +02:00
inftrees.c 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
inftrees.h Add zng_ prefix to internal functions to avoid linking conflicts with zlib. (#363) 2019-07-18 13:21:13 +02:00
LICENSE.md Update readme and create LICENSE.md file 2015-04-10 12:26:51 +02:00
Makefile.in Split crc table generating code (MAKECRCH) out into separate tool makecrct. 2019-09-20 22:29:21 +02:00
match_p.h 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
memcopy.h 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
README.md Added codecov badge to README.md. 2020-02-07 21:26:25 +01:00
trees_p.h Split maketrees out into a separate tool 2019-09-20 22:29:21 +02:00
trees.c Renamed bit buffer local variables consistently. 2020-02-08 13:53:43 +01:00
trees.h 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
uncompr.c 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
zbuild.h Make functable thread-local. 2018-09-17 11:28:28 +02:00
zconf-ng.h.in typedef ptrdiff_t when stddef.h does not provide it 2019-01-17 08:55:02 +01:00
zconf.h.in Compatibility fix 2019-11-26 12:52:09 +01:00
zendian.h 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
zlib-ng.h 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
zlib-ng.map Add two new public zng_deflate{Set,Get}Params() functions 2019-07-18 13:19:09 +02:00
zlib.3 zlib 1.2.11 2017-02-13 10:16:17 +01:00
zlib.h 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
zlib.map Add crc32_combine_gen() and crc32_combine_op() for fast combines. 2018-12-08 12:36:30 +01:00
zlib.pc.cmakein ENH: Use modern cmake variable conventions 2019-01-31 13:07:20 +01:00
zlib.pc.in Rename library based on zlib-compat setting 2018-01-31 10:45:29 +01:00
zutil.c Support aligned alloc/free functions for Windows and define them only if MZ_ZALLOC is not defined. 2020-02-07 19:33:30 +01:00
zutil.h 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

zlib-ng

zlib data compression library for the next generation systems

Maintained by Hans Kristian Rosbach aka Dead2 (zlib-ng àt circlestorm dót org)

CI Status
GitHub Actions Master Branch Status Master Branch Status
Buildkite Build status
CodeFactor CodeFactor
OSS-Fuzz Fuzzing Status
Codecov codecov.io

Fork Motivation

The motivation for this fork was due to seeing several 3rd party contributions containing new optimizations not getting implemented into the official zlib repository.

Mark Adler has been maintaining zlib for a very long time, and he has done a great job and hopefully he will continue for a long time yet. The idea of zlib-ng is not to replace zlib, but to co-exist as a drop-in replacement with a lower threshold for code change.

zlib has a long history and is incredibly portable, even supporting lots of systems that predate the Internet. This is great, but it does complicate further development and maintainability. The zlib code has numerous workarounds for old compilers that do not understand ANSI-C or to accommodate systems with limitations such as operating in a 16-bit environment.

Many of these workarounds are only maintenance burdens, some of them are pretty huge code-wise. For example, the [v]s[n]printf workaround code has a whopping 8 different implementations just to cater to various old compilers. With this many workarounds cluttered throughout the code, new programmers with an idea/interest for zlib will need to take some time to figure out why all of these seemingly strange things are used, and how to work within those confines.

So I decided to make a fork, merge all the Intel optimizations, merge the Cloudflare optimizations that did not conflict, plus a couple of other smaller patches. Then I started cleaning out workarounds, various dead code, all contrib and example code as there is little point in having those in this fork for various reasons.

A lot of improvements have gone into zlib-ng since its start, and numerous people have contributed both small and big improvements, or valuable testing.

Please read LICENSE.md, it is very simple and very liberal.

Build

There are two ways to build zlib-ng:

Cmake

To build zlib-ng using the cross-platform makefile generator cmake.

cmake .
cmake --build . --config Release
ctest --verbose -C Release

Alternatively, yuou can use the cmake configuration GUI tool ccmake:

ccmake .

Configure

To build zlib-ng using the bash configure script:

./configure
make
make test

Build Options

CMake configure Description Default
ZLIB_COMPAT --zlib-compat Compile with zlib compatible API OFF
ZLIB_ENABLE_TESTS Build test binaries ON
WITH_GZFILEOP --with-gzfileops Compile with support for gzFile related functions OFF
WITH_MSAN --with-msan Build with memory sanitizer OFF
WITH_OPTIM --without-optimizations Build with optimisations ON
WITH_NEW_STRATEGIES --without-new-strategies Use new strategies ON
WITH_NATIVE_INSTRUCTIONS Instruct the compiler to use the full instruction set on this host (gcc/clang -march=native) OFF
--force-sse2 Assume SSE2 instructions are always available DISABLED (x86), ENABLED (x86_64)
WITH_ACLE --without-acle Build with ACLE CRC ON
WITH_NEON --without-neon Build with NEON intrinsics ON
WITH_DFLTCC_DEFLATE --with-dfltcc-deflate Use DEFLATE COMPRESSION CALL instruction for compression on IBM Z OFF
WITH_DFLTCC_INFLATE --with-dfltcc-inflate Use DEFLATE COMPRESSION CALL instruction for decompression on IBM Z OFF
WITH_SANITIZERS --with-sanitizers Build with address sanitizer and all supported sanitizers other than memory sanitizer OFF
WITH_FUZZERS --with-fuzzers Build test/fuzz OFF
WITH_MAINTAINER_WARNINGS Build with project maintainer warnings OFF
WITH_CODE_COVERAGE Enable code coverage reporting OFF

Install

WARNING: We do not recommend manually installing unless you really know what you are doing, because this can potentially override the system default zlib library, and any incompatability or wrong configuration of zlib-ng can make the whole system unusable, requiring recovery or reinstall. If you still want a manual install, we recommend using the /opt/ path prefix.

For Linux distros, an alternative way to use zlib-ng (if compiled in zlib-compat mode) instead of zlib, is through the use of the LD_PRELOAD environment variable. If the program is dynamically linked with zlib, then zlib-ng will temporarily be used instead by the program, without risking system-wide instability.

LD_PRELOAD=/opt/zlib-ng/libz.so.1.2.11.zlib-ng /usr/bin/program

Cmake

To install zlib-ng system-wide using cmake:

cmake --build . --target install

Configure

To install zlib-ng system-wide using the configure script:

make install

Contributing

Zlib-ng is a young project, and we aim to be open to contributions, and we would be delighted to receive pull requests on github. Just remember that any code you submit must be your own and it must be zlib licensed. Help with testing and reviewing of pull requests etc is also very much appreciated.

If you are interested in contributing, please consider joining our IRC channel #zlib-ng on the Freenode IRC network.

Acknowledgments

Thanks to Servebolt.com for sponsoring my maintainership of zlib-ng.

Thanks go out to all the people and companies who have taken the time to contribute code reviews, testing and/or patches. Zlib-ng would not have been nearly as good without you.

The deflate format used by zlib was defined by Phil Katz. The deflate and zlib specifications were written by L. Peter Deutsch.

zlib was originally created by Jean-loup Gailly (compression) and Mark Adler (decompression).

Contents

Name Description
arch/ Architecture-specific code
doc/ Documentation for formats and algorithms
test/example.c Zlib usages examples for build testing
test/minigzip.c Minimal gzip-like functionality for build testing
test/infcover.c Inflate code coverage for build testing
win32/ Shared library version resources for Windows
CMakeLists.txt Cmake build script
configure Bash configure/build script
adler32.c Compute the Adler-32 checksum of a data stream
compress.c Compress a memory buffer
deflate.* Compress data using the deflate algorithm
deflate_fast.c Compress data using the deflate algorithm with fast strategy
deflate_medium.c Compress data using the deflate algorithm with medium stragety
deflate_slow.c Compress data using the deflate algorithm with slow strategy
functable.* Struct containing function pointers to optimized functions
gzclose.c Close gzip files
gzguts.h Internal definitions for gzip operations
gzlib.c Functions common to reading and writing gzip files
gzread.c Read gzip files
gzwrite.c Write gzip files
infback.* Inflate using a callback interface
inflate.* Decompress data
inffast.* Decompress data with speed optimizations
inffixed.h Table for decoding fixed codes
inftrees.h Generate Huffman trees for efficient decoding
memcopy.h Inline functions to copy small data chunks
trees.* Output deflated data using Huffman coding
uncompr.c Decompress a memory buffer
zconf.h.cmakein zconf.h template for cmake
zendian.h BYTE_ORDER for endian tests
zlib.3 Man page for zlib
zlib.map Linux symbol information
zlib.pc.in Pkg-config template