]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Use uin32_t for Pos in match_tpl.h
authorHans Kristian Rosbach <hk-git@circlestorm.org>
Thu, 11 Dec 2025 16:24:59 +0000 (17:24 +0100)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Mon, 22 Dec 2025 21:58:06 +0000 (22:58 +0100)
13 files changed:
arch/arm/arm_functions.h
arch/generic/generic_functions.h
arch/loongarch/loongarch_functions.h
arch/power/power_functions.h
arch/riscv/riscv_functions.h
arch/x86/x86_functions.h
deflate_fast.c
deflate_medium.c
deflate_p.h
deflate_slow.c
functable.c
functable.h
match_tpl.h

index 2175c94d59851ec239bd2bead9a545f5417f3b36..1dbb3fb55fe7c8c46a104b35d898218223772ff8 100644 (file)
@@ -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);
index a04aca38254f466dd7b93f65f717e42e8579fea7..f95fe4bb0ee0134ab8d66548f4636c1ab5c7a36f 100644 (file)
@@ -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);
 
index 54950629cbd45766298e1273b93fc292930a2433..2ddb9041fbcd836afd5c155bb582658f71289bd1 100644 (file)
@@ -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);
index 6508b979d4f6f739a1ecf4a6c78649d44bcb1ae4..d2291516ba99e547ec348aa82771186ef15b941a 100644 (file)
@@ -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
 
 
index 7334eb64fd6696d7c5f77bd7134a1b1f9d27c021..9f0f3880ce6eb66dc49e099ac7c4065b6b2313cf 100644 (file)
@@ -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
index faca5f5ba283c31a27e93ddc92e06e37f3f60617..b97bee5359fb885a4fbace9802980868d8807a12 100644 (file)
@@ -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
index 4040e65dcb75a1bff42dea81a562d01e9941478e..b13a31d727caae31a4de0b29225ea532ccc1fce9 100644 (file)
@@ -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 {
index 300f56532db95edf75a8c52de102fe9e52176ee1..2f5893c872d7af97c2e1a00c915dda8397451d7e 100644 (file)
@@ -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;
index 597a70370b4eadffbd83aadd0277853f99c2ac50..f9c635b1ee14e1da278e9b5021b82613cb59c353 100644 (file)
@@ -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
index 37fa21f4000716ec1d98a6210ff4923911678c65..0567f7148bf7d2d8b21df8758e11de681e4e2568 100644 (file)
@@ -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)) {
index c3a6183e573951ab3c878f8ba61170a775718c9f..69b87cb3a7ebf56079b2b7c2d5ba1646e5420ecc 100644 (file)
@@ -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);
 }
index 209db4a67d43b45e1373eb8a5ee1eb324d5a509d..044cf8ac756cb621c597f23fbeb836e60e78fa7e 100644 (file)
@@ -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);
 };
 
index f321f700e274516fd152166e45ac5b465db006b1..62287fb8d19308246a203aede988124025e118f1 100644 (file)
@@ -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;