]> git.ipfire.org Git - thirdparty/zlib-ng.git/log
thirdparty/zlib-ng.git
5 years agoFixed use of uninitialized value state in makefixed. #437
Nathan Moinvaziri [Mon, 7 Oct 2019 01:54:05 +0000 (18:54 -0700)] 
Fixed use of uninitialized value state in makefixed. #437

5 years agoFixed signed warnings in match_p.h on arm. #430
Nathan Moinvaziri [Mon, 7 Oct 2019 02:01:31 +0000 (19:01 -0700)] 
Fixed signed warnings in match_p.h on arm. #430

5 years agoFixed missing comma in msvc inline asm.
Nathan Moinvaziri [Sat, 5 Oct 2019 07:36:55 +0000 (00:36 -0700)] 
Fixed missing comma in msvc inline asm.

5 years agoFixed tab formatting in fuzzers (#414)
Nathan Moinvaziri [Sun, 6 Oct 2019 17:59:07 +0000 (10:59 -0700)] 
Fixed tab formatting in fuzzers (#414)

* Fixed tab formatting in fuzzers.
* Fixed function argument spacing.
* Fixed whitespace in comments and strings.

5 years agotravis.yml changes:
Hans Kristian Rosbach [Thu, 19 Sep 2019 08:12:49 +0000 (10:12 +0200)] 
travis.yml changes:
 - Select minimal vm image instead of generic ('C'), reducing size and boot time.
   - Windows needs 'C' image to not hang on booting
 - Update from Xenial to Bionic for linux tests.
   - ppc64 images don't have Bionic, set to Xenial
   - ppc64 is having misc failures with Xenial tools, so use GCC-9 and Clang-6
   - ppc64 cannot run MSAN
 - Add another test for more complete testing across architectures.
 - Enable fuzzers, msan and/or sanitizers most various tests.
 - Disable ASAN leak detection on aarch64, since it crashes under qemu
 - Reorder tests to be better grouped and running windows/macox tests lasts.
 - Enable verbose messages from sanitizers

CmakeLists.txt changes:
 - Enable warnings by default.
 - Add MAINTAINER setting to cmake
   - Enables extra warnings.
   - Enables fuzzers.
 - Add CI detection to cmake, currently auto-enables MAINTAINER mode.
 - Add detection of several more sanitizer features.
 - Test sanitizer features together, not just alone.
   This also helps with their inter-dependencies.

.gitignore changes:
 - Add switchlevels.

5 years agoConfigure: Don't enable optimizations if without-optimizations has been set.
Hans Kristian Rosbach [Fri, 20 Sep 2019 22:07:05 +0000 (00:07 +0200)] 
Configure: Don't enable optimizations if without-optimizations has been set.
Add ARM_GETAUXVAL define for ARM platforms if optimizations is enabled.

5 years agoUnify detection of ARM getauxval code availability.
Hans Kristian Rosbach [Fri, 20 Sep 2019 20:50:50 +0000 (22:50 +0200)] 
Unify detection of ARM getauxval code availability.
We don't want to compile arch-specific code when WITH_OPTIM is not set,
and the current checks don't take that into account.

5 years agoClean up parts of CMakeLists.txt
Hans Kristian Rosbach [Fri, 20 Sep 2019 18:53:16 +0000 (20:53 +0200)] 
Clean up parts of CMakeLists.txt

5 years agoAdd archdetect as separate cmake include file.
Hans Kristian Rosbach [Fri, 20 Sep 2019 18:35:44 +0000 (20:35 +0200)] 
Add archdetect as separate cmake include file.
Simplify architecture checking by setting BASEARCH in addition to ARCH.

5 years agoFixed running fuzzers with cmake on arm.
Nathan Moinvaziri [Fri, 20 Sep 2019 23:46:50 +0000 (16:46 -0700)] 
Fixed running fuzzers with cmake on arm.

5 years agoFixed crc1 unused variable warning. #418.
Nathan Moinvaziri [Fri, 20 Sep 2019 22:37:00 +0000 (15:37 -0700)] 
Fixed crc1 unused variable warning. #418.

5 years agoAdd oss-fuzz to readme.
Nathan Moinvaziri [Fri, 20 Sep 2019 22:45:18 +0000 (15:45 -0700)] 
Add oss-fuzz to readme.

5 years agoAdd makecrct test and clean up makecrct.c code
Hans Kristian Rosbach [Tue, 17 Sep 2019 12:12:15 +0000 (14:12 +0200)] 
Add makecrct test and clean up makecrct.c code
Update crc32.h tables to match makecrct output.

5 years agoSplit crc table generating code (MAKECRCH) out into separate tool makecrct.
Hans Kristian Rosbach [Tue, 17 Sep 2019 11:18:02 +0000 (13:18 +0200)] 
Split crc table generating code (MAKECRCH) out into separate tool makecrct.

5 years agoAdd maketrees test and clean up maketrees.c code
Hans Kristian Rosbach [Sun, 15 Sep 2019 16:15:08 +0000 (18:15 +0200)] 
Add maketrees test and clean up maketrees.c code

5 years agoSplit maketrees out into a separate tool
Hans Kristian Rosbach [Sun, 15 Sep 2019 12:52:27 +0000 (14:52 +0200)] 
Split maketrees out into a separate tool

5 years agotravis.yml changes:
Hans Kristian Rosbach [Fri, 20 Sep 2019 09:26:28 +0000 (11:26 +0200)] 
travis.yml changes:
 - Add shorthand-variables for some of the long parameters often used
 - Enable --warn in a couple configure tests that did not have it enabled.
 - Make travis print out CMakeError.log or configure.log in after_failure.
 - Reorder some cmake parameters to improve consistency
 - Disable ccache. Downloading and uploading the cache archive is quite slow,
   especially if travis is having network-connectivity issues.
   Also ccache caches gcno (coverage) files, making the coverage data wrong
   because it is being shared across builds, branches and PRs.

CmakeLists.txt changes:
 - Enable -Wall by default in cmake.

5 years agoPotential fix for clang array warnings. #416
Nathan Moinvaziri [Fri, 20 Sep 2019 04:57:20 +0000 (21:57 -0700)] 
Potential fix for clang array warnings. #416

5 years agoFixed warnings in checksum fuzzer and example. #418
Nathan Moinvaziri [Fri, 20 Sep 2019 01:21:46 +0000 (18:21 -0700)] 
Fixed warnings in checksum fuzzer and example. #418

5 years agoFixed minigzip fuzzer failures on Windows. #411
Nathan Moinvaziri [Thu, 19 Sep 2019 17:17:04 +0000 (10:17 -0700)] 
Fixed minigzip fuzzer failures on Windows. #411

5 years agoIn test_deflate_copy(), we free the original struct but forget to free the copy stuct.
Hans Kristian Rosbach [Thu, 19 Sep 2019 14:14:48 +0000 (16:14 +0200)] 
In test_deflate_copy(), we free the original struct but forget to free the copy stuct.
Found by msan.

5 years agoFixed several warnings in example and fuzzers. #409
Nathan Moinvaziri [Thu, 19 Sep 2019 16:57:42 +0000 (09:57 -0700)] 
Fixed several warnings in example and fuzzers. #409

5 years agoFixed use of uninitialized value warning in crc_folding.c #394
Nathan Moinvaziri [Sun, 15 Sep 2019 22:34:12 +0000 (15:34 -0700)] 
Fixed use of uninitialized value warning in crc_folding.c #394

5 years agoSimplify adding src files with list() command. (#405)
Nathan Moinvaziri [Wed, 18 Sep 2019 20:13:15 +0000 (13:13 -0700)] 
Simplify adding src files with list() command. (#405)

5 years agoMake travis retry its operations, to attempt to avoid many of the
Hans Kristian Rosbach [Tue, 17 Sep 2019 14:12:22 +0000 (16:12 +0200)] 
Make travis retry its operations, to attempt to avoid many of the
failed builds due to silly things like git failed to look up github.com
or apt failed to install deps due to network timeout, etc.

Make curl retry download of codecov bash script, and
make codecov re-try the uploads, since all the network errors
travis has is causing erratic coverage data.

5 years agoAdd test cases to #437
jiangjufa [Thu, 25 Jul 2019 03:13:49 +0000 (11:13 +0800)] 
Add test cases to #437

5 years agoAdded travis msvc 64 bit builds.
Nathan Moinvaziri [Wed, 11 Sep 2019 01:37:32 +0000 (18:37 -0700)] 
Added travis msvc 64 bit builds.

5 years agoAdded cmake tests to verify output of makefixed (#398)
Nathan Moinvaziri [Sat, 14 Sep 2019 17:02:45 +0000 (10:02 -0700)] 
Added cmake tests to verify output of makefixed (#398)

* Add auto-generated header files to .gitignore
* Remove auto-generated header files in make clean

5 years agoRemoved obsolete text file.
Nathan Moinvaziri [Sat, 7 Sep 2019 23:33:41 +0000 (16:33 -0700)] 
Removed obsolete text file.

5 years agoAdd support for Visual Studio 2019 nmake.
Mika Lindqvist [Thu, 29 Aug 2019 16:40:03 +0000 (19:40 +0300)] 
Add support for Visual Studio 2019 nmake.

5 years agocrc_folding: use temp buffer for partial stores
Jim Kukunas [Thu, 8 Dec 2016 04:13:26 +0000 (20:13 -0800)] 
crc_folding: use temp buffer for partial stores

With deflate, the only destination for crc folding was the window, which
was guaranteed to have an extra 15B of padding (because we allocated it).
This padding allowed us to handle the partial store case (len < 16)
with a regular SSE store.

For inflate, this is no longer the case. For crc folding to be
efficient, it needs to operate on large chunks of the data each call.
For inflate, this means copying the decompressed data out to the
user-provided output buffer (moreso with our reorganized window). Since
it's user-provided, we don't have the padding guarantee and therefore
need to fallback to a slower method of handling partial length stores.

5 years agocrc_folding: Fix potential out-of-bounds access
Nicolas Trangez [Thu, 3 Mar 2016 17:17:43 +0000 (18:17 +0100)] 
crc_folding: Fix potential out-of-bounds access

In some (very rare) scenarios, the SIMD code in the `crc_folding` module
can perform out-of-bounds reads or writes, which could lead to GPF
crashes.

Here's the deal: when the `crc_fold_copy` function is called with a
non-zero `len` argument of less then 16, `src` is read through
`_mm_loadu_si128` which always reads 16 bytes. If the `src` pointer
points to a location which contains `len` bytes, but any of the `16 -
len` out-of-bounds bytes falls in unmapped memory, this operation will
trigger a GPF.

The same goes for the `dst` pointer when written to through
`_mm_storeu_si128`.

With this patch applied, the crash no longer occurs.

We first discovered this issue though Valgrind reporting an
out-of-bounds access while running a unit-test for some code derived
from `crc_fold_copy`. In general, the out-of-bounds read is not an issue
because reads only occur in sections which are definitely mapped
(assuming page size is a multiple of 16), and garbage bytes are ignored.
While giving this some more thought we realized for small `len` values
and `src` or `dst` pointers at a very specific place in the address
space can lead to GPFs.

- Minor tweaks to merge request by Jim Kukunas <james.t.kukunas@linux.intel.com>
- removed C11-isms
- use unaligned load
- better integrated w/ zlib (use zalign)
- removed full example code from commit msg

5 years agoUse slide_hash_sse2 from fill_window_sse instead of having a local
Hans Kristian Rosbach [Fri, 23 Aug 2019 19:02:55 +0000 (21:02 +0200)] 
Use slide_hash_sse2 from fill_window_sse instead of having a local
copy of the code.

5 years agoAdd slide_hash to functable, and enable the sse2-optimized version.
Hans Kristian Rosbach [Fri, 23 Aug 2019 18:25:26 +0000 (20:25 +0200)] 
Add slide_hash to functable, and enable the sse2-optimized version.
Add necessary code to cmake and configure.
Fix slide_hash_sse2 to compile with zlib-ng.

5 years agoAdds SSE2 optimized slide_hash.
Jim Kukunas [Thu, 21 Jun 2018 20:47:32 +0000 (20:47 +0000)] 
Adds SSE2 optimized slide_hash.

Edit: Removed glue code in deflate.c, since we want
to implement this differently in zlib-ng.

5 years agoChanges to support compilation with MSVC ARM & ARM64 (#386)
Nathan Moinvaziri [Wed, 4 Sep 2019 06:35:23 +0000 (23:35 -0700)] 
Changes to support compilation with MSVC ARM & ARM64 (#386)

* Merge aarch64 and arm cmake sections.
* Updated MSVC compiler support for ARM and ARM64.
* Moved detection for -mfpu=neon to where the flag is set to simplify add_intrinsics_option.
* Only add ${ACLEFLAG} on aarch64 if not WITH_NEON.
* Rename arch/x86/ctzl.h to fallback_builtins.h.

5 years agoRename #defines for consistency (#378)
Nathan Moinvaziri [Fri, 23 Aug 2019 20:16:28 +0000 (13:16 -0700)] 
Rename #defines for consistency (#378)

5 years ago* Fixed wrong compilers listed for Windows.
Nathan Moinvaziri [Fri, 23 Aug 2019 08:16:22 +0000 (01:16 -0700)] 
* Fixed wrong compilers listed for Windows.

5 years agoAdded support for configuring project based on BUILD_SHARED_LIBS.
Nathan Moinvaziri [Fri, 23 Aug 2019 06:54:34 +0000 (23:54 -0700)] 
Added support for configuring project based on BUILD_SHARED_LIBS.

* If BUILD_SHARED_LIBS is not set, both static and shared libraries will be built.
* Compact cmake by putting all srcs in one variable.

5 years agoClean up travis config.
Hans Kristian Rosbach [Wed, 7 Aug 2019 13:37:43 +0000 (15:37 +0200)] 
Clean up travis config.
Remove a duplicate config, replace with a missing variant.
Add a little more variety to some of the tests.
Add ctest to x86_64 runs.

5 years agoAdd support for codecov.io and GCC-9 testing.
Hans Kristian Rosbach [Wed, 7 Aug 2019 12:05:10 +0000 (14:05 +0200)] 
Add support for codecov.io and GCC-9 testing.
Also added a few section comments to the travis config

5 years agouse relative header path
cielavenir [Fri, 16 Aug 2019 17:18:25 +0000 (02:18 +0900)] 
use relative header path

5 years agotry to consume available data if Z_FINISH is used
cielavenir [Fri, 16 Aug 2019 16:59:38 +0000 (01:59 +0900)] 
try to consume available data if Z_FINISH is used

5 years agoFixed GCC version for bswap intrinsics (#385)
T.Yamada [Wed, 21 Aug 2019 07:17:22 +0000 (16:17 +0900)] 
Fixed GCC version for bswap intrinsics (#385)

Use gcc 4.8 for __builtin_bswap16

6 years agoFixed optimizations not being used when compiler is msvc. (#376)
Nathan Moinvaziri [Sun, 11 Aug 2019 10:49:01 +0000 (03:49 -0700)] 
Fixed optimizations not being used when compiler is msvc. (#376)

This issue I mentioned in #370. Optimization code such as crc_folding.c, deflate_quick_sse.c, fill_window_sse.c, and insert_string_sse.c were not being compiled when the compiler was MSVC because the checks for the instrincs were not being done and the HAVE_[TARGET]_INTRIN variables weren't being set. I could have simply set HAVE_[TARGET]_INTRIN variables to ON manually in the case of MSVC, but it is better this way to have one path for all the compilers (that it runs and checks some code for determination). I have just added MSVC code where necessary in the checks.

* Rename HAVE_SSE42_INTRIN to HAVE_SSE42CRC_INLINE_ASM.
* Added msvc inline asm support to insert_string_sse.c

6 years agoRemove pdf from readme contents.
Nathan Moinvaziri [Thu, 8 Aug 2019 18:01:39 +0000 (11:01 -0700)] 
Remove pdf from readme contents.

6 years agoRemove BUILDFIXED and MAKEFIXED. (#375)
Hans Kristian Rosbach [Thu, 8 Aug 2019 08:38:06 +0000 (10:38 +0200)] 
Remove BUILDFIXED and MAKEFIXED. (#375)

Remove BUILDFIXED support.
Split out MAKEFIXED into a separate 'makefixed' util that is easy
to use if we want to regenerate/verify inffixed.h.

6 years agoRemove syntax, whitespace and comment differences between inflate.c
Hans Kristian Rosbach [Tue, 6 Aug 2019 10:50:57 +0000 (12:50 +0200)] 
Remove syntax, whitespace and comment differences between inflate.c
and infback.c, making actual differences much easier to spot, easing maintenance.

6 years agoReadme and index restructuring (#346)
Nathan Moinvaziri [Thu, 8 Aug 2019 08:13:28 +0000 (01:13 -0700)] 
Readme and index restructuring (#346)

* Added cmake build instructions, build options, install instructions, and repository contents to README.md.
* Moved INDEX file content to README.md files.
* Added configure instructions and options.
* Added CodeFactor to build integration.

6 years agoRemove old zlib artifacts (#345)
Nathan Moinvaziri [Thu, 8 Aug 2019 08:08:20 +0000 (01:08 -0700)] 
Remove old zlib artifacts (#345)

* Remove old zlib readme.
* Remove old zlib change history from inflate.c.
* Remove old treebuild.xml and zlib pdf.

6 years agoEnables neon implementation of memcopy on Android arm64-v8a
taigacon [Tue, 23 Jul 2019 18:58:35 +0000 (02:58 +0800)] 
Enables neon implementation of memcopy on Android arm64-v8a

6 years agoFix wrong chunkmemset_6 implementation
taigacon [Tue, 23 Jul 2019 18:20:17 +0000 (02:20 +0800)] 
Fix wrong chunkmemset_6 implementation

6 years agoRename gzendian to zendian since it is included in more than just the gzip library...
Nathan Moinvaziri [Sat, 20 Jul 2019 04:53:24 +0000 (21:53 -0700)] 
Rename gzendian to zendian since it is included in more than just the gzip library code.

6 years agoDeduplicate inflate's fixedtables(), and no longer inline the inffixed tables.
Hans Kristian Rosbach [Thu, 18 Jul 2019 14:17:49 +0000 (16:17 +0200)] 
Deduplicate inflate's fixedtables(), and no longer inline the inffixed tables.
This also reduces the library size by 4120bytes or ~2.9%.

6 years agoDeduplicate common inflate/inflatefast/inflateBack macros into inflate_p.h
Hans Kristian Rosbach [Thu, 18 Jul 2019 13:49:54 +0000 (15:49 +0200)] 
Deduplicate common inflate/inflatefast/inflateBack macros into inflate_p.h

6 years agoAdd zng_ prefix to internal functions to avoid linking conflicts with zlib. (#363)
Nathan Moinvaziri [Thu, 18 Jul 2019 11:21:13 +0000 (04:21 -0700)] 
Add zng_ prefix to internal functions to avoid linking conflicts with zlib. (#363)

6 years agoAdd "reproducible" deflate parameter
Ilya Leoshkevich [Fri, 24 May 2019 09:18:33 +0000 (11:18 +0200)] 
Add "reproducible" deflate parameter

IBM Z DEFLATE CONVERSION CALL may produce different (but valid)
compressed data for the same uncompressed data. This behavior might be
unacceptable for certain use cases (e.g. reproducible builds). This
patch introduces Z_DEFLATE_REPRODUCIBLE parameter, which can be used to
indicate that this is the case, and turn off IBM Z DEFLATE CONVERSION
CALL.

6 years agoAdd two new public zng_deflate{Set,Get}Params() functions
Ilya Leoshkevich [Thu, 23 May 2019 11:57:43 +0000 (13:57 +0200)] 
Add two new public zng_deflate{Set,Get}Params() functions

These functions allow zlib-ng callers to modify and query the
compression parameters in a future-proof way. When the caller requests a
parameter, which is not supported by the current zlib-ng version, this
situation is detected and reported to the caller. The caller may modify
or query multiple parameters at once. Currently only "level" and
"strategy" parameters are supported. It is planned to add a
"reproducible" parameter, which would affect whether IBM Z DEFLATE
CONVERSION CALL is used.

Passing enum and void * buffer was chosen over passing strings, because
of simplicity for the caller. If strings were used, C callers would have
to call snprintf() and strtoul() for setting and getting integer-valued
parameters respectively, which is quite tedious.

Bulk updates were chosen over updating individual parameters separately,
because it might make sense to apply some parameters atomically, e.g.
level and strategy.

The new functions are defined only for zlib-ng, but not compat zlib.

6 years agoFixed use of uninitialized value found by memory sanitizer and reported by @sebpop.
Nathan Moinvaziri [Wed, 17 Jul 2019 03:00:33 +0000 (20:00 -0700)] 
Fixed use of uninitialized value found by memory sanitizer and reported by @sebpop.

6 years agoIBM Z DFLTCC: fix 31-bit build
Ilya Leoshkevich [Mon, 8 Jul 2019 13:23:12 +0000 (15:23 +0200)] 
IBM Z DFLTCC: fix 31-bit build

* Add machine mode hint for STFLE.
* Adjust offset calculations.

6 years agolongest_match: avoid using negative indices
Ilya Leoshkevich [Mon, 24 Jun 2019 14:57:19 +0000 (16:57 +0200)] 
longest_match: avoid using negative indices

Fixes #364

6 years agodeflate_medium: fix handling of overlapping matches
Ilya Leoshkevich [Fri, 14 Jun 2019 13:33:04 +0000 (15:33 +0200)] 
deflate_medium: fix handling of overlapping matches

Fixes #361

6 years agoAdded cmake support for testing against CVEs (#354)
Nathan Moinvaziri [Sat, 22 Jun 2019 07:49:32 +0000 (00:49 -0700)] 
Added cmake support for testing against CVEs (#354)

6 years agoRemove duplicate gz functions in test code (#348)
Nathan Moinvaziri [Sat, 22 Jun 2019 07:25:39 +0000 (00:25 -0700)] 
Remove duplicate gz functions in test code (#348)

Change CMakeLists.txt so that if WITH_GZFILEOP is OFF, gz* sources are still compiled against the tests which need them.
Remove duplicate gz functions from test code.
Always compile with gz functions when zlib tests enabled in makefile.

6 years agoAdded linux arm for cmake to travis matrix.
Nathan Moinvaziri [Tue, 4 Jun 2019 16:34:20 +0000 (09:34 -0700)] 
Added linux arm for cmake to travis matrix.

6 years agoUnify most of the option() and add_feature_info() statements to the top.
Nathan Moinvaziri [Wed, 29 May 2019 19:19:13 +0000 (12:19 -0700)] 
Unify most of the option() and add_feature_info() statements to the top.
Updated comments to all begin with proper casing.
Convert tabs to spaces.

6 years agoIBM Z DFLTCC: fix STFLE usage
Ilya Leoshkevich [Mon, 3 Jun 2019 14:47:14 +0000 (16:47 +0200)] 
IBM Z DFLTCC: fix STFLE usage

QEMU maintainers have found and issue related to incorrect usage of
STFLE instruction [1], which is used to get features supported by the
machine. There are three potential problems with the current usage:

- R0 must contain the number of requested doublewords *minus one*. The
existing code lacks the "minus one" part.
- Older machines may not fill all the doublewords - this is fixed by
calling `memset`.
- STFLE updates R0, but we don't tell the compiler about this - this is
fixed by using a `+` constraint.
- Not really a problem, but it's enough to load 8 bits into R0, so its
type was changed to `uint8_t`. Also, STFLE only writes to `facilities`
variable, therefore memory clobber is unnecessary.

[1] https://lists.gnu.org/archive/html/qemu-devel/2019-06/msg00113.html

6 years agoIBM Z DFLTCC: minor documentation fixes
Ilya Leoshkevich [Fri, 24 May 2019 10:36:46 +0000 (12:36 +0200)] 
IBM Z DFLTCC: minor documentation fixes

* Replace "DEFLATE COMPRESSION CALL" term with "DEFLATE CONVERSION
  CALL", since the latter is the proper name of the new IBM Z
  instruction.
* Mention CMake options in README.md.
* Replace "new macro" term with just "macro" in README.md (calling
  macros "new" is not correct in this context).
* Replace "zlib" term with "zlib-ng", except in probe point names - it's
  better to keep those common between gzip, zlib and zlib-ng.

6 years agoAdded Windows OS to travis matrix (#355)
Nathan Moinvaziri [Tue, 4 Jun 2019 08:57:55 +0000 (01:57 -0700)] 
Added Windows OS to travis matrix (#355)

This pull request adds Windows OS to travis matrix using cmake.

I had to rename the environment variables because I believed there might have been a conflict with the previous naming. I had to break the script section into multiple lines because Windows didn't like them altogether using &&.

6 years agoFixed float-abi detection command in cmake. Should have been using $ENV{CC} but using...
Nathan Moinvaziri [Wed, 29 May 2019 19:32:29 +0000 (12:32 -0700)] 
Fixed float-abi detection command in cmake. Should have been using $ENV{CC} but using ${CMAKE_C_COMPILER} is more exact.

6 years agoSimplify creating cmake fuzzer test executables.
Nathan Moinvaziri [Wed, 29 May 2019 19:03:20 +0000 (12:03 -0700)] 
Simplify creating cmake fuzzer test executables.

6 years agoFixed compiler warnings on Windows in release mode (#349)
Nathan Moinvaziri [Tue, 4 Jun 2019 08:50:22 +0000 (01:50 -0700)] 
Fixed compiler warnings on Windows in release mode (#349)

This pull request attempts to fix some compiler warnings on Windows when compiled in Release mode.

```
"zlib-ng\ALL_BUILD.vcxproj" (default target) (1) ->
"zlib-ng\zlibstatic.vcxproj" (default target) (6) ->
  zlib-ng\deflate.c(1626): warning C4244: '=': conversion from 'uint16_t' to 'unsigned cha
r', possible loss of data [zlib-ng\zlibstatic.vcxproj]
  zlib-ng\deflate_fast.c(61): warning C4244: '=': conversion from 'uint16_t' to 'unsigned
char', possible loss of data [zlib-ng\zlibstatic.vcxproj]
  zlib-ng\deflate_slow.c(89): warning C4244: '=': conversion from 'uint16_t' to 'unsigned
char', possible loss of data [zlib-ng\zlibstatic.vcxproj]
```

6 years agoAdded cmake toolchain arm support. (#350)
Nathan Moinvaziri [Tue, 4 Jun 2019 08:48:43 +0000 (01:48 -0700)] 
Added cmake toolchain arm support. (#350)

This PR only adds cmake toolchain files for ARM. NAME/COMMAND stuff is so CMAKE_CROSSCOMPILING_EMULATOR is used. The message() is to prevent a warning about unused variable when specifying CMAKE_TOOLCHAIN_FILE.

6 years agoFixed assert(n_read == len) in standalone fuzz target runner on certain file types.
Nathan Moinvaziri [Mon, 27 May 2019 05:01:01 +0000 (22:01 -0700)] 
Fixed assert(n_read == len) in standalone fuzz target runner on certain file types.

6 years agoFix build when DYNAMIC_CRC_TABLE is defined.
Mika T. Lindqvist [Mon, 20 May 2019 08:41:09 +0000 (11:41 +0300)] 
Fix build when DYNAMIC_CRC_TABLE is defined.

6 years agoAdd support for IBM Z hardware-accelerated deflate
Ilya Leoshkevich [Wed, 10 Apr 2019 13:46:58 +0000 (15:46 +0200)] 
Add support for IBM Z hardware-accelerated deflate

Future versions of IBM Z mainframes will provide DFLTCC instruction,
which implements deflate algorithm in hardware with estimated
compression and decompression performance orders of magnitude faster
than the current zlib-ng and ratio comparable with that of level 1.

This patch adds DFLTCC support to zlib-ng. In order to enable it, the
following build commands should be used:

    $ ./configure --with-dfltcc-deflate --with-dfltcc-inflate
    $ make

When built like this, zlib-ng would compress in hardware on level 1,
and in software on all other levels. Decompression will always happen
in hardware. In order to enable DFLTCC compression for levels 1-6 (i.e.
to make it used by default) one could add -DDFLTCC_LEVEL_MASK=0x7e to
CFLAGS when building zlib-ng.

Two DFLTCC compression calls produce the same results only when they
both are made on machines of the same generation, and when the
respective buffers have the same offset relative to the start of the
page. Therefore care should be taken when using hardware compression
when reproducible results are desired.

DFLTCC does not support every single zlib-ng feature, in particular:

    * inflate(Z_BLOCK) and inflate(Z_TREES)
    * inflateMark()
    * inflatePrime()
    * deflateParams() after the first deflate() call

When used, these functions will either switch to software, or, in case
this is not possible, gracefully fail.

This patch tries to add DFLTCC support in a least intrusive way.
All SystemZ-specific code was placed into a separate file, but
unfortunately there is still a noticeable amount of changes in the
main zlib-ng code. Below is the summary of those changes.

DFLTCC takes as arguments a parameter block, an input buffer, an output
buffer and a window. Since DFLTCC requires parameter block to be
doubleword-aligned, and it's reasonable to allocate it alongside
deflate and inflate states, ZALLOC_STATE, ZFREE_STATE and ZCOPY_STATE
macros were introduced in order to encapsulate the allocation details.
The same is true for window, for which ZALLOC_WINDOW and
TRY_FREE_WINDOW macros were introduced.

While for inflate software and hardware window formats match, this is
not the case for deflate. Therefore, deflateSetDictionary and
deflateGetDictionary need special handling, which is triggered using the
new DEFLATE_SET_DICTIONARY_HOOK and DEFLATE_GET_DICTIONARY_HOOK macros.

deflateResetKeep() and inflateResetKeep() now update the DFLTCC
parameter block, which is allocated alongside zlib-ng state, using
the new DEFLATE_RESET_KEEP_HOOK and INFLATE_RESET_KEEP_HOOK macros.

In order to make unsupported deflateParams(), inflatePrime() and
inflateMark() calls to fail gracefully, the new DEFLATE_PARAMS_HOOK,
INFLATE_PRIME_HOOK and INFLATE_MARK_HOOK macros were introduced.

The algorithm implemented in hardware has different compression ratio
than the one implemented in software. In order for deflateBound() to
return the correct results for the hardware implementation, the new
DEFLATE_BOUND_ADJUST_COMPLEN and DEFLATE_NEED_CONSERVATIVE_BOUND macros
were introduced.

Actual compression and decompression are handled by the new DEFLATE_HOOK
and INFLATE_TYPEDO_HOOK macros. Since inflation with DFLTCC manages the
window on its own, calling updatewindow() is suppressed using the new
INFLATE_NEED_UPDATEWINDOW() macro.

In addition to compression, DFLTCC computes CRC-32 and Adler-32
checksums, therefore, whenever it's used, software checksumming needs to
be suppressed using the new DEFLATE_NEED_CHECKSUM and
INFLATE_NEED_CHECKSUM macros.

DFLTCC will refuse to write an End-of-block Symbol if there is no input
data, thus in some cases it is necessary to do this manually. In order
to achieve this, bi_reverse and flush_pending were promoted from static
to ZLIB_INTERNAL and exposed via deflate.h.

Since the first call to dfltcc_inflate already needs the window, and it
might be not allocated yet, inflate_ensure_window was factored out of
updatewindow and made ZLIB_INTERNAL.

6 years agoIntroduce inflate and deflate hooks
Ilya Leoshkevich [Wed, 10 Apr 2019 11:52:07 +0000 (13:52 +0200)] 
Introduce inflate and deflate hooks

6 years agoIntroduce inflate_ensure_window, make bi_reverse and flush_pending ZLIB_INTERNAL
Ilya Leoshkevich [Wed, 10 Apr 2019 11:41:58 +0000 (13:41 +0200)] 
Introduce inflate_ensure_window, make bi_reverse and flush_pending ZLIB_INTERNAL

6 years agoIgnore CLion files
Ilya Leoshkevich [Fri, 12 Apr 2019 14:21:15 +0000 (16:21 +0200)] 
Ignore CLion files

6 years agoFix infcover.c build
Ilya Leoshkevich [Tue, 26 Mar 2019 12:30:51 +0000 (13:30 +0100)] 
Fix infcover.c build

infcover.c includes inflate.h, which makes use of PREFIX3 macro. This
macro is defined in zbuild.h, which is not included.

6 years agocleanup arm/adler32_neon.c code
Sebastian Pop [Mon, 1 Apr 2019 20:05:53 +0000 (15:05 -0500)] 
cleanup arm/adler32_neon.c code

6 years agoonly call NEON adler32 for more than 16 bytes
Sebastian Pop [Mon, 28 Jan 2019 22:05:50 +0000 (16:05 -0600)] 
only call NEON adler32 for more than 16 bytes

improves performance of inflate by up to 6% on an A-73 Hikey running at 2.36 GHz
when executing the chromium benchmark on the snappy data set.  In a few cases
inflate is slower by up to 0.8%.  Overall performance of inflate is better by
about 0.3%.

6 years agofix configure output when compiler is clang
Sebastian Pop [Mon, 1 Apr 2019 18:21:18 +0000 (13:21 -0500)] 
fix configure output when compiler is clang

The patch cleans up the expected errors that clutter the output of configure:

$ CC=clang ./configure
Checking for compiler... clang-6.0
clang: error: unknown argument: '-print-multiarch'
clang: error: no input files

With this patch the last two lines disappear.

6 years agofix configure --help text to match parsed options
Sebastian Pop [Wed, 3 Apr 2019 14:50:02 +0000 (09:50 -0500)] 
fix configure --help text to match parsed options

6 years agofix warning when compiling for AArch64
Sebastian Pop [Wed, 3 Apr 2019 15:00:08 +0000 (10:00 -0500)] 
fix warning when compiling for AArch64

gcc stopped warning about an unused function when I declared `arm_has_neon` as
`static inline`.  However clang still warns about an unused function:

```
arch/arm/armfeature.c:20:19: warning: unused function 'arm_has_neon' [-Wunused-function]
static inline int arm_has_neon()

                  ^
1 warning generated.
```

This patch moves the function under a preprocessor `#if !defined(__aarch64)`
which makes clang stop warn about it.

6 years agoFix building with gcc 8.2.1 and -Wall -Wextra -pedantic -Werror
Ilya Leoshkevich [Tue, 26 Mar 2019 09:52:02 +0000 (10:52 +0100)] 
Fix building with gcc 8.2.1 and -Wall -Wextra -pedantic -Werror

* ptrdiff_t check always failed because of unused parameter
* sizeof(void *) check always failed because of double semicolon
* Sign issue in nice_match assignment
* dist parameter of set_bytes may be unused
* Parameters of main may be unused in test/example.c
* snprintf requires a _POSIX_C_SOURCE #define in test/minigzip.c,
  because a _POSIX_SOURCE #define is present

6 years agoIncrease verbosity required to warn about bit length overflow.
Mark Adler [Sun, 20 Nov 2016 19:36:15 +0000 (11:36 -0800)] 
Increase verbosity required to warn about bit length overflow.

When debugging the Huffman coding would warn about resulting codes
greater than 15 bits in length. This is handled properly, and is
not uncommon. This increases the verbosity of the warning by one,
so that it is not displayed by default.

6 years agoFix endianness detection in memcopy.h
Ilya Leoshkevich [Tue, 26 Mar 2019 12:06:36 +0000 (13:06 +0100)] 
Fix endianness detection in memcopy.h

When memcopy.h is included into inffast.c, endianness-related
preperocessor defines are not set, which leads to
BYTE_ORDER == LITTLE_ENDIAN condition being always true. This breaks
decompression at least on s390x.

6 years agofix oss-fuzz/13863
Sebastian Pop [Tue, 26 Mar 2019 16:59:45 +0000 (11:59 -0500)] 
fix oss-fuzz/13863

The oss fuzzers started failing with the following assert
```
ASSERT: 0 == memcmp(data + offset, buf, len)
```
after the following patch has been pulled in the tree:

```
commit 20ca64fa5d2d8a7421ed86b68709ef971dcfbddf
Author: Sebastian Pop <s.pop@samsung.com>
Date:   Wed Mar 6 14:16:20 2019 -0600

    define and use chunkmemset instead of byte_memset for INFFAST_CHUNKSIZE
```

The function chunkcopysafe is assuming that the input `len` is less than 16 bytes:
```
    if ((safe - out) < (ptrdiff_t)INFFAST_CHUNKSIZE) {
```
but we were called with `len = 22` because `safe` was defined too small:

```
-    safe = out + (strm->avail_out - INFFAST_CHUNKSIZE);
```
and the difference `safe - out` was 16 bytes smaller than the actual `len`.
The patch fixes the initialization of `safe` to:
```
+    safe = out + strm->avail_out;
```

6 years agouse sizeof(type) instead of magic numbers
Sebastian Pop [Tue, 5 Mar 2019 19:36:25 +0000 (19:36 +0000)] 
use sizeof(type) instead of magic numbers

6 years agoautomatically update makefile dependences
Sebastian Pop [Sat, 26 Jan 2019 21:54:59 +0000 (15:54 -0600)] 
automatically update makefile dependences

6 years agofix all ASan errors on arm/aarch64
Sebastian Pop [Tue, 5 Mar 2019 19:15:17 +0000 (19:15 +0000)] 
fix all ASan errors on arm/aarch64

6 years agofactor out code in arch/{arm,aarch64}
Sebastian Pop [Tue, 5 Mar 2019 15:57:05 +0000 (09:57 -0600)] 
factor out code in arch/{arm,aarch64}

6 years agofix UBSan warnings of unsigned overflow
Sebastian Pop [Wed, 6 Mar 2019 20:33:49 +0000 (14:33 -0600)] 
fix UBSan warnings of unsigned overflow

6 years agochunk_memcpy is not needed under INFFAST_CHUNKSIZE
Sebastian Pop [Wed, 6 Mar 2019 20:32:14 +0000 (14:32 -0600)] 
chunk_memcpy is not needed under INFFAST_CHUNKSIZE

6 years agouse chunkcopysafe and chunkmemsetsafe under INFFAST_CHUNKSIZE from inflate
Sebastian Pop [Wed, 6 Mar 2019 20:20:04 +0000 (14:20 -0600)] 
use chunkcopysafe and chunkmemsetsafe under INFFAST_CHUNKSIZE from inflate

6 years agodefine and use chunkmemset instead of byte_memset for INFFAST_CHUNKSIZE
Sebastian Pop [Wed, 6 Mar 2019 20:16:20 +0000 (14:16 -0600)] 
define and use chunkmemset instead of byte_memset for INFFAST_CHUNKSIZE

6 years agofactor out code
Sebastian Pop [Wed, 6 Mar 2019 20:00:30 +0000 (14:00 -0600)] 
factor out code

6 years agoenable INFFAST_CHUNKSIZE on x86
Sebastian Pop [Fri, 1 Mar 2019 15:48:58 +0000 (09:48 -0600)] 
enable INFFAST_CHUNKSIZE on x86

6 years agofix indent for pre-processor
Sebastian Pop [Wed, 6 Mar 2019 19:37:18 +0000 (13:37 -0600)] 
fix indent for pre-processor