Line | Count | Source |
1 | | #ifndef DEFLATE_H_ |
2 | | #define DEFLATE_H_ |
3 | | /* deflate.h -- internal compression state |
4 | | * Copyright (C) 1995-2016 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 | | /* LIT_MEM uses separate distance/length buffers instead of the overlaid sym_buf. |
31 | | This uses ~20% more memory but is 1-2% faster on platforms without fast unaligned |
32 | | access. By default, LIT_MEM is only enabled when OPTIMAL_CMP < 32. Define LIT_MEM |
33 | | to force separate buffers, or NO_LIT_MEM to force sym_buf usage. */ |
34 | | #if !defined(LIT_MEM) && !defined(NO_LIT_MEM) && (OPTIMAL_CMP < 32) |
35 | | # define LIT_MEM |
36 | | #endif |
37 | | |
38 | | /* =========================================================================== |
39 | | * Internal compression state. |
40 | | */ |
41 | | |
42 | 1.38M | #define LENGTH_CODES 29 |
43 | | /* number of length codes, not counting the special END_BLOCK code */ |
44 | | |
45 | 4.79M | #define LITERALS 256 |
46 | | /* number of literal bytes 0..255 */ |
47 | | |
48 | 1.38M | #define L_CODES (LITERALS+1+LENGTH_CODES) |
49 | | /* number of Literal or Length codes, including the END_BLOCK code */ |
50 | | |
51 | 142k | #define D_CODES 30 |
52 | | /* number of distance codes */ |
53 | | |
54 | 95.2k | #define BL_CODES 19 |
55 | | /* number of codes used to transfer the bit lengths */ |
56 | | |
57 | 57.9k | #define HEAP_SIZE (2*L_CODES+1) |
58 | | /* maximum heap size */ |
59 | | |
60 | 5.58M | #define BIT_BUF_SIZE 64 |
61 | | /* size of bit buffer in bi_buf */ |
62 | | |
63 | 4.60k | #define END_BLOCK 256 |
64 | | /* end of block literal code */ |
65 | | |
66 | 55.2k | #define INIT_STATE 1 /* zlib header -> BUSY_STATE */ |
67 | | #ifdef GZIP |
68 | 1.53k | # define GZIP_STATE 4 /* gzip header -> BUSY_STATE | EXTRA_STATE */ |
69 | 1.53k | # define EXTRA_STATE 5 /* gzip extra block -> NAME_STATE */ |
70 | 1.53k | # define NAME_STATE 6 /* gzip file name -> COMMENT_STATE */ |
71 | 1.53k | # define COMMENT_STATE 7 /* gzip comment -> HCRC_STATE */ |
72 | 16.8k | # define HCRC_STATE 8 /* gzip header CRC -> BUSY_STATE */ |
73 | | #endif |
74 | 21.5k | #define BUSY_STATE 2 /* deflate -> FINISH_STATE */ |
75 | 50.6k | #define FINISH_STATE 3 /* stream complete */ |
76 | | #ifdef GZIP |
77 | 15.3k | # define MAX_STATE HCRC_STATE |
78 | | #else |
79 | | # define MAX_STATE FINISH_STATE |
80 | | #endif |
81 | | /* Stream status */ |
82 | | |
83 | 0 | #define HASH_BITS 16u /* log2(HASH_SIZE) */ |
84 | | #ifndef HASH_SIZE |
85 | 15.1k | # define HASH_SIZE 65536u /* number of elements in hash table */ |
86 | | #endif |
87 | 0 | #define HASH_MASK (HASH_SIZE - 1u) /* HASH_SIZE-1 */ |
88 | | |
89 | | |
90 | | /* Data structure describing a single value and its code string. */ |
91 | | typedef struct ct_data_s { |
92 | | union { |
93 | | uint16_t freq; /* frequency count */ |
94 | | uint16_t code; /* bit string */ |
95 | | } fc; |
96 | | union { |
97 | | uint16_t dad; /* father node in Huffman tree */ |
98 | | uint16_t len; /* length of bit string */ |
99 | | } dl; |
100 | | } ct_data; |
101 | | |
102 | 6.38M | #define Freq fc.freq |
103 | 3.44M | #define Code fc.code |
104 | 79.0k | #define Dad dl.dad |
105 | 7.13M | #define Len dl.len |
106 | | |
107 | | typedef struct static_tree_desc_s static_tree_desc; |
108 | | |
109 | | typedef struct tree_desc_s { |
110 | | ct_data *dyn_tree; /* the dynamic tree */ |
111 | | int max_code; /* largest code with non zero frequency */ |
112 | | const static_tree_desc *stat_desc; /* the corresponding static tree */ |
113 | | } tree_desc; |
114 | | |
115 | | typedef uint16_t Pos; |
116 | | |
117 | | /* A Pos is an index in the character window. We use short instead of int to |
118 | | * save space in the various tables. |
119 | | */ |
120 | | /* Type definitions for hash callbacks */ |
121 | | typedef struct internal_state deflate_state; |
122 | | |
123 | | typedef void (* insert_string_cb) (deflate_state *const s, unsigned char *window, uint32_t str, uint32_t count); |
124 | | void insert_string (deflate_state *const s, unsigned char *window, uint32_t str, uint32_t count); |
125 | | void insert_string_roll (deflate_state *const s, unsigned char *window, uint32_t str, uint32_t count); |
126 | | |
127 | | /* Struct for memory allocation handling */ |
128 | | typedef struct deflate_allocs_s { |
129 | | char *buf_start; |
130 | | free_func zfree; |
131 | | deflate_state *state; |
132 | | unsigned char *window; |
133 | | unsigned char *pending_buf; |
134 | | Pos *prev; |
135 | | Pos *head; |
136 | | } deflate_allocs; |
137 | | |
138 | | struct ALIGNED_(64) internal_state { |
139 | | /* Cacheline 0 */ |
140 | | PREFIX3(stream) *strm; /* pointer back to this zlib stream */ |
141 | | unsigned char *pending_buf; /* output still pending */ |
142 | | unsigned char *pending_out; /* next pending byte to output to the stream */ |
143 | | uint32_t pending_buf_size; /* size of pending_buf */ |
144 | | uint32_t pending; /* nb of bytes in the pending buffer */ |
145 | | int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ |
146 | | uint32_t gzindex; /* where in extra, name, or comment */ |
147 | | PREFIX(gz_headerp) gzhead; /* gzip header information to write */ |
148 | | int status; /* as the name implies */ |
149 | | int last_flush; /* value of flush param for previous deflate call */ |
150 | | int reproducible; /* Whether reproducible compression results are required. */ |
151 | | |
152 | | unsigned int block_open; |
153 | | /* Whether or not a block is currently open for the QUICK deflation scheme. |
154 | | * This is set to 1 if there is an active block, or 0 if the block was just closed. |
155 | | */ |
156 | | |
157 | | /* Cacheline 1 */ |
158 | | |
159 | | unsigned int lookahead; /* number of valid bytes ahead in window */ |
160 | | unsigned int strstart; /* start of string to insert */ |
161 | | unsigned int w_size; /* LZ77 window size (32K by default) */ |
162 | | |
163 | | int block_start; /* Window position at the beginning of the current output block. |
164 | | * Gets negative when the window is moved backwards. */ |
165 | | |
166 | | unsigned int high_water; |
167 | | /* High water mark offset in window for initialized bytes -- bytes above |
168 | | * this are set to zero in order to avoid memory check warnings when |
169 | | * longest match routines access bytes past the input. This is then |
170 | | * updated to the new high water mark. |
171 | | */ |
172 | | |
173 | | unsigned int window_size; |
174 | | /* Actual size of window: 2*wSize, except when the user input buffer |
175 | | * is directly used as sliding window. |
176 | | */ |
177 | | |
178 | | unsigned char *window; |
179 | | /* Sliding window. Input bytes are read into the second half of the window, |
180 | | * and move to the first half later to keep a dictionary of at least wSize |
181 | | * bytes. With this organization, matches are limited to a distance of |
182 | | * wSize-STD_MAX_MATCH bytes, but this ensures that IO is always |
183 | | * performed with a length multiple of the block size. Also, it limits |
184 | | * the window size to 64K, which is quite useful on MSDOS. |
185 | | * To do: use the user input buffer as sliding window. |
186 | | */ |
187 | | |
188 | | Pos *prev; |
189 | | /* Link to older string with same hash index. To limit the size of this |
190 | | * array to 64K, this link is maintained only for the last 32K strings. |
191 | | * An index in this array is thus a window index modulo 32K. |
192 | | */ |
193 | | |
194 | | Pos *head; /* Heads of the hash chains or 0. */ |
195 | | |
196 | | uint32_t ins_h; /* hash index of string to be inserted */ |
197 | | |
198 | | unsigned int match_length; /* length of best match */ |
199 | | int match_available; /* set if previous match exists */ |
200 | | uint32_t prev_match; /* previous match (used by deflate_slow) */ |
201 | | |
202 | | /* Cacheline 2 */ |
203 | | |
204 | | unsigned int match_start; /* start of matching string */ |
205 | | |
206 | | unsigned int prev_length; |
207 | | /* Length of the best match at previous step. Matches not greater than this |
208 | | * are discarded. This is used in the lazy match evaluation. |
209 | | */ |
210 | | |
211 | | unsigned int max_chain_length; |
212 | | /* To speed up deflation, hash chains are never searched beyond this length. |
213 | | * A higher limit improves compression ratio but degrades the speed. |
214 | | */ |
215 | | |
216 | | unsigned int max_lazy_match; |
217 | | /* Attempt to find a better match only when the current match is strictly smaller |
218 | | * than this value. This mechanism is used only for compression levels >= 4. |
219 | | */ |
220 | 0 | # define max_insert_length max_lazy_match |
221 | | /* Insert new strings in the hash table only if the match length is not |
222 | | * greater than this length. This saves time but degrades compression. |
223 | | * max_insert_length is used only for compression levels <= 6. |
224 | | */ |
225 | | |
226 | | int level; /* compression level (1..9) */ |
227 | | int strategy; /* favor or force Huffman coding*/ |
228 | | unsigned int good_match; /* Use a faster search when the previous match is longer than this */ |
229 | | int nice_match; /* Stop searching when current match exceeds this */ |
230 | | unsigned int matches; /* number of string matches in current block */ |
231 | | unsigned int insert; /* bytes at end of window left to insert */ |
232 | | |
233 | | uint64_t bi_buf; /* Output buffer. |
234 | | * Bits are inserted starting at the bottom (least significant bits). */ |
235 | | int32_t bi_valid; /* Number of valid bits in bi_buf. |
236 | | * All bits above the last valid bit are always zero. */ |
237 | | |
238 | | int heap_len; /* number of elements in the heap */ |
239 | | int heap_max; /* element of largest frequency */ |
240 | | |
241 | | /* used by trees.c: */ |
242 | | unsigned int lit_bufsize; |
243 | | /* Size of match buffer for literals/lengths. There are 4 reasons for |
244 | | * limiting lit_bufsize to 64K: |
245 | | * - frequencies can be kept in 16 bit counters |
246 | | * - if compression is not successful for the first block, all input |
247 | | * data is still in the window so we can still emit a stored block even |
248 | | * when input comes from standard input. (This can also be done for |
249 | | * all blocks if lit_bufsize is not greater than 32K.) |
250 | | * - if compression is not successful for a file smaller than 64K, we can |
251 | | * even emit a stored file instead of a stored block (saving 5 bytes). |
252 | | * This is applicable only for zip (not gzip or zlib). |
253 | | * - creating new Huffman trees less frequently may not provide fast |
254 | | * adaptation to changes in the input data statistics. (Take for |
255 | | * example a binary file with poorly compressible code followed by |
256 | | * a highly compressible string table.) Smaller buffer sizes give |
257 | | * fast adaptation but have of course the overhead of transmitting |
258 | | * trees more frequently. |
259 | | * - I can't count above 4 |
260 | | */ |
261 | | |
262 | | /* Cacheline 3 */ |
263 | | |
264 | | #ifdef LIT_MEM |
265 | | # define LIT_BUFS 5 |
266 | | uint16_t *d_buf; /* buffer for distances */ |
267 | | unsigned char *l_buf; /* buffer for literals/lengths */ |
268 | | #else |
269 | 1.53k | # define LIT_BUFS 4 |
270 | | unsigned char *sym_buf; /* buffer for distances and literals/lengths */ |
271 | | #endif |
272 | | |
273 | | unsigned int sym_next; /* running index in symbol buffer */ |
274 | | unsigned int sym_end; /* symbol table full when sym_next reaches this */ |
275 | | |
276 | | unsigned int opt_len; /* bit length of current block with optimal trees */ |
277 | | unsigned int static_len; /* bit length of current block with static trees */ |
278 | | |
279 | | struct tree_desc_s l_desc; /* desc. for literal tree */ |
280 | | struct tree_desc_s d_desc; /* desc. for distance tree */ |
281 | | struct tree_desc_s bl_desc; /* desc. for bit length tree */ |
282 | | |
283 | | uint16_t bl_count[MAX_BITS+1]; |
284 | | /* number of codes at each bit length for an optimal tree */ |
285 | | |
286 | | int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ |
287 | | /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. |
288 | | * The same heap array is used to build all trees. |
289 | | */ |
290 | | |
291 | | unsigned char depth[2*L_CODES+1]; |
292 | | /* Depth of each subtree used as tie breaker for trees of equal frequency |
293 | | */ |
294 | | |
295 | | /* Didn't use ct_data typedef below to suppress compiler warning */ |
296 | | struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ |
297 | | struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ |
298 | | struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ |
299 | | |
300 | | deflate_allocs *alloc_bufs; |
301 | | |
302 | | #ifdef HAVE_ARCH_DEFLATE_STATE |
303 | | arch_deflate_state arch; /* architecture-specific extensions */ |
304 | | #endif |
305 | | |
306 | | /* compressed_len and bits_sent are only used if ZLIB_DEBUG is defined */ |
307 | | #ifdef ZLIB_DEBUG |
308 | | unsigned long compressed_len; /* total bit length of compressed file mod 2^32 */ |
309 | | unsigned long bits_sent; /* bit length of compressed data sent mod 2^32 */ |
310 | | #endif |
311 | | |
312 | | /* Reserved for future use and alignment purposes */ |
313 | | int32_t reserved[19]; |
314 | | }; |
315 | | |
316 | | typedef enum { |
317 | | need_more, /* block not completed, need more input or more output */ |
318 | | block_done, /* block flush performed */ |
319 | | finish_started, /* finish started, need only more output at next deflate */ |
320 | | finish_done /* finish done, accept no more input or output */ |
321 | | } block_state; |
322 | | |
323 | | /* Output a byte on the stream. |
324 | | * IN assertion: there is enough room in pending_buf. |
325 | | */ |
326 | 2.72k | #define put_byte(s, c) { \ |
327 | 2.72k | s->pending_buf[s->pending++] = (unsigned char)(c); \ |
328 | 2.72k | } |
329 | | |
330 | | /* =========================================================================== |
331 | | * Output a short LSB first on the stream. |
332 | | * IN assertion: there is enough room in pending_buf. |
333 | | */ |
334 | 7.86k | static inline void put_short(deflate_state *s, uint16_t w) { |
335 | 7.86k | w = Z_U16_TO_LE(w); |
336 | 7.86k | zng_memwrite_2(&s->pending_buf[s->pending], w); |
337 | 7.86k | s->pending += 2; |
338 | 7.86k | } 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 deflate_stored.c:put_short Line | Count | Source | 334 | 3.07k | static inline void put_short(deflate_state *s, uint16_t w) { | 335 | 3.07k | w = Z_U16_TO_LE(w); | 336 | 3.07k | zng_memwrite_2(&s->pending_buf[s->pending], w); | 337 | 3.07k | s->pending += 2; | 338 | 3.07k | } |
Unexecuted instantiation: functable.c:put_short Unexecuted instantiation: inflate.c:put_short Unexecuted instantiation: insert_string.c:put_short Line | Count | Source | 334 | 4.78k | static inline void put_short(deflate_state *s, uint16_t w) { | 335 | 4.78k | w = Z_U16_TO_LE(w); | 336 | 4.78k | zng_memwrite_2(&s->pending_buf[s->pending], w); | 337 | 4.78k | s->pending += 2; | 338 | 4.78k | } |
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_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_braid_c.c:put_short Unexecuted instantiation: crc32_chorba_c.c:put_short Unexecuted instantiation: crc32.c:put_short |
339 | | |
340 | | /* =========================================================================== |
341 | | * Output a short MSB first on the stream. |
342 | | * IN assertion: there is enough room in pending_buf. |
343 | | */ |
344 | 1.53k | static inline void put_short_msb(deflate_state *s, uint16_t w) { |
345 | 1.53k | w = Z_U16_TO_BE(w); |
346 | 1.53k | zng_memwrite_2(&s->pending_buf[s->pending], w); |
347 | 1.53k | s->pending += 2; |
348 | 1.53k | } Line | Count | Source | 344 | 1.53k | static inline void put_short_msb(deflate_state *s, uint16_t w) { | 345 | 1.53k | w = Z_U16_TO_BE(w); | 346 | 1.53k | zng_memwrite_2(&s->pending_buf[s->pending], w); | 347 | 1.53k | s->pending += 2; | 348 | 1.53k | } |
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_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_braid_c.c:put_short_msb Unexecuted instantiation: crc32_chorba_c.c:put_short_msb Unexecuted instantiation: crc32.c:put_short_msb |
349 | | |
350 | | /* =========================================================================== |
351 | | * Output a 32-bit unsigned int LSB first on the stream. |
352 | | * IN assertion: there is enough room in pending_buf. |
353 | | */ |
354 | 1.62k | static inline void put_uint32(deflate_state *s, uint32_t dw) { |
355 | 1.62k | dw = Z_U32_TO_LE(dw); |
356 | 1.62k | zng_memwrite_4(&s->pending_buf[s->pending], dw); |
357 | 1.62k | s->pending += 4; |
358 | 1.62k | } 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 | 354 | 1.62k | static inline void put_uint32(deflate_state *s, uint32_t dw) { | 355 | 1.62k | dw = Z_U32_TO_LE(dw); | 356 | 1.62k | zng_memwrite_4(&s->pending_buf[s->pending], dw); | 357 | 1.62k | s->pending += 4; | 358 | 1.62k | } |
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_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_braid_c.c:put_uint32 Unexecuted instantiation: crc32_chorba_c.c:put_uint32 Unexecuted instantiation: crc32.c:put_uint32 |
359 | | |
360 | | /* =========================================================================== |
361 | | * Output a 32-bit unsigned int MSB first on the stream. |
362 | | * IN assertion: there is enough room in pending_buf. |
363 | | */ |
364 | 1.53k | static inline void put_uint32_msb(deflate_state *s, uint32_t dw) { |
365 | 1.53k | dw = Z_U32_TO_BE(dw); |
366 | 1.53k | zng_memwrite_4(&s->pending_buf[s->pending], dw); |
367 | 1.53k | s->pending += 4; |
368 | 1.53k | } Line | Count | Source | 364 | 1.53k | static inline void put_uint32_msb(deflate_state *s, uint32_t dw) { | 365 | 1.53k | dw = Z_U32_TO_BE(dw); | 366 | 1.53k | zng_memwrite_4(&s->pending_buf[s->pending], dw); | 367 | 1.53k | s->pending += 4; | 368 | 1.53k | } |
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_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_braid_c.c:put_uint32_msb Unexecuted instantiation: crc32_chorba_c.c:put_uint32_msb Unexecuted instantiation: crc32.c:put_uint32_msb |
369 | | |
370 | | /* =========================================================================== |
371 | | * Output a 64-bit unsigned int LSB first on the stream. |
372 | | * IN assertion: there is enough room in pending_buf. |
373 | | */ |
374 | 57.6k | static inline void put_uint64(deflate_state *s, uint64_t lld) { |
375 | 57.6k | lld = Z_U64_TO_LE(lld); |
376 | 57.6k | zng_memwrite_8(&s->pending_buf[s->pending], lld); |
377 | 57.6k | s->pending += 8; |
378 | 57.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 | 374 | 57.6k | static inline void put_uint64(deflate_state *s, uint64_t lld) { | 375 | 57.6k | lld = Z_U64_TO_LE(lld); | 376 | 57.6k | zng_memwrite_8(&s->pending_buf[s->pending], lld); | 377 | 57.6k | s->pending += 8; | 378 | 57.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_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_braid_c.c:put_uint64 Unexecuted instantiation: crc32_chorba_c.c:put_uint64 Unexecuted instantiation: crc32.c:put_uint64 |
379 | | |
380 | 10.1M | #define MIN_LOOKAHEAD (STD_MAX_MATCH + STD_MIN_MATCH + 1) |
381 | | /* Minimum amount of lookahead, except at the end of the input file. |
382 | | * See deflate.c for comments about the STD_MIN_MATCH+1. |
383 | | */ |
384 | | |
385 | 10.1M | #define MAX_DIST(s) ((s)->w_size - MIN_LOOKAHEAD) |
386 | | /* In order to simplify the code, particularly on 16 bit machines, match |
387 | | * distances are limited to MAX_DIST instead of WSIZE. |
388 | | */ |
389 | | |
390 | 6.83M | #define W_MASK(s) ((s)->w_size - 1) |
391 | | /* Window mask: w_size is always a power of 2, so w_mask = w_size - 1 */ |
392 | | |
393 | 1.53k | #define W_BITS(s) zng_ctz32((s)->w_size) |
394 | | /* Window bits: log2(w_size), computed from w_size since w_size is a power of 2 */ |
395 | | |
396 | 12.3k | #define WIN_INIT STD_MAX_MATCH |
397 | | /* Number of bytes after end of data in window to initialize in order to avoid |
398 | | memory checker errors from longest match routines */ |
399 | | |
400 | | |
401 | | void Z_INTERNAL PREFIX(fill_window)(deflate_state *s); |
402 | | void Z_INTERNAL slide_hash_c(deflate_state *s); |
403 | | |
404 | | /* in trees.c */ |
405 | | void Z_INTERNAL zng_tr_init(deflate_state *s); |
406 | | void Z_INTERNAL zng_tr_flush_block(deflate_state *s, unsigned char *buf, uint32_t stored_len, int last); |
407 | | void Z_INTERNAL zng_tr_flush_bits(deflate_state *s); |
408 | | void Z_INTERNAL zng_tr_align(deflate_state *s); |
409 | | void Z_INTERNAL zng_tr_stored_block(deflate_state *s, unsigned char *buf, uint32_t stored_len, int last); |
410 | | void Z_INTERNAL PREFIX(flush_pending)(PREFIX3(streamp) strm); |
411 | 3.41M | #define d_code(dist) ((dist) < 256 ? zng_dist_code[dist] : zng_dist_code[256+((dist)>>7)]) |
412 | | /* Mapping from a distance to a distance code. dist is the distance - 1 and |
413 | | * must not have side effects. zng_dist_code[256] and zng_dist_code[257] are never |
414 | | * used. |
415 | | */ |
416 | | |
417 | | /* Bit buffer and compress bits calculation debugging */ |
418 | | #ifdef ZLIB_DEBUG |
419 | | # define cmpr_bits_add(s, len) s->compressed_len += (len) |
420 | | # define cmpr_bits_align(s) s->compressed_len = ALIGN_UP(s->compressed_len, 8) |
421 | | # define sent_bits_add(s, bits) s->bits_sent += (bits) |
422 | | # define sent_bits_align(s) s->bits_sent = ALIGN_UP(s->bits_sent, 8) |
423 | | #else |
424 | 10.7k | # define cmpr_bits_add(s, len) Z_UNUSED(len) |
425 | | # define cmpr_bits_align(s) |
426 | 1.80M | # define sent_bits_add(s, bits) Z_UNUSED(bits) |
427 | | # define sent_bits_align(s) |
428 | | #endif |
429 | | |
430 | | /* =========================================================================== |
431 | | * Architecture-specific hooks. |
432 | | */ |
433 | | #ifdef S390_DFLTCC_DEFLATE |
434 | | # include "arch/s390/dfltcc_deflate.h" |
435 | | /* DFLTCC instructions require window to be page-aligned */ |
436 | | # define PAD_WINDOW PAD_4096 |
437 | | # define WINDOW_PAD_SIZE 4096 |
438 | | # define HINT_ALIGNED_WINDOW HINT_ALIGNED_4096 |
439 | | #else |
440 | 3.07k | # define PAD_WINDOW PAD_64 |
441 | | # define WINDOW_PAD_SIZE 64 |
442 | 6.14k | # define HINT_ALIGNED_WINDOW HINT_ALIGNED_64 |
443 | | /* Adjust the window size for the arch-specific deflate code. */ |
444 | 1.53k | # define DEFLATE_ADJUST_WINDOW_SIZE(n) (n) |
445 | | /* Invoked at the beginning of deflateSetDictionary(). Useful for checking arch-specific window data. */ |
446 | 0 | # define DEFLATE_SET_DICTIONARY_HOOK(strm, dict, dict_len) do {} while (0) |
447 | | /* Invoked at the beginning of deflateGetDictionary(). Useful for adjusting arch-specific window data. */ |
448 | 0 | # define DEFLATE_GET_DICTIONARY_HOOK(strm, dict, dict_len) do {} while (0) |
449 | | /* Invoked at the end of deflateResetKeep(). Useful for initializing arch-specific extension blocks. */ |
450 | 1.53k | # define DEFLATE_RESET_KEEP_HOOK(strm) do {} while (0) |
451 | | /* Invoked at the beginning of deflateParams(). Useful for updating arch-specific compression parameters. */ |
452 | 3.07k | # define DEFLATE_PARAMS_HOOK(strm, level, strategy, hook_flush) do {} while (0) |
453 | | /* Returns whether the last deflate(flush) operation did everything it's supposed to do. */ |
454 | 0 | # define DEFLATE_DONE(strm, flush) 1 |
455 | | /* Adjusts the upper bound on compressed data length based on compression parameters and uncompressed data length. |
456 | | * Useful when arch-specific deflation code behaves differently than regular zlib-ng algorithms. */ |
457 | 0 | # define DEFLATE_BOUND_ADJUST_COMPLEN(strm, complen, sourceLen) do {} while (0) |
458 | | /* Returns whether an optimistic upper bound on compressed data length should *not* be used. |
459 | | * Useful when arch-specific deflation code behaves differently than regular zlib-ng algorithms. */ |
460 | 0 | # define DEFLATE_NEED_CONSERVATIVE_BOUND(strm) 0 |
461 | | /* Invoked for each deflate() call. Useful for plugging arch-specific deflation code. */ |
462 | 9.21k | # define DEFLATE_HOOK(strm, flush, bstate) 0 |
463 | | /* Returns whether zlib-ng should compute a checksum. Set to 0 if arch-specific deflation code already does that. */ |
464 | 16.5k | # define DEFLATE_NEED_CHECKSUM(strm) 1 |
465 | | /* Returns whether reproducibility parameter can be set to a given value. */ |
466 | 0 | # define DEFLATE_CAN_SET_REPRODUCIBLE(strm, reproducible) 1 |
467 | | #endif |
468 | | |
469 | | #endif /* DEFLATE_H_ */ |