]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Remove unnecessary CHUNK_SIZE define
authorPavel P <pavlov.pavel@gmail.com>
Thu, 22 Jan 2026 09:04:33 +0000 (11:04 +0200)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Thu, 22 Jan 2026 20:39:07 +0000 (21:39 +0100)
arch/generic/chunkset_c.c
arch/power/chunkset_power8.c
arch/riscv/chunkset_rvv.c

index 0a585e6caaf52be08d3ed9814fc2dc7965fb7816..ff9b1cb5fb4a206f2507270365fae50c463ab60f 100644 (file)
@@ -7,8 +7,6 @@
 
 typedef uint64_t chunk_t;
 
-#define CHUNK_SIZE 8
-
 #define HAVE_CHUNKMEMSET_4
 #define HAVE_CHUNKMEMSET_8
 
index 673fe0e1128a8166b9aaf549662f50531ee70965..c7e560bb9297ecce0fb6ad5cb5e9cc845c6e1284 100644 (file)
@@ -9,8 +9,6 @@
 
 typedef vector unsigned char chunk_t;
 
-#define CHUNK_SIZE 16
-
 #define HAVE_CHUNKMEMSET_2
 #define HAVE_CHUNKMEMSET_4
 #define HAVE_CHUNKMEMSET_8
index 45ff8d333e5f25d8452d88f977defcf45fb34afc..c07d3300710966e0dea45befd6c0fe5b1f95100b 100644 (file)
@@ -16,9 +16,9 @@
 #define HAVE_CHUNKMEMSET_4
 #define HAVE_CHUNKMEMSET_8
 
-#define CHUNK_MEMSET_RVV_IMPL(elen)                                     \
+#define CHUNK_MEMSET_RVV_IMPL(from, chunk, elen)                        \
 do {                                                                    \
-    size_t vl, len = CHUNK_SIZE / sizeof(uint##elen##_t);               \
+    size_t vl, len = sizeof(*chunk) / sizeof(uint##elen##_t);           \
     uint##elen##_t val = *(uint##elen##_t*)from;                        \
     uint##elen##_t* chunk_p = (uint##elen##_t*)chunk;                   \
     do {                                                                \
@@ -35,23 +35,23 @@ typedef struct chunk_s {
 } chunk_t;
 
 static inline void chunkmemset_2(uint8_t *from, chunk_t *chunk) {
-    CHUNK_MEMSET_RVV_IMPL(16);
+    CHUNK_MEMSET_RVV_IMPL(from, chunk, 16);
 }
 
 static inline void chunkmemset_4(uint8_t *from, chunk_t *chunk) {
-    CHUNK_MEMSET_RVV_IMPL(32);
+    CHUNK_MEMSET_RVV_IMPL(from, chunk, 32);
 }
 
 static inline void chunkmemset_8(uint8_t *from, chunk_t *chunk) {
-    CHUNK_MEMSET_RVV_IMPL(64);
+    CHUNK_MEMSET_RVV_IMPL(from, chunk, 64);
 }
 
 static inline void loadchunk(uint8_t const *s, chunk_t *chunk) {
-    memcpy(chunk->data, (uint8_t *)s, CHUNK_SIZE);
+    memcpy(chunk->data, (uint8_t *)s, sizeof(*chunk));
 }
 
 static inline void storechunk(uint8_t *out, chunk_t *chunk) {
-    memcpy(out, chunk->data, CHUNK_SIZE);
+    memcpy(out, chunk->data, sizeof(*chunk));
 }
 
 #define CHUNKSIZE        chunksize_rvv
@@ -69,18 +69,18 @@ static inline void storechunk(uint8_t *out, chunk_t *chunk) {
  * We load/store a single chunk once in the `CHUNKCOPY`.
  * However, RISC-V glibc would enable RVV optimized memcpy at runtime by IFUNC,
  * such that, we prefer copy large memory size once to make good use of the the RVV advance.
- * 
+ *
  * To be aligned to the other platforms, we didn't modify `CHUNKCOPY` method a lot,
  * but we still copy as much memory as possible for some conditions.
- * 
+ *
  * case 1: out - from >= len (no overlap)
  *         We can use memcpy to copy `len` size once
  *         because the memory layout would be the same.
  *
  * case 2: overlap
- *         We copy N chunks using memcpy at once, aiming to achieve our goal: 
+ *         We copy N chunks using memcpy at once, aiming to achieve our goal:
  *         to copy as much memory as possible.
- * 
+ *
  *         After using a single memcpy to copy N chunks, we have to use series of
  *         loadchunk and storechunk to ensure the result is correct.
  */
@@ -119,4 +119,4 @@ static inline uint8_t* CHUNKCOPY(uint8_t *out, uint8_t const *from, unsigned len
 
 #define INFLATE_FAST     inflate_fast_rvv
 
-#include "inffast_tpl.h"
\ No newline at end of file
+#include "inffast_tpl.h"