From: Nathan Moinvaziri Date: Sun, 2 Jan 2022 23:27:00 +0000 (-0800) Subject: Clean up crc32_fold structure and clearly define the size of the fold buffer. X-Git-Tag: 2.1.0-beta1~440 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=91bc814e39e6b012b3ca4ae6ae62ed11ad0795ae;p=thirdparty%2Fzlib-ng.git Clean up crc32_fold structure and clearly define the size of the fold buffer. --- diff --git a/arch/x86/crc32_fold_pclmulqdq.c b/arch/x86/crc32_fold_pclmulqdq.c index 1434357a8..a01cdf775 100644 --- a/arch/x86/crc32_fold_pclmulqdq.c +++ b/arch/x86/crc32_fold_pclmulqdq.c @@ -244,7 +244,7 @@ static inline void crc32_fold_save_partial(__m128i *fold, __m128i foldp) { Z_INTERNAL uint32_t crc32_fold_reset_pclmulqdq(crc32_fold *crc) { __m128i xmm_crc0 = _mm_cvtsi32_si128(0x9db42487); __m128i xmm_zero = _mm_setzero_si128(); - crc32_fold_save((__m128i *)&crc->fold, xmm_crc0, xmm_zero, xmm_zero, xmm_zero); + crc32_fold_save((__m128i *)crc->fold, xmm_crc0, xmm_zero, xmm_zero, xmm_zero); return 0; } @@ -254,7 +254,7 @@ Z_INTERNAL void crc32_fold_copy_pclmulqdq(crc32_fold *crc, uint8_t *dst, const u __m128i xmm_crc0, xmm_crc1, xmm_crc2, xmm_crc3, xmm_crc_part; char ALIGNED_(16) partial_buf[16] = { 0 }; - crc32_fold_load((__m128i *)&crc->fold, &xmm_crc0, &xmm_crc1, &xmm_crc2, &xmm_crc3); + crc32_fold_load((__m128i *)crc->fold, &xmm_crc0, &xmm_crc1, &xmm_crc2, &xmm_crc3); if (len < 16) { if (len == 0) @@ -375,8 +375,8 @@ Z_INTERNAL void crc32_fold_copy_pclmulqdq(crc32_fold *crc, uint8_t *dst, const u partial: partial_fold((size_t)len, &xmm_crc0, &xmm_crc1, &xmm_crc2, &xmm_crc3, &xmm_crc_part); done: - crc32_fold_save((__m128i *)&crc->fold, xmm_crc0, xmm_crc1, xmm_crc2, xmm_crc3); - crc32_fold_save_partial((__m128i *)&crc->fold, xmm_crc_part); + crc32_fold_save((__m128i *)crc->fold, xmm_crc0, xmm_crc1, xmm_crc2, xmm_crc3); + crc32_fold_save_partial((__m128i *)crc->fold, xmm_crc_part); } static const unsigned ALIGNED_(16) crc_k[] = { @@ -402,7 +402,7 @@ Z_INTERNAL uint32_t crc32_fold_final_pclmulqdq(crc32_fold *crc) { __m128i xmm_crc0, xmm_crc1, xmm_crc2, xmm_crc3; __m128i x_tmp0, x_tmp1, x_tmp2, crc_fold; - crc32_fold_load((__m128i *)&crc->fold, &xmm_crc0, &xmm_crc1, &xmm_crc2, &xmm_crc3); + crc32_fold_load((__m128i *)crc->fold, &xmm_crc0, &xmm_crc1, &xmm_crc2, &xmm_crc3); /* * k1 diff --git a/crc32_fold.h b/crc32_fold.h index ec6d13d15..8bd0b6bc2 100644 --- a/crc32_fold.h +++ b/crc32_fold.h @@ -5,8 +5,11 @@ #ifndef CRC32_FOLD_H_ #define CRC32_FOLD_H_ +#define CRC32_FOLD_BUFFER_SIZE (16 * 5) +/* sizeof(__m128i) * (4 folds & 1 partial fold) */ + typedef struct crc32_fold_s { - uint32_t ALIGNED_(16) fold[4 * 5]; + uint8_t fold[CRC32_FOLD_BUFFER_SIZE]; uint32_t value; } crc32_fold; diff --git a/deflate.h b/deflate.h index 030db4f09..7f4eb43f9 100644 --- a/deflate.h +++ b/deflate.h @@ -211,7 +211,7 @@ struct internal_state { int nice_match; /* Stop searching when current match exceeds this */ - crc32_fold ALIGNED_(16) crc_fold; + struct crc32_fold_s ALIGNED_(16) crc_fold; /* used by trees.c: */ /* Didn't use ct_data typedef below to suppress compiler warning */ diff --git a/inflate.h b/inflate.h index d33ea2a70..3f57e7840 100644 --- a/inflate.h +++ b/inflate.h @@ -103,7 +103,7 @@ struct inflate_state { uint32_t wnext; /* window write index */ unsigned char *window; /* allocated sliding window, if needed */ - crc32_fold ALIGNED_(16) crc_fold; + struct crc32_fold_s ALIGNED_(16) crc_fold; /* bit accumulator */ uint32_t hold; /* input bit accumulator */