]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Remove support for compiling with Z_SOLO.
authorHans Kristian Rosbach <hk-git@circlestorm.org>
Mon, 11 May 2015 13:55:42 +0000 (15:55 +0200)
committerHans Kristian Rosbach <hk-git@circlestorm.org>
Tue, 12 May 2015 09:26:30 +0000 (11:26 +0200)
Make compiling without gzip file operation support the default
 (define WITH_GZFILEOP or use --zlib-compat to enable them).
Add initial support for compiling in a zlib-compatible mode, this currently only
 enables gzip file operations and sets the ZLIB_COMPAT flag.

Conflicts:
test/minigzip.c

Makefile.in
configure
deflate.c
infback.c
inflate.c
test/example.c
test/minigzip.c
zconf.h.in
zlib.h
zutil.c
zutil.h

index 75e65c3113f2d2a4f043d3de37f4aefc34c128a7..80aad73cb6b715d923d1970796e001e0cb7dd472 100644 (file)
@@ -64,12 +64,12 @@ mandir = ${prefix}/share/man
 man3dir = ${mandir}/man3
 pkgconfigdir = ${libdir}/pkgconfig
 
-OBJZ = adler32.o crc32.o deflate.o match.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o $(ARCH_STATIC_OBJS)
-OBJG = compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o
+OBJZ = adler32.o compress.o crc32.o deflate.o match.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o $(ARCH_STATIC_OBJS)
+OBJG = gzclose.o gzlib.o gzread.o gzwrite.o
 OBJC = $(OBJZ) $(OBJG)
 
-PIC_OBJZ = adler32.lo crc32.lo deflate.lo match.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo $(ARCH_SHARED_OBJS)
-PIC_OBJG = compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo
+PIC_OBJZ = adler32.lo compress.lo crc32.lo deflate.lo match.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo uncompr.lo zutil.lo $(ARCH_SHARED_OBJS)
+PIC_OBJG = gzclose.lo gzlib.lo gzread.lo gzwrite.lo
 PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG)
 
 OBJS = $(OBJC)
index d9e515bdcf27c4d635fdd4ec6981a5228080f45e..071f51de6f0a77ddfe880cf7612ea1058e5d1668 100755 (executable)
--- a/configure
+++ b/configure
@@ -94,7 +94,8 @@ includedir=${includedir-'${prefix}/include'}
 mandir=${mandir-'${prefix}/share/man'}
 shared_ext='.so'
 shared=1
-solo=0
+gzfileops=0
+compat=0
 cover=0
 zconst=0
 build64=0
@@ -103,8 +104,8 @@ without_new_strategies=0
 gcc=0
 old_cc="$CC"
 old_cflags="$CFLAGS"
-OBJC='$(OBJZ) $(OBJG)'
-PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)'
+OBJC='$(OBJZ)'
+PIC_OBJC='$(PIC_OBJZ)'
 
 # leave this script, optionally in a bad way
 leave()
@@ -125,7 +126,7 @@ do
 case "$1" in
     -h* | --help)
       echo 'usage:' | tee -a configure.log
-      echo '  configure [--const] [--prefix=PREFIX]  [--eprefix=EXPREFIX]' | tee -a configure.log
+      echo '  configure [--const] [--zlib-compat] [--prefix=PREFIX]  [--eprefix=EXPREFIX]' | tee -a configure.log
       echo '    [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log
       echo '    [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]' | tee -a configure.log
         exit 0 ;;
@@ -141,7 +142,7 @@ case "$1" in
     -i* | --includedir) includedir="$2"; shift; shift ;;
     -s* | --shared | --enable-shared) shared=1; shift ;;
     -t | --static) shared=0; shift ;;
-    --solo) solo=1; shift ;;
+    --zlib-compat) compat=1; shift ;;
     --cover) cover=1; shift ;;
     -6* | --64) build64=1; shift ;;
     -a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;;
@@ -476,15 +477,12 @@ else
   echo "Checking for stdarg.h... No." | tee -a configure.log
 fi
 
-# if --solo compilation was requested, save that in zconf.h and remove gz stuff from object lists
-if test $solo -eq 1; then
-  sed '/#define ZCONF_H/a\
-#define Z_SOLO
-
-' < zconf.h > zconf.temp.h
-  mv zconf.temp.h zconf.h
-OBJC='$(OBJZ)'
-PIC_OBJC='$(PIC_OBJZ)'
+# if --zlib-compat was requested
+if test $compat -eq 1; then
+  CFLAGS="${CFLAGS} -DZLIB_COMPAT -DWITH_GZFILEOP"
+  SFLAGS="${SFLAGS} -DZLIB_COMPAT -DWITH_GZFILEOP"
+  OBJC="${OBJC} \$(OBJG)"
+  PIC_OBJC="${PIC_OBJC} \$(PIC_OBJG)"
 fi
 
 # if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X
