Commit Graph

72 Commits

Author SHA1 Message Date
Mark Adler
4fe59efbe0 zlib 1.3.1
madler/zlib#51b7f2abdade71cd9bb0e7a373ef2610ec6f9daf
2024-02-07 19:15:56 +01:00
Nathan Moinvaziri
efae7678b0 Add back gz_intmax for zlib compatibility when linking statically 2024-02-07 19:15:56 +01:00
Milan Bulat
0d2984d0d3 Make the existence of gz_intmax() unconditional.
gz_intmax() is noted in zlib.map. This assures it's always there.

madler/zlib#01253ecd7e0a01d311670f2d03c61b82fc12d338
2024-02-07 19:15:56 +01:00
Mark Adler
faf6cf70cd Avoid compiler complaints if _TIME_BITS defined when building zlib.
zlib does not use time_t, so _TIME_BITS is irrelevant. However it
may be defined anyway as part of a sledgehammer indiscriminately
applied to all builds.
2023-08-24 11:22:33 +02:00
Nathan Moinvaziri
d43822b9a7 zlib 1.2.12 2022-06-13 15:58:03 +02:00
Nathan Moinvaziri
348f4155c7 Remove unistd.h include from gzguts.h which is already included from zconf.h via zlib.h. 2022-03-28 11:08:25 +02:00
Hans Kristian Rosbach
b1ebcc0ee9 Remove gz_intmax implementation, since INT_MAX is always available in modern C implementations. 2021-12-19 15:40:52 +01:00
Nathan Moinvaziri
baff847dc1 Increase size of gzip output buffer to be a multiple of the size of deflate's pending buffer for improved performance and fewer calls to deflate. 2021-06-12 20:16:45 +02:00
Nathan Moinvaziri
7cffba4dd6 Rename ZLIB_INTERNAL to Z_INTERNAL for consistency. 2020-08-31 12:33:16 +02:00
Nathan Moinvaziri
6dcc7bf815 For gzseek, gzoffset, gzopen, adler32_combine, crc32_combine and crc32_combine_gen, export 32-bit and 64-bit versions for zlib-compatible api and only 64-bit version (without 64 suffix) for zlib-ng native api. 2020-06-08 21:14:07 +02:00
Pavel P
6dfff29c01 Clean up windows defines, use _WIN32
+ replaced WIN32 with _WIN32
 + removed unused WINDOWS/_WINDOWS defines
 + no need to test for __MINGW__, as _WIN32 is also defined
2020-06-08 15:09:17 +02:00
Nathan Moinvaziri
d14fae1860 Make GZBUFSIZE and BUFLEN configurable. 2020-04-16 13:08:05 +02:00
Nathan Moinvaziri
e0a711cdde 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
Mark Adler
72c9ed1415 Avoid adding empty gzip member after gzflush with Z_FINISH. 2019-10-22 09:55:41 +02:00
Nathan Moinvaziri
743def4c93 Rename #defines for consistency (#378) 2019-08-23 22:16:27 +02:00
Ilya Leoshkevich
8e30d11736 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.
2019-05-23 12:44:59 +02:00
Hans Johnson
80c2fdf2cd COMP: Fix missing header unistd.h
zlib-ng/gzlib.c:196:9: warning: implicit declaration of function 'lseek' is invalid in C99 [-Wimplicit-function-declaration]
        LSEEK(state->fd, 0, SEEK_END);  /* so gzoffset() is correct */
        ^
zlib-ng/gzlib.c:17:17: note: expanded from macro 'LSEEK'
                ^
[ 61%] Building C object CMakeFiles/zlibstatic.dir/gzread.c.o
zlib-ng/gzread.c:27:15: warning: implicit declaration of function 'read' is invalid in C99 [-Wimplicit-function-declaration]
        ret = read(state->fd, buf + *have, len - *have);
              ^
zlib-ng/gzread.c:596:11: warning: implicit declaration of function 'close' is invalid in C99 [-Wimplicit-function-declaration]
    ret = close(state->fd);
          ^
[ 62%] Building C object CMakeFiles/zlibstatic.dir/gzwrite.c.o
zlib-ng/gzwrite.c:84:15: warning: implicit declaration of function 'write' is invalid in C99 [-Wimplicit-function-declaration]
        got = write(state->fd, strm->next_in, strm->avail_in);
              ^
