From: Nathan Moinvaziri Date: Sun, 14 Dec 2025 18:32:02 +0000 (-0800) Subject: Move crc32_fold_s struct into x86 implementation. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=17d50ac2e03cbfe6248a34f89a7cc82305bf8938;p=thirdparty%2Fzlib-ng.git Move crc32_fold_s struct into x86 implementation. --- diff --git a/arch/s390/dfltcc_deflate.c b/arch/s390/dfltcc_deflate.c index 2eaf8e1cf..f94950033 100644 --- a/arch/s390/dfltcc_deflate.c +++ b/arch/s390/dfltcc_deflate.c @@ -228,7 +228,7 @@ again: if (state->wrap == 1) param->cv = strm->adler; else if (state->wrap == 2) - param->cv = ZSWAP32(state->crc_fold.value); + param->cv = ZSWAP32(strm->adler); /* When opening a block, choose a Huffman-Table Type */ if (!param->bcf) { @@ -262,7 +262,7 @@ again: if (state->wrap == 1) strm->adler = param->cv; else if (state->wrap == 2) - state->crc_fold.value = ZSWAP32(param->cv); + strm->adler = ZSWAP32(param->cv); /* Unmask the input data */ strm->avail_in += masked_avail_in; diff --git a/arch/x86/crc32_fold_pclmulqdq_tpl.h b/arch/x86/crc32_fold_pclmulqdq_tpl.h index e7e57c546..b36a9f040 100644 --- a/arch/x86/crc32_fold_pclmulqdq_tpl.h +++ b/arch/x86/crc32_fold_pclmulqdq_tpl.h @@ -28,6 +28,15 @@ #include "crc32_braid_tbl.h" #include "x86_intrins.h" +/* sizeof(__m128i) * (4 folds) */ +#define CRC32_FOLD_BUFFER_SIZE (16 * 4) + +typedef struct crc32_fold_s { + uint8_t fold[CRC32_FOLD_BUFFER_SIZE]; + uint32_t value; +} crc32_fold; + + static const unsigned ALIGNED_(16) crc_k[] = { 0xccaa009e, 0x00000000, /* rk1 */ 0x751997d0, 0x00000001, /* rk2 */ diff --git a/crc32.h b/crc32.h index d41af8f01..e20577759 100644 --- a/crc32.h +++ b/crc32.h @@ -5,9 +5,6 @@ #ifndef CRC32_H_ #define CRC32_H_ -/* sizeof(__m128i) * (4 folds) */ -#define CRC32_FOLD_BUFFER_SIZE (16 * 4) - /* Size thresholds for Chorba algorithm variants */ #define CHORBA_LARGE_THRESHOLD (sizeof(z_word_t) * 64 * 1024) #define CHORBA_MEDIUM_UPPER_THRESHOLD 32768 @@ -19,9 +16,4 @@ # define CHORBA_SMALL_THRESHOLD 80 #endif -typedef struct crc32_fold_s { - uint8_t fold[CRC32_FOLD_BUFFER_SIZE]; - uint32_t value; -} crc32_fold; - #endif diff --git a/deflate.h b/deflate.h index 95c76f1e2..4957b940d 100644 --- a/deflate.h +++ b/deflate.h @@ -240,7 +240,7 @@ struct ALIGNED_(64) internal_state { int32_t padding1[1]; /* Cacheline 3 */ - struct crc32_fold_s ALIGNED_(16) crc_fold; + uint8_t ALIGNED_(16) padding4[68]; /* used by trees.c: */ /* Didn't use ct_data typedef below to suppress compiler warning */ diff --git a/inflate.h b/inflate.h index 1427e9085..1bc845c75 100644 --- a/inflate.h +++ b/inflate.h @@ -142,7 +142,7 @@ struct ALIGNED_(64) inflate_state { #if defined(_M_IX86) || defined(_M_ARM) uint32_t padding[1]; #endif - struct crc32_fold_s ALIGNED_(16) crc_fold; + uint8_t ALIGNED_(16) padding4[68]; uint16_t lens[320]; /* temporary storage for code lengths */ uint16_t work[288]; /* work area for code table building */