From: Ilya Leoshkevich Date: Tue, 21 May 2024 12:42:12 +0000 (+0200) Subject: Prepare DFLTCC changes for new malloc system X-Git-Tag: 2.2.0~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a55ec9aca9335402ddc310c32e0c35f0d6d33c4;p=thirdparty%2Fzlib-ng.git Prepare DFLTCC changes for new malloc system --- diff --git a/arch/s390/dfltcc_common.h b/arch/s390/dfltcc_common.h index 5acef291f..8aec9e945 100644 --- a/arch/s390/dfltcc_common.h +++ b/arch/s390/dfltcc_common.h @@ -95,6 +95,15 @@ void Z_INTERNAL PREFIX(dfltcc_free_window)(PREFIX3(streamp) strm, void *w); #define TRY_FREE_WINDOW PREFIX(dfltcc_free_window) +/* + History buffer size. + */ +#define HB_BITS 15 +#define HB_SIZE (1 << HB_BITS) + +/* + Sizes of deflate block parts. + */ #define DFLTCC_BLOCK_HEADER_BITS 3 #define DFLTCC_HLITS_COUNT_BITS 5 #define DFLTCC_HDISTS_COUNT_BITS 5 diff --git a/arch/s390/dfltcc_deflate.h b/arch/s390/dfltcc_deflate.h index 02c671420..35e2fd3f6 100644 --- a/arch/s390/dfltcc_deflate.h +++ b/arch/s390/dfltcc_deflate.h @@ -53,4 +53,6 @@ int Z_INTERNAL PREFIX(dfltcc_deflate_get_dictionary)(PREFIX3(streamp) strm, unsi #define DEFLATE_CAN_SET_REPRODUCIBLE PREFIX(dfltcc_can_set_reproducible) +#define DEFLATE_ADJUST_WINDOW_SIZE(n) MAX(n, HB_SIZE) + #endif diff --git a/arch/s390/dfltcc_detail.h b/arch/s390/dfltcc_detail.h index 497753069..ae6001ba3 100644 --- a/arch/s390/dfltcc_detail.h +++ b/arch/s390/dfltcc_detail.h @@ -100,8 +100,6 @@ typedef enum { #define DFLTCC_XPND 4 #define HBT_CIRCULAR (1 << 7) #define DFLTCC_FN_MASK ((1 << 7) - 1) -#define HB_BITS 15 -#define HB_SIZE (1 << HB_BITS) /* Return lengths of high (starting at param->ho) and low (starting at 0) fragments of the circular history buffer. */ static inline void get_history_lengths(struct dfltcc_param_v0 *param, size_t *hl_high, size_t *hl_low) { diff --git a/arch/s390/dfltcc_inflate.h b/arch/s390/dfltcc_inflate.h index 8fcab1d77..3623f8ed7 100644 --- a/arch/s390/dfltcc_inflate.h +++ b/arch/s390/dfltcc_inflate.h @@ -62,4 +62,6 @@ int Z_INTERNAL PREFIX(dfltcc_inflate_get_dictionary)(PREFIX3(streamp) strm, return PREFIX(dfltcc_inflate_get_dictionary)((strm), (dict), (dict_len)); \ } while (0) +#define INFLATE_ADJUST_WINDOW_SIZE(n) MAX(n, HB_SIZE) + #endif diff --git a/deflate.c b/deflate.c index b66255e91..696551ba7 100644 --- a/deflate.c +++ b/deflate.c @@ -75,6 +75,8 @@ const char PREFIX(deflate_copyright)[] = " deflate 1.3.1 Copyright 1995-2024 Jea /* Memory management for the window. Useful for allocation the aligned window. */ # define ZALLOC_WINDOW(strm, items, size) ZALLOC(strm, items, size) # define TRY_FREE_WINDOW(strm, addr) TRY_FREE(strm, addr) +/* Adjust the window size for the arch-specific deflate code. */ +# define DEFLATE_ADJUST_WINDOW_SIZE(n) (n) /* Invoked at the beginning of deflateSetDictionary(). Useful for checking arch-specific window data. */ # define DEFLATE_SET_DICTIONARY_HOOK(strm, dict, dict_len) do {} while (0) /* Invoked at the beginning of deflateGetDictionary(). Useful for adjusting arch-specific window data. */ diff --git a/inflate_p.h b/inflate_p.h index c3123931f..ce25531ee 100644 --- a/inflate_p.h +++ b/inflate_p.h @@ -15,6 +15,8 @@ # define ZALLOC_WINDOW(strm, items, size) ZALLOC(strm, items, size) # define ZCOPY_WINDOW(dest, src, n) memcpy(dest, src, n) # define ZFREE_WINDOW(strm, addr) ZFREE(strm, addr) +/* Adjust the window size for the arch-specific inflate code. */ +# define INFLATE_ADJUST_WINDOW_SIZE(n) (n) /* Invoked at the end of inflateResetKeep(). Useful for initializing arch-specific extension blocks. */ # define INFLATE_RESET_KEEP_HOOK(strm) do {} while (0) /* Invoked at the beginning of inflatePrime(). Useful for updating arch-specific buffers. */