Skip to content

Commit 4327004

Browse files
authored
Merge pull request #16305 from pshipton/zlib13
Update to zlib 1.2.13
2 parents f21e296 + d0c89c4 commit 4327004

14 files changed

+250
-216
lines changed

runtime/include/zconf.h

+16-3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
# define crc32(x, y, z) j9zlib_crc32(x, y, z)
4343
# define crc32_combine z_crc32_combine
4444
# define crc32_combine64 z_crc32_combine64
45+
# define crc32_combine_gen z_crc32_combine_gen
46+
# define crc32_combine_gen64 z_crc32_combine_gen64
47+
# define crc32_combine_op z_crc32_combine_op
4548
# define crc32_z z_crc32_z
4649
# define deflate j9zlib_deflate
4750
# define deflateBound z_deflateBound
@@ -354,6 +357,9 @@
354357
# ifdef FAR
355358
# undef FAR
356359
# endif
360+
# ifndef WIN32_LEAN_AND_MEAN
361+
# define WIN32_LEAN_AND_MEAN
362+
# endif
357363
# include <windows.h>
358364
/* No need for _export, use ZLIB.DEF instead. */
359365
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
@@ -472,11 +478,18 @@ typedef uLong FAR uLongf;
472478
# undef _LARGEFILE64_SOURCE
473479
#endif
474480

475-
#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)
476-
# define Z_HAVE_UNISTD_H
481+
#ifndef Z_HAVE_UNISTD_H
482+
# ifdef __WATCOMC__
483+
# define Z_HAVE_UNISTD_H
484+
# endif
485+
#endif
486+
#ifndef Z_HAVE_UNISTD_H
487+
# if defined(_LARGEFILE64_SOURCE) && !defined(_WIN32)
488+
# define Z_HAVE_UNISTD_H
489+
# endif
477490
#endif
478491
#ifndef Z_SOLO
479-
# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
492+
# if defined(Z_HAVE_UNISTD_H)
480493
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
481494
# ifdef VMS
482495
# include <unixio.h> /* for off_t */

runtime/include/zlib.h

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* zlib.h -- interface of the 'zlib' general purpose compression library
2-
version 1.2.12, March 11th, 2022
2+
version 1.2.13, October 13th, 2022
33
44
Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler
55
@@ -37,11 +37,11 @@
3737
extern "C" {
3838
#endif
3939

40-
#define ZLIB_VERSION "1.2.12"
41-
#define ZLIB_VERNUM 0x12c0
40+
#define ZLIB_VERSION "1.2.13"
41+
#define ZLIB_VERNUM 0x12d0
4242
#define ZLIB_VER_MAJOR 1
4343
#define ZLIB_VER_MINOR 2
44-
#define ZLIB_VER_REVISION 12
44+
#define ZLIB_VER_REVISION 13
4545
#define ZLIB_VER_SUBREVISION 0
4646

4747
/*
@@ -276,7 +276,7 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
276276
== 0), or after each call of deflate(). If deflate returns Z_OK and with
277277
zero avail_out, it must be called again after making room in the output
278278
buffer because there might be more output pending. See deflatePending(),
279-
which can be used if desired to determine whether or not there is more ouput
279+
which can be used if desired to determine whether or not there is more output
280280
in that case.
281281
282282
Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to
@@ -660,7 +660,7 @@ ZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm,
660660
to dictionary. dictionary must have enough space, where 32768 bytes is
661661
always enough. If deflateGetDictionary() is called with dictionary equal to
662662
Z_NULL, then only the dictionary length is returned, and nothing is copied.
663-
Similary, if dictLength is Z_NULL, then it is not set.
663+
Similarly, if dictLength is Z_NULL, then it is not set.
664664
665665
deflateGetDictionary() may return a length less than the window size, even
666666
when more than the window size in input has been provided. It may return up
@@ -915,7 +915,7 @@ ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm,
915915
to dictionary. dictionary must have enough space, where 32768 bytes is
916916
always enough. If inflateGetDictionary() is called with dictionary equal to
917917
Z_NULL, then only the dictionary length is returned, and nothing is copied.
918-
Similary, if dictLength is Z_NULL, then it is not set.
918+
Similarly, if dictLength is Z_NULL, then it is not set.
919919
920920
inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the
921921
stream state is inconsistent.
@@ -1437,12 +1437,12 @@ ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems,
14371437
14381438
In the event that the end of file is reached and only a partial item is
14391439
available at the end, i.e. the remaining uncompressed data length is not a
1440-
multiple of size, then the final partial item is nevetheless read into buf
1440+
multiple of size, then the final partial item is nevertheless read into buf
14411441
and the end-of-file flag is set. The length of the partial item read is not
14421442
provided, but could be inferred from the result of gztell(). This behavior
14431443
is the same as the behavior of fread() implementations in common libraries,
14441444
but it prevents the direct use of gzfread() to read a concurrently written
1445-
file, reseting and retrying on end-of-file, when size is not 1.
1445+
file, resetting and retrying on end-of-file, when size is not 1.
14461446
*/
14471447

14481448
ZEXTERN int ZEXPORT gzwrite OF((gzFile file, voidpc buf, unsigned len));
@@ -1913,7 +1913,7 @@ ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));
19131913
ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void));
19141914
ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
19151915
ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int));
1916-
ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF ((z_streamp));
1916+
ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF((z_streamp));
19171917
ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));
19181918
ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
19191919
#if defined(_WIN32) && !defined(Z_SOLO)