index 16d5c83e40a338faa16b219bec86d2a9cc24422d..d871cc81e3fbb71205ee82cef5323478ad24891b 100644 (file)
--- a/deflate.c
+++ b/deflate.c
@@ -278,19 +278,11 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
 
     strm->msg = Z_NULL;
     if (strm->zalloc == (alloc_func)0) {
-#ifdef Z_SOLO
-        return Z_STREAM_ERROR;
-#else
         strm->zalloc = zcalloc;
         strm->opaque = (void *)0;
-#endif
     }
     if (strm->zfree == (free_func)0)
-#ifdef Z_SOLO
-        return Z_STREAM_ERROR;
-#else
         strm->zfree = zcfree;
-#endif
 
     if (level == Z_DEFAULT_COMPRESSION) level = 6;
 
index 922eeeb38af571b95e5cae07f7ec5a2386bc0268..c8eee5e9f119ee4d3f6f22440f404ee7fcff37e8 100644 (file)
--- a/infback.c
+++ b/infback.c
@@ -42,19 +42,11 @@ int stream_size;
         return Z_STREAM_ERROR;
     strm->msg = Z_NULL;                 /* in case we return an error */
     if (strm->zalloc == (alloc_func)0) {
-#ifdef Z_SOLO
-        return Z_STREAM_ERROR;
-#else
         strm->zalloc = zcalloc;
         strm->opaque = (void *)0;
-#endif
     }
     if (strm->zfree == (free_func)0)
-#ifdef Z_SOLO
-        return Z_STREAM_ERROR;
-#else
     strm->zfree = zcfree;
-#endif
     state = (struct inflate_state *)ZALLOC(strm, 1,
                                                sizeof(struct inflate_state));
     if (state == Z_NULL) return Z_MEM_ERROR;
index a03c7cd6be56535df16254cb9383c50bf56d15c8..2cf1d7ee23ddc7944007b405ca6a739ebe2b43c8 100644 (file)
--- a/inflate.c
+++ b/inflate.c
@@ -190,19 +190,11 @@ int stream_size;
     if (strm == Z_NULL) return Z_STREAM_ERROR;
     strm->msg = Z_NULL;                 /* in case we return an error */
     if (strm->zalloc == (alloc_func)0) {
-#ifdef Z_SOLO
-        return Z_STREAM_ERROR;
-#else
         strm->zalloc = zcalloc;
         strm->opaque = (void *)0;
-#endif
     }
     if (strm->zfree == (free_func)0)
-#ifdef Z_SOLO
-        return Z_STREAM_ERROR;
-#else
         strm->zfree = zcfree;
-#endif
     state = (struct inflate_state *)
             ZALLOC(strm, 1, sizeof(struct inflate_state));
     if (state == Z_NULL) return Z_MEM_ERROR;
index 50fc370a9cb0a02560656fafeff832e2240eb1de..15bf810504f2c0998e34ca49dc055b865565570a 100644 (file)
@@ -39,35 +39,11 @@ void test_dict_inflate  (Byte *compr, uLong comprLen, Byte *uncompr, uLong uncom
 int  main               (int argc, char *argv[]);
 
 
-#ifdef Z_SOLO
-
-void *myalloc (void *, unsigned, unsigned);
-void myfree (void *, void *);
-
-void *myalloc(void *q, unsigned n, unsigned m)
-{
-    q = Z_NULL;
-    return calloc(n, m);
-}
-
-void myfree(void *q, void *p)
-{
-    q = Z_NULL;
-    free(p);
-}
-
-static alloc_func zalloc = myalloc;
-static free_func zfree = myfree;
-
-#else /* !Z_SOLO */
-
 static alloc_func zalloc = (alloc_func)0;
 static free_func zfree = (free_func)0;
 
 void test_compress      (Byte *compr, uLong comprLen,
                             Byte *uncompr, uLong uncomprLen);
-void test_gzio          (const char *fname,
-                            Byte *uncompr, uLong uncomprLen);
 
 /* ===========================================================================
  * Test compress() and uncompress()
@@ -93,6 +69,10 @@ void test_compress(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)
     }
 }
 
+#ifdef WITH_GZFILEOP
+void test_gzio          (const char *fname,
+                            Byte *uncompr, uLong uncomprLen);
+
 /* ===========================================================================
  * Test read/write of .gz files
  */
@@ -174,7 +154,7 @@ void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen)
 #endif
 }
 
