Check for match length exceeding lookahead each time a new best match is found. This reduces some code complexity in GOTO_NEXT_CHAIN by removing the need for RETURN_BEST_LEN.
Use unaligned 32-bit and 64-bit compare based on best match length when searching for matches.
Move TRIGGER_LEVEL to match_tpl.h since it is only used in longest match.
Use early return inside match loops instead of cont variable.
Added back two variable check for platforms that don't supported unaligned access.
Fix switching compression levels on older SystemZ machines
When switching to a compression level that is in general supported by
the hardware accelerator, the code doesn't check whether acceleration is
available or enabled.
Ilya Leoshkevich [Fri, 14 Aug 2020 11:50:39 +0000 (13:50 +0200)]
Fix DFLTCC detection
On some Z machines ARCH is determined to be s390, not s390x, which
prevents DFLTCC support from being built. In general, it is safe to
build zlib-ng with DFLTCC support on any SystemZ machine, because its
usage is guarded by STFLE.
Josh Triplett [Sun, 16 Aug 2020 23:12:13 +0000 (16:12 -0700)]
Fix testsuite warnings on Windows, using PRIu64
zlib-ng already counts on inttypes.h and stdint.h, so use those to avoid
printf-related warnings by casting integer fields whose size may vary to
uint64_t and printing them that way.
Josh Triplett [Fri, 14 Aug 2020 03:59:17 +0000 (20:59 -0700)]
Optimize inflate_fast for a 0.8% speedup
When inflate_fast checks for extra length bits, it first checks if the
number of extra length bits (in op) is non-zero. However, if the number
of extra length bits is 0, the `bits < op` check will be false, BITS(op)
will be 0, and DROPBITS(op) will do nothing. So, drop the conditional,
for a speedup of about 0.8%.
This makes the handling of extra length bits match the handling of extra
dist bits, which already lacks the extra conditional.
Fixed conversion from unsigned int to short warning in slide_hash_sse2 and slide_hash_avx2.
slide_sse.c(20,51): warning C4244: 'function': conversion from 'unsigned int' to 'short', possible loss of data
slide_avx.c(21,54): warning C4244: 'function': conversion from 'unsigned int' to 'short', possible loss of data
Fixed warning about indexing literal string in GCC macOS
infcover.c:378:56: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
infcover.c:378:56: note: use array indexing to silence this warning
Remove ARM crc instruction set from NEONFLAG. The crc instruction set is not used for neon source files. It may have been necessary back when the NEONFLAG was applied to all source files in CMake. Configure script does not apply crc instruction set when setting neon flags.
Change ctest to test all the files in test/data.
Improved minigzip test configurations in ctest.
Added corpora repository to test/data to test for each run.
Allow for CMake to run tests in parallel.
Seperate minigzip and switchlevels set of tests into test-compress.cmake.
Create run-and-compare.cmake for tests that need to run a command and compare output.
Dan Kegel [Thu, 2 Jul 2020 17:21:50 +0000 (10:21 -0700)]
CMakeLists.txt, configure: match source order; .so's now identical on more platforms.
Also:
- use same name for .so on CMake and configure in --zlib-compat case
- configure: merge i686 and x86_64 sections, since they were essentially identical
- pkgcheck.sh: verify resulting shared libraries are bit-for-bit identical
- pkgcheck.sh: use diffoscope if present to show differences in shared libraries
Don't install diffoscope in ci, since that slows down successful
runs; we can add it later if failures become common.
Dan Kegel [Sun, 21 Jun 2020 00:26:00 +0000 (17:26 -0700)]
configure: don't link shared libraries explicitly with -lc
The -lc was introduced by d6231142d2b883a8c3b253fa34992b5cdb4ac2fe :
which said in part
"Changes in 1.2.3.2 (3 September 2006)
...
- Rig configure --shared to build both shared and static [Teredesai, Truta]"
It's not clear why it was needed. On powerpc, linking -lc explicitly
causes __moddi3 and __stack_chk_fail_local to swap location in the
binary.
If we want configure and cmake to generate identical shared libraries,
either we need to link -lc explicitly in both configure and cmake,
or in neither. Occam's Razor suggests omitting it from configure
rather than adding it to cmake.
Dan Kegel [Fri, 19 Jun 2020 15:50:13 +0000 (08:50 -0700)]
Make static libraries produced by cmake and configure identical.
Also make compat mode .pc files identical.
- cmake: don't do runtime feature checks when doing native builds.
- test/pkgcheck.sh: also compare .a, check compat mode, and handle mac better
- CMakeLists.txt: get Version right in compat mode .pc file
- .github/workflows/pkgcheck.sh: test on more systems, including mac
Default to optimization level 2 in cmake for release mode. Can be overwritten by setting the optimization level with CMAKE_C_FLAGS. MSVC does not have optimization level 3.
Since the introduction of test/adler32_test.c there has been a new
warning about too long strings:
/home/runner/work/zlib-ng/zlib-ng/test/adler32_test.c:178:5: warning: string
length ‘5552’ is greater than the length ‘4095’ ISO C99 compilers are required
to support [-Woverlength-strings]
"byRKqAu3J", 5552, 0x8b81718f},
^~~~~~~~~~~
/home/runner/work/zlib-ng/zlib-ng/test/adler32_test.c:321:5: warning: string
length ‘5552’ is greater than the length ‘4095’ ISO C99 compilers are required
to support [-Woverlength-strings]
"byRKqAu3J", 5552, 0x7dc51be2},
^~~~~~~~~~~
Declaring the long string as a static byte array fixes the issue.
Fixed ubsan error in deflatePrime when bits is 32.
deflate.c:602:15: runtime error: shift exponent 32 is too large for 32-bit type 'int32_t' (aka 'int')
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /src/zlib-ng/deflate.c:602:15
Apply float abi flag to all files in cmake (same as configure).
Don't override -mfloat-abi if set via -DCMAKE_C_FLAGS in cmake.
Only set -mfloat-abi=softfp if compiler ends in eabi in cmake. (same as configure).
Fixed integer casting and signed comparison warning in test_gzio.
example.c(199,57): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
example.c:207:32: warning: comparison between signed and unsigned integer expressions
Fixed wrong size being used in calloc in test_deflate_set_header.
CID 293478 (#1 of 1): Wrong size argument (SIZEOF_MISMATCH)
suspicious_sizeof: Passing argument 1UL to function calloc that returns a pointer of type zng_gz_header * is suspicious because a multiple of sizeof (zng_gz_header) /*80*/ is expected.
Fixed avail_out == 0 conditional not returning need_more in deflate_quick.
Fixed ending block when returning need_more caused problems with inflate.
So instead of ending the block each time the function returns to finish the last block, we check upon start to see if it is the last block and if the last block has been started, and if not it will close the previous block and start the last block.
Clean up header includes for Win32 and ARM.
Fixed MSVC compiler warning in storechunk for ARM Neon.
Fixed arm_neon.h include for memchunk for ARM Neon.