runtime/zlib/compress.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
2020
Z_STREAM_ERROR if the level parameter is invalid.
2121
*/
22-
int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
22+
int ZEXPORT compress2(dest, destLen, source, sourceLen, level)
2323
Bytef *dest;
2424
uLongf *destLen;
2525
const Bytef *source;
@@ -65,7 +65,7 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
6565

6666
/* ===========================================================================
6767
*/
68-
int ZEXPORT compress (dest, destLen, source, sourceLen)
68+
int ZEXPORT compress(dest, destLen, source, sourceLen)
6969
Bytef *dest;
7070
uLongf *destLen;
7171
const Bytef *source;
@@ -78,7 +78,7 @@ int ZEXPORT compress (dest, destLen, source, sourceLen)
7878
If the default memLevel or windowBits for deflateInit() is changed, then
7979
this function needs to be updated.
8080
*/
81-
uLong ZEXPORT compressBound (sourceLen)
81+
uLong ZEXPORT compressBound(sourceLen)
8282
uLong sourceLen;
8383
{
8484
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +

runtime/zlib/crc32.c

+21-12
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,22 @@
105105
# endif
106106
#endif
107107

108+
/* If available, use the ARM processor CRC32 instruction. */
109+
#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32) && W == 8
110+
# define ARMCRC32
111+
#endif
112+
108113
/* Local functions. */
109114
local z_crc_t multmodp OF((z_crc_t a, z_crc_t b));
110115
local z_crc_t x2nmodp OF((z_off64_t n, unsigned k));
111116

112-
/* If available, use the ARM processor CRC32 instruction. */
113-
#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32) && W == 8
114-
# define ARMCRC32
117+
#if defined(W) && (!defined(ARMCRC32) || defined(DYNAMIC_CRC_TABLE))
118+
local z_word_t byte_swap OF((z_word_t word));
119+
#endif
120+
121+
#if defined(W) && !defined(ARMCRC32)
122+
local z_crc_t crc_word OF((z_word_t data));
123+
local z_word_t crc_word_big OF((z_word_t data));
115124
#endif
116125

117126
#if defined(W) && (!defined(ARMCRC32) || defined(DYNAMIC_CRC_TABLE))
@@ -637,7 +646,7 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
637646
#endif /* DYNAMIC_CRC_TABLE */
638647

639648
/* Pre-condition the CRC */
640-
crc ^= 0xffffffff;
649+
crc = (~crc) & 0xffffffff;
641650

642651
/* Compute the CRC up to a word boundary. */
643652
while (len && ((z_size_t)buf & 7) != 0) {
@@ -652,8 +661,8 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
652661
len &= 7;
653662

654663
/* Do three interleaved CRCs to realize the throughput of one crc32x
655-
instruction per cycle. Each CRC is calcuated on Z_BATCH words. The three
656-
CRCs are combined into a single CRC after each set of batches. */
664+
instruction per cycle. Each CRC is calculated on Z_BATCH words. The
665+
three CRCs are combined into a single CRC after each set of batches. */
657666
while (num >= 3 * Z_BATCH) {
658667
crc1 = 0;
659668
crc2 = 0;
@@ -756,7 +765,7 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
756765
#endif /* DYNAMIC_CRC_TABLE */
757766

758767
/* Pre-condition the CRC */
759-
crc ^= 0xffffffff;
768+
crc = (~crc) & 0xffffffff;
760769

761770
#ifdef W
762771

@@ -1084,7 +1093,7 @@ uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
10841093
#ifdef DYNAMIC_CRC_TABLE
10851094
once(&made, make_crc_table);
10861095
#endif /* DYNAMIC_CRC_TABLE */
1087-
return multmodp(x2nmodp(len2, 3), crc1) ^ crc2;
1096+
return multmodp(x2nmodp(len2, 3), crc1) ^ (crc2 & 0xffffffff);
10881097
}
10891098

10901099
/* ========================================================================= */
@@ -1093,7 +1102,7 @@ uLong ZEXPORT crc32_combine(crc1, crc2, len2)
10931102
uLong crc2;
10941103
z_off_t len2;
10951104
{
1096-
return crc32_combine64(crc1, crc2, len2);
1105+
return crc32_combine64(crc1, crc2, (z_off64_t)len2);
10971106
}
10981107

10991108
/* ========================================================================= */
@@ -1110,14 +1119,14 @@ uLong ZEXPORT crc32_combine_gen64(z_off64_t len2)
11101119
uLong ZEXPORT crc32_combine_gen(len2)
11111120
z_off_t len2;
11121121
{
1113-
return crc32_combine_gen64(len2);
1122+
return crc32_combine_gen64((z_off64_t)len2);
11141123
}
11151124

11161125
/* ========================================================================= */
1117-
uLong crc32_combine_op(crc1, crc2, op)
1126+
uLong ZEXPORT crc32_combine_op(crc1, crc2, op)
11181127
uLong crc1;
11191128
uLong crc2;
11201129
uLong op;
11211130
{
1122-
return multmodp(op, crc1) ^ crc2;
1131+
return multmodp(op, crc1) ^ (crc2 & 0xffffffff);
11231132
}

0 commit comments

Comments
 (0)