Library:Zlib-ng
Appearance
| Developer | zlib-ng contributors |
|---|---|
| Versions | 2.x (2.3.90 in the current repository head) |
| License | Zlib |
| Website | https://github.com/zlib-ng/zlib-ng |
| On this wiki | Facts · Code · Notes · Topics |
The zlib fork by Nathan Moinvaziri and others (Zlib license) with SIMD-optimised deflate/inflate, CRC-32 and Adler-32, built either as a native-API library (zng_* functions, zlib-ng.h) or in zlib-compat mode that exports the original zlib names with a ZLIB_VERSION ending in .zlib-ng; used as a replacement system zlib by some distributions and wrapped by Rust crates.
Overview
zlib-ng rewrote deflate and many hot paths of Library:Zlib (new deflate strategies, SIMD checksums, different deflate_state), but its inflate keeps zlib's table-building code (inftrees.c) and stream format. Built in compat mode it is a drop-in libz.so.1; native mode exports zng_deflateInit, zng_inflate, zng_compress, zng_uncompress, zng_crc32, zng_adler32 and zlibng_version.
Identification
- Version strings (
zlib-ng.h.in,zlib.h.in):ZLIBNG_VERSIONis "2.3.90" at the pinned commit; in compat modeZLIB_VERSIONis "1.3.2.zlib-ng" (the zlib version it tracks plus the suffix), returned byzlibVersion(), andzlibng_version()returns the zlib-ng number. Callers pass the zlib-style string toinflateInit_/deflateInit_, so a"1.3.x.zlib-ng"literal at an init call identifies it. - Inflate tables are zlib's:
src/inftrees.clines 168-181 holdlbase,lext,dbase,dextwith the same values as madler/zlib 1.3.2 (lextends 199, 75;dextends 64, 64). So the lext/dext version pairs of Library:Zlib#Versions cannot tell zlib from zlib-ng; use the version string, the exports, or thezng_names. - CRC and checksum code: runtime CPU dispatch (functable) with PCLMULQDQ/VPCLMULQDQ, AVX2, NEON and others; the generic fallback keeps the ordinary reflected CRC-32 table:
crc32_braid_tbl.h(commit 1727258b764262c73149014cdf6a39bd551b3bd5, line 10) declaresstatic const uint32_t crc_table[]starting0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, the same first entries as zlib's, followed by further braid tables (BRAID_Nis 5,crc32_braid_p.hline 7;BRAID_Wis 8 or 4). So a 256-entry CRC table starting 0x77073096 in a zlib-ng build is not evidence against zlib-ng, and not evidence for it either.
Code & repositories
- https://github.com/zlib-ng/zlib-ng @
1727258b764262c73149014cdf6a39bd551b3bd5· license: Zlib
zlib-ng source: zlib-ng.h.in and zlib.h.in carry the version macros, inftrees.c the unchanged inflate tables; arch/ has the SIMD code.
Tested on: source read, not run: source read at the pinned commit; nothing built or run · checked 2026-10-18; last activity 2026-10-17; Note: the latest release ships binaries; the wiki links only the source, never the binaries
Pitfalls
- A distribution with zlib-ng in compat mode shows
libz.so.1and zlib-compatible exports; checkzlibVersion()output for the.zlib-ngsuffix. - The
lexttail pairs differ between zlib-ng releases, so do not use one pair for all zlib-ng:inftrees.chas... 16, 77, 202at tag 2.0.0 (line 59),... 16, 203, 77at tag 2.2.1 (line 57) and... 16, 199, 75at the pinned head commit (line 173). Compare them with the zlib pairs on Library:Zlib#Versions. Releases before 2.0.0 were not read.
Evidence & references
- zlib-ng/zlib-ng commit 1727258b764262c73149014cdf6a39bd551b3bd5:
zlib-ng.h.in(lines 51-53, 221),zlib.h.in(lines 52-61),inftrees.c(168-181). Read only.