Skip to content

Commit 2ab12b9

Browse files
kwrobotdzenanz
authored andcommitted
zlib-ng 2023-06-29 (cf89cf35)
Code extracted from: https://github.com/zlib-ng/zlib-ng.git at commit cf89cf35037f152ce7adfeca864656de5d33ea1e (develop).
1 parent 15cd2ff commit 2ab12b9

File tree

93 files changed

+1497
-1014
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+1497
-1014
lines changed

CMakeLists.txt

Lines changed: 138 additions & 73 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 41 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1+
| CI | Stable | Develop |
2+
|:---|:-------|:--------|
3+
| GitHub Actions | [![Stable Status](https://github.com/zlib-ng/zlib-ng/workflows/CI%20CMake/badge.svg?branch=stable)](https://github.com/zlib-ng/zlib-ng/actions) <br> [![Stable Status](https://github.com/zlib-ng/zlib-ng/workflows/CI%20Configure/badge.svg?branch=stable)](https://github.com/zlib-ng/zlib-ng/actions) <br> [![Stable Status](https://github.com/zlib-ng/zlib-ng/workflows/CI%20NMake/badge.svg?branch=stable)](https://github.com/zlib-ng/zlib-ng/actions) | [![Develop Status](https://github.com/zlib-ng/zlib-ng/workflows/CI%20CMake/badge.svg?branch=develop)](https://github.com/zlib-ng/zlib-ng/actions) <br> [![Develop Status](https://github.com/zlib-ng/zlib-ng/workflows/CI%20Configure/badge.svg?branch=develop)](https://github.com/zlib-ng/zlib-ng/actions) <br> [![Develop Status](https://github.com/zlib-ng/zlib-ng/workflows/CI%20NMake/badge.svg?branch=develop)](https://github.com/zlib-ng/zlib-ng/actions) |
4+
| CodeFactor | [![CodeFactor](https://www.codefactor.io/repository/github/zlib-ng/zlib-ng/badge/stable)](https://www.codefactor.io/repository/github/zlib-ng/zlib-ng/overview/stable) | [![CodeFactor](https://www.codefactor.io/repository/github/zlib-ng/zlib-ng/badge/develop)](https://www.codefactor.io/repository/github/zlib-ng/zlib-ng/overview/develop) |
5+
| OSS-Fuzz | [![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/zlib-ng.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:zlib-ng) | [![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/zlib-ng.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:zlib-ng) |
6+
| Codecov | [![codecov](https://codecov.io/github/zlib-ng/zlib-ng/branch/stable/graph/badge.svg?token=uKsgK9LIuC)](https://codecov.io/github/zlib-ng/zlib-ng/tree/stable) | [![codecov](https://codecov.io/github/zlib-ng/zlib-ng/branch/develop/graph/badge.svg?token=uKsgK9LIuC)](https://codecov.io/github/zlib-ng/zlib-ng/tree/develop) |
7+
18
## zlib-ng
29
*zlib data compression library for the next generation systems*
310

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

7-
|CI|Status|
8-
|:-|-|
9-
|GitHub Actions|[![Master Branch Status](https://github.com/zlib-ng/zlib-ng/workflows/CI%20CMake/badge.svg)](https://github.com/zlib-ng/zlib-ng/actions) [![Master Branch Status](https://github.com/zlib-ng/zlib-ng/workflows/CI%20Configure/badge.svg)](https://github.com/zlib-ng/zlib-ng/actions) [![Master Branch Status](https://github.com/zlib-ng/zlib-ng/workflows/CI%20NMake/badge.svg)](https://github.com/zlib-ng/zlib-ng/actions)|
10-
|Buildkite|[![Build status](https://badge.buildkite.com/7bb1ef84356d3baee26202706cc053ee1de871c0c712b65d26.svg?branch=develop)](https://buildkite.com/circlestorm-productions/zlib-ng)|
11-
|CodeFactor|[![CodeFactor](https://www.codefactor.io/repository/github/zlib-ng/zlib-ng/badge)](https://www.codefactor.io/repository/github/zlib-ng/zlib-ng)|
12-
|OSS-Fuzz|[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/zlib-ng.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:zlib-ng)
13-
|Codecov|[![codecov.io](https://codecov.io/github/zlib-ng/zlib-ng/coverage.svg?branch=develop)](https://codecov.io/github/zlib-ng/zlib-ng/)|
14-
15-
1614
Features
1715
--------
1816

@@ -25,60 +23,46 @@ Features
2523
* CRC32-B implementation using PCLMULQDQ, VPCLMULQDQ, ACLE, & IBM Z
2624
* Hash table implementation using CRC32-C intrinsics on x86 and ARM
2725
* Slide hash implementations using SSE2, AVX2, Neon, VMX & VSX
28-
* Compare256 implementations using SSE2, AVX2, Neon, & POWER9
29-
* Inflate chunk copying using SSE2, AVX, Neon & VSX
26+
* Compare256 implementations using SSE2, AVX2, Neon, POWER9 & RVV
27+
* Inflate chunk copying using SSE2, SSSE3, AVX, Neon & VSX
3028
* Support for hardware-accelerated deflate using IBM Z DFLTCC
3129
* Unaligned memory read/writes and large bit buffer improvements
3230
* Includes improvements from Cloudflare and Intel forks
3331
* Configure, CMake, and NMake build system support
3432
* Comprehensive set of CMake unit tests
3533
* Code sanitizers, fuzzing, and coverage
3634
* GitHub Actions continuous integration on Windows, macOS, and Linux
37-
* Emulated CI for ARM, AARCH64, PPC, PPC64, SPARC64, S390x using qemu
35+
* Emulated CI for ARM, AARCH64, PPC, PPC64, RISCV, SPARC64, S390x using qemu
3836

3937

4038
History
4139
-------
4240

43-
The motivation for this fork came after seeing several 3rd party
44-
contributions containing new optimizations not getting implemented
45-
into the official zlib repository.
41+
The motivation for this fork was seeing several 3rd party contributions with new optimizations not getting
42+
implemented into the official zlib repository.
4643

47-
Mark Adler has been maintaining zlib for a very long time, and he has
48-
done a great job and hopefully he will continue for a long time yet.
49-
The idea of zlib-ng is not to replace zlib, but to co-exist as a
50-
drop-in replacement with a lower threshold for code change.
44+
Mark Adler has been maintaining zlib for a very long time, and he has done a great job and hopefully he will continue
45+
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
46+
lower threshold for code change.
5147

52-
zlib has a long history and is incredibly portable, even supporting
53-
lots of systems that predate the Internet. This is great, but it does
54-
complicate further development and maintainability.
55-
The zlib code has numerous workarounds for old compilers that do not
56-
understand ANSI-C or to accommodate systems with limitations such as
57-
operating in a 16-bit environment.
48+
zlib has a long history and is incredibly portable, even supporting many systems that predate the Internet.<br>
49+
That is great, but it can complicate further development and maintainability. The zlib code contains many workarounds
50+
for really old compilers or to accommodate systems with limitations such as operating in a 16-bit environment.
5851

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

67-
So I decided to make a fork, merge all the Intel optimizations, merge
68-
the Cloudflare optimizations that did not conflict, plus a couple
69-
of other smaller patches. Then I started cleaning out workarounds,
70-
various dead code, all contrib and example code as there is little
71-
point in having those in this fork for various reasons.
55+
I decided to make a fork, merge all the Intel optimizations, some of the Cloudflare optimizations, plus a couple other
56+
smaller patches. Then started cleaning out workarounds, various dead code, all contrib and example code.<br>
57+
The result is a better performing and easier to maintain zlib-ng.
7258

73-
A lot of improvements have gone into zlib-ng since its start, and
74-
numerous people and companies have contributed both small and big
75-
improvements, or valuable testing.
76-
77-
Please read LICENSE.md, it is very simple and very liberal.
59+
A lot of improvements have gone into zlib-ng since its start, and numerous people and companies have contributed both
60+
small and big improvements, or valuable testing.
7861

7962

8063
Build
8164
-----
65+
<sup>Please read LICENSE.md, it is very simple and very liberal.</sup>
8266

8367
There are two ways to build zlib-ng:
8468

@@ -130,17 +114,14 @@ Build Options
130114
Install
131115
-------
132116

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

139-
For Linux distros, an alternative way to use zlib-ng (if compiled in
140-
zlib-compat mode) instead of zlib, is through the use of the
141-
_LD_PRELOAD_ environment variable. If the program is dynamically linked
142-
with zlib, then zlib-ng will temporarily be used instead by the program,
143-
without risking system-wide instability.
122+
For Linux distros, an alternative way to use zlib-ng (if compiled in zlib-compat mode) instead of zlib, is through
123+
the use of the _LD_PRELOAD_ environment variable. If the program is dynamically linked with zlib, then the program
124+
will temporarily attempt to use zlib-ng instead, without risking system-wide instability.
144125

145126
```
146127
LD_PRELOAD=/opt/zlib-ng/libz.so.1.2.13.zlib-ng /usr/bin/program
@@ -174,33 +155,27 @@ cd vcpkg
174155
./vcpkg install zlib-ng
175156
```
176157

177-
The zlib-ng port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
158+
The zlib-ng port in vcpkg is kept up to date by Microsoft team members and community contributors.
159+
If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
178160

179161
Contributing
180162
------------
181163

182-
Zlib-ng is a aiming to be open to contributions, and we would be delighted to
183-
receive pull requests on github.
184-
Just remember that any code you submit must be your own and it must be zlib licensed.
185-
Help with testing and reviewing of pull requests etc is also very much appreciated.
186-
187-
If you are interested in contributing, please consider joining our
188-
IRC channel #zlib-ng on the Freenode IRC network.
164+
Zlib-ng is aiming to be open to contributions, and we would be delighted to receive pull requests on github.
165+
Help with testing and reviewing pull requests etc is also very much appreciated.
189166

167+
Please check the Wiki for more info: [Contributing](https://github.com/zlib-ng/zlib-ng/wiki/Contributing)
190168

191169
Acknowledgments
192170
----------------
193171

194-
Thanks to Servebolt.com for sponsoring my maintainership of zlib-ng.
195-
196172
Thanks go out to all the people and companies who have taken the time to contribute
197173
code reviews, testing and/or patches. Zlib-ng would not have been nearly as good without you.
198174

199-
The deflate format used by zlib was defined by Phil Katz.
175+
The deflate format used by zlib was defined by Phil Katz.<br>
200176
The deflate and zlib specifications were written by L. Peter Deutsch.
201177

202-
zlib was originally created by Jean-loup Gailly (compression)
203-
and Mark Adler (decompression).
178+
zlib was originally created by Jean-loup Gailly (compression) and Mark Adler (decompression).
204179

205180

206181
Advanced Build Options
@@ -213,14 +188,15 @@ Advanced Build Options
213188
| WITH_AVX512 | | Build with AVX512 intrinsics | ON |
214189
| WITH_AVX512VNNI | | Build with AVX512VNNI intrinsics | ON |
215190
| WITH_SSE2 | | Build with SSE2 intrinsics | ON |
216-
| WITH_SSE41 | | Build with SSE41 intrinsics | ON |
191+
| WITH_SSSE3 | | Build with SSSE3 intrinsics | ON |
217192
| WITH_SSE42 | | Build with SSE42 intrinsics | ON |
218193
| WITH_PCLMULQDQ | | Build with PCLMULQDQ intrinsics | ON |
219194
| WITH_VPCLMULQDQ | --without-vpclmulqdq | Build with VPCLMULQDQ intrinsics | ON |
220195
| WITH_ACLE | --without-acle | Build with ACLE intrinsics | ON |
221196
| WITH_NEON | --without-neon | Build with NEON intrinsics | ON |
222197
| WITH_ALTIVEC | --without-altivec | Build with AltiVec (VMX) intrinsics | ON |
223198
| WITH_POWER8 | --without-power8 | Build with POWER8 optimisations | ON |
199+
| WITH_RVV | | Build with RVV intrinsics | ON |
224200
| WITH_CRC32_VX | --without-crc32-vx | Build with vectorized CRC32 on IBM Z | ON |
225201
| WITH_DFLTCC_DEFLATE | --with-dfltcc-deflate | Build with DFLTCC intrinsics for compression on IBM Z | OFF |
226202
| WITH_DFLTCC_INFLATE | --with-dfltcc-inflate | Build with DFLTCC intrinsics for decompression on IBM Z | OFF |

arch/arm/Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,5 @@ clean:
7373
rm -rf objs
7474
rm -f *.gcda *.gcno *.gcov
7575

76-
distclean:
76+
distclean: clean
7777
rm -f Makefile

arch/arm/adler32_neon.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Adam Stylinski <kungfujesus06@gmail.com>
66
* For conditions of distribution and use, see copyright notice in zlib.h
77
*/
8-
#ifdef ARM_NEON_ADLER32
8+
#ifdef ARM_NEON
99
#include "neon_intrins.h"
1010
#include "../../zbuild.h"
1111
#include "../../adler32_p.h"
@@ -141,7 +141,7 @@ static void NEON_handle_tail(uint32_t *pair, const uint8_t *buf, size_t len) {
141141
}
142142
}
143143

144-
uint32_t adler32_neon(uint32_t adler, const uint8_t *buf, size_t len) {
144+
Z_INTERNAL uint32_t adler32_neon(uint32_t adler, const uint8_t *buf, size_t len) {
145145
/* split Adler-32 into component sums */
146146
uint32_t sum2 = (adler >> 16) & 0xffff;
147147
adler &= 0xffff;

arch/arm/arm_features.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "../../zbuild.h"
2+
#include "arm_features.h"
23

34
#if defined(__linux__) && defined(HAVE_SYS_AUXV_H)
45
# include <sys/auxv.h>
@@ -71,14 +72,11 @@ static inline int arm_has_neon() {
7172
}
7273
#endif
7374

74-
Z_INTERNAL int arm_cpu_has_neon;
75-
Z_INTERNAL int arm_cpu_has_crc32;
76-
77-
void Z_INTERNAL arm_check_features(void) {
75+
void Z_INTERNAL arm_check_features(struct arm_cpu_features *features) {
7876
#if defined(__aarch64__) || defined(_M_ARM64)
79-
arm_cpu_has_neon = 1; /* always available */
77+
features->has_neon = 1; /* always available */
8078
#else
81-
arm_cpu_has_neon = arm_has_neon();
79+
features->has_neon = arm_has_neon();
8280
#endif
83-
arm_cpu_has_crc32 = arm_has_crc32();
81+
features->has_crc32 = arm_has_crc32();
8482
}

arch/arm/arm_features.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
#ifndef ARM_H_
66
#define ARM_H_
77

8-
extern int arm_cpu_has_neon;
9-
extern int arm_cpu_has_crc32;
8+
struct arm_cpu_features {
9+
int has_neon;
10+
int has_crc32;
11+
};
1012

11-
void Z_INTERNAL arm_check_features(void);
13+
void Z_INTERNAL arm_check_features(struct arm_cpu_features *features);
1214

1315
#endif /* ARM_H_ */

arch/arm/chunkset_neon.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* For conditions of distribution and use, see copyright notice in zlib.h
33
*/
44

5-
#ifdef ARM_NEON_CHUNKSET
5+
#ifdef ARM_NEON
66
#include "neon_intrins.h"
77
#include "../../zbuild.h"
88
#include "../generic/chunk_permute_table.h"
@@ -69,7 +69,7 @@ static inline chunk_t GET_CHUNK_MAG(uint8_t *buf, uint32_t *chunk_rem, uint32_t
6969
*chunk_rem = lut_rem.remval;
7070

7171
#ifdef Z_MEMORY_SANITIZER
72-
/* See note in chunkset_sse41.c for why this is ok */
72+
/* See note in chunkset_ssse3.c for why this is ok */
7373
__msan_unpoison(buf + dist, 16 - dist);
7474
#endif
7575

arch/arm/crc32_acle.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
*
66
*/
77

8-
#ifdef ARM_ACLE_CRC_HASH
8+
#ifdef ARM_ACLE
99
#ifdef _MSC_VER
1010
# include <intrin.h>
1111
#else
1212
# include <arm_acle.h>
1313
#endif
1414
#include "../../zbuild.h"
1515

16-
uint32_t crc32_acle(uint32_t crc, const uint8_t *buf, size_t len) {
16+
Z_INTERNAL uint32_t crc32_acle(uint32_t crc, const uint8_t *buf, size_t len) {
1717
Z_REGISTER uint32_t c;
1818
Z_REGISTER const uint16_t *buf2;
1919
Z_REGISTER const uint32_t *buf4;

arch/arm/insert_string_acle.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
*/
77

8-
#ifdef ARM_ACLE_CRC_HASH
8+
#ifdef ARM_ACLE
99
#ifndef _MSC_VER
1010
# include <arm_acle.h>
1111
#endif

arch/arm/neon_intrins.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
# include <arm_neon.h>
88
#endif
99

10-
#if defined(ARM_NEON_ADLER32) && !defined(__aarch64__) && !defined(_M_ARM64)
10+
#if defined(ARM_NEON) && !defined(__aarch64__) && !defined(_M_ARM64)
1111
/* Compatibility shim for the _high family of functions */
1212
#define vmull_high_u8(a, b) vmull_u8(vget_high_u8(a), vget_high_u8(b))
1313
#define vmlal_high_u8(a, b, c) vmlal_u8(a, vget_high_u8(b), vget_high_u8(c))
1414
#define vmlal_high_u16(a, b, c) vmlal_u16(a, vget_high_u16(b), vget_high_u16(c))
1515
#define vaddw_high_u8(a, b) vaddw_u8(a, vget_high_u8(b))
1616
#endif
1717

18-
#ifdef ARM_NEON_SLIDEHASH
18+
#ifdef ARM_NEON
1919

2020
#define vqsubq_u16_x4_x1(out, a, b) do { \
2121
out.val[0] = vqsubq_u16(a.val[0], b); \
@@ -24,9 +24,8 @@
2424
out.val[3] = vqsubq_u16(a.val[3], b); \
2525
} while (0)
2626

27-
#endif
2827

29-
#if !defined(ARM_NEON_HASLD4) && (defined(ARM_NEON_ADLER32) || defined(ARM_NEON_SLIDEHASH))
28+
# ifndef ARM_NEON_HASLD4
3029

3130
static inline uint16x8x4_t vld1q_u16_x4(uint16_t const *a) {
3231
uint16x8x4_t ret = (uint16x8x4_t) {{
@@ -52,6 +51,7 @@ static inline void vst1q_u16_x4(uint16_t *p, uint16x8x4_t a) {
5251
vst1q_u16(p + 16, a.val[2]);
5352
vst1q_u16(p + 24, a.val[3]);
5453
}
55-
#endif // HASLD4 check
54+
# endif // HASLD4 check
55+
#endif
5656

5757
#endif // include guard ARM_NEON_INTRINS_H

0 commit comments

Comments
 (0)