Coverage Report

Created: 2025-07-11 06:15

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