-#endif /* Z_SOLO */
+#endif /* WITH_GZFILEOP */
 
 /* ===========================================================================
  * Test deflate() with small buffers
@@ -536,11 +516,9 @@ int main(int argc, char *argv[])
         exit(1);
     }
 
-#ifdef Z_SOLO
-    argc = strlen(argv[0]);
-#else
     test_compress(compr, comprLen, uncompr, uncomprLen);
 
+#ifdef WITH_GZFILEOP
     test_gzio((argc > 1 ? argv[1] : TESTFILE),
               uncompr, uncomprLen);
 #endif
index 777102184afd5baa8a163f955ae5ee138107ab4b..8fb028803dabcb3adbd8fff02c5c5fe8eff4b74d 100644 (file)
@@ -52,8 +52,8 @@
 #define BUFLEN      16384
 #define MAX_NAME_LEN 1024
 
-#ifdef Z_SOLO
-/* for Z_SOLO, create simplified gz* functions using deflate and inflate */
+#ifndef WITH_GZFILEOP
+/* without WITH_GZFILEOP, create simplified gz* functions using deflate and inflate */
 
 #if defined(Z_HAVE_UNISTD_H) || defined(Z_LARGE)
 #  include <unistd.h>       /* for unlink() */
@@ -222,7 +222,7 @@ const char *gzerror(gzFile gz, int *err)
     return gz->msg;
 }
 
-#endif
+#endif 
 
 char *prog;
 
index 76d163ae598e91ef80b9826c9650b44906edb6bd..1258b2da4f88fe14358695ad7d9922c8e5a8469e 100644 (file)
@@ -113,7 +113,7 @@ typedef void const *voidpc;
 typedef void       *voidpf;
 typedef void       *voidp;
 
-#if !defined(Z_U4) && !defined(Z_SOLO)
+#if !defined(Z_U4)
 #  include <limits.h>
 #  if (UINT_MAX == 0xffffffffUL)
 #    define Z_U4 unsigned
@@ -138,15 +138,11 @@ typedef void       *voidp;
 #  define Z_HAVE_STDARG_H
 #endif
 
-#ifndef Z_SOLO
-#  include <sys/types.h>      /* for off_t */
-#  include <stdarg.h>         /* for va_list */
-#endif
+#include <sys/types.h>      /* for off_t */
+#include <stdarg.h>         /* for va_list */
 
 #ifdef _WIN32
-#  ifndef Z_SOLO
-#    include <stddef.h>         /* for wchar_t */
-#  endif
+#  include <stddef.h>         /* for wchar_t */
 #endif
 
 /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
@@ -159,12 +155,10 @@ typedef void       *voidp;
 #  undef _LARGEFILE64_SOURCE
 #endif
 
-#ifndef Z_SOLO
-#  if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
-#    include <unistd.h>         /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
-#    ifndef z_off_t
-#      define z_off_t off_t
-#    endif
+#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
+#  include <unistd.h>         /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
+#  ifndef z_off_t
+#    define z_off_t off_t
 #  endif
 #endif
 
@@ -180,7 +174,7 @@ typedef void       *voidp;
 #  define Z_WANT64
 #endif
 
-#if !defined(SEEK_SET) && !defined(Z_SOLO)
+#if !defined(SEEK_SET) && defined(WITH_GZFILEOP)
 #  define SEEK_SET        0       /* Seek from beginning of file.  */
 #  define SEEK_CUR        1       /* Seek from current position.  */
 #  define SEEK_END        2       /* Set file pointer to EOF plus "offset" */
@@ -193,7 +187,7 @@ typedef void       *voidp;
 #if !defined(_WIN32) && defined(Z_LARGE64)
 #  define z_off64_t off64_t
 #else
-#  if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)
+#  if defined(_WIN32) && !defined(__GNUC__)
 #    define z_off64_t __int64
 #  else
 #    define z_off64_t z_off_t
diff --git a/zlib.h b/zlib.h
index cc52572cc3f45327e52ca7f5c5b1b639629fe3ab..201ea4c9d95d6d2f0db54da9a434efabb474f799 100644 (file)
--- a/zlib.h
+++ b/zlib.h
@@ -1144,7 +1144,6 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags (void);
      27-31: 0 (reserved)
  */
 
-#ifndef Z_SOLO
 
                         /* utility functions */
 
@@ -1211,6 +1210,7 @@ ZEXTERN int ZEXPORT uncompress (Byte *dest,   uLong *destLen,
    buffer with the uncompressed data up to that point.
 */
 
+#ifdef WITH_GZFILEOP
                         /* gzip file access functions */
 
 /*
@@ -1554,7 +1554,7 @@ ZEXTERN void ZEXPORT gzclearerr (gzFile file);
    file that is being written concurrently.
 */
 
-#endif /* !Z_SOLO */
+#endif /* WITH_GZFILEOP */
 
                         /* checksum functions */
 
@@ -1649,7 +1649,7 @@ ZEXTERN int ZEXPORT inflateBackInit_ (z_stream *strm, int windowBits, unsigned c
         inflateBackInit_((strm), (windowBits), (window), \
                       ZLIB_VERSION, (int)sizeof(z_stream))
 
-#ifndef Z_SOLO
+#ifdef WITH_GZFILEOP
 
 /* gzgetc() macro and its supporting function and exposed data structure.  Note
  * that the real internal state is much larger than the exposed structure.
@@ -1721,12 +1721,12 @@ ZEXTERN int ZEXPORT gzgetc_ (gzFile file);  /* backward compatibility */
    ZEXTERN uint32_t ZEXPORT crc32_combine (uint32_t, uint32_t, z_off_t);
 #endif
 
-#else /* Z_SOLO */
+#else /* !WITH_GZFILEOP */
 
    ZEXTERN uLong ZEXPORT adler32_combine (uLong, uLong, z_off_t);
    ZEXTERN uLong ZEXPORT crc32_combine (uLong, uLong, z_off_t);
 
-#endif /* !Z_SOLO */
+#endif /* WITH_GZFILEOP */
 
 /* undocumented functions */
 ZEXTERN const char   * ZEXPORT zError           (int);
@@ -1735,10 +1735,10 @@ ZEXTERN const z_crc_t * ZEXPORT get_crc_table   (void);
 ZEXTERN int            ZEXPORT inflateUndermine (z_stream *, int);
 ZEXTERN int            ZEXPORT inflateResetKeep (z_stream *);
 ZEXTERN int            ZEXPORT deflateResetKeep (z_stream *);
-#if defined(_WIN32) && !defined(Z_SOLO)
+#if defined(_WIN32) && defined(WITH_GZFILEOP)
 ZEXTERN gzFile         ZEXPORT gzopen_w (const wchar_t *path, const char *mode);
 #endif
-#ifndef Z_SOLO
+#ifdef WITH_GZFILEOP
 ZEXTERN int            ZEXPORTVA gzvprintf (gzFile file, const char *format, va_list va);
 #endif
 
diff --git a/zutil.c b/zutil.c
index ada99dd3bf7b31bef41f066b71c767f7cda2cdec..5c1c7540a978dabe3e6c8519543596d1b9623fdb 100644 (file)
--- a/zutil.c
+++ b/zutil.c
@@ -6,7 +6,7 @@
 /* @(#) $Id$ */
 
 #include "zutil.h"
-#ifndef Z_SOLO
+#ifdef WITH_GZFILEOP
 #  include "gzguts.h"
 #endif
 
@@ -107,8 +107,6 @@ const char * ZEXPORT zError(err)
     return ERR_MSG(err);
 }
 
-#ifndef Z_SOLO
-
 #ifndef MY_ZCALLOC /* Any system without a special alloc function */
 
 void ZLIB_INTERNAL *zcalloc (void *opaque, unsigned items, unsigned size)
@@ -125,5 +123,3 @@ void ZLIB_INTERNAL zcfree (void *opaque, void *ptr)
 }
 
 #endif /* MY_ZCALLOC */
-
-#endif /* !Z_SOLO */
diff --git a/zutil.h b/zutil.h
index 31b411dbcb54f538cfa57bde7e2e227892c3b096..9d37f6f6557d6ac66c47669c41ac363cf1540e26 100644 (file)
--- a/zutil.h
+++ b/zutil.h
 #endif
 
 #include "zlib.h"
-
-#ifndef Z_SOLO
-#  include <stddef.h>
-#  include <string.h>
-#  include <stdlib.h>
-#endif
-
-#ifdef Z_SOLO
-   typedef long ptrdiff_t;  /* guess -- will be caught if guess is wrong */
-#endif
+#include <stddef.h>
+#include <string.h>
+#include <stdlib.h>
 
 #ifndef local
 #  define local static
@@ -130,10 +123,8 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
 #  define Tracecv(c,x)
 #endif
 
-#ifndef Z_SOLO
-   void ZLIB_INTERNAL *zcalloc (void *opaque, unsigned items, unsigned size);
-   void ZLIB_INTERNAL  zcfree  (void *opaque, void *ptr);
-#endif
+void ZLIB_INTERNAL *zcalloc (void *opaque, unsigned items, unsigned size);
+void ZLIB_INTERNAL  zcfree  (void *opaque, void *ptr);
 
 #define ZALLOC(strm, items, size) \
            (*((strm)->zalloc))((strm)->opaque, (items), (size))