From: Nathan Moinvaziri Date: Thu, 28 May 2020 01:16:50 +0000 (-0700) Subject: For gzseek, gzoffset, gzopen, adler32_combine, crc32_combine and crc32_combine_gen... X-Git-Tag: 1.9.9-b1~234 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6dcc7bf815c803fe7712e449b3c8fee8f3ab6dda;p=thirdparty%2Fzlib-ng.git 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. --- diff --git a/adler32.c b/adler32.c index a25a2e8c..2cd51bb0 100644 --- a/adler32.c +++ b/adler32.c @@ -121,10 +121,12 @@ static uint32_t adler32_combine_(uint32_t adler1, uint32_t adler2, z_off64_t len } /* ========================================================================= */ +#ifdef ZLIB_COMPAT uint32_t ZEXPORT PREFIX(adler32_combine)(uint32_t adler1, uint32_t adler2, z_off_t len2) { return adler32_combine_(adler1, adler2, len2); } +#endif -uint32_t ZEXPORT PREFIX(adler32_combine64)(uint32_t adler1, uint32_t adler2, z_off64_t len2) { +uint32_t ZEXPORT PREFIX4(adler32_combine)(uint32_t adler1, uint32_t adler2, z_off64_t len2) { return adler32_combine_(adler1, adler2, len2); } diff --git a/crc32.c b/crc32.c index 7939d491..341fd6fb 100644 --- a/crc32.c +++ b/crc32.c @@ -181,11 +181,13 @@ static uint32_t crc32_combine_(uint32_t crc1, uint32_t crc2, z_off64_t len2) { } /* ========================================================================= */ +#ifdef ZLIB_COMPAT uint32_t ZEXPORT PREFIX(crc32_combine)(uint32_t crc1, uint32_t crc2, z_off_t len2) { return crc32_combine_(crc1, crc2, len2); } +#endif -uint32_t ZEXPORT PREFIX(crc32_combine64)(uint32_t crc1, uint32_t crc2, z_off64_t len2) { +uint32_t ZEXPORT PREFIX4(crc32_combine)(uint32_t crc1, uint32_t crc2, z_off64_t len2) { return crc32_combine_(crc1, crc2, len2); } @@ -266,11 +268,13 @@ static void crc32_combine_gen_(uint32_t *op, z_off64_t len2) { /* ========================================================================= */ +#ifdef ZLIB_COMPAT void ZEXPORT PREFIX(crc32_combine_gen)(uint32_t *op, z_off_t len2) { crc32_combine_gen_(op, len2); } +#endif -void ZEXPORT PREFIX(crc32_combine_gen64)(uint32_t *op, z_off64_t len2) { +void ZEXPORT PREFIX4(crc32_combine_gen)(uint32_t *op, z_off64_t len2) { crc32_combine_gen_(op, len2); } diff --git a/gzguts.h b/gzguts.h index 263bc9a0..0bdc12bf 100644 --- a/gzguts.h +++ b/gzguts.h @@ -78,14 +78,6 @@ # define zstrerror() "stdio error (consult errno)" #endif -/* provide prototypes for these when building zlib without LFS */ -#if (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) && defined(WITH_GZFILEOP) - ZEXTERN gzFile ZEXPORT PREFIX(gzopen64)(const char *, const char *); - ZEXTERN z_off64_t ZEXPORT PREFIX(gzseek64)(gzFile, z_off64_t, int); - ZEXTERN z_off64_t ZEXPORT PREFIX(gztell64)(gzFile); - ZEXTERN z_off64_t ZEXPORT PREFIX(gzoffset64)(gzFile); -#endif - /* default memLevel */ #if MAX_MEM_LEVEL >= 8 # define DEF_MEM_LEVEL 8 diff --git a/gzlib.c b/gzlib.c index 9da7a113..f449d2e0 100644 --- a/gzlib.c +++ b/gzlib.c @@ -215,10 +215,11 @@ gzFile ZEXPORT PREFIX(gzopen)(const char *path, const char *mode) { return gz_open(path, -1, mode); } -/* -- see zlib.h -- */ -gzFile ZEXPORT PREFIX(gzopen64)(const char *path, const char *mode) { +#ifdef ZLIB_COMPAT +gzFile ZEXPORT PREFIX4(gzopen)(const char *path, const char *mode) { return gz_open(path, -1, mode); } +#endif /* -- see zlib.h -- */ gzFile ZEXPORT PREFIX(gzdopen)(int fd, const char *mode) { @@ -285,7 +286,7 @@ int ZEXPORT PREFIX(gzrewind)(gzFile file) { } /* -- see zlib.h -- */ -z_off64_t ZEXPORT PREFIX(gzseek64)(gzFile file, z_off64_t offset, int whence) { +z_off64_t ZEXPORT PREFIX4(gzseek)(gzFile file, z_off64_t offset, int whence) { unsigned n; z_off64_t ret; gz_state *state; @@ -356,15 +357,17 @@ z_off64_t ZEXPORT PREFIX(gzseek64)(gzFile file, z_off64_t offset, int whence) { } /* -- see zlib.h -- */ +#ifdef ZLIB_COMPAT z_off_t ZEXPORT PREFIX(gzseek)(gzFile file, z_off_t offset, int whence) { z_off64_t ret; - ret = PREFIX(gzseek64)(file, (z_off64_t)offset, whence); + ret = PREFIX4(gzseek)(file, (z_off64_t)offset, whence); return ret == (z_off_t)ret ? (z_off_t)ret : -1; } +#endif /* -- see zlib.h -- */ -z_off64_t ZEXPORT PREFIX(gztell64)(gzFile file) { +z_off64_t ZEXPORT PREFIX4(gztell)(gzFile file) { gz_state *state; /* get internal structure and check integrity */ @@ -379,15 +382,18 @@ z_off64_t ZEXPORT PREFIX(gztell64)(gzFile file) { } /* -- see zlib.h -- */ +#ifdef ZLIB_COMPAT z_off_t ZEXPORT PREFIX(gztell)(gzFile file) { + z_off64_t ret; - ret = PREFIX(gztell64)(file); + ret = PREFIX4(gztell)(file); return ret == (z_off_t)ret ? (z_off_t)ret : -1; } +#endif /* -- see zlib.h -- */ -z_off64_t ZEXPORT PREFIX(gzoffset64)(gzFile file) { +z_off64_t ZEXPORT PREFIX4(gzoffset)(gzFile file) { z_off64_t offset; gz_state *state; @@ -408,12 +414,14 @@ z_off64_t ZEXPORT PREFIX(gzoffset64)(gzFile file) { } /* -- see zlib.h -- */ +#ifdef ZLIB_COMPAT z_off_t ZEXPORT PREFIX(gzoffset)(gzFile file) { z_off64_t ret; - ret = PREFIX(gzoffset64)(file); + ret = PREFIX4(gzoffset)(file); return ret == (z_off_t)ret ? (z_off_t)ret : -1; } +#endif /* -- see zlib.h -- */ int ZEXPORT PREFIX(gzeof)(gzFile file) { diff --git a/win32/zlib-ng.def b/win32/zlib-ng.def index 2525a861..467d7900 100644 --- a/win32/zlib-ng.def +++ b/win32/zlib-ng.def @@ -37,9 +37,6 @@ EXPORTS zng_compressBound zng_uncompress zng_uncompress2 -; large file functions - zng_adler32_combine64 - zng_crc32_combine64 ; checksum functions zng_adler32 zng_adler32_z diff --git a/zbuild.h b/zbuild.h index 8774c75c..d45b1fee 100644 --- a/zbuild.h +++ b/zbuild.h @@ -15,12 +15,14 @@ # define PREFIX(x) x # define PREFIX2(x) ZLIB_ ## x # define PREFIX3(x) z_ ## x +# define PREFIX4(x) x ## 64 # define zVersion zlibVersion # define z_size_t unsigned long #else # define PREFIX(x) zng_ ## x # define PREFIX2(x) ZLIBNG_ ## x # define PREFIX3(x) zng_ ## x +# define PREFIX4(x) zng_ ## x # define zVersion zlibng_version # define z_size_t size_t #endif diff --git a/zconf.h.in b/zconf.h.in index 44c1697a..eef5207f 100644 --- a/zconf.h.in +++ b/zconf.h.in @@ -132,18 +132,6 @@ typedef PTRDIFF_TYPE ptrdiff_t; # endif #endif -#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 -# define Z_LFS64 -#endif - -#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) -# define Z_LARGE64 -#endif - -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) -# define Z_WANT64 -#endif - #if !defined(SEEK_SET) # define SEEK_SET 0 /* Seek from beginning of file. */ # define SEEK_CUR 1 /* Seek from current position. */ diff --git a/zlib-ng.h b/zlib-ng.h index 7d792eee..ed597fb3 100644 --- a/zlib-ng.h +++ b/zlib-ng.h @@ -1285,10 +1285,9 @@ int zng_uncompress2(unsigned char *dest, size_t *destLen, const unsigned char *s typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ -/* ZEXTERN ZEXPORT gzFile zng_gzopen(const char *path, const char *mode); - +/* Opens a gzip (.gz) file for reading or writing. The mode parameter is as in fopen ("rb" or "wb") but can also include a compression level ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only @@ -1537,10 +1536,9 @@ int zng_gzflush(gzFile file, int flush); degrade compression if called too often. */ -/* ZEXTERN ZEXPORT -z_off_t zng_gzseek(gzFile file, z_off_t offset, int whence); - +z_off64_t zng_gzseek(gzFile file, z_off64_t offset, int whence); +/* Sets the starting position for the next gzread or gzwrite on the given compressed file. The offset represents a number of bytes in the uncompressed data stream. The whence parameter is defined as in lseek(2); @@ -1565,10 +1563,9 @@ int zng_gzrewind(gzFile file); gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) */ -/* ZEXTERN ZEXPORT -z_off_t zng_gztell(gzFile file); - +z_off64_t zng_gztell(gzFile file); +/* Returns the starting position for the next gzread or gzwrite on the given compressed file. This position represents a number of bytes in the uncompressed data stream, and is zero when starting, even if appending or @@ -1577,10 +1574,9 @@ z_off_t zng_gztell(gzFile file); gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) */ -/* ZEXTERN ZEXPORT -z_off_t zng_gzoffset(gzFile file); - +z_off64_t zng_gzoffset(gzFile file); +/* Returns the current offset in the file being read or written. This offset includes the count of bytes that precede the gzip stream, for example when appending or when using gzdopen() for reading. When reading, the offset @@ -1715,10 +1711,9 @@ uint32_t zng_adler32_z(uint32_t adler, const unsigned char *buf, size_t len); Same as adler32(), but with a size_t length. */ -/* ZEXTERN ZEXPORT -uint32_t zng_adler32_combine(uint32_t adler1, uint32_t adler2, z_off_t len2); - +uint32_t zng_adler32_combine(uint32_t adler1, uint32_t adler2, z_off64_t len2); +/* Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of @@ -1751,10 +1746,10 @@ uint32_t zng_crc32_z(uint32_t crc, const unsigned char *buf, size_t len); Same as crc32(), but with a size_t length. */ -/* ZEXTERN ZEXPORT uint32_t zng_crc32_combine(uint32_t crc1, uint32_t crc2, z_off64_t len2); +/* Combine two CRC-32 check values into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, CRC-32 check values were calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 @@ -1762,10 +1757,10 @@ uint32_t zng_crc32_combine(uint32_t crc1, uint32_t crc2, z_off64_t len2); len2. */ -/* ZEXTERN ZEXPORT -void zng_crc32_combine_gen(uint32_t op[32], z_off_t len2); +void zng_crc32_combine_gen(uint32_t op[32], z_off64_t len2); +/* Generate the operator op corresponding to length len2, to be used with crc32_combine_op(). op must have room for 32 uint32_t values. (32 is the number of bits in the CRC.) @@ -1818,36 +1813,6 @@ struct gzFile_s { ZEXTERN ZEXPORT int zng_gzgetc_(gzFile file); /* backward compatibility */ # define zng_gzgetc(g) ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (zng_gzgetc)(g)) -/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or - * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if - * both are true, the application gets the *64 functions, and the regular - * functions are changed to 64 bits) -- in case these are set on systems - * without large file support, _LFS64_LARGEFILE must also be true - */ -#ifdef Z_LARGE64 - ZEXTERN ZEXPORT gzFile zng_gzopen64(const char *, const char *); - ZEXTERN ZEXPORT z_off64_t zng_gzseek64(gzFile, z_off64_t, int); - ZEXTERN ZEXPORT z_off64_t zng_gztell64(gzFile); - ZEXTERN ZEXPORT z_off64_t zng_gzoffset64(gzFile); -#endif - -#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) -# define zng_gzopen zng_gzopen64 -# define zng_gzseek zng_gzseek64 -# define zng_gztell zng_gztell64 -# define zng_gzoffset zng_gzoffset64 -# ifndef Z_LARGE64 - ZEXTERN ZEXPORT gzFile zng_gzopen64(const char *, const char *); - ZEXTERN ZEXPORT z_off_t zng_gzseek64(gzFile, z_off_t, int); - ZEXTERN ZEXPORT z_off_t zng_gztell64(gzFile); - ZEXTERN ZEXPORT z_off_t zng_gzoffset64(gzFile); -# endif -#else - ZEXTERN ZEXPORT gzFile zng_gzopen(const char *, const char *); - ZEXTERN ZEXPORT z_off_t zng_gzseek(gzFile, z_off_t, int); - ZEXTERN ZEXPORT z_off_t zng_gztell(gzFile); - ZEXTERN ZEXPORT z_off_t zng_gzoffset(gzFile); -#endif #endif /* WITH_GZFILEOP */ @@ -1899,35 +1864,6 @@ int zng_deflateGetParams(zng_stream *strm, zng_deflate_param_value *params, size entire value of the corresponding parameter. */ - -/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or - * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if - * both are true, the application gets the *64 functions, and the regular - * functions are changed to 64 bits) -- in case these are set on systems - * without large file support, _LFS64_LARGEFILE must also be true - */ -#ifdef Z_LARGE64 - ZEXTERN ZEXPORT uint32_t zng_adler32_combine64(uint32_t, uint32_t, z_off64_t); - ZEXTERN ZEXPORT uint32_t zng_crc32_combine64(uint32_t, uint32_t, z_off64_t); - ZEXTERN ZEXPORT void zng_crc32_combine_gen64(uint32_t *op, z_off64_t); -#endif - -#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) -# define zng_adler32_combine zng_adler32_combine64 -# define zng_crc32_combine zng_crc32_combine64 -# define zng_crc32_combine_gen zng_crc32_combine_gen64 -# ifndef Z_LARGE64 - ZEXTERN ZEXPORT uint32_t zng_adler32_combine64(uint32_t, uint32_t, z_off_t); - ZEXTERN ZEXPORT uint32_t zng_crc32_combine64(uint32_t, uint32_t, z_off_t); - ZEXTERN ZEXPORT void zng_crc32_combine_gen64(uint32_t *op, z_off64_t); -# endif -#else - ZEXTERN ZEXPORT uint32_t zng_adler32_combine(uint32_t, uint32_t, z_off_t); - ZEXTERN ZEXPORT uint32_t zng_crc32_combine(uint32_t, uint32_t, z_off_t); - ZEXTERN ZEXPORT void zng_crc32_combine_gen(uint32_t *op, z_off_t); -#endif - - /* undocumented functions */ ZEXTERN ZEXPORT const char * zng_zError (int); ZEXTERN ZEXPORT int zng_inflateSyncPoint (zng_stream *); diff --git a/zlib-ng.map b/zlib-ng.map index 29744f5b..cda2122d 100644 --- a/zlib-ng.map +++ b/zlib-ng.map @@ -3,14 +3,12 @@ ZLIB_NG_1.9.9 { zng_adler32; zng_adler32_c; zng_adler32_combine; - zng_adler32_combine64; zng_adler32_z; zng_compress; zng_compress2; zng_compressBound; zng_crc32; zng_crc32_combine; - zng_crc32_combine64; zng_crc32_combine_gen; zng_crc32_combine_op; zng_crc32_z; diff --git a/zlib.h b/zlib.h index 33bfd9cb..655e2e33 100644 --- a/zlib.h +++ b/zlib.h @@ -1777,6 +1777,9 @@ ZEXTERN int ZEXPORT gzgetc_(gzFile file); /* backward compatibility */ ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int); ZEXTERN z_off64_t ZEXPORT gztell64(gzFile); ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile); + ZEXTERN uint32_t ZEXPORT adler32_combine64(uint32_t, uint32_t, z_off64_t); + ZEXTERN uint32_t ZEXPORT crc32_combine64(uint32_t, uint32_t, z_off64_t); + ZEXTERN void ZEXPORT crc32_combine_gen64(uint32_t *op, z_off64_t); #endif #if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) @@ -1784,48 +1787,28 @@ ZEXTERN int ZEXPORT gzgetc_(gzFile file); /* backward compatibility */ # define gzseek gzseek64 # define gztell gztell64 # define gzoffset gzoffset64 +# define adler32_combine adler32_combine64 +# define crc32_combine crc32_combine64 +# define crc32_combine_gen crc32_combine_gen64 # ifndef Z_LARGE64 ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); ZEXTERN z_off_t ZEXPORT gzseek64(gzFile, z_off_t, int); ZEXTERN z_off_t ZEXPORT gztell64(gzFile); ZEXTERN z_off_t ZEXPORT gzoffset64(gzFile); + ZEXTERN uint32_t ZEXPORT adler32_combine64(uint32_t, uint32_t, z_off_t); + ZEXTERN uint32_t ZEXPORT crc32_combine64(uint32_t, uint32_t, z_off_t); + ZEXTERN void ZEXPORT crc32_combine_gen64(uint32_t *op, z_off64_t); # endif #else ZEXTERN gzFile ZEXPORT gzopen(const char *, const char *); ZEXTERN z_off_t ZEXPORT gzseek(gzFile, z_off_t, int); ZEXTERN z_off_t ZEXPORT gztell(gzFile); ZEXTERN z_off_t ZEXPORT gzoffset(gzFile); -#endif - - -/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or - * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if - * both are true, the application gets the *64 functions, and the regular - * functions are changed to 64 bits) -- in case these are set on systems - * without large file support, _LFS64_LARGEFILE must also be true - */ -#ifdef Z_LARGE64 - ZEXTERN uint32_t ZEXPORT adler32_combine64(uint32_t, uint32_t, z_off64_t); - ZEXTERN uint32_t ZEXPORT crc32_combine64(uint32_t, uint32_t, z_off64_t); - ZEXTERN void ZEXPORT crc32_combine_gen64(uint32_t *op, z_off64_t); -#endif - -#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) -# define adler32_combine adler32_combine64 -# define crc32_combine crc32_combine64 -# define crc32_combine_gen crc32_combine_gen64 -# ifndef Z_LARGE64 - ZEXTERN uint32_t ZEXPORT adler32_combine64(uint32_t, uint32_t, z_off_t); - ZEXTERN uint32_t ZEXPORT crc32_combine64(uint32_t, uint32_t, z_off_t); - ZEXTERN void ZEXPORT crc32_combine_gen64(uint32_t *op, z_off64_t); -# endif -#else ZEXTERN uint32_t ZEXPORT adler32_combine(uint32_t, uint32_t, z_off_t); ZEXTERN uint32_t ZEXPORT crc32_combine(uint32_t, uint32_t, z_off_t); ZEXTERN void ZEXPORT crc32_combine_gen(uint32_t *op, z_off_t); #endif - /* undocumented functions */ ZEXTERN const char * ZEXPORT zError (int); ZEXTERN int ZEXPORT inflateSyncPoint (z_stream *); diff --git a/zutil.h b/zutil.h index f4d26e3d..62b8e175 100644 --- a/zutil.h +++ b/zutil.h @@ -114,13 +114,6 @@ extern const char * const zng_errmsg[10]; /* indexed by 2-zlib_error */ # define fdopen(fd, type) _fdopen(fd, type) #endif -/* provide prototypes for these when building zlib without LFS */ -#if !defined(_WIN32) && !defined(__MSYS__) && (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) -# include "zbuild.h" /* For PREFIX() */ - ZEXTERN uint32_t ZEXPORT PREFIX(adler32_combine64)(uint32_t, uint32_t, z_off_t); - ZEXTERN uint32_t ZEXPORT PREFIX(crc32_combine64)(uint32_t, uint32_t, z_off_t); -#endif - /* MS Visual Studio does not allow inline in C, only C++. But it provides __inline instead, so use that. */ #if defined(_MSC_VER) && !defined(inline) && !defined(__cplusplus)