zlib-ng/gzwrite.c💯33: warning: implicit declaration of function 'write' is invalid in C99 [-Wimplicit-function-declaration]
            if (have && ((got = write(state->fd, state->x.next, (unsigned long)have)) < 0 || (unsigned)got != have)) {
                                ^
zlib-ng/gzwrite.c:512:9: warning: implicit declaration of function 'close' is invalid in C99 [-Wimplicit-function-declaration]
    if (close(state->fd) == -1)"
2019-01-21 10:28:07 +01:00
Mark Adler
ec85a0a556 Cygwin does not have _wopen(), so do not create gzopen_w() there. 2018-12-21 16:25:05 +01:00
Hans Kristian Rosbach
584dd13b11 Fix ZLIB_COMPAT=OFF and WITH_GZFILEOP=ON compilation failure.
Also add this combination to travis testing.

Remove --native testing from travis, since they somehow make this fail very often,
probably due to caching or running the executables on a different platform than
the compiler thinks it is running on.
2018-09-17 12:22:43 +02:00
Hans Kristian Rosbach
f5e888a6a6 Add function prefix (zng_) to all exported functions to allow zlib-ng
to co-exist in an application that has been linked to something that
depends on stock zlib. Previously, that would cause random problems
since there is no way to guarantee what zlib version is being used
for each dynamically linked function.

Add the corresponding zlib-ng.h.

Tests, example and minigzip will not compile before they have been
adapted to use the correct functions as well.
Either duplicate them, so we have minigzip-ng.c for example, or add
compile-time detection in the source code.
2018-01-31 10:45:29 +01:00
Mika Lindqvist
8a3815bf99 Type cleanup...
* gz_statep -> gz_state *
2017-02-25 12:52:11 +01:00
Mark Adler
2a51c84f6c zlib 1.2.9 2017-02-09 11:39:40 +01:00
Mika Lindqvist
631817cce8 local -> static
* local -> static
* Normalize and cleanup line-endings
* Fix warnings under Visual Studio.
* Whitespace cleanup

***
This patch has been edited to merge cleanly and to exclude type changes.
Based on 8d7a7c3b82c6e38734bd504dac800b148ab410d0 "Type Cleanup"
2017-01-30 10:35:05 +01:00
Hans Kristian Rosbach
616a60367f Fix the remaining warnings due to conflicting defines of ZLIB_INTERNAL 2016-04-28 14:06:46 +02:00
Mika Lindqvist
9c3a280877 Type cleanup. 2015-12-14 11:00:22 +02:00
Mika Lindqvist
962354736f Fix creating shared library under MSYS64. 2015-11-25 16:12:13 +01:00
Mark Adler
fa1c29c7f4 Compile the gzopen_w() function when __CYGWIN__ defined.
Conflicts:
	gzlib.c
	zlib.h
2015-11-03 19:10:23 +01:00
Mark Adler
48e985b618 Improve speed of gzprintf() in transparent mode.
A few minor modifications done to help with conflicts.
2015-11-03 18:43:48 +01:00
tbeu
ed5a7c1657 Remove now obsolete comment
... about snprintf() being not available in MSVC
2015-10-06 21:53:40 +02:00
Hans Kristian Rosbach
7e13ce3e3d Style cleanup for gzfile code 2015-05-25 23:01:55 +02:00
Hans Kristian Rosbach
04f4c5e7b3 Remove support for NO_DEFLATE 2015-05-24 19:34:12 +02:00
Mika Lindqvist
6c00a3ed36 snprintf() was added to Visual Studio 2015. 2015-05-22 16:13:48 +03:00
Mika Lindqvist
7d17132436 Integrate win32/Makefile.gcc into Makefile.in 2015-05-13 17:53:06 +03:00
Daniel Axtens
239692bf13 Remove UNDER_CE: Windows CE is old.
Signed-off-by: Daniel Axtens <dja@axtens.net>
2015-05-11 20:40:22 +02:00
hansr
3f8e26e0b7 Remove workarounds for non-ANSI-C compatible compilers (Part 2)
-Removing usage of OF() definition
2014-10-12 22:57:27 +02:00
hansr
f7e1e0130f Remove workarounds for non-ANSI-C compatible compilers (Part 1) 2014-10-12 12:38:06 +02:00
hansr
f5c5de6859 Remove support for SASC and TURBOC compilers 2014-10-10 13:26:04 +02:00
hansr
0db1040667 Remove FAR definition
Remove a few leftovers from the legacy OS support removal
2014-10-09 13:55:20 +02:00
hansr
e88676a00e Remove code related to older operating systems 2014-10-09 13:28:39 +02:00
Mark Adler
70252daf89 Add casts in gzwrite.c for pointer differences. 2013-04-13 18:04:06 -07:00
Mark Adler
0b16609409 zlib 1.2.7.1 2013-03-24 22:47:59 -07:00
Mark Adler
d3b613e320 Minor spacing cleanup in a comment in gzguts.h. 2013-03-24 16:56:05 -07:00
Mark Adler
d211ecdf02 Use underscored I/O function names for WINAPI_FAMILY.
Suggested by E. Timothy Uy.
2013-02-23 20:27:13 -08:00
Mark Adler
25e4a3da55 Use _snprintf for snprinf in Microsoft C.
More than a decade later, Microsoft C does not support the C99
standard.  It's good that _snprintf has a different name, since it
does not guarantee that the result is null terminated, as does
snprintf.  However where _snprintf is used under Microsoft C, the
destination string is assured to be long enough, so this will not
be a problem.  This occurs in two places, both in gzlib.c.  Where
sprintf functionality is needed by gzprintf, vsnprintf is used in
the case of Microsoft C.
2012-06-03 12:45:55 -07:00
Mark Adler
a1af6e96e3 Fix gzopen_w() type and add #include for the type. 2012-03-17 21:45:01 -07:00
Mark Adler
dbe0bed739 Add gzopen_w() in Windows for wide character path names. 2012-03-16 20:53:09 -07:00
Mark Adler
dab7531ecc Simplify test and use of gcc hidden attribute. 2012-03-03 00:20:00 -08:00
Mark Adler
3f4339b61b Improve the detection of no hidden visibility attribute. 2012-02-19 23:33:10 -08:00
Mark Adler
e6d2a8471b Do not use the visibility attribute if NO_VIZ defined. 2012-02-19 22:45:10 -08:00
Mark Adler
a75d6ea070 Require gcc 4.0 or later on Mac OS X to use the hidden attribute. 2012-02-18 15:37:28 -08:00