]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Added CRC32_INITIAL_VALUE to prevent initial call to crc32 function.
authorNathan Moinvaziri <nathan@nathanm.com>
Fri, 2 Jul 2021 23:56:20 +0000 (16:56 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Fri, 13 Aug 2021 13:05:34 +0000 (15:05 +0200)
arch/x86/crc_folding.c
arch/x86/crc_folding.h
crc32.c
inflate.c
zutil.h

index 2f38f6332e0692e6f4d9146fec9b33a3cefab106..de087e34409e5390f432b528bca6dbbe77b3d7c6 100644 (file)
 
 #include "crc_folding.h"
 
-Z_INTERNAL uint32_t crc_fold_init(unsigned int crc0[4 * 5]) {
+Z_INTERNAL void crc_fold_init(unsigned int crc0[4 * 5]) {
     /* CRC_SAVE */
     _mm_storeu_si128((__m128i *)crc0 + 0, _mm_cvtsi32_si128(0x9db42487));
     _mm_storeu_si128((__m128i *)crc0 + 1, _mm_setzero_si128());
     _mm_storeu_si128((__m128i *)crc0 + 2, _mm_setzero_si128());
     _mm_storeu_si128((__m128i *)crc0 + 3, _mm_setzero_si128());
-
-    return 0;
 }
 
 static void fold_1(__m128i *xmm_crc0, __m128i *xmm_crc1, __m128i *xmm_crc2, __m128i *xmm_crc3) {
index a9ed41f3c05b6ba55b51920a19b10592f2eb4ac0..3af7f079a1db7e9d296aa6a179e7ebfbdeafcd93 100644 (file)
@@ -12,7 +12,7 @@
 
 #include "../../zutil.h"
 
-Z_INTERNAL uint32_t crc_fold_init(unsigned int crc0[4 * 5]);
+Z_INTERNAL void crc_fold_init(unsigned int crc0[4 * 5]);
 Z_INTERNAL uint32_t crc_fold_512to32(unsigned int crc0[4 * 5]);
 Z_INTERNAL void crc_fold_copy(unsigned int crc0[4 * 5], unsigned char *, const unsigned char *, long);
 
diff --git a/crc32.c b/crc32.c
index 74d9c414c2a71ea01ec72bae1feab318a38e7a4f..3cb066ce5ea74279eff8604253c7cdc2974053a2 100644 (file)
--- a/crc32.c
+++ b/crc32.c
@@ -183,11 +183,10 @@ Z_INTERNAL void crc_reset(deflate_state *const s) {
 #ifdef X86_PCLMULQDQ_CRC
     x86_check_features();
     if (x86_cpu_has_pclmulqdq) {
-        s->strm->adler = crc_fold_init(s->crc0);
-        return;
+        crc_fold_init(s->crc0);
     }
 #endif
-    s->strm->adler = PREFIX(crc32)(0L, NULL, 0);
+    s->strm->adler = CRC32_INITIAL_VALUE;
 }
 
 Z_INTERNAL void copy_with_crc(PREFIX3(stream) *strm, unsigned char *dst, unsigned long size) {
index 6ba6e83dea3de0b3439d490c647069d519d5afc0..45c90232ad0da30ee41f740f173e029176fc7964 100644 (file)
--- a/inflate.c
+++ b/inflate.c
@@ -410,7 +410,7 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) {
             if ((state->wrap & 2) && hold == 0x8b1f) {  /* gzip header */
                 if (state->wbits == 0)
                     state->wbits = 15;
-                state->check = PREFIX(crc32)(0L, NULL, 0);
+                state->check = CRC32_INITIAL_VALUE;
                 CRC2(state->check, hold);
                 INITBITS();
                 state->mode = FLAGS;
@@ -578,7 +578,7 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) {
                 state->head->hcrc = (int)((state->flags >> 9) & 1);
                 state->head->done = 1;
             }
-            strm->adler = state->check = PREFIX(crc32)(0L, NULL, 0);
+            strm->adler = state->check = CRC32_INITIAL_VALUE;
             state->mode = TYPE;
             break;
 #endif
diff --git a/zutil.h b/zutil.h
index bcb9ed12fccba0eb2d605d021f1bc7a57913c0f9..30bd6394ea9f3d9afc256d4e9e1de50cb38477c7 100644 (file)
--- a/zutil.h
+++ b/zutil.h
@@ -76,6 +76,7 @@ extern z_const char * const PREFIX(z_errmsg)[10]; /* indexed by 2-zlib_error */
 #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
 
 #define ADLER32_INITIAL_VALUE 1 /* initial adler-32 hash value */
+#define CRC32_INITIAL_VALUE 0 /* initial crc-32 hash value */
 
         /* target dependencies */