]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
zlibWrapper: support for zlib versions from 1.2.3 to 1.2.8
authorinikep <inikep@gmail.com>
Thu, 2 Jun 2016 08:19:35 +0000 (10:19 +0200)
committerinikep <inikep@gmail.com>
Thu, 2 Jun 2016 08:19:35 +0000 (10:19 +0200)
.travis.yml
zlibWrapper/Makefile
zlibWrapper/zstd_zlibwrapper.c
zlibWrapper/zstd_zlibwrapper.h

index e6a32c255b690a43c46e9511d4ffd56a55d03b81..41f67c77aaaec3fe78dfd7800dddbc04d23c8058 100644 (file)
@@ -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
index 3f293cd90d6eaae064a606d7145346925d9bf388..6c00622b02507f2d9c24007876daba677826cafb 100644 (file)
@@ -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
index 7ec68a4c56c6b1e1fa9b22184629956255073687..c9a8b1d13663fa67f8af6b4e6a20fb56241c8709 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <stdio.h>           /* fprintf */
 #include <stdlib.h>          /* malloc */
+#include <stdarg.h>          /* va_list */
 #include <zlib.h>
 #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)
index c2c908ddb58908b616174bf701936187adb8b0ec..e438789acc9a6d59339c016f6d4047b4a6f9389b 100644 (file)
@@ -41,7 +41,11 @@ extern "C" {
 #include <zlib.h>
 
 #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);