From: Pavel P Date: Thu, 22 Jan 2026 09:04:33 +0000 (+0200) Subject: Remove unnecessary CHUNK_SIZE define X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=948378559952e62d2e8b73b3df07eb99177b0a85;p=thirdparty%2Fzlib-ng.git Remove unnecessary CHUNK_SIZE define --- diff --git a/arch/generic/chunkset_c.c b/arch/generic/chunkset_c.c index 0a585e6ca..ff9b1cb5f 100644 --- a/arch/generic/chunkset_c.c +++ b/arch/generic/chunkset_c.c @@ -7,8 +7,6 @@ typedef uint64_t chunk_t; -#define CHUNK_SIZE 8 - #define HAVE_CHUNKMEMSET_4 #define HAVE_CHUNKMEMSET_8 diff --git a/arch/power/chunkset_power8.c b/arch/power/chunkset_power8.c index 673fe0e11..c7e560bb9 100644 --- a/arch/power/chunkset_power8.c +++ b/arch/power/chunkset_power8.c @@ -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 diff --git a/arch/riscv/chunkset_rvv.c b/arch/riscv/chunkset_rvv.c index 45ff8d333..c07d33007 100644 --- a/arch/riscv/chunkset_rvv.c +++ b/arch/riscv/chunkset_rvv.c @@ -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"