From: Hans Kristian Rosbach Date: Mon, 11 May 2015 13:55:42 +0000 (+0200) Subject: Remove support for compiling with Z_SOLO. X-Git-Tag: 1.9.9-b1~842 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b3dca09caf3350d711066c85ef0101628ed0947c;p=thirdparty%2Fzlib-ng.git Remove support for compiling with Z_SOLO. 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 --- diff --git a/Makefile.in b/Makefile.in index 75e65c311..80aad73cb 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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) diff --git a/configure b/configure index d9e515bdc..071f51de6 100755 --- 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 diff --git a/deflate.c b/deflate.c index 16d5c83e4..d871cc81e 100644 --- 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; diff --git a/infback.c b/infback.c index 922eeeb38..c8eee5e9f 100644 --- 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; diff --git a/inflate.c b/inflate.c index a03c7cd6b..2cf1d7ee2 100644 --- 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; diff --git a/test/example.c b/test/example.c index 50fc370a9..15bf81050 100644 --- a/test/example.c +++ b/test/example.c @@ -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 diff --git a/test/minigzip.c b/test/minigzip.c index 777102184..8fb028803 100644 --- a/test/minigzip.c +++ b/test/minigzip.c @@ -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 /* for unlink() */ @@ -222,7 +222,7 @@ const char *gzerror(gzFile gz, int *err) return gz->msg; } -#endif +#endif char *prog; diff --git a/zconf.h.in b/zconf.h.in index 76d163ae5..1258b2da4 100644 --- a/zconf.h.in +++ b/zconf.h.in @@ -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 # 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 /* for off_t */ -# include /* for va_list */ -#endif +#include /* for off_t */ +#include /* for va_list */ #ifdef _WIN32 -# ifndef Z_SOLO -# include /* for wchar_t */ -# endif +# include /* 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 /* 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 /* 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 cc52572cc..201ea4c9d 100644 --- 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 ada99dd3b..5c1c7540a 100644 --- 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 31b411dbc..9d37f6f65 100644 --- a/zutil.h +++ b/zutil.h @@ -20,16 +20,9 @@ #endif #include "zlib.h" - -#ifndef Z_SOLO -# include -# include -# include -#endif - -#ifdef Z_SOLO - typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */ -#endif +#include +#include +#include #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))