Line | Count | Source |
1 | | #ifndef DEFLATE_H_ |
2 | | #define DEFLATE_H_ |
3 | | /* deflate.h -- internal compression state |
4 | | * Copyright (C) 1995-2026 Jean-loup Gailly |
5 | | * For conditions of distribution and use, see copyright notice in zlib.h |
6 | | */ |
7 | | |
8 | | /* WARNING: this file should *not* be used by applications. It is |
9 | | part of the implementation of the compression library and is |
10 | | subject to change. Applications should only use zlib.h. |
11 | | */ |
12 | | |
13 | | #include "zutil.h" |
14 | | #include "zendian.h" |
15 | | #include "zmemory.h" |
16 | | |
17 | | #ifdef S390_DFLTCC_DEFLATE |
18 | | # include "arch/s390/dfltcc_common.h" |
19 | | # define HAVE_ARCH_DEFLATE_STATE |
20 | | #endif |
21 | | |
22 | | /* define NO_GZIP when compiling if you want to disable gzip header and |
23 | | trailer creation by deflate(). NO_GZIP would be used to avoid linking in |
24 | | the crc code when it is not needed. For shared libraries, gzip encoding |
25 | | should be left enabled. */ |
26 | | #ifndef NO_GZIP |
27 | | # define GZIP |
28 | | #endif |
29 | | |
30 | | /* =========================================================================== |
31 | | * Internal compression state. |
32 | | */ |
33 | | |
34 | 8.17M | #define LENGTH_CODES 29 |
35 | | /* number of length codes, not counting the special END_BLOCK code */ |
36 | | |
37 | 16.5M | #define LITERALS 256 |
38 | | /* number of literal bytes 0..255 */ |
39 | | |
40 | 8.17M | #define L_CODES (LITERALS+1+LENGTH_CODES) |
41 | | /* number of Literal or Length codes, including the END_BLOCK code */ |
42 | | |
43 | 882k | #define D_CODES 30 |
44 | | /* number of distance codes */ |
45 | | |
46 | 592k | #define BL_CODES 19 |
47 | | /* number of codes used to transfer the bit lengths */ |
48 | | |
49 | | #define HEAP_SIZE (2*L_CODES+1) |
50 | | /* maximum heap size */ |
51 | | |
52 | 0 | #define BIT_BUF_SIZE 64 |
53 | | /* size of bit buffer in bi_buf */ |
54 | | |
55 | 28.4k | #define END_BLOCK 256 |
56 | | /* end of block literal code */ |
57 | | |
58 | 90.1k | #define INIT_STATE 1 /* zlib header -> BUSY_STATE */ |
59 | | #ifdef GZIP |
60 | 5.63k | # define GZIP_STATE 4 /* gzip header -> BUSY_STATE | EXTRA_STATE */ |
61 | 5.63k | # define EXTRA_STATE 5 /* gzip extra block -> NAME_STATE */ |
62 | 5.63k | # define NAME_STATE 6 /* gzip file name -> COMMENT_STATE */ |
63 | 5.63k | # define COMMENT_STATE 7 /* gzip comment -> HCRC_STATE */ |
64 | 28.1k | # define HCRC_STATE 8 /* gzip header CRC -> BUSY_STATE */ |
65 | | #endif |
66 | 33.7k | #define BUSY_STATE 2 /* deflate -> FINISH_STATE */ |
67 | 67.5k | #define FINISH_STATE 3 /* stream complete */ |
68 | | #ifdef GZIP |
69 | 22.5k | # define MAX_STATE HCRC_STATE |
70 | | #else |
71 | | # define MAX_STATE FINISH_STATE |
72 | | #endif |
73 | | /* Stream status */ |
74 | | |
75 | | #ifndef HASH_SIZE |
76 | 23.2k | # define HASH_SIZE 65536u /* number of elements in hash table */ |
77 | 223M | # define HASH_BITS 16u /* log2(HASH_SIZE) */ |
78 | | #else |
79 | | # if ((HASH_SIZE) & ((HASH_SIZE) - 1)) != 0 |
80 | | # error HASH_SIZE must be a perfect power of 2! |
81 | | # endif |
82 | | # if (HASH_SIZE) < 64u || (HASH_SIZE) > 524288u |
83 | | # error HASH_SIZE must be within 64-524288. Note that non-default sizes are not supported, and might not work correctly. |
84 | | # endif |
85 | | # define HASH_BITS ( \ |
86 | | (HASH_SIZE) == 64u ? 6u : \ |
87 | | (HASH_SIZE) == 128u ? 7u : \ |
88 | | (HASH_SIZE) == 256u ? 8u : \ |
89 | | (HASH_SIZE) == 512u ? 9u : \ |
90 | | (HASH_SIZE) == 1024u ? 10u : \ |
91 | | (HASH_SIZE) == 2048u ? 11u : \ |
92 | | (HASH_SIZE) == 4096u ? 12u : \ |
93 | | (HASH_SIZE) == 8192u ? 13u : \ |
94 | | (HASH_SIZE) == 16384u ? 14u : \ |
95 | | (HASH_SIZE) == 32768u ? 15u : \ |
96 | | (HASH_SIZE) == 65536u ? 16u : \ |
97 | | (HASH_SIZE) == 131072u ? 17u : \ |
98 | | (HASH_SIZE) == 262144u ? 18u : \ |
99 | | (HASH_SIZE) == 524288u ? 19u : 0u) |
100 | | #endif |
101 | | |
102 | | #define HASH_MASK (HASH_SIZE - 1u) /* HASH_SIZE-1 */ |
103 | | |
104 | 5.63k | #define MIN_ROLL_LEVEL 9 |
105 | | /* Levels at and above this use the rolling three-byte hash, which can find |
106 | | * minimum-length matches the four-byte Knuth hash cannot index. |
107 | | * |
108 | | * Every level at and above this must map to deflate_slow in configuration_table |
109 | | * to prevent the hash chains from mixing Knuth and rolling hashes. |
110 | | */ |
111 | | #if MIN_ROLL_LEVEL < 7 |
112 | | # error MIN_ROLL_LEVEL must only reach levels that map to deflate_slow |
113 | | #endif |
114 | | |
115 | | /* Data structure describing a single value and its code string. */ |
116 | | typedef struct ct_data_s { |
117 | | union { |
118 | | uint16_t freq; /* frequency count */ |
119 | | uint16_t code; /* bit string */ |
120 | | } fc; |
121 | | union { |
122 | | uint16_t dad; /* father node in Huffman tree */ |
123 | | uint16_t len; /* length of bit string */ |
124 | | } dl; |
125 | | } ct_data; |
126 | | |
127 | 227M | #define Freq fc.freq |
128 | 11.6M | #define Code fc.code |
129 | 13.7M | #define Dad dl.dad |
130 | 46.1M | #define Len dl.len |
131 | | |
132 | | typedef struct static_tree_desc_s static_tree_desc; |
133 | | |
134 | | typedef struct tree_desc_s { |
135 | | ct_data *dyn_tree; /* the dynamic tree */ |
136 | | int max_code; /* largest code with non zero frequency */ |
137 | | const static_tree_desc *stat_desc; /* the corresponding static tree */ |
138 | | } tree_desc; |
139 | | |
140 | | typedef uint16_t Pos; |
141 | | |
142 | | /* A Pos is an index in the character window. We use short instead of int to |
143 | | * save space in the various tables. |
144 | | */ |
145 | | /* Type definitions for hash callbacks */ |
146 | | typedef struct internal_state deflate_state; |
147 | | |
148 | | typedef void (* insert_batch_func) (deflate_state *const s, unsigned char *window, uint32_t str, uint32_t count); |
149 | | void insert_knuth_batch (deflate_state *const s, unsigned char *window, uint32_t str, uint32_t count); |
150 | | void insert_knuth_stepped (deflate_state *const s, unsigned char *window, uint32_t str, uint32_t count, uint32_t step); |
151 | | void insert_roll_batch (deflate_state *const s, unsigned char *window, uint32_t str, uint32_t count); |
152 | | void insert_knuth_batch_head (deflate_state *const s, unsigned char *window, uint32_t str, uint32_t count); |
153 | | |
154 | | /* Match function. Returns the longest match. */ |
155 | | typedef uint32_t (* longest_match_func) (deflate_state *const s, uint32_t cur_match); |
156 | | |
157 | | /* Struct for memory allocation handling */ |
158 | | typedef struct deflate_allocs_s { |
159 | | char *buf_start; |
160 | | free_func zfree; |
161 | | deflate_state *state; |
162 | | unsigned char *window; |
163 | | unsigned char *pending_buf; |
164 | | Pos *prev; |
165 | | Pos *head; |
166 | | } deflate_allocs; |
167 | | |
168 | | struct ALIGNED_(64) internal_state { |
169 | | /* Cacheline 0 */ |
170 | | PREFIX3(stream) *strm; /* pointer back to this zlib stream */ |
171 | | unsigned char *pending_buf; /* output still pending */ |
172 | | unsigned char *pending_out; /* next pending byte to output to the stream */ |
173 | | uint32_t pending_buf_size; /* size of pending_buf */ |
174 | | uint32_t pending; /* nb of bytes in the pending buffer */ |
175 | | int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ |
176 | | uint32_t gzindex; /* where in extra, name, or comment */ |
177 | | PREFIX(gz_headerp) gzhead; /* gzip header information to write */ |
178 | | int status; /* as the name implies */ |
179 | | int last_flush; /* value of flush param for previous deflate call */ |
180 | | int reproducible; /* Whether reproducible compression results are required. */ |
181 | | |
182 | | unsigned int block_open; |
183 | | /* Whether or not a block is currently open for the QUICK deflation scheme. |
184 | | * This is set to 1 if there is an active block, or 0 if the block was just closed. |
185 | | */ |
186 | | |
187 | | /* Cacheline 1 */ |
188 | | |
189 | | unsigned int lookahead; /* number of valid bytes ahead in window */ |
190 | | unsigned int strstart; /* start of string to insert */ |
191 | | unsigned int w_size; /* LZ77 window size (32K by default) */ |
192 | | |
193 | | int block_start; /* Window position at the beginning of the current output block. |
194 | | * Gets negative when the window is moved backwards. */ |
195 | | |
196 | | unsigned int high_water; |
197 | | /* High water mark offset in window for initialized bytes -- bytes above |
198 | | * this are set to zero in order to avoid memory check warnings when |
199 | | * longest match routines access bytes past the input. This is then |
200 | | * updated to the new high water mark. |
201 | | */ |
202 | | |
203 | | unsigned int window_size; |
204 | | /* Actual size of the window buffer: W_BUF_SIZE, except when the user |
205 | | * input buffer is directly used as sliding window. |
206 | | */ |
207 | | |
208 | | unsigned char *window; |
209 | | /* Sliding window. Input bytes are read into the free space at the end of |
210 | | * the buffer, and move down later to keep a dictionary of at least wSize |
211 | | * bytes. With this organization, matches are limited to a distance of |
212 | | * wSize-STD_MAX_MATCH bytes, but this ensures that IO is always |
213 | | * performed with a length multiple of the block size. Also, it limits |
214 | | * the window size to 64K, which is quite useful on MSDOS. |
215 | | * To do: use the user input buffer as sliding window. |
216 | | */ |
217 | | |
218 | | Pos *prev; |
219 | | /* Link to older string with same hash index. To limit the size of this |
220 | | * array to 64K, this link is maintained only for the last 32K strings. |
221 | | * An index in this array is thus a window index modulo 32K. |
222 | | */ |
223 | | |
224 | | Pos *head; /* Heads of the hash chains or 0. */ |
225 | | |
226 | | uint32_t ins_h; /* hash index of string to be inserted */ |
227 | | |
228 | | unsigned int match_length; /* length of best match */ |
229 | | int match_available; /* set if previous match exists */ |
230 | | uint32_t prev_match; /* previous match (used by deflate_slow) */ |
231 | | |
232 | | /* Cacheline 2 */ |
233 | | |
234 | | unsigned int match_start; /* start of matching string */ |
235 | | |
236 | | unsigned int prev_length; |
237 | | /* Length of the best match at previous step. Matches not greater than this |
238 | | * are discarded. This is used in the lazy match evaluation. |
239 | | */ |
240 | | |
241 | | unsigned int max_chain_length; |
242 | | /* To speed up deflation, hash chains are never searched beyond this length. |
243 | | * A higher limit improves compression ratio but degrades the speed. |
244 | | */ |
245 | | |
246 | | unsigned int max_lazy_match; |
247 | | /* Attempt to find a better match only when the current match is strictly smaller |
248 | | * than this value. This mechanism is used only for compression levels >= 4. |
249 | | */ |
250 | 8.31M | # define max_insert_count max_lazy_match |
251 | | /* Limit number of hash inserts, saving time but sacrificing compression. |
252 | | * Used by deflate_fast and deflate_medium. |
253 | | */ |
254 | | |
255 | | int level; /* compression level (1..9) */ |
256 | | int strategy; /* favor or force Huffman coding*/ |
257 | | unsigned int good_match; /* Use a faster search when the previous match is longer than this */ |
258 | | int nice_match; /* Stop searching when current match exceeds this */ |
259 | | unsigned int insert; /* bytes at end of window left to insert */ |
260 | | |
261 | | int32_t bi_used; /* Last number of used bits when going to a byte boundary. */ |
262 | | uint64_t bi_buf; /* Output buffer. |
263 | | * Bits are inserted starting at the bottom (least significant bits). */ |
264 | | int32_t bi_valid; /* Number of valid bits in bi_buf. |
265 | | * All bits above the last valid bit are always zero. */ |
266 | | |
267 | | int32_t padding[2]; /* Keeps Cacheline 3 aligned */ |
268 | | |
269 | | /* used by trees.c: */ |
270 | | unsigned int lit_bufsize; |
271 | | /* Size of match buffer for literals/lengths. There are 4 reasons for |
272 | | * limiting lit_bufsize to 64K: |
273 | | * - frequencies can be kept in 16 bit counters |
274 | | * - if compression is not successful for the first block, all input |
275 | | * data is still in the window so we can still emit a stored block even |
276 | | * when input comes from standard input. (This can also be done for |
277 | | * all blocks if lit_bufsize is not greater than 32K.) |
278 | | * - if compression is not successful for a file smaller than 64K, we can |
279 | | * even emit a stored file instead of a stored block (saving 5 bytes). |
280 | | * This is applicable only for zip (not gzip or zlib). |
281 | | * - creating new Huffman trees less frequently may not provide fast |
282 | | * adaptation to changes in the input data statistics. (Take for |
283 | | * example a binary file with poorly compressible code followed by |
284 | | * a highly compressible string table.) Smaller buffer sizes give |
285 | | * fast adaptation but have of course the overhead of transmitting |
286 | | * trees more frequently. |
287 | | * - I can't count above 4 |
288 | | */ |
289 | | |
290 | | /* Cacheline 3 */ |
291 | | |
292 | | unsigned char *sym_buf; /* buffer for distances and literals/lengths */ |
293 | | unsigned int sym_next; /* running index in symbol buffer */ |
294 | | unsigned int sym_end; /* symbol table full when sym_next reaches this */ |
295 | | |
296 | | unsigned int opt_len; /* bit length of current block with optimal trees */ |
297 | | unsigned int static_len; /* bit length of current block with static trees */ |
298 | | |
299 | | struct tree_desc_s l_desc; /* desc. for literal tree */ |
300 | | struct tree_desc_s d_desc; /* desc. for distance tree */ |
301 | | struct tree_desc_s bl_desc; /* desc. for bit length tree */ |
302 | | |
303 | | uint16_t bl_count[MAX_BITS+1]; |
304 | | /* number of codes at each bit length for an optimal tree */ |
305 | | |
306 | | uint32_t pq_leaves[L_CODES+1]; /* build_tree() packed leaf entries */ |
307 | | uint32_t pq_scratch[L_CODES+1]; /* build_tree() radix buffer and internal node FIFO */ |
308 | | |
309 | | /* Didn't use ct_data typedef below to suppress compiler warning */ |
310 | | struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ |
311 | | struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ |
312 | | struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ |
313 | | |
314 | | deflate_allocs *alloc_bufs; |
315 | | |
316 | | #ifdef HAVE_ARCH_DEFLATE_STATE |
317 | | arch_deflate_state arch; /* architecture-specific extensions */ |
318 | | #endif |
319 | | |
320 | | /* compressed_len and bits_sent are only used if ZLIB_DEBUG is defined */ |
321 | | #ifdef ZLIB_DEBUG |
322 | | unsigned long compressed_len; /* total bit length of compressed file mod 2^32 */ |
323 | | unsigned long bits_sent; /* bit length of compressed data sent mod 2^32 */ |
324 | | #endif |
325 | | |
326 | | /* Level-selected function variants, set by lm_set_level() */ |
327 | | longest_match_func longest_match; |
328 | | insert_batch_func insert_batch; |
329 | | |
330 | | uint32_t slide_len; |
331 | | /* Number of bytes the window was moved down by the last slide. Always a |
332 | | * multiple of w_size so prev slots keep their positions. |
333 | | */ |
334 | | |
335 | | uint32_t fill_end; |
336 | | /* Where a 2 * w_size buffer would end its data, minus MIN_LOOKAHEAD. Reads stop there so |
337 | | * refills happen at the same positions as with a 2 * w_size buffer. |
338 | | */ |
339 | | |
340 | | /* Reserved for future use and alignment purposes */ |
341 | | int32_t reserved[18]; |
342 | | }; |
343 | | |
344 | | typedef enum { |
345 | | need_more, /* block not completed, need more input or more output */ |
346 | | block_done, /* block flush performed */ |
347 | | finish_started, /* finish started, need only more output at next deflate */ |
348 | | finish_done /* finish done, accept no more input or output */ |
349 | | } block_state; |
350 | | |
351 | | /* Output a byte on the stream. |
352 | | * IN assertion: there is enough room in pending_buf. |
353 | | */ |
354 | 16.7k | #define put_byte(s, c) { \ |
355 | 16.7k | s->pending_buf[s->pending++] = (unsigned char)(c); \ |
356 | 16.7k | } |
357 | | |
358 | | /* =========================================================================== |
359 | | * Output a short LSB first on the stream. |
360 | | * IN assertion: there is enough room in pending_buf. |
361 | | */ |
362 | 36.3k | static inline void put_short(deflate_state *s, uint16_t w) { |
363 | 36.3k | w = Z_U16_TO_LE(w); |
364 | 36.3k | zng_memwrite_2(&s->pending_buf[s->pending], w); |
365 | 36.3k | s->pending += 2; |
366 | 36.3k | } Unexecuted instantiation: deflate.c:put_short Unexecuted instantiation: deflate_fast.c:put_short Unexecuted instantiation: deflate_huff.c:put_short Unexecuted instantiation: deflate_medium.c:put_short Unexecuted instantiation: deflate_quick.c:put_short Unexecuted instantiation: deflate_rle.c:put_short Unexecuted instantiation: deflate_slow.c:put_short Unexecuted instantiation: deflate_stored.c:put_short Unexecuted instantiation: functable.c:put_short Unexecuted instantiation: inflate.c:put_short Unexecuted instantiation: insert_string.c:put_short Line | Count | Source | 362 | 36.3k | static inline void put_short(deflate_state *s, uint16_t w) { | 363 | 36.3k | w = Z_U16_TO_LE(w); | 364 | 36.3k | zng_memwrite_2(&s->pending_buf[s->pending], w); | 365 | 36.3k | s->pending += 2; | 366 | 36.3k | } |
Unexecuted instantiation: chunkset_sse2.c:put_short Unexecuted instantiation: compare256_sse2.c:put_short Unexecuted instantiation: crc32_chorba_sse2.c:put_short Unexecuted instantiation: slide_hash_sse2.c:put_short Unexecuted instantiation: chunkset_ssse3.c:put_short Unexecuted instantiation: crc32_chorba_sse41.c:put_short Unexecuted instantiation: slide_hash_avx2.c:put_short Unexecuted instantiation: chunkset_avx2.c:put_short Unexecuted instantiation: compare256_avx2.c:put_short Unexecuted instantiation: adler32_avx2_vnni.c:put_short Unexecuted instantiation: adler32_avx512.c:put_short Unexecuted instantiation: chunkset_avx512.c:put_short Unexecuted instantiation: compare256_avx512.c:put_short Unexecuted instantiation: adler32_avx512_vnni.c:put_short Unexecuted instantiation: adler32_c.c:put_short Unexecuted instantiation: crc32_chorba_c.c:put_short Unexecuted instantiation: crc32.c:put_short |
367 | | |
368 | | /* =========================================================================== |
369 | | * Output a short MSB first on the stream. |
370 | | * IN assertion: there is enough room in pending_buf. |
371 | | */ |
372 | 5.63k | static inline void put_short_msb(deflate_state *s, uint16_t w) { |
373 | 5.63k | w = Z_U16_TO_BE(w); |
374 | 5.63k | zng_memwrite_2(&s->pending_buf[s->pending], w); |
375 | 5.63k | s->pending += 2; |
376 | 5.63k | } Line | Count | Source | 372 | 5.63k | static inline void put_short_msb(deflate_state *s, uint16_t w) { | 373 | 5.63k | w = Z_U16_TO_BE(w); | 374 | 5.63k | zng_memwrite_2(&s->pending_buf[s->pending], w); | 375 | 5.63k | s->pending += 2; | 376 | 5.63k | } |
Unexecuted instantiation: deflate_fast.c:put_short_msb Unexecuted instantiation: deflate_huff.c:put_short_msb Unexecuted instantiation: deflate_medium.c:put_short_msb Unexecuted instantiation: deflate_quick.c:put_short_msb Unexecuted instantiation: deflate_rle.c:put_short_msb Unexecuted instantiation: deflate_slow.c:put_short_msb Unexecuted instantiation: deflate_stored.c:put_short_msb Unexecuted instantiation: functable.c:put_short_msb Unexecuted instantiation: inflate.c:put_short_msb Unexecuted instantiation: insert_string.c:put_short_msb Unexecuted instantiation: trees.c:put_short_msb Unexecuted instantiation: chunkset_sse2.c:put_short_msb Unexecuted instantiation: compare256_sse2.c:put_short_msb Unexecuted instantiation: crc32_chorba_sse2.c:put_short_msb Unexecuted instantiation: slide_hash_sse2.c:put_short_msb Unexecuted instantiation: chunkset_ssse3.c:put_short_msb Unexecuted instantiation: crc32_chorba_sse41.c:put_short_msb Unexecuted instantiation: slide_hash_avx2.c:put_short_msb Unexecuted instantiation: chunkset_avx2.c:put_short_msb Unexecuted instantiation: compare256_avx2.c:put_short_msb Unexecuted instantiation: adler32_avx2_vnni.c:put_short_msb Unexecuted instantiation: adler32_avx512.c:put_short_msb Unexecuted instantiation: chunkset_avx512.c:put_short_msb Unexecuted instantiation: compare256_avx512.c:put_short_msb Unexecuted instantiation: adler32_avx512_vnni.c:put_short_msb Unexecuted instantiation: adler32_c.c:put_short_msb Unexecuted instantiation: crc32_chorba_c.c:put_short_msb Unexecuted instantiation: crc32.c:put_short_msb |
377 | | |
378 | | /* =========================================================================== |
379 | | * Output a 32-bit unsigned int LSB first on the stream. |
380 | | * IN assertion: there is enough room in pending_buf. |
381 | | */ |
382 | 1.51k | static inline void put_uint32(deflate_state *s, uint32_t dw) { |
383 | 1.51k | dw = Z_U32_TO_LE(dw); |
384 | 1.51k | zng_memwrite_4(&s->pending_buf[s->pending], dw); |
385 | 1.51k | s->pending += 4; |
386 | 1.51k | } Unexecuted instantiation: deflate.c:put_uint32 Unexecuted instantiation: deflate_fast.c:put_uint32 Unexecuted instantiation: deflate_huff.c:put_uint32 Unexecuted instantiation: deflate_medium.c:put_uint32 Unexecuted instantiation: deflate_quick.c:put_uint32 Unexecuted instantiation: deflate_rle.c:put_uint32 Unexecuted instantiation: deflate_slow.c:put_uint32 Unexecuted instantiation: deflate_stored.c:put_uint32 Unexecuted instantiation: functable.c:put_uint32 Unexecuted instantiation: inflate.c:put_uint32 Unexecuted instantiation: insert_string.c:put_uint32 Line | Count | Source | 382 | 1.51k | static inline void put_uint32(deflate_state *s, uint32_t dw) { | 383 | 1.51k | dw = Z_U32_TO_LE(dw); | 384 | 1.51k | zng_memwrite_4(&s->pending_buf[s->pending], dw); | 385 | 1.51k | s->pending += 4; | 386 | 1.51k | } |
Unexecuted instantiation: chunkset_sse2.c:put_uint32 Unexecuted instantiation: compare256_sse2.c:put_uint32 Unexecuted instantiation: crc32_chorba_sse2.c:put_uint32 Unexecuted instantiation: slide_hash_sse2.c:put_uint32 Unexecuted instantiation: chunkset_ssse3.c:put_uint32 Unexecuted instantiation: crc32_chorba_sse41.c:put_uint32 Unexecuted instantiation: slide_hash_avx2.c:put_uint32 Unexecuted instantiation: chunkset_avx2.c:put_uint32 Unexecuted instantiation: compare256_avx2.c:put_uint32 Unexecuted instantiation: adler32_avx2_vnni.c:put_uint32 Unexecuted instantiation: adler32_avx512.c:put_uint32 Unexecuted instantiation: chunkset_avx512.c:put_uint32 Unexecuted instantiation: compare256_avx512.c:put_uint32 Unexecuted instantiation: adler32_avx512_vnni.c:put_uint32 Unexecuted instantiation: adler32_c.c:put_uint32 Unexecuted instantiation: crc32_chorba_c.c:put_uint32 Unexecuted instantiation: crc32.c:put_uint32 |
387 | | |
388 | | /* =========================================================================== |
389 | | * Output a 32-bit unsigned int MSB first on the stream. |
390 | | * IN assertion: there is enough room in pending_buf. |
391 | | */ |
392 | 5.63k | static inline void put_uint32_msb(deflate_state *s, uint32_t dw) { |
393 | 5.63k | dw = Z_U32_TO_BE(dw); |
394 | 5.63k | zng_memwrite_4(&s->pending_buf[s->pending], dw); |
395 | 5.63k | s->pending += 4; |
396 | 5.63k | } Line | Count | Source | 392 | 5.63k | static inline void put_uint32_msb(deflate_state *s, uint32_t dw) { | 393 | 5.63k | dw = Z_U32_TO_BE(dw); | 394 | 5.63k | zng_memwrite_4(&s->pending_buf[s->pending], dw); | 395 | 5.63k | s->pending += 4; | 396 | 5.63k | } |
Unexecuted instantiation: deflate_fast.c:put_uint32_msb Unexecuted instantiation: deflate_huff.c:put_uint32_msb Unexecuted instantiation: deflate_medium.c:put_uint32_msb Unexecuted instantiation: deflate_quick.c:put_uint32_msb Unexecuted instantiation: deflate_rle.c:put_uint32_msb Unexecuted instantiation: deflate_slow.c:put_uint32_msb Unexecuted instantiation: deflate_stored.c:put_uint32_msb Unexecuted instantiation: functable.c:put_uint32_msb Unexecuted instantiation: inflate.c:put_uint32_msb Unexecuted instantiation: insert_string.c:put_uint32_msb Unexecuted instantiation: trees.c:put_uint32_msb Unexecuted instantiation: chunkset_sse2.c:put_uint32_msb Unexecuted instantiation: compare256_sse2.c:put_uint32_msb Unexecuted instantiation: crc32_chorba_sse2.c:put_uint32_msb Unexecuted instantiation: slide_hash_sse2.c:put_uint32_msb Unexecuted instantiation: chunkset_ssse3.c:put_uint32_msb Unexecuted instantiation: crc32_chorba_sse41.c:put_uint32_msb Unexecuted instantiation: slide_hash_avx2.c:put_uint32_msb Unexecuted instantiation: chunkset_avx2.c:put_uint32_msb Unexecuted instantiation: compare256_avx2.c:put_uint32_msb Unexecuted instantiation: adler32_avx2_vnni.c:put_uint32_msb Unexecuted instantiation: adler32_avx512.c:put_uint32_msb Unexecuted instantiation: chunkset_avx512.c:put_uint32_msb Unexecuted instantiation: compare256_avx512.c:put_uint32_msb Unexecuted instantiation: adler32_avx512_vnni.c:put_uint32_msb Unexecuted instantiation: adler32_c.c:put_uint32_msb Unexecuted instantiation: crc32_chorba_c.c:put_uint32_msb Unexecuted instantiation: crc32.c:put_uint32_msb |
397 | | |
398 | | /* =========================================================================== |
399 | | * Output a 64-bit unsigned int LSB first on the stream. |
400 | | * IN assertion: there is enough room in pending_buf. |
401 | | */ |
402 | 87.6k | static inline void put_uint64(deflate_state *s, uint64_t lld) { |
403 | 87.6k | lld = Z_U64_TO_LE(lld); |
404 | 87.6k | zng_memwrite_8(&s->pending_buf[s->pending], lld); |
405 | 87.6k | s->pending += 8; |
406 | 87.6k | } Unexecuted instantiation: deflate.c:put_uint64 Unexecuted instantiation: deflate_fast.c:put_uint64 Unexecuted instantiation: deflate_huff.c:put_uint64 Unexecuted instantiation: deflate_medium.c:put_uint64 Unexecuted instantiation: deflate_quick.c:put_uint64 Unexecuted instantiation: deflate_rle.c:put_uint64 Unexecuted instantiation: deflate_slow.c:put_uint64 Unexecuted instantiation: deflate_stored.c:put_uint64 Unexecuted instantiation: functable.c:put_uint64 Unexecuted instantiation: inflate.c:put_uint64 Unexecuted instantiation: insert_string.c:put_uint64 Line | Count | Source | 402 | 87.6k | static inline void put_uint64(deflate_state *s, uint64_t lld) { | 403 | 87.6k | lld = Z_U64_TO_LE(lld); | 404 | 87.6k | zng_memwrite_8(&s->pending_buf[s->pending], lld); | 405 | 87.6k | s->pending += 8; | 406 | 87.6k | } |
Unexecuted instantiation: chunkset_sse2.c:put_uint64 Unexecuted instantiation: compare256_sse2.c:put_uint64 Unexecuted instantiation: crc32_chorba_sse2.c:put_uint64 Unexecuted instantiation: slide_hash_sse2.c:put_uint64 Unexecuted instantiation: chunkset_ssse3.c:put_uint64 Unexecuted instantiation: crc32_chorba_sse41.c:put_uint64 Unexecuted instantiation: slide_hash_avx2.c:put_uint64 Unexecuted instantiation: chunkset_avx2.c:put_uint64 Unexecuted instantiation: compare256_avx2.c:put_uint64 Unexecuted instantiation: adler32_avx2_vnni.c:put_uint64 Unexecuted instantiation: adler32_avx512.c:put_uint64 Unexecuted instantiation: chunkset_avx512.c:put_uint64 Unexecuted instantiation: compare256_avx512.c:put_uint64 Unexecuted instantiation: adler32_avx512_vnni.c:put_uint64 Unexecuted instantiation: adler32_c.c:put_uint64 Unexecuted instantiation: crc32_chorba_c.c:put_uint64 Unexecuted instantiation: crc32.c:put_uint64 |
407 | | |
408 | 134M | #define MIN_LOOKAHEAD (STD_MAX_MATCH + STD_MIN_MATCH + 1) |
409 | | /* Minimum amount of lookahead, except at the end of the input file. |
410 | | * See deflate.c for comments about the STD_MIN_MATCH+1. |
411 | | */ |
412 | | |
413 | 133M | #define MAX_DIST(s) ((s)->w_size - MIN_LOOKAHEAD) |
414 | | /* In order to simplify the code, particularly on 16 bit machines, match |
415 | | * distances are limited to MAX_DIST instead of WSIZE. |
416 | | */ |
417 | | |
418 | 271M | #define W_MASK(s) ((s)->w_size - 1) |
419 | | /* Window mask: w_size is always a power of 2, so w_mask = w_size - 1 */ |
420 | | |
421 | | #ifndef W_BUF_MIN |
422 | | # define W_BUF_MIN 32768 |
423 | | #endif |
424 | | /* Smallest physical window buffer. WITH_REDUCED_MEM lowers it to 8K. */ |
425 | | |
426 | 5.63k | #define W_BUF_SIZE(wsize) MAX(2 * (wsize), W_BUF_MIN) |
427 | | /* Size of the physical window buffer. By default, it is at least 32K so small |
428 | | * compression windows slide rarely instead of every w_size bytes. 16-bit head |
429 | | * and prev entries cap the buffer at 64K. |
430 | | */ |
431 | | |
432 | 5.63k | #define W_BITS(s) zng_ctz32((s)->w_size) |
433 | | /* Window bits: log2(w_size), computed from w_size since w_size is a power of 2 */ |
434 | | |
435 | 369k | #define WIN_INIT STD_MAX_MATCH |
436 | | /* Number of bytes after end of data in window to initialize in order to avoid |
437 | | memory checker errors from longest match routines */ |
438 | | |
439 | | |
440 | | void Z_INTERNAL PREFIX(fill_window)(deflate_state *s); |
441 | | void Z_INTERNAL slide_hash_c(deflate_state *s); |
442 | | void Z_INTERNAL slide_hash_head_c(deflate_state *s); |
443 | | |
444 | | /* in trees.c */ |
445 | | void Z_INTERNAL zng_tr_init(deflate_state *s); |
446 | | void Z_INTERNAL zng_tr_flush_block(deflate_state *s, unsigned char *buf, uint32_t stored_len, int last); |
447 | | void Z_INTERNAL zng_tr_flush_bits(deflate_state *s); |
448 | | void Z_INTERNAL zng_tr_align(deflate_state *s); |
449 | | void Z_INTERNAL zng_tr_stored_block(deflate_state *s, unsigned char *buf, uint32_t stored_len, int last); |
450 | | void Z_INTERNAL PREFIX(flush_pending)(PREFIX3(streamp) strm); |
451 | 8.13M | #define d_code(dist) ((dist) < 256 ? zng_dist_code[dist] : zng_dist_code[256+((dist)>>7)]) |
452 | | /* Mapping from a distance to a distance code. dist is the distance - 1 and |
453 | | * must not have side effects. zng_dist_code[256] and zng_dist_code[257] are never |
454 | | * used. |
455 | | */ |
456 | | |
457 | | /* Bit buffer and compress bits calculation debugging */ |
458 | | #ifdef ZLIB_DEBUG |
459 | | # define cmpr_bits_add(s, len) s->compressed_len += (len) |
460 | | # define cmpr_bits_align(s) s->compressed_len = ALIGN_UP(s->compressed_len, 8) |
461 | | # define sent_bits_add(s, bits) s->bits_sent += (bits) |
462 | | # define sent_bits_align(s) s->bits_sent = ALIGN_UP(s->bits_sent, 8) |
463 | | #else |
464 | 60.6k | # define cmpr_bits_add(s, len) Z_UNUSED(len) |
465 | | # define cmpr_bits_align(s) |
466 | 142M | # define sent_bits_add(s, bits) Z_UNUSED(bits) |
467 | | # define sent_bits_align(s) |
468 | | #endif |
469 | | |
470 | | /* =========================================================================== |
471 | | * Architecture-specific hooks. |
472 | | */ |
473 | | #ifdef S390_DFLTCC_DEFLATE |
474 | | # include "arch/s390/dfltcc_deflate.h" |
475 | | /* DFLTCC instructions require window to be page-aligned */ |
476 | | # define PAD_WINDOW PAD_4096 |
477 | | # define WINDOW_PAD_SIZE 4096 |
478 | | # define HINT_ALIGNED_WINDOW HINT_ALIGNED_4096 |
479 | | #else |
480 | 11.2k | # define PAD_WINDOW PAD_64 |
481 | | # define WINDOW_PAD_SIZE 64 |
482 | 22.5k | # define HINT_ALIGNED_WINDOW HINT_ALIGNED_64 |
483 | | /* Adjust the window size for the arch-specific deflate code. */ |
484 | 11.2k | # define DEFLATE_ADJUST_WINDOW_SIZE(n) (n) |
485 | | /* Invoked at the beginning of deflateSetDictionary(). Useful for checking arch-specific window data. */ |
486 | 0 | # define DEFLATE_SET_DICTIONARY_HOOK(strm, dict, dict_len) do {} while (0) |
487 | | /* Invoked at the beginning of deflateGetDictionary(). Useful for adjusting arch-specific window data. */ |
488 | 0 | # define DEFLATE_GET_DICTIONARY_HOOK(strm, dict, dict_len) do {} while (0) |
489 | | /* Invoked at the end of deflateResetKeep(). Useful for initializing arch-specific extension blocks. */ |
490 | 5.63k | # define DEFLATE_RESET_KEEP_HOOK(strm) do {} while (0) |
491 | | /* Invoked at the beginning of deflateParams(). Useful for updating arch-specific compression parameters. */ |
492 | 0 | # define DEFLATE_PARAMS_HOOK(strm, level, strategy, hook_flush) do {} while (0) |
493 | | /* Returns whether the last deflate(flush) operation did everything it's supposed to do. */ |
494 | 0 | # define DEFLATE_DONE(strm, flush) 1 |
495 | | /* Adjusts the upper bound on compressed data length based on compression parameters and uncompressed data length. |
496 | | * Useful when arch-specific deflation code behaves differently than regular zlib-ng algorithms. */ |
497 | 0 | # define DEFLATE_BOUND_ADJUST_COMPLEN(strm, complen, sourceLen) do {} while (0) |
498 | | /* Returns whether an optimistic upper bound on compressed data length should *not* be used. |
499 | | * Useful when arch-specific deflation code behaves differently than regular zlib-ng algorithms. */ |
500 | 0 | # define DEFLATE_NEED_CONSERVATIVE_BOUND(strm) 0 |
501 | | /* Invoked for each deflate() call. Useful for plugging arch-specific deflation code. */ |
502 | 11.2k | # define DEFLATE_HOOK(strm, flush, bstate) 0 |
503 | | /* Returns whether zlib-ng should compute a checksum. Set to 0 if arch-specific deflation code already does that. */ |
504 | 17.3k | # define DEFLATE_NEED_CHECKSUM(strm) 1 |
505 | | /* Returns whether reproducibility parameter can be set to a given value. */ |
506 | 0 | # define DEFLATE_CAN_SET_REPRODUCIBLE(strm, reproducible) 1 |
507 | | #endif |
508 | | |
509 | | #endif /* DEFLATE_H_ */ |