]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Separate slide_hash_c in the same way that insert_string_c is separated from deflate.c.
authorNathan Moinvaziri <nathan@nathanm.com>
Tue, 15 Jun 2021 02:55:09 +0000 (19:55 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Thu, 8 Jul 2021 07:33:41 +0000 (09:33 +0200)
CMakeLists.txt
Makefile.in
deflate.c
slide_hash.c [new file with mode: 0644]
win32/Makefile.a64
win32/Makefile.arm
win32/Makefile.msc

index 51b4555d00103deb5e0ce7269d3f8aae7d80c94a..4deef8235a6cdaaea5ee94a46bf771f7e998eea9 100644 (file)
@@ -855,6 +855,7 @@ set(ZLIB_SRCS
     inftrees.c
     insert_string.c
     insert_string_roll.c
+    slide_hash.c
     trees.c
     uncompr.c
     zutil.c
index 379cab52922f22827baf5d8134d9e92d9a0ab704..de37b190679e1e9b12fd47c24c4667b7c63c5240 100644 (file)
@@ -93,6 +93,7 @@ OBJZ = \
        inftrees.o \
        insert_string.o \
        insert_string_roll.o \
+       slide_hash.o \
        trees.o \
        uncompr.o \
        zutil.o \
@@ -127,6 +128,7 @@ PIC_OBJZ = \
        inftrees.lo \
        insert_string.lo \
        insert_string_roll.lo \
+       slide_hash.lo \
        trees.lo \
        uncompr.lo \
        zutil.lo \
index c66c1e17a58cf7b03dd7e6312b466e5fd66aeb81..c1ee6d41043269a58737c173b16271b604bd9b6a 100644 (file)
--- a/deflate.c
+++ b/deflate.c
@@ -185,50 +185,6 @@ static const config configuration_table[10] = {
     memset((unsigned char *)s->head, 0, HASH_SIZE * sizeof(*s->head)); \
   } while (0)
 
-/* ===========================================================================
- * Slide the hash table when sliding the window down (could be avoided with 32
- * bit values at the expense of memory usage). We slide even when level == 0 to
- * keep the hash table consistent if we switch back to level > 0 later.
- */
-static inline void slide_hash_c_chain(Pos *table, uint32_t entries, uint16_t wsize) {
-#ifdef NOT_TWEAK_COMPILER
-    table += entries;
-    do {
-        unsigned m;
-        m = *--table;
-        *table = (Pos)(m >= wsize ? m-wsize : 0);
-        /* If entries is not on any hash chain, prev[entries] is garbage but
-         * its value will never be used.
-         */
-    } while (--entries);
-#else
-    {
-    /* As of I make this change, gcc (4.8.*) isn't able to vectorize
-     * this hot loop using saturated-subtraction on x86-64 architecture.
-     * To avoid this defect, we can change the loop such that
-     *    o. the pointer advance forward, and
-     *    o. demote the variable 'm' to be local to the loop, and
-     *       choose type "Pos" (instead of 'unsigned int') for the
-     *       variable to avoid unnecessary zero-extension.
-     */
-        unsigned int i;
-        Pos *q = table;
-        for (i = 0; i < entries; i++) {
-            Pos m = *q;
-            Pos t = (Pos)wsize;
-            *q++ = (Pos)(m >= t ? m-t: 0);
-        }
-    }
-#endif /* NOT_TWEAK_COMPILER */
-}
-
-Z_INTERNAL void slide_hash_c(deflate_state *s) {
-    unsigned int wsize = s->w_size;
-
-    slide_hash_c_chain(s->head, HASH_SIZE, wsize);
-    slide_hash_c_chain(s->prev, wsize, wsize);
-        }
-
 /* ========================================================================= */
 int32_t Z_EXPORT PREFIX(deflateInit_)(PREFIX3(stream) *strm, int32_t level, const char *version, int32_t stream_size) {
     return PREFIX(deflateInit2_)(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, version, stream_size);
diff --git a/slide_hash.c b/slide_hash.c
new file mode 100644 (file)
index 0000000..d25e710
--- /dev/null
@@ -0,0 +1,52 @@
+/* slide_hash.c -- slide hash table C implementation
+ *
+ * Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#include "zbuild.h"
+#include "deflate.h"
+
+/* ===========================================================================
+ * Slide the hash table when sliding the window down (could be avoided with 32
+ * bit values at the expense of memory usage). We slide even when level == 0 to
+ * keep the hash table consistent if we switch back to level > 0 later.
+ */
+static inline void slide_hash_c_chain(Pos *table, uint32_t entries, uint16_t wsize) {
+#ifdef NOT_TWEAK_COMPILER
+    table += entries;
+    do {
+        unsigned m;
+        m = *--table;
+        *table = (Pos)(m >= wsize ? m-wsize : 0);
+        /* If entries is not on any hash chain, prev[entries] is garbage but
+         * its value will never be used.
+         */
+    } while (--entries);
+#else
+    {
+    /* As of I make this change, gcc (4.8.*) isn't able to vectorize
+     * this hot loop using saturated-subtraction on x86-64 architecture.
+     * To avoid this defect, we can change the loop such that
+     *    o. the pointer advance forward, and
+     *    o. demote the variable 'm' to be local to the loop, and
+     *       choose type "Pos" (instead of 'unsigned int') for the
+     *       variable to avoid unnecessary zero-extension.
+     */
+        unsigned int i;
+        Pos *q = table;
+        for (i = 0; i < entries; i++) {
+            Pos m = *q;
+            Pos t = (Pos)wsize;
+            *q++ = (Pos)(m >= t ? m-t: 0);
+        }
+    }
+#endif /* NOT_TWEAK_COMPILER */
+}
+
+Z_INTERNAL void slide_hash_c(deflate_state *s) {
+    unsigned int wsize = s->w_size;
+
+    slide_hash_c_chain(s->head, HASH_SIZE, wsize);
+    slide_hash_c_chain(s->prev, wsize, wsize);
+}
index a272810a8729865c75b530b0f41c097019f81f23..8a39249dd86fc9fe1f450b48b79c601ea5dceb40 100644 (file)
@@ -64,6 +64,7 @@ OBJS = \
        inffast.obj \
        insert_string.obj \
        insert_string_roll.obj \
+       slide_hash.obj \
        trees.obj \
        uncompr.obj \
        zutil.obj \
@@ -179,6 +180,7 @@ infback.obj: $(SRCDIR)/infback.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/
 inffast.obj: $(SRCDIR)/inffast.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/functable.h
 inflate.obj: $(SRCDIR)/inflate.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/functable.h $(SRCDIR)/functable.h
 inftrees.obj: $(SRCDIR)/inftrees.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h
+slide_hash.obj: $(SRCDIR)/slide_hash.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h
 trees.obj: $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/trees_tbl.h
 zutil.obj: $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/zutil_p.h
 
index 23ed761a4a2e1de239939f9553da96769d136fe0..9897ad8e90ef515cfb34a27c141a6584067eab1d 100644 (file)
@@ -67,6 +67,7 @@ OBJS = \
        inffast.obj \
        insert_string.obj \
        insert_string_roll.obj \
+       slide_hash.obj \
        trees.obj \
        uncompr.obj \
        zutil.obj \
@@ -191,6 +192,7 @@ infback.obj: $(SRCDIR)/infback.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/
 inffast.obj: $(SRCDIR)/inffast.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/functable.h
 inflate.obj: $(SRCDIR)/inflate.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/functable.h $(SRCDIR)/functable.h
 inftrees.obj: $(SRCDIR)/inftrees.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h
+slide_hash.obj: $(SRCDIR)/slide_hash.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h
 trees.obj: $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/trees_tbl.h
 zutil.obj: $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/zutil_p.h
 
index 94462f5968b8dd8a3424e870575c4d92516d37ad..0ff683e2f764a8abaebcb40495bec680046f81b4 100644 (file)
@@ -75,6 +75,7 @@ OBJS = \
        insert_string.obj \
        insert_string_roll.obj \
        insert_string_sse.obj \
+       slide_hash.obj \
        slide_avx.obj \
        slide_sse.obj \
        trees.obj \
@@ -185,6 +186,7 @@ infback.obj: $(SRCDIR)/infback.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/
 inffast.obj: $(SRCDIR)/inffast.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/functable.h
 inflate.obj: $(SRCDIR)/inflate.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/functable.h $(SRCDIR)/functable.h
 inftrees.obj: $(SRCDIR)/inftrees.c $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/inftrees.h
+slide_hash.obj: $(SRCDIR)/slide_hash.c $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h
 slide_sse.obj: $(SRCDIR)/arch/x86/slide_sse.c $(SRCDIR)/deflate.h
 trees.obj: $(SRCDIR)/zbuild.h $(SRCDIR)/deflate.h $(SRCDIR)/trees_tbl.h
 zutil.obj: $(SRCDIR)/zbuild.h $(SRCDIR)/zutil.h $(SRCDIR)/zutil_p.h