]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Make deflate_quick algorithm available to all architectures. #205
authorNathan Moinvaziri <nathan@nathanm.com>
Sun, 24 May 2020 15:42:38 +0000 (08:42 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Mon, 8 Jun 2020 13:01:50 +0000 (15:01 +0200)
CMakeLists.txt
Makefile.in
arch/x86/Makefile.in
compress.c
configure
deflate.c
deflate_quick.c [moved from arch/x86/deflate_quick.c with 93% similarity]
win32/Makefile.a64
win32/Makefile.arm
win32/Makefile.msc

index ce6d011b8effa3a0d13ca0dc6378eebe69d1e77b..404b0639d945ee210817b5ecda702f523a9b8e32 100644 (file)
@@ -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
index fb91bf7ec551610a934c71b80ea0ce81064da42e..74857d6893b18058ae6419bb882b0c70aaeae508 100644 (file)
@@ -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 \
index b7b923fd52236232f132016defa7d2daf657b6a4..4f8a753b4b98c8260a1190de1e0d7ad10d8ab23f 100644 (file)
@@ -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
 
index 41a4573d5e83c80a57f5a38f3fd072bc3a2fda54..bbbed658ed33bce58bc63f93daba5bd08886a0dd 100644 (file)
@@ -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;
index 4928c3468645c61e8cc2aff71ed47c6f772ff8f9..5e20aa950014376806bc97a12e9142938f96188f 100755 (executable)
--- 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
     ;;
 
index 37afe4dcd7850b45bc2416a177dfccca5e5d6682..ee31d2c407826e45d96687b92e4205257cf049d2 100644 (file)
--- 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);
 
similarity index 93%
rename from arch/x86/deflate_quick.c
rename to deflate_quick.c
index c00cb73342aa87b786509eab0bac38de5e715a1d..cd79af4ffd0fb593b0f04604fa1a55798efaf24c 100644 (file)
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
-#include "../../zbuild.h"
-#include <immintrin.h>
-#ifdef _MSC_VER
-#  include <nmmintrin.h>
-#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];
index 43c978cd2fc8ccdb09fe46ae638f759f9b2b5422..b27aa8fc8ba747874e3bc607481b21e7879acbe3 100644 (file)
@@ -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
index df6ffc4dba6810e009359516e337e85000e83c29..f1b95caa193b7439140741ce621fed153c50ab95 100644 (file)
@@ -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
index e7beedac6666958fdccc8877e47f96c17850fb10..1e343bb8956a609c59f19a0bb6d872e99d1bd23c 100644 (file)
@@ -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