From: inikep Date: Thu, 2 Jun 2016 08:19:35 +0000 (+0200) Subject: zlibWrapper: support for zlib versions from 1.2.3 to 1.2.8 X-Git-Tag: v0.7.0^2~49^2~21^2^2~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf25d7ac574bac5da3e1fbdc4dc6273392d4daf2;p=thirdparty%2Fzstd.git zlibWrapper: support for zlib versions from 1.2.3 to 1.2.8 --- diff --git a/.travis.yml b/.travis.yml index e6a32c255..41f67c77a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,9 @@ matrix: - os: linux sudo: false env: PLATFORM="Ubuntu 12.04 container" MAKE_PARAM=asan + - os: linux + sudo: false + env: PLATFORM="Ubuntu 12.04 container" MAKE_PARAM=zlibwrapper # Standard Ubuntu 12.04 LTS Server Edition 64 bit - os: linux sudo: required @@ -53,15 +56,6 @@ matrix: - os: linux sudo: required env: PLATFORM="Ubuntu 12.04" MAKE_PARAM="-C programs valgrindTest" - - os: linux - sudo: required - env: PLATFORM="Ubuntu 12.04" MAKE_PARAM=gnu90test - - os: linux - sudo: required - env: PLATFORM="Ubuntu 12.04" MAKE_PARAM=c99test - #- os: linux - # sudo: required - # env: PLATFORM="Ubuntu 12.04" MAKE_PARAM=zlibwrapper # Ubuntu 14.04 LTS Server Edition 64 bit - os: linux dist: trusty diff --git a/zlibWrapper/Makefile b/zlibWrapper/Makefile index 3f293cd90..6c00622b0 100644 --- a/zlibWrapper/Makefile +++ b/zlibWrapper/Makefile @@ -7,8 +7,9 @@ # Paths to static and dynamic zlib and zstd libraries ifneq (,$(filter Windows%,$(OS))) -STATICLIB = ../../zlib/libz.a ../lib/libzstd.a -IMPLIB = ../../zlib/libz.dll.a ../lib/libzstd.a +ZLIBDIR = ../../zlib1.2.8 +STATICLIB = $(ZLIBDIR)/libz.a ../lib/libzstd.a +IMPLIB = $(ZLIBDIR)/libz.dll.a ../lib/libzstd.a else STATICLIB = -static -lz ../lib/libzstd.a IMPLIB = -lz ../lib/libzstd.a @@ -17,12 +18,12 @@ endif ZLIBWRAPPER_PATH = . EXAMPLE_PATH = examples CC = gcc -CFLAGS = $(LOC) -I../lib/common -I$(ZLIBWRAPPER_PATH) -O3 -Wall -std=gnu89 +CFLAGS = $(LOC) -I../lib/common -I$(ZLIBDIR) -I$(ZLIBWRAPPER_PATH) -O3 -Wall -std=gnu89 LDFLAGS = $(LOC) RM = rm -f -all: clean test testdll testzstd +all: clean test testzstd test: example ./example diff --git a/zlibWrapper/zstd_zlibwrapper.c b/zlibWrapper/zstd_zlibwrapper.c index 7ec68a4c5..c9a8b1d13 100644 --- a/zlibWrapper/zstd_zlibwrapper.c +++ b/zlibWrapper/zstd_zlibwrapper.c @@ -31,6 +31,7 @@ #include /* fprintf */ #include /* malloc */ +#include /* va_list */ #include #include "zstd_zlibwrapper.h" #include "zstd.h" @@ -492,6 +493,7 @@ ZEXTERN int ZEXPORT z_deflateTune OF((z_streamp strm, } +#if ZLIB_VERNUM >= 0x1260 ZEXTERN int ZEXPORT z_deflatePending OF((z_streamp strm, unsigned *pending, int *bits)) @@ -500,6 +502,7 @@ ZEXTERN int ZEXPORT z_deflatePending OF((z_streamp strm, return deflatePending(strm, pending, bits); FINISH_WITH_ERR("deflatePending is not supported!"); } +#endif ZEXTERN int ZEXPORT z_deflatePrime OF((z_streamp strm, @@ -524,6 +527,7 @@ ZEXTERN int ZEXPORT z_deflateSetHeader OF((z_streamp strm, /* Advanced compression functions */ +#if ZLIB_VERNUM >= 0x1280 ZEXTERN int ZEXPORT z_inflateGetDictionary OF((z_streamp strm, Bytef *dictionary, uInt *dictLength)) @@ -532,7 +536,7 @@ ZEXTERN int ZEXPORT z_inflateGetDictionary OF((z_streamp strm, return inflateGetDictionary(strm, dictionary, dictLength); FINISH_WITH_ERR("inflateGetDictionary is not supported!"); } - +#endif ZEXTERN int ZEXPORT z_inflateCopy OF((z_streamp dest, @@ -552,6 +556,7 @@ ZEXTERN int ZEXPORT z_inflateReset OF((z_streamp strm)) } +#if ZLIB_VERNUM >= 0x1240 ZEXTERN int ZEXPORT z_inflateReset2 OF((z_streamp strm, int windowBits)) { @@ -559,23 +564,26 @@ ZEXTERN int ZEXPORT z_inflateReset2 OF((z_streamp strm, return inflateReset2(strm, windowBits); FINISH_WITH_ERR("inflateReset2 is not supported!"); } +#endif -ZEXTERN int ZEXPORT z_inflatePrime OF((z_streamp strm, - int bits, - int value)) +#if ZLIB_VERNUM >= 0x1240 +ZEXTERN long ZEXPORT z_inflateMark OF((z_streamp strm)) { if (!strm->reserved) - return inflatePrime(strm, bits, value); - FINISH_WITH_ERR("inflatePrime is not supported!"); + return inflateMark(strm); + FINISH_WITH_ERR("inflateMark is not supported!"); } +#endif -ZEXTERN long ZEXPORT z_inflateMark OF((z_streamp strm)) +ZEXTERN int ZEXPORT z_inflatePrime OF((z_streamp strm, + int bits, + int value)) { if (!strm->reserved) - return inflateMark(strm); - FINISH_WITH_ERR("inflateMark is not supported!"); + return inflatePrime(strm, bits, value); + FINISH_WITH_ERR("inflatePrime is not supported!"); } @@ -699,6 +707,7 @@ ZEXTERN gzFile ZEXPORT z_gzdopen OF((int fd, const char *mode)) } +#if ZLIB_VERNUM >= 0x1240 ZEXTERN int ZEXPORT z_gzbuffer OF((gzFile file, unsigned size)) { if (!g_useZSTD) @@ -707,6 +716,31 @@ ZEXTERN int ZEXPORT z_gzbuffer OF((gzFile file, unsigned size)) } +ZEXTERN z_off_t ZEXPORT z_gzoffset OF((gzFile file)) +{ + if (!g_useZSTD) + return gzoffset(file); + FINISH_WITH_ERR("gzoffset is not supported!"); +} + + +ZEXTERN int ZEXPORT z_gzclose_r OF((gzFile file)) +{ + if (!g_useZSTD) + return gzclose_r(file); + FINISH_WITH_ERR("gzclose_r is not supported!"); +} + + +ZEXTERN int ZEXPORT z_gzclose_w OF((gzFile file)) +{ + if (!g_useZSTD) + return gzclose_w(file); + FINISH_WITH_ERR("gzclose_w is not supported!"); +} +#endif + + ZEXTERN int ZEXPORT z_gzsetparams OF((gzFile file, int level, int strategy)) { if (!g_useZSTD) @@ -732,7 +766,11 @@ ZEXTERN int ZEXPORT z_gzwrite OF((gzFile file, } +#if ZLIB_VERNUM >= 0x1260 ZEXTERN int ZEXPORTVA z_gzprintf Z_ARG((gzFile file, const char *format, ...)) +#else +ZEXTERN int ZEXPORTVA z_gzprintf OF((gzFile file, const char *format, ...)) +#endif { if (!g_useZSTD) { int ret; @@ -774,7 +812,11 @@ ZEXTERN int ZEXPORT z_gzputc OF((gzFile file, int c)) } +#if ZLIB_VERNUM == 0x1260 +ZEXTERN int ZEXPORT z_gzgetc_ OF((gzFile file)) +#else ZEXTERN int ZEXPORT z_gzgetc OF((gzFile file)) +#endif { if (!g_useZSTD) return gzgetc(file); @@ -822,14 +864,6 @@ ZEXTERN z_off_t ZEXPORT z_gztell OF((gzFile file)) } -ZEXTERN z_off_t ZEXPORT z_gzoffset OF((gzFile file)) -{ - if (!g_useZSTD) - return gzoffset(file); - FINISH_WITH_ERR("gzoffset is not supported!"); -} - - ZEXTERN int ZEXPORT z_gzeof OF((gzFile file)) { if (!g_useZSTD) @@ -854,22 +888,6 @@ ZEXTERN int ZEXPORT z_gzclose OF((gzFile file)) } -ZEXTERN int ZEXPORT z_gzclose_r OF((gzFile file)) -{ - if (!g_useZSTD) - return gzclose_r(file); - FINISH_WITH_ERR("gzclose_r is not supported!"); -} - - -ZEXTERN int ZEXPORT z_gzclose_w OF((gzFile file)) -{ - if (!g_useZSTD) - return gzclose_w(file); - FINISH_WITH_ERR("gzclose_w is not supported!"); -} - - ZEXTERN const char * ZEXPORT z_gzerror OF((gzFile file, int *errnum)) { if (!g_useZSTD) diff --git a/zlibWrapper/zstd_zlibwrapper.h b/zlibWrapper/zstd_zlibwrapper.h index c2c908ddb..e438789ac 100644 --- a/zlibWrapper/zstd_zlibwrapper.h +++ b/zlibWrapper/zstd_zlibwrapper.h @@ -41,7 +41,11 @@ extern "C" { #include #if !defined(z_const) -# define z_const const +#if ZLIB_VERNUM >= 0x1260 + #define z_const const +#else + #define z_const +#endif #endif void useZSTD(int turn_on);