From 60879ac4cc75bd9da5387dded4854c9fe2bc2c70 Mon Sep 17 00:00:00 2001 From: Hans Kristian Rosbach Date: Thu, 11 Dec 2025 17:24:59 +0100 Subject: Use uin32_t for Pos in match_tpl.h --- arch/arm/arm_functions.h | 4 ++-- arch/generic/generic_functions.h | 4 ++-- arch/loongarch/loongarch_functions.h | 8 ++++---- arch/power/power_functions.h | 4 ++-- arch/riscv/riscv_functions.h | 4 ++-- arch/x86/x86_functions.h | 12 ++++++------ deflate_fast.c | 2 +- deflate_medium.c | 2 +- deflate_p.h | 2 +- deflate_slow.c | 2 +- functable.c | 4 ++-- functable.h | 4 ++-- match_tpl.h | 20 ++++++++++---------- 13 files changed, 36 insertions(+), 36 deletions(-) diff --git a/arch/arm/arm_functions.h b/arch/arm/arm_functions.h index 2175c94d59..1dbb3fb55f 100644 --- a/arch/arm/arm_functions.h +++ b/arch/arm/arm_functions.h @@ -12,8 +12,8 @@ uint8_t* chunkmemset_safe_neon(uint8_t *out, uint8_t *from, unsigned len, unsign # ifdef HAVE_BUILTIN_CTZLL uint32_t compare256_neon(const uint8_t *src0, const uint8_t *src1); -uint32_t longest_match_neon(deflate_state *const s, Pos cur_match); -uint32_t longest_match_slow_neon(deflate_state *const s, Pos cur_match); +uint32_t longest_match_neon(deflate_state *const s, uint32_t cur_match); +uint32_t longest_match_slow_neon(deflate_state *const s, uint32_t cur_match); # endif void slide_hash_neon(deflate_state *s); void inflate_fast_neon(PREFIX3(stream) *strm, uint32_t start); diff --git a/arch/generic/generic_functions.h b/arch/generic/generic_functions.h index a04aca3825..f95fe4bb0e 100644 --- a/arch/generic/generic_functions.h +++ b/arch/generic/generic_functions.h @@ -43,8 +43,8 @@ uint32_t crc32_fold_final_c(crc32_fold *crc); void inflate_fast_c(PREFIX3(stream) *strm, uint32_t start); -uint32_t longest_match_c(deflate_state *const s, Pos cur_match); -uint32_t longest_match_slow_c(deflate_state *const s, Pos cur_match); +uint32_t longest_match_c(deflate_state *const s, uint32_t cur_match); +uint32_t longest_match_slow_c(deflate_state *const s, uint32_t cur_match); void slide_hash_c(deflate_state *s); diff --git a/arch/loongarch/loongarch_functions.h b/arch/loongarch/loongarch_functions.h index 54950629cb..2ddb9041fb 100644 --- a/arch/loongarch/loongarch_functions.h +++ b/arch/loongarch/loongarch_functions.h @@ -20,8 +20,8 @@ uint32_t adler32_copy_lsx(uint32_t adler, uint8_t *dst, const uint8_t *src, size void slide_hash_lsx(deflate_state *s); # ifdef HAVE_BUILTIN_CTZ uint32_t compare256_lsx(const uint8_t *src0, const uint8_t *src1); - uint32_t longest_match_lsx(deflate_state *const s, Pos cur_match); - uint32_t longest_match_slow_lsx(deflate_state *const s, Pos cur_match); + uint32_t longest_match_lsx(deflate_state *const s, uint32_t cur_match); + uint32_t longest_match_slow_lsx(deflate_state *const s, uint32_t cur_match); # endif uint8_t* chunkmemset_safe_lsx(uint8_t *out, uint8_t *from, unsigned len, unsigned left); void inflate_fast_lsx(PREFIX3(stream) *strm, uint32_t start); @@ -33,8 +33,8 @@ uint32_t adler32_copy_lasx(uint32_t adler, uint8_t *dst, const uint8_t *src, siz void slide_hash_lasx(deflate_state *s); # ifdef HAVE_BUILTIN_CTZ uint32_t compare256_lasx(const uint8_t *src0, const uint8_t *src1); - uint32_t longest_match_lasx(deflate_state *const s, Pos cur_match); - uint32_t longest_match_slow_lasx(deflate_state *const s, Pos cur_match); + uint32_t longest_match_lasx(deflate_state *const s, uint32_t cur_match); + uint32_t longest_match_slow_lasx(deflate_state *const s, uint32_t cur_match); # endif uint8_t* chunkmemset_safe_lasx(uint8_t *out, uint8_t *from, unsigned len, unsigned left); void inflate_fast_lasx(PREFIX3(stream) *strm, uint32_t start); diff --git a/arch/power/power_functions.h b/arch/power/power_functions.h index 6508b979d4..d2291516ba 100644 --- a/arch/power/power_functions.h +++ b/arch/power/power_functions.h @@ -22,8 +22,8 @@ void inflate_fast_power8(PREFIX3(stream) *strm, uint32_t start); #ifdef POWER9 uint32_t compare256_power9(const uint8_t *src0, const uint8_t *src1); -uint32_t longest_match_power9(deflate_state *const s, Pos cur_match); -uint32_t longest_match_slow_power9(deflate_state *const s, Pos cur_match); +uint32_t longest_match_power9(deflate_state *const s, uint32_t cur_match); +uint32_t longest_match_slow_power9(deflate_state *const s, uint32_t cur_match); #endif diff --git a/arch/riscv/riscv_functions.h b/arch/riscv/riscv_functions.h index 7334eb64fd..9f0f3880ce 100644 --- a/arch/riscv/riscv_functions.h +++ b/arch/riscv/riscv_functions.h @@ -15,8 +15,8 @@ uint32_t adler32_copy_rvv(uint32_t adler, uint8_t *dst, const uint8_t *src, size uint8_t* chunkmemset_safe_rvv(uint8_t *out, uint8_t *from, unsigned len, unsigned left); uint32_t compare256_rvv(const uint8_t *src0, const uint8_t *src1); -uint32_t longest_match_rvv(deflate_state *const s, Pos cur_match); -uint32_t longest_match_slow_rvv(deflate_state *const s, Pos cur_match); +uint32_t longest_match_rvv(deflate_state *const s, uint32_t cur_match); +uint32_t longest_match_slow_rvv(deflate_state *const s, uint32_t cur_match); void slide_hash_rvv(deflate_state *s); void inflate_fast_rvv(PREFIX3(stream) *strm, uint32_t start); #endif diff --git a/arch/x86/x86_functions.h b/arch/x86/x86_functions.h index faca5f5ba2..b97bee5359 100644 --- a/arch/x86/x86_functions.h +++ b/arch/x86/x86_functions.h @@ -19,8 +19,8 @@ uint8_t* chunkmemset_safe_sse2(uint8_t *out, uint8_t *from, unsigned len, unsign # ifdef HAVE_BUILTIN_CTZ uint32_t compare256_sse2(const uint8_t *src0, const uint8_t *src1); - uint32_t longest_match_sse2(deflate_state *const s, Pos cur_match); - uint32_t longest_match_slow_sse2(deflate_state *const s, Pos cur_match); + uint32_t longest_match_sse2(deflate_state *const s, uint32_t cur_match); + uint32_t longest_match_slow_sse2(deflate_state *const s, uint32_t cur_match); # endif void slide_hash_sse2(deflate_state *s); void inflate_fast_sse2(PREFIX3(stream)* strm, uint32_t start); @@ -51,8 +51,8 @@ uint8_t* chunkmemset_safe_avx2(uint8_t *out, uint8_t *from, unsigned len, unsign # ifdef HAVE_BUILTIN_CTZ uint32_t compare256_avx2(const uint8_t *src0, const uint8_t *src1); - uint32_t longest_match_avx2(deflate_state *const s, Pos cur_match); - uint32_t longest_match_slow_avx2(deflate_state *const s, Pos cur_match); + uint32_t longest_match_avx2(deflate_state *const s, uint32_t cur_match); + uint32_t longest_match_slow_avx2(deflate_state *const s, uint32_t cur_match); # endif void slide_hash_avx2(deflate_state *s); void inflate_fast_avx2(PREFIX3(stream)* strm, uint32_t start); @@ -64,8 +64,8 @@ uint8_t* chunkmemset_safe_avx512(uint8_t *out, uint8_t *from, unsigned len, unsi void inflate_fast_avx512(PREFIX3(stream)* strm, uint32_t start); # ifdef HAVE_BUILTIN_CTZLL uint32_t compare256_avx512(const uint8_t *src0, const uint8_t *src1); - uint32_t longest_match_avx512(deflate_state *const s, Pos cur_match); - uint32_t longest_match_slow_avx512(deflate_state *const s, Pos cur_match); + uint32_t longest_match_avx512(deflate_state *const s, uint32_t cur_match); + uint32_t longest_match_slow_avx512(deflate_state *const s, uint32_t cur_match); # endif #endif #ifdef X86_AVX512VNNI diff --git a/deflate_fast.c b/deflate_fast.c index 4040e65dcb..b13a31d727 100644 --- a/deflate_fast.c +++ b/deflate_fast.c @@ -61,7 +61,7 @@ Z_INTERNAL block_state deflate_fast(deflate_state *s, int flush) { * of window index 0 (in particular we have to avoid a match * of the string with itself at the start of the input file). */ - match_len = FUNCTABLE_CALL(longest_match)(s, hash_head); + match_len = FUNCTABLE_CALL(longest_match)(s, (uint32_t)hash_head); /* longest_match() sets match_start */ } } else { diff --git a/deflate_medium.c b/deflate_medium.c index 300f56532d..2f5893c872 100644 --- a/deflate_medium.c +++ b/deflate_medium.c @@ -219,7 +219,7 @@ Z_INTERNAL block_state deflate_medium(deflate_state *s, int flush) { * of window index 0 (in particular we have to avoid a match * of the string with itself at the start of the input file). */ - current_match.match_length = (uint16_t)FUNCTABLE_CALL(longest_match)(s, hash_head); + current_match.match_length = (uint16_t)FUNCTABLE_CALL(longest_match)(s, (uint32_t)hash_head); current_match.match_start = (uint16_t)s->match_start; if (UNLIKELY(current_match.match_length < WANT_MIN_MATCH)) current_match.match_length = 1; diff --git a/deflate_p.h b/deflate_p.h index 597a70370b..f9c635b1ee 100644 --- a/deflate_p.h +++ b/deflate_p.h @@ -192,6 +192,6 @@ Z_FORCEINLINE static unsigned read_buf(PREFIX3(stream) *strm, unsigned char *buf /* Compression function. Returns the block state after the call. */ typedef block_state (*compress_func) (deflate_state *s, int flush); /* Match function. Returns the longest match. */ -typedef uint32_t (*match_func) (deflate_state *const s, Pos cur_match); +typedef uint32_t (*match_func) (deflate_state *const s, uint32_t cur_match); #endif diff --git a/deflate_slow.c b/deflate_slow.c index 37fa21f400..0567f7148b 100644 --- a/deflate_slow.c +++ b/deflate_slow.c @@ -68,7 +68,7 @@ Z_INTERNAL block_state deflate_slow(deflate_state *s, int flush) { * of window index 0 (in particular we have to avoid a match * of the string with itself at the start of the input file). */ - match_len = longest_match(s, hash_head); + match_len = longest_match(s, (uint32_t)hash_head); /* longest_match() sets match_start */ if (match_len <= 5 && (s->strategy == Z_FILTERED)) { diff --git a/functable.c b/functable.c index c3a6183e57..69b87cb3a7 100644 --- a/functable.c +++ b/functable.c @@ -428,12 +428,12 @@ static void inflate_fast_stub(PREFIX3(stream) *strm, uint32_t start) { functable.inflate_fast(strm, start); } -static uint32_t longest_match_stub(deflate_state* const s, Pos cur_match) { +static uint32_t longest_match_stub(deflate_state* const s, uint32_t cur_match) { FUNCTABLE_INIT_ABORT; return functable.longest_match(s, cur_match); } -static uint32_t longest_match_slow_stub(deflate_state* const s, Pos cur_match) { +static uint32_t longest_match_slow_stub(deflate_state* const s, uint32_t cur_match) { FUNCTABLE_INIT_ABORT; return functable.longest_match_slow(s, cur_match); } diff --git a/functable.h b/functable.h index 209db4a67d..044cf8ac75 100644 --- a/functable.h +++ b/functable.h @@ -35,8 +35,8 @@ struct functable_s { uint32_t (* crc32_fold_final) (struct crc32_fold_s *crc); uint32_t (* crc32_fold_reset) (struct crc32_fold_s *crc); void (* inflate_fast) (PREFIX3(stream) *strm, uint32_t start); - uint32_t (* longest_match) (deflate_state *const s, Pos cur_match); - uint32_t (* longest_match_slow) (deflate_state *const s, Pos cur_match); + uint32_t (* longest_match) (deflate_state *const s, uint32_t cur_match); + uint32_t (* longest_match_slow) (deflate_state *const s, uint32_t cur_match); void (* slide_hash) (deflate_state *s); }; diff --git a/match_tpl.h b/match_tpl.h index f321f700e2..62287fb8d1 100644 --- a/match_tpl.h +++ b/match_tpl.h @@ -28,7 +28,7 @@ * The LONGEST_MATCH_SLOW variant spends more time to attempt to find longer * matches once a match has already been found. */ -Z_INTERNAL uint32_t LONGEST_MATCH(deflate_state *const s, Pos cur_match) { +Z_INTERNAL uint32_t LONGEST_MATCH(deflate_state *const s, uint32_t cur_match) { const unsigned wmask = W_MASK(s); unsigned int strstart = s->strstart; const unsigned char *window = s->window; @@ -39,9 +39,9 @@ Z_INTERNAL uint32_t LONGEST_MATCH(deflate_state *const s, Pos cur_match) { const unsigned char *scan; const unsigned char *mbase_start = window; const unsigned char *mbase_end; - Pos limit; + uint32_t limit; #ifdef LONGEST_MATCH_SLOW - Pos limit_base; + uint32_t limit_base; #else int32_t early_exit; #endif @@ -49,7 +49,7 @@ Z_INTERNAL uint32_t LONGEST_MATCH(deflate_state *const s, Pos cur_match) { uint32_t nice_match = (uint32_t)s->nice_match; uint32_t best_len, offset; uint32_t lookahead = s->lookahead; - Pos match_offset = 0; + uint32_t match_offset = 0; uint64_t scan_start; uint64_t scan_end; @@ -80,13 +80,13 @@ Z_INTERNAL uint32_t LONGEST_MATCH(deflate_state *const s, Pos cur_match) { /* Stop when cur_match becomes <= limit. To simplify the code, * we prevent matches with the string of window index 0 */ - limit = strstart > MAX_DIST(s) ? (Pos)(strstart - MAX_DIST(s)) : 0; + limit = strstart > MAX_DIST(s) ? (strstart - MAX_DIST(s)) : 0; #ifdef LONGEST_MATCH_SLOW limit_base = limit; if (best_len >= STD_MIN_MATCH) { /* We're continuing search (lazy evaluation). */ uint32_t hash; - Pos pos; + uint32_t pos; /* Find a most distant chain starting from scan with index=1 (index=0 corresponds * to cur_match). We cannot use s->prev[strstart+1,...] immediately, because @@ -102,7 +102,7 @@ Z_INTERNAL uint32_t LONGEST_MATCH(deflate_state *const s, Pos cur_match) { /* If we're starting with best_len >= 3, we can use offset search. */ pos = head[hash]; if (pos < cur_match) { - match_offset = (Pos)(i - 2); + match_offset = i - 2; cur_match = pos; } } @@ -180,7 +180,7 @@ Z_INTERNAL uint32_t LONGEST_MATCH(deflate_state *const s, Pos cur_match) { if (UNLIKELY(len > STD_MIN_MATCH && match_start + len < strstart)) { const unsigned char *scan_endstr; uint32_t hash; - Pos pos, next_pos; + uint32_t pos, next_pos; /* Go back to offset 0 */ cur_match -= match_offset; @@ -193,7 +193,7 @@ Z_INTERNAL uint32_t LONGEST_MATCH(deflate_state *const s, Pos cur_match) { if (pos <= limit_base + i) goto break_matching; next_pos = pos; - match_offset = (Pos)i; + match_offset = i; } } /* Switch cur_match to next_pos chain */ @@ -213,7 +213,7 @@ Z_INTERNAL uint32_t LONGEST_MATCH(deflate_state *const s, Pos cur_match) { pos = head[hash]; if (pos < cur_match) { - match_offset = (Pos)(len - (STD_MIN_MATCH+1)); + match_offset = len - (STD_MIN_MATCH+1); if (pos <= limit_base + match_offset) goto break_matching; cur_match = pos; -- cgit 0.0.5-2-1-g0f52