From: Nathan Moinvaziri Date: Sun, 24 May 2020 15:42:38 +0000 (-0700) Subject: Make deflate_quick algorithm available to all architectures. #205 X-Git-Tag: 1.9.9-b1~240 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b6b8ad6c0fe22875add044da50efb181d8e33dc4;p=thirdparty%2Fzlib-ng.git Make deflate_quick algorithm available to all architectures. #205 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index ce6d011b..404b0639 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -560,6 +560,12 @@ elseif(BASEARCH_X86_FOUND) endif() endif() +# +# Enable deflate_quick at level 1 +# +if(NOT WITH_NEW_STRATEGIES) + add_definitions(-DNO_QUICK_STRATEGY) +endif() # # Enable deflate_medium at level 4-6 # @@ -688,11 +694,6 @@ if(WITH_OPTIM) if(HAVE_SSE42CRC_INTRIN) add_definitions(-DX86_SSE42_CRC_INTRIN) endif() - if(WITH_NEW_STRATEGIES) - add_definitions(-DX86_QUICK_STRATEGY) - list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/deflate_quick.c) - add_feature_info(SSE42_DEFLATE_QUICK 1 "Support SSE4.2 accelerated quick compression") - endif() endif() if(HAVE_SSE42CMPSTR_INTRIN) add_definitions(-DX86_SSE42_CMP_STR) @@ -811,6 +812,7 @@ set(ZLIB_SRCS compress.c crc32.c deflate.c + deflate_quick.c deflate_fast.c deflate_medium.c deflate_slow.c diff --git a/Makefile.in b/Makefile.in index fb91bf7e..74857d68 100644 --- a/Makefile.in +++ b/Makefile.in @@ -79,6 +79,7 @@ OBJZ = \ deflate.o \ deflate_fast.o \ deflate_medium.o \ + deflate_quick.o \ deflate_slow.o \ functable.o \ infback.o \ @@ -107,6 +108,7 @@ PIC_OBJZ = \ deflate.lo \ deflate_fast.lo \ deflate_medium.lo \ + deflate_quick.lo \ deflate_slow.lo \ functable.lo \ infback.lo \ diff --git a/arch/x86/Makefile.in b/arch/x86/Makefile.in index b7b923fd..4f8a753b 100644 --- a/arch/x86/Makefile.in +++ b/arch/x86/Makefile.in @@ -21,7 +21,6 @@ all: \ x86.o x86.lo \ compare258_avx.o compare258_avx.lo \ compare258_sse.o compare258_sse.lo \ - deflate_quick.o deflate_quick.lo \ insert_string_sse.o insert_string_sse.lo \ crc_folding.o crc_folding.lo \ slide_avx.o slide_avx.lo @@ -45,12 +44,6 @@ compare258_sse.o: compare258_sse.lo: $(CC) $(SFLAGS) $(SSE4FLAG) -DPIC $(INCLUDES) -c -o $@ $(SRCDIR)/compare258_sse.c -deflate_quick.o: - $(CC) $(CFLAGS) $(SSE4FLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/deflate_quick.c - -deflate_quick.lo: - $(CC) $(SFLAGS) $(SSE4FLAG) -DPIC $(INCLUDES) -c -o $@ $(SRCDIR)/deflate_quick.c - insert_string_sse.o: $(CC) $(CFLAGS) $(SSE4FLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/insert_string_sse.c diff --git a/compress.c b/compress.c index 41a4573d..bbbed658 100644 --- a/compress.c +++ b/compress.c @@ -73,7 +73,7 @@ int ZEXPORT PREFIX(compress)(unsigned char *dest, z_size_t *destLen, const unsig this function needs to be updated. */ z_size_t ZEXPORT PREFIX(compressBound)(z_size_t sourceLen) { -#ifdef X86_QUICK_STRATEGY +#ifndef NO_QUICK_STRATEGY /* Quick deflate strategy worse case is 9 bits per literal, rounded to nearest byte, plus the size of block & gzip headers and footers */ return sourceLen + ((sourceLen + 13 + 7) >> 3) + 18; diff --git a/configure b/configure index 4928c346..5e20aa95 100755 --- a/configure +++ b/configure @@ -988,6 +988,11 @@ EOF HAVE_PCLMULQDQ_INTRIN=0 fi + # Enable deflate_medium at level 1 + if test $without_new_strategies -eq 1; then + CFLAGS="${CFLAGS} -DNO_QUICK_STRATEGY" + SFLAGS="${SFLAGS} -DNO_QUICK_STRATEGY" + fi # Enable deflate_medium at level 4-6 if test $without_new_strategies -eq 1; then CFLAGS="${CFLAGS} -DNO_MEDIUM_STRATEGY" @@ -1096,15 +1101,6 @@ case "${ARCH}" in CFLAGS="${CFLAGS} -DX86_NOCHECK_SSE2" SFLAGS="${SFLAGS} -DX86_NOCHECK_SSE2" fi - - # Enable deflate_quick at level 1? - if test $without_new_strategies -eq 0; then - CFLAGS="${CFLAGS} -DX86_QUICK_STRATEGY" - SFLAGS="${SFLAGS} -DX86_QUICK_STRATEGY" - - ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} deflate_quick.o" - ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} deflate_quick.lo" - fi fi if test ${HAVE_SSE42CRC_INTRIN} -eq 1; then @@ -1183,15 +1179,6 @@ case "${ARCH}" in ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} compare258_sse.o" ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} compare258_sse.lo" fi - - # Enable deflate_quick at level 1? - if test $without_new_strategies -eq 0; then - CFLAGS="${CFLAGS} -DX86_QUICK_STRATEGY" - SFLAGS="${SFLAGS} -DX86_QUICK_STRATEGY" - - ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} deflate_quick.o" - ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} deflate_quick.lo" - fi fi ;; diff --git a/deflate.c b/deflate.c index 37afe4dc..ee31d2c4 100644 --- a/deflate.c +++ b/deflate.c @@ -144,7 +144,7 @@ static const config configuration_table[10] = { /* good lazy nice chain */ /* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ -#ifdef X86_QUICK_STRATEGY +#ifndef NO_QUICK_STRATEGY /* 1 */ {4, 4, 8, 4, deflate_quick}, /* 2 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */ #else @@ -302,7 +302,7 @@ int ZEXPORT PREFIX(deflateInit2_)(PREFIX3(stream) *strm, int level, int method, if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */ -#ifdef X86_QUICK_STRATEGY +#ifndef NO_QUICK_STRATEGY if (level == 1) windowBits = 13; #endif @@ -1002,8 +1002,8 @@ int ZEXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int flush) { s->level == 0 ? deflate_stored(s, flush) : s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : s->strategy == Z_RLE ? deflate_rle(s, flush) : -#ifdef X86_QUICK_STRATEGY - (s->level == 1 && !x86_cpu_has_sse42) ? deflate_fast(s, flush) : +#ifndef NO_QUICK_STRATEGY + s->level == 1 ? deflate_fast(s, flush) : #endif (*(configuration_table[s->level].func))(s, flush); diff --git a/arch/x86/deflate_quick.c b/deflate_quick.c similarity index 93% rename from arch/x86/deflate_quick.c rename to deflate_quick.c index c00cb733..cd79af4f 100644 --- a/arch/x86/deflate_quick.c +++ b/deflate_quick.c @@ -17,16 +17,11 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ -#include "../../zbuild.h" -#include -#ifdef _MSC_VER -# include -#endif -#include "../../deflate.h" -#include "../../deflate_p.h" -#include "../../functable.h" -#include "../../memcopy.h" -#include "../../trees_emit.h" +#include "zbuild.h" +#include "deflate.h" +#include "deflate_p.h" +#include "functable.h" +#include "trees_emit.h" extern const ct_data static_ltree[L_CODES+2]; extern const ct_data static_dtree[D_CODES]; diff --git a/win32/Makefile.a64 b/win32/Makefile.a64 index 43c978cd..b27aa8fc 100644 --- a/win32/Makefile.a64 +++ b/win32/Makefile.a64 @@ -41,6 +41,7 @@ OBJS = \ deflate.obj \ deflate_fast.obj \ deflate_slow.obj \ + deflate_quick.obj \ deflate_medium.obj \ functable.obj \ infback.obj \ @@ -142,6 +143,7 @@ compress.obj: $(SRCDIR)/compress.c $(SRCDIR)/zbuild.h $(SRCDIR)/zlib$(SUFFIX).h uncompr.obj: $(SRCDIR)/uncompr.c $(SRCDIR)/zbuild.h $(SRCDIR)/zlib$(SUFFIX).h crc32.obj: $(SRCDIR)/crc32.c $(SRCDIR)/zbuild.h $(SRCDIR)/zendian.h $(SRCDIR)/deflate.h $(SRCDIR)/functable.h $(SRCDIR)/crc32.h deflate.obj: $(SRCDIR)/deflate.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h +deflate_quick.obj: $(SRCDIR)/deflate_quick.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/trees_emit.h deflate_fast.obj: $(SRCDIR)/deflate_fast.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h deflate_medium.obj: $(SRCDIR)/deflate_medium.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h deflate_slow.obj: $(SRCDIR)/deflate_slow.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h diff --git a/win32/Makefile.arm b/win32/Makefile.arm index df6ffc4d..f1b95caa 100644 --- a/win32/Makefile.arm +++ b/win32/Makefile.arm @@ -158,6 +158,7 @@ crc32.obj: $(SRCDIR)/crc32.c $(SRCDIR)/zbuild.h $(SRCDIR)/zendian.h $(SRCDIR)/de deflate.obj: $(SRCDIR)/deflate.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h deflate_fast.obj: $(SRCDIR)/deflate_fast.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h deflate_medium.obj: $(SRCDIR)/deflate_medium.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h +deflate_quick.obj: $(SRCDIR)/deflate_quick.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/trees_emit.h deflate_slow.obj: $(SRCDIR)/deflate_slow.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h infback.obj: $(SRCDIR)/infback.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h inffast.obj: $(SRCDIR)/inffast.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/memcopy.h diff --git a/win32/Makefile.msc b/win32/Makefile.msc index e7beedac..1e343bb8 100644 --- a/win32/Makefile.msc +++ b/win32/Makefile.msc @@ -23,7 +23,7 @@ AR = lib RC = rc CP = copy /y CFLAGS = -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" $(LOC) -WFLAGS = -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DX86_PCLMULQDQ_CRC -DX86_SSE2 -DX86_CPUID -DX86_SSE42_CRC_INTRIN -DX86_SSE42_CRC_HASH -DX86_AVX2 -DUNALIGNED_OK -DX86_QUICK_STRATEGY +WFLAGS = -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DX86_PCLMULQDQ_CRC -DX86_SSE2 -DX86_CPUID -DX86_SSE42_CRC_INTRIN -DX86_SSE42_CRC_HASH -DX86_AVX2 -DUNALIGNED_OK LDFLAGS = -nologo -debug -incremental:no -opt:ref -manifest ARFLAGS = -nologo RCFLAGS = /dWIN32 /r @@ -155,7 +155,7 @@ crc32.obj: $(SRCDIR)/crc32.c $(SRCDIR)/zbuild.h $(SRCDIR)/zendian.h $(SRCDIR)/de deflate.obj: $(SRCDIR)/deflate.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h deflate_fast.obj: $(SRCDIR)/deflate_fast.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h deflate_medium.obj: $(SRCDIR)/deflate_medium.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h -deflate_quick.obj: $(SRCDIR)/arch/x86/deflate_quick.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/memcopy.h +deflate_quick.obj: $(SRCDIR)/deflate_quick.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/trees_emit.h deflate_slow.obj: $(SRCDIR)/deflate_slow.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h infback.obj: $(SRCDIR)/infback.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h inffast.obj: $(SRCDIR)/inffast.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/memcopy.h