freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Git][freetype/freetype][master] [gzip] Update sources to zlib 1.2.12.


From: Werner Lemberg (@wl)
Subject: [Git][freetype/freetype][master] [gzip] Update sources to zlib 1.2.12.
Date: Fri, 01 Apr 2022 08:58:09 +0000

Werner Lemberg pushed to branch master at FreeType / FreeType

Commits:

13 changed files:

Changes:

  • src/gzip/README.freetype
    1 1
     Name: zlib
    
    2 2
     Short Name: zlib
    
    3 3
     URL: http://zlib.net/
    
    4
    -Version: 1.2.11
    
    4
    +Version: 1.2.12
    
    5 5
     License: see `zlib.h`
    
    6 6
     
    
    7 7
     Description:
    

  • src/gzip/crc32.c
    1 1
     /* crc32.c -- compute the CRC-32 of a data stream
    
    2
    - * Copyright (C) 1995-2006, 2010, 2011, 2012, 2016 Mark Adler
    
    2
    + * Copyright (C) 1995-2022 Mark Adler
    
    3 3
      * For conditions of distribution and use, see copyright notice in zlib.h
    
    4 4
      *
    
    5
    - * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
    
    6
    - * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing
    
    7
    - * tables for updating the shift register in one step with three exclusive-ors
    
    8
    - * instead of four steps with four exclusive-ors.  This results in about a
    
    9
    - * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
    
    5
    + * This interleaved implementation of a CRC makes use of pipelined multiple
    
    6
    + * arithmetic-logic units, commonly found in modern CPU cores. It is due to
    
    7
    + * Kadatch and Jenkins (2010). See doc/crc-doc.1.0.pdf in this distribution.
    
    10 8
      */
    
    11 9
     
    
    12 10
     /* @(#) $Id$ */
    
    ... ... @@ -14,11 +12,12 @@
    14 12
     /*
    
    15 13
       Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore
    
    16 14
       protection on the static variables used to control the first-use generation
    
    17
    -  of the crc tables.  Therefore, if you #define DYNAMIC_CRC_TABLE, you should
    
    15
    +  of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should
    
    18 16
       first call get_crc_table() to initialize the tables before allowing more than
    
    19 17
       one thread to use crc32().
    
    20 18
     
    
    21
    -  DYNAMIC_CRC_TABLE and MAKECRCH can be #defined to write out crc32.h.
    
    19
    +  MAKECRCH can be #defined to write out crc32.h. A main() routine is also
    
    20
    +  produced, so that this one source file can be compiled to an executable.
    
    22 21
      */
    
    23 22
     
    
    24 23
     #ifdef MAKECRCH
    
    ... ... @@ -28,417 +27,1090 @@
    28 27
     #  endif /* !DYNAMIC_CRC_TABLE */
    
    29 28
     #endif /* MAKECRCH */
    
    30 29
     
    
    31
    -#include "zutil.h"      /* for STDC and FAR definitions */
    
    30
    +#include "zutil.h"      /* for Z_U4, Z_U8, z_crc_t, and FAR definitions */
    
    32 31
     
    
    33
    -/* Definitions for doing the crc four data bytes at a time. */
    
    34
    -#if !defined(NOBYFOUR) && defined(Z_U4)
    
    35
    -#  define BYFOUR
    
    32
    + /*
    
    33
    +  A CRC of a message is computed on N braids of words in the message, where
    
    34
    +  each word consists of W bytes (4 or 8). If N is 3, for example, then three
    
    35
    +  running sparse CRCs are calculated respectively on each braid, at these
    
    36
    +  indices in the array of words: 0, 3, 6, ..., 1, 4, 7, ..., and 2, 5, 8, ...
    
    37
    +  This is done starting at a word boundary, and continues until as many blocks
    
    38
    +  of N * W bytes as are available have been processed. The results are combined
    
    39
    +  into a single CRC at the end. For this code, N must be in the range 1..6 and
    
    40
    +  W must be 4 or 8. The upper limit on N can be increased if desired by adding
    
    41
    +  more #if blocks, extending the patterns apparent in the code. In addition,
    
    42
    +  crc32.h would need to be regenerated, if the maximum N value is increased.
    
    43
    +
    
    44
    +  N and W are chosen empirically by benchmarking the execution time on a given
    
    45
    +  processor. The choices for N and W below were based on testing on Intel Kaby
    
    46
    +  Lake i7, AMD Ryzen 7, ARM Cortex-A57, Sparc64-VII, PowerPC POWER9, and MIPS64
    
    47
    +  Octeon II processors. The Intel, AMD, and ARM processors were all fastest
    
    48
    +  with N=5, W=8. The Sparc, PowerPC, and MIPS64 were all fastest at N=5, W=4.
    
    49
    +  They were all tested with either gcc or clang, all using the -O3 optimization
    
    50
    +  level. Your mileage may vary.
    
    51
    + */
    
    52
    +
    
    53
    +/* Define N */
    
    54
    +#ifdef Z_TESTN
    
    55
    +#  define N Z_TESTN
    
    56
    +#else
    
    57
    +#  define N 5
    
    58
    +#endif
    
    59
    +#if N < 1 || N > 6
    
    60
    +#  error N must be in 1..6
    
    36 61
     #endif
    
    37
    -#ifdef BYFOUR
    
    38
    -   local unsigned long crc32_little OF((unsigned long,
    
    39
    -                        const unsigned char FAR *, z_size_t));
    
    40
    -   local unsigned long crc32_big OF((unsigned long,
    
    41
    -                        const unsigned char FAR *, z_size_t));
    
    42
    -#  define TBLS 8
    
    62
    +
    
    63
    +/*
    
    64
    +  z_crc_t must be at least 32 bits. z_word_t must be at least as long as
    
    65
    +  z_crc_t. It is assumed here that z_word_t is either 32 bits or 64 bits, and
    
    66
    +  that bytes are eight bits.
    
    67
    + */
    
    68
    +
    
    69
    +/*
    
    70
    +  Define W and the associated z_word_t type. If W is not defined, then a
    
    71
    +  braided calculation is not used, and the associated tables and code are not
    
    72
    +  compiled.
    
    73
    + */
    
    74
    +#ifdef Z_TESTW
    
    75
    +#  if Z_TESTW-1 != -1
    
    76
    +#    define W Z_TESTW
    
    77
    +#  endif
    
    43 78
     #else
    
    44
    -#  define TBLS 1
    
    45
    -#endif /* BYFOUR */
    
    79
    +#  ifdef MAKECRCH
    
    80
    +#    define W 8         /* required for MAKECRCH */
    
    81
    +#  else
    
    82
    +#    if defined(__x86_64__) || defined(__aarch64__)
    
    83
    +#      define W 8
    
    84
    +#    else
    
    85
    +#      define W 4
    
    86
    +#    endif
    
    87
    +#  endif
    
    88
    +#endif
    
    89
    +#ifdef W
    
    90
    +#  if W == 8 && defined(Z_U8)
    
    91
    +     typedef Z_U8 z_word_t;
    
    92
    +#  elif defined(Z_U4)
    
    93
    +#    undef W
    
    94
    +#    define W 4
    
    95
    +     typedef Z_U4 z_word_t;
    
    96
    +#  else
    
    97
    +#    undef W
    
    98
    +#  endif
    
    99
    +#endif
    
    46 100
     
    
    47
    -/* Local functions for crc concatenation */
    
    48
    -local unsigned long gf2_matrix_times OF((unsigned long *mat,
    
    49
    -                                         unsigned long vec));
    
    50
    -local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
    
    51
    -local uLong crc32_combine_ OF((uLong crc1, uLong crc2, z_off64_t len2));
    
    101
    +/* Local functions. */
    
    102
    +local z_crc_t multmodp OF((z_crc_t a, z_crc_t b));
    
    103
    +local z_crc_t x2nmodp OF((z_off64_t n, unsigned k));
    
    104
    +
    
    105
    +/* If available, use the ARM processor CRC32 instruction. */
    
    106
    +#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32) && W == 8
    
    107
    +#  define ARMCRC32
    
    108
    +#endif
    
    109
    +
    
    110
    +#if defined(W) && (!defined(ARMCRC32) || defined(DYNAMIC_CRC_TABLE))
    
    111
    +/*
    
    112
    +  Swap the bytes in a z_word_t to convert between little and big endian. Any
    
    113
    +  self-respecting compiler will optimize this to a single machine byte-swap
    
    114
    +  instruction, if one is available. This assumes that word_t is either 32 bits
    
    115
    +  or 64 bits.
    
    116
    + */
    
    117
    +local z_word_t byte_swap(
    
    118
    +    z_word_t word)
    
    119
    +{
    
    120
    +#  if W == 8
    
    121
    +    return
    
    122
    +        (word & 0xff00000000000000) >> 56 |
    
    123
    +        (word & 0xff000000000000) >> 40 |
    
    124
    +        (word & 0xff0000000000) >> 24 |
    
    125
    +        (word & 0xff00000000) >> 8 |
    
    126
    +        (word & 0xff000000) << 8 |
    
    127
    +        (word & 0xff0000) << 24 |
    
    128
    +        (word & 0xff00) << 40 |
    
    129
    +        (word & 0xff) << 56;
    
    130
    +#  else   /* W == 4 */
    
    131
    +    return
    
    132
    +        (word & 0xff000000) >> 24 |
    
    133
    +        (word & 0xff0000) >> 8 |
    
    134
    +        (word & 0xff00) << 8 |
    
    135
    +        (word & 0xff) << 24;
    
    136
    +#  endif
    
    137
    +}
    
    138
    +#endif
    
    52 139
     
    
    140
    +/* CRC polynomial. */
    
    141
    +#define POLY 0xedb88320         /* p(x) reflected, with x^32 implied */
    
    53 142
     
    
    54 143
     #ifdef DYNAMIC_CRC_TABLE
    
    55 144
     
    
    56
    -local volatile int crc_table_empty = 1;
    
    57
    -local z_crc_t FAR crc_table[TBLS][256];
    
    145
    +local z_crc_t FAR crc_table[256];
    
    146
    +local z_crc_t FAR x2n_table[32];
    
    58 147
     local void make_crc_table OF((void));
    
    148
    +#ifdef W
    
    149
    +   local z_word_t FAR crc_big_table[256];
    
    150
    +   local z_crc_t FAR crc_braid_table[W][256];
    
    151
    +   local z_word_t FAR crc_braid_big_table[W][256];
    
    152
    +   local void braid OF((z_crc_t [][256], z_word_t [][256], int, int));
    
    153
    +#endif
    
    59 154
     #ifdef MAKECRCH
    
    60
    -   local void write_table OF((FILE *, const z_crc_t FAR *));
    
    155
    +   local void write_table OF((FILE *, const z_crc_t FAR *, int));
    
    156
    +   local void write_table32hi OF((FILE *, const z_word_t FAR *, int));
    
    157
    +   local void write_table64 OF((FILE *, const z_word_t FAR *, int));
    
    61 158
     #endif /* MAKECRCH */
    
    159
    +
    
    160
    +/*
    
    161
    +  Define a once() function depending on the availability of atomics. If this is
    
    162
    +  compiled with DYNAMIC_CRC_TABLE defined, and if CRCs will be computed in
    
    163
    +  multiple threads, and if atomics are not available, then get_crc_table() must
    
    164
    +  be called to initialize the tables and must return before any threads are
    
    165
    +  allowed to compute or combine CRCs.
    
    166
    + */
    
    167
    +
    
    168
    +/* Definition of once functionality. */
    
    169
    +typedef struct once_s once_t;
    
    170
    +local void once OF((once_t *, void (*)(void)));
    
    171
    +
    
    172
    +/* Check for the availability of atomics. */
    
    173
    +#if defined(__STDC__) && __STDC_VERSION__ >= 201112L && \
    
    174
    +    !defined(__STDC_NO_ATOMICS__)
    
    175
    +
    
    176
    +#include <stdatomic.h>
    
    177
    +
    
    178
    +/* Structure for once(), which must be initialized with ONCE_INIT. */
    
    179
    +struct once_s {
    
    180
    +    atomic_flag begun;
    
    181
    +    atomic_int done;
    
    182
    +};
    
    183
    +#define ONCE_INIT {ATOMIC_FLAG_INIT, 0}
    
    184
    +
    
    185
    +/*
    
    186
    +  Run the provided init() function exactly once, even if multiple threads
    
    187
    +  invoke once() at the same time. The state must be a once_t initialized with
    
    188
    +  ONCE_INIT.
    
    189
    + */
    
    190
    +local void once(state, init)
    
    191
    +    once_t *state;
    
    192
    +    void (*init)(void);
    
    193
    +{
    
    194
    +    if (!atomic_load(&state->done)) {
    
    195
    +        if (atomic_flag_test_and_set(&state->begun))
    
    196
    +            while (!atomic_load(&state->done))
    
    197
    +                ;
    
    198
    +        else {
    
    199
    +            init();
    
    200
    +            atomic_store(&state->done, 1);
    
    201
    +        }
    
    202
    +    }
    
    203
    +}
    
    204
    +
    
    205
    +#else   /* no atomics */
    
    206
    +
    
    207
    +/* Structure for once(), which must be initialized with ONCE_INIT. */
    
    208
    +struct once_s {
    
    209
    +    volatile int begun;
    
    210
    +    volatile int done;
    
    211
    +};
    
    212
    +#define ONCE_INIT {0, 0}
    
    213
    +
    
    214
    +/* Test and set. Alas, not atomic, but tries to minimize the period of
    
    215
    +   vulnerability. */
    
    216
    +local int test_and_set OF((int volatile *));
    
    217
    +local int test_and_set(
    
    218
    +    int volatile *flag)
    
    219
    +{
    
    220
    +    int was;
    
    221
    +
    
    222
    +    was = *flag;
    
    223
    +    *flag = 1;
    
    224
    +    return was;
    
    225
    +}
    
    226
    +
    
    227
    +/* Run the provided init() function once. This is not thread-safe. */
    
    228
    +local void once(state, init)
    
    229
    +    once_t *state;
    
    230
    +    void (*init)(void);
    
    231
    +{
    
    232
    +    if (!state->done) {
    
    233
    +        if (test_and_set(&state->begun))
    
    234
    +            while (!state->done)
    
    235
    +                ;
    
    236
    +        else {
    
    237
    +            init();
    
    238
    +            state->done = 1;
    
    239
    +        }
    
    240
    +    }
    
    241
    +}
    
    242
    +
    
    243
    +#endif
    
    244
    +
    
    245
    +/* State for once(). */
    
    246
    +local once_t made = ONCE_INIT;
    
    247
    +
    
    62 248
     /*
    
    63 249
       Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
    
    64 250
       x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
    
    65 251
     
    
    66 252
       Polynomials over GF(2) are represented in binary, one bit per coefficient,
    
    67
    -  with the lowest powers in the most significant bit.  Then adding polynomials
    
    253
    +  with the lowest powers in the most significant bit. Then adding polynomials
    
    68 254
       is just exclusive-or, and multiplying a polynomial by x is a right shift by
    
    69
    -  one.  If we call the above polynomial p, and represent a byte as the
    
    255
    +  one. If we call the above polynomial p, and represent a byte as the
    
    70 256
       polynomial q, also with the lowest power in the most significant bit (so the
    
    71
    -  byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,
    
    257
    +  byte 0xb1 is the polynomial x^7+x^3+x^2+1), then the CRC is (q*x^32) mod p,
    
    72 258
       where a mod b means the remainder after dividing a by b.
    
    73 259
     
    
    74 260
       This calculation is done using the shift-register method of multiplying and
    
    75
    -  taking the remainder.  The register is initialized to zero, and for each
    
    261
    +  taking the remainder. The register is initialized to zero, and for each
    
    76 262
       incoming bit, x^32 is added mod p to the register if the bit is a one (where
    
    77
    -  x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by
    
    78
    -  x (which is shifting right by one and adding x^32 mod p if the bit shifted
    
    79
    -  out is a one).  We start with the highest power (least significant bit) of
    
    80
    -  q and repeat for all eight bits of q.
    
    81
    -
    
    82
    -  The first table is simply the CRC of all possible eight bit values.  This is
    
    83
    -  all the information needed to generate CRCs on data a byte at a time for all
    
    84
    -  combinations of CRC register values and incoming bytes.  The remaining tables
    
    85
    -  allow for word-at-a-time CRC calculation for both big-endian and little-
    
    86
    -  endian machines, where a word is four bytes.
    
    87
    -*/
    
    263
    +  x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by x
    
    264
    +  (which is shifting right by one and adding x^32 mod p if the bit shifted out
    
    265
    +  is a one). We start with the highest power (least significant bit) of q and
    
    266
    +  repeat for all eight bits of q.
    
    267
    +
    
    268
    +  The table is simply the CRC of all possible eight bit values. This is all the
    
    269
    +  information needed to generate CRCs on data a byte at a time for all
    
    270
    +  combinations of CRC register values and incoming bytes.
    
    271
    + */
    
    272
    +
    
    88 273
     local void make_crc_table()
    
    89 274
     {
    
    90
    -    z_crc_t c;
    
    91
    -    int n, k;
    
    92
    -    z_crc_t poly;                       /* polynomial exclusive-or pattern */
    
    93
    -    /* terms of polynomial defining this crc (except x^32): */
    
    94
    -    static volatile int first = 1;      /* flag to limit concurrent making */
    
    95
    -    static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
    
    96
    -
    
    97
    -    /* See if another task is already doing this (not thread-safe, but better
    
    98
    -       than nothing -- significantly reduces duration of vulnerability in
    
    99
    -       case the advice about DYNAMIC_CRC_TABLE is ignored) */
    
    100
    -    if (first) {
    
    101
    -        first = 0;
    
    102
    -
    
    103
    -        /* make exclusive-or pattern from polynomial (0xedb88320UL) */
    
    104
    -        poly = 0;
    
    105
    -        for (n = 0; n < (int)(sizeof(p)/sizeof(unsigned char)); n++)
    
    106
    -            poly |= (z_crc_t)1 << (31 - p[n]);
    
    107
    -
    
    108
    -        /* generate a crc for every 8-bit value */
    
    109
    -        for (n = 0; n < 256; n++) {
    
    110
    -            c = (z_crc_t)n;
    
    111
    -            for (k = 0; k < 8; k++)
    
    112
    -                c = c & 1 ? poly ^ (c >> 1) : c >> 1;
    
    113
    -            crc_table[0][n] = c;
    
    114
    -        }
    
    275
    +    unsigned i, j, n;
    
    276
    +    z_crc_t p;
    
    115 277
     
    
    116
    -#ifdef BYFOUR
    
    117
    -        /* generate crc for each value followed by one, two, and three zeros,
    
    118
    -           and then the byte reversal of those as well as the first table */
    
    119
    -        for (n = 0; n < 256; n++) {
    
    120
    -            c = crc_table[0][n];
    
    121
    -            crc_table[4][n] = ZSWAP32(c);
    
    122
    -            for (k = 1; k < 4; k++) {
    
    123
    -                c = crc_table[0][c & 0xff] ^ (c >> 8);
    
    124
    -                crc_table[k][n] = c;
    
    125
    -                crc_table[k + 4][n] = ZSWAP32(c);
    
    126
    -            }
    
    127
    -        }
    
    128
    -#endif /* BYFOUR */
    
    129
    -
    
    130
    -        crc_table_empty = 0;
    
    131
    -    }
    
    132
    -    else {      /* not first */
    
    133
    -        /* wait for the other guy to finish (not efficient, but rare) */
    
    134
    -        while (crc_table_empty)
    
    135
    -            ;
    
    278
    +    /* initialize the CRC of bytes tables */
    
    279
    +    for (i = 0; i < 256; i++) {
    
    280
    +        p = i;
    
    281
    +        for (j = 0; j < 8; j++)
    
    282
    +            p = p & 1 ? (p >> 1) ^ POLY : p >> 1;
    
    283
    +        crc_table[i] = p;
    
    284
    +#ifdef W
    
    285
    +        crc_big_table[i] = byte_swap(p);
    
    286
    +#endif
    
    136 287
         }
    
    137 288
     
    
    289
    +    /* initialize the x^2^n mod p(x) table */
    
    290
    +    p = (z_crc_t)1 << 30;         /* x^1 */
    
    291
    +    x2n_table[0] = p;
    
    292
    +    for (n = 1; n < 32; n++)
    
    293
    +        x2n_table[n] = p = multmodp(p, p);
    
    294
    +
    
    295
    +#ifdef W
    
    296
    +    /* initialize the braiding tables -- needs x2n_table[] */
    
    297
    +    braid(crc_braid_table, crc_braid_big_table, N, W);
    
    298
    +#endif
    
    299
    +
    
    138 300
     #ifdef MAKECRCH
    
    139
    -    /* write out CRC tables to crc32.h */
    
    140 301
         {
    
    302
    +        /*
    
    303
    +          The crc32.h header file contains tables for both 32-bit and 64-bit
    
    304
    +          z_word_t's, and so requires a 64-bit type be available. In that case,
    
    305
    +          z_word_t must be defined to be 64-bits. This code then also generates
    
    306
    +          and writes out the tables for the case that z_word_t is 32 bits.
    
    307
    +         */
    
    308
    +#if !defined(W) || W != 8
    
    309
    +#  error Need a 64-bit integer type in order to generate crc32.h.
    
    310
    +#endif
    
    141 311
             FILE *out;
    
    312
    +        int k, n;
    
    313
    +        z_crc_t ltl[8][256];
    
    314
    +        z_word_t big[8][256];
    
    142 315
     
    
    143 316
             out = fopen("crc32.h", "w");
    
    144 317
             if (out == NULL) return;
    
    145
    -        fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n");
    
    146
    -        fprintf(out, " * Generated automatically by crc32.c\n */\n\n");
    
    147
    -        fprintf(out, "local const z_crc_t FAR ");
    
    148
    -        fprintf(out, "crc_table[TBLS][256] =\n{\n  {\n");
    
    149
    -        write_table(out, crc_table[0]);
    
    150
    -#  ifdef BYFOUR
    
    151
    -        fprintf(out, "#ifdef BYFOUR\n");
    
    152
    -        for (k = 1; k < 8; k++) {
    
    153
    -            fprintf(out, "  },\n  {\n");
    
    154
    -            write_table(out, crc_table[k]);
    
    318
    +
    
    319
    +        /* write out little-endian CRC table to crc32.h */
    
    320
    +        fprintf(out,
    
    321
    +            "/* crc32.h -- tables for rapid CRC calculation\n"
    
    322
    +            " * Generated automatically by crc32.c\n */\n"
    
    323
    +            "\n"
    
    324
    +            "local const z_crc_t FAR crc_table[] = {\n"
    
    325
    +            "    ");
    
    326
    +        write_table(out, crc_table, 256);
    
    327
    +        fprintf(out,
    
    328
    +            "};\n");
    
    329
    +
    
    330
    +        /* write out big-endian CRC table for 64-bit z_word_t to crc32.h */
    
    331
    +        fprintf(out,
    
    332
    +            "\n"
    
    333
    +            "#ifdef W\n"
    
    334
    +            "\n"
    
    335
    +            "#if W == 8\n"
    
    336
    +            "\n"
    
    337
    +            "local const z_word_t FAR crc_big_table[] = {\n"
    
    338
    +            "    ");
    
    339
    +        write_table64(out, crc_big_table, 256);
    
    340
    +        fprintf(out,
    
    341
    +            "};\n");
    
    342
    +
    
    343
    +        /* write out big-endian CRC table for 32-bit z_word_t to crc32.h */
    
    344
    +        fprintf(out,
    
    345
    +            "\n"
    
    346
    +            "#else /* W == 4 */\n"
    
    347
    +            "\n"
    
    348
    +            "local const z_word_t FAR crc_big_table[] = {\n"
    
    349
    +            "    ");
    
    350
    +        write_table32hi(out, crc_big_table, 256);
    
    351
    +        fprintf(out,
    
    352
    +            "};\n"
    
    353
    +            "\n"
    
    354
    +            "#endif\n");
    
    355
    +
    
    356
    +        /* write out braid tables for each value of N */
    
    357
    +        for (n = 1; n <= 6; n++) {
    
    358
    +            fprintf(out,
    
    359
    +            "\n"
    
    360
    +            "#if N == %d\n", n);
    
    361
    +
    
    362
    +            /* compute braid tables for this N and 64-bit word_t */
    
    363
    +            braid(ltl, big, n, 8);
    
    364
    +
    
    365
    +            /* write out braid tables for 64-bit z_word_t to crc32.h */
    
    366
    +            fprintf(out,
    
    367
    +            "\n"
    
    368
    +            "#if W == 8\n"
    
    369
    +            "\n"
    
    370
    +            "local const z_crc_t FAR crc_braid_table[][256] = {\n");
    
    371
    +            for (k = 0; k < 8; k++) {
    
    372
    +                fprintf(out, "   {");
    
    373
    +                write_table(out, ltl[k], 256);
    
    374
    +                fprintf(out, "}%s", k < 7 ? ",\n" : "");
    
    375
    +            }
    
    376
    +            fprintf(out,
    
    377
    +            "};\n"
    
    378
    +            "\n"
    
    379
    +            "local const z_word_t FAR crc_braid_big_table[][256] = {\n");
    
    380
    +            for (k = 0; k < 8; k++) {
    
    381
    +                fprintf(out, "   {");
    
    382
    +                write_table64(out, big[k], 256);
    
    383
    +                fprintf(out, "}%s", k < 7 ? ",\n" : "");
    
    384
    +            }
    
    385
    +            fprintf(out,
    
    386
    +            "};\n");
    
    387
    +
    
    388
    +            /* compute braid tables for this N and 32-bit word_t */
    
    389
    +            braid(ltl, big, n, 4);
    
    390
    +
    
    391
    +            /* write out braid tables for 32-bit z_word_t to crc32.h */
    
    392
    +            fprintf(out,
    
    393
    +            "\n"
    
    394
    +            "#else /* W == 4 */\n"
    
    395
    +            "\n"
    
    396
    +            "local const z_crc_t FAR crc_braid_table[][256] = {\n");
    
    397
    +            for (k = 0; k < 4; k++) {
    
    398
    +                fprintf(out, "   {");
    
    399
    +                write_table(out, ltl[k], 256);
    
    400
    +                fprintf(out, "}%s", k < 3 ? ",\n" : "");
    
    401
    +            }
    
    402
    +            fprintf(out,
    
    403
    +            "};\n"
    
    404
    +            "\n"
    
    405
    +            "local const z_word_t FAR crc_braid_big_table[][256] = {\n");
    
    406
    +            for (k = 0; k < 4; k++) {
    
    407
    +                fprintf(out, "   {");
    
    408
    +                write_table32hi(out, big[k], 256);
    
    409
    +                fprintf(out, "}%s", k < 3 ? ",\n" : "");
    
    410
    +            }
    
    411
    +            fprintf(out,
    
    412
    +            "};\n"
    
    413
    +            "\n"
    
    414
    +            "#endif\n"
    
    415
    +            "\n"
    
    416
    +            "#endif\n");
    
    155 417
             }
    
    156
    -        fprintf(out, "#endif\n");
    
    157
    -#  endif /* BYFOUR */
    
    158
    -        fprintf(out, "  }\n};\n");
    
    418
    +        fprintf(out,
    
    419
    +            "\n"
    
    420
    +            "#endif\n");
    
    421
    +
    
    422
    +        /* write out zeros operator table to crc32.h */
    
    423
    +        fprintf(out,
    
    424
    +            "\n"
    
    425
    +            "local const z_crc_t FAR x2n_table[] = {\n"
    
    426
    +            "    ");
    
    427
    +        write_table(out, x2n_table, 32);
    
    428
    +        fprintf(out,
    
    429
    +            "};\n");
    
    159 430
             fclose(out);
    
    160 431
         }
    
    161 432
     #endif /* MAKECRCH */
    
    162 433
     }
    
    163 434
     
    
    164 435
     #ifdef MAKECRCH
    
    436
    +
    
    437
    +/*
    
    438
    +   Write the 32-bit values in table[0..k-1] to out, five per line in
    
    439
    +   hexadecimal separated by commas.
    
    440
    + */
    
    165 441
     local void write_table(
    
    166 442
         FILE *out,
    
    167
    -    const z_crc_t FAR *table)
    
    443
    +    const z_crc_t FAR *table,
    
    444
    +    int k)
    
    168 445
     {
    
    169 446
         int n;
    
    170 447
     
    
    171
    -    for (n = 0; n < 256; n++)
    
    172
    -        fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : "    ",
    
    448
    +    for (n = 0; n < k; n++)
    
    449
    +        fprintf(out, "%s0x%08lx%s", n == 0 || n % 5 ? "" : "    ",
    
    173 450
                     (unsigned long)(table[n]),
    
    174
    -                n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", "));
    
    451
    +                n == k - 1 ? "" : (n % 5 == 4 ? ",\n" : ", "));
    
    175 452
     }
    
    453
    +
    
    454
    +/*
    
    455
    +   Write the high 32-bits of each value in table[0..k-1] to out, five per line
    
    456
    +   in hexadecimal separated by commas.
    
    457
    + */
    
    458
    +local void write_table32hi(
    
    459
    +    FILE *out,
    
    460
    +    const z_word_t FAR *table,
    
    461
    +    int k)
    
    462
    +{
    
    463
    +    int n;
    
    464
    +
    
    465
    +    for (n = 0; n < k; n++)
    
    466
    +        fprintf(out, "%s0x%08lx%s", n == 0 || n % 5 ? "" : "    ",
    
    467
    +                (unsigned long)(table[n] >> 32),
    
    468
    +                n == k - 1 ? "" : (n % 5 == 4 ? ",\n" : ", "));
    
    469
    +}
    
    470
    +
    
    471
    +/*
    
    472
    +  Write the 64-bit values in table[0..k-1] to out, three per line in
    
    473
    +  hexadecimal separated by commas. This assumes that if there is a 64-bit
    
    474
    +  type, then there is also a long long integer type, and it is at least 64
    
    475
    +  bits. If not, then the type cast and format string can be adjusted
    
    476
    +  accordingly.
    
    477
    + */
    
    478
    +local void write_table64(
    
    479
    +    FILE *out,
    
    480
    +    const z_word_t FAR *table,
    
    481
    +    int k)
    
    482
    +{
    
    483
    +    int n;
    
    484
    +
    
    485
    +    for (n = 0; n < k; n++)
    
    486
    +        fprintf(out, "%s0x%016llx%s", n == 0 || n % 3 ? "" : "    ",
    
    487
    +                (unsigned long long)(table[n]),
    
    488
    +                n == k - 1 ? "" : (n % 3 == 2 ? ",\n" : ", "));
    
    489
    +}
    
    490
    +
    
    491
    +/* Actually do the deed. */
    
    492
    +int main()
    
    493
    +{
    
    494
    +    make_crc_table();
    
    495
    +    return 0;
    
    496
    +}
    
    497
    +
    
    176 498
     #endif /* MAKECRCH */
    
    177 499
     
    
    500
    +#ifdef W
    
    501
    +/*
    
    502
    +  Generate the little and big-endian braid tables for the given n and z_word_t
    
    503
    +  size w. Each array must have room for w blocks of 256 elements.
    
    504
    + */
    
    505
    +local void braid(ltl, big, n, w)
    
    506
    +    z_crc_t ltl[][256];
    
    507
    +    z_word_t big[][256];
    
    508
    +    int n;
    
    509
    +    int w;
    
    510
    +{
    
    511
    +    int k;
    
    512
    +    z_crc_t i, p, q;
    
    513
    +    for (k = 0; k < w; k++) {
    
    514
    +        p = x2nmodp((n * w + 3 - k) << 3, 0);
    
    515
    +        ltl[k][0] = 0;
    
    516
    +        big[w - 1 - k][0] = 0;
    
    517
    +        for (i = 1; i < 256; i++) {
    
    518
    +            ltl[k][i] = q = multmodp(i << 24, p);
    
    519
    +            big[w - 1 - k][i] = byte_swap(q);
    
    520
    +        }
    
    521
    +    }
    
    522
    +}
    
    523
    +#endif
    
    524
    +
    
    178 525
     #else /* !DYNAMIC_CRC_TABLE */
    
    179 526
     /* ========================================================================
    
    180
    - * Tables of CRC-32s of all single-byte values, made by make_crc_table().
    
    527
    + * Tables for byte-wise and braided CRC-32 calculations, and a table of powers
    
    528
    + * of x for combining CRC-32s, all made by make_crc_table().
    
    181 529
      */
    
    182 530
     #include "crc32.h"
    
    183 531
     #endif /* DYNAMIC_CRC_TABLE */
    
    184 532
     
    
    533
    +/* ========================================================================
    
    534
    + * Routines used for CRC calculation. Some are also required for the table
    
    535
    + * generation above.
    
    536
    + */
    
    537
    +
    
    538
    +/*
    
    539
    +  Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial,
    
    540
    +  reflected. For speed, this requires that a not be zero.
    
    541
    + */
    
    542
    +local z_crc_t multmodp(
    
    543
    +    z_crc_t a,
    
    544
    +    z_crc_t b)
    
    545
    +{
    
    546
    +    z_crc_t m, p;
    
    547
    +
    
    548
    +    m = (z_crc_t)1 << 31;
    
    549
    +    p = 0;
    
    550
    +    for (;;) {
    
    551
    +        if (a & m) {
    
    552
    +            p ^= b;
    
    553
    +            if ((a & (m - 1)) == 0)
    
    554
    +                break;
    
    555
    +        }
    
    556
    +        m >>= 1;
    
    557
    +        b = b & 1 ? (b >> 1) ^ POLY : b >> 1;
    
    558
    +    }
    
    559
    +    return p;
    
    560
    +}
    
    561
    +
    
    562
    +/*
    
    563
    +  Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been
    
    564
    +  initialized.
    
    565
    + */
    
    566
    +local z_crc_t x2nmodp(
    
    567
    +    z_off64_t n,
    
    568
    +    unsigned k)
    
    569
    +{
    
    570
    +    z_crc_t p;
    
    571
    +
    
    572
    +    p = (z_crc_t)1 << 31;           /* x^0 == 1 */
    
    573
    +    while (n) {
    
    574
    +        if (n & 1)
    
    575
    +            p = multmodp(x2n_table[k & 31], p);
    
    576
    +        n >>= 1;
    
    577
    +        k++;
    
    578
    +    }
    
    579
    +    return p;
    
    580
    +}
    
    581
    +
    
    185 582
     /* =========================================================================
    
    186
    - * This function can be used by asm versions of crc32()
    
    583
    + * This function can be used by asm versions of crc32(), and to force the
    
    584
    + * generation of the CRC tables in a threaded application.
    
    187 585
      */
    
    188 586
     const z_crc_t FAR * ZEXPORT get_crc_table()
    
    189 587
     {
    
    190 588
     #ifdef DYNAMIC_CRC_TABLE
    
    191
    -    if (crc_table_empty)
    
    192
    -        make_crc_table();
    
    589
    +    once(&made, make_crc_table);
    
    193 590
     #endif /* DYNAMIC_CRC_TABLE */
    
    194 591
         return (const z_crc_t FAR *)crc_table;
    
    195 592
     }
    
    196 593
     
    
    197
    -/* ========================================================================= */
    
    198
    -#undef DO1
    
    199
    -#undef DO8
    
    200
    -#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
    
    201
    -#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
    
    594
    +/* =========================================================================
    
    595
    + * Use ARM machine instructions if available. This will compute the CRC about
    
    596
    + * ten times faster than the braided calculation. This code does not check for
    
    597
    + * the presence of the CRC instruction at run time. __ARM_FEATURE_CRC32 will
    
    598
    + * only be defined if the compilation specifies an ARM processor architecture
    
    599
    + * that has the instructions. For example, compiling with -march=armv8.1-a or
    
    600
    + * -march=armv8-a+crc, or -march=native if the compile machine has the crc32
    
    601
    + * instructions.
    
    602
    + */
    
    603
    +#ifdef ARMCRC32
    
    604
    +
    
    605
    +/*
    
    606
    +   Constants empirically determined to maximize speed. These values are from
    
    607
    +   measurements on a Cortex-A57. Your mileage may vary.
    
    608
    + */
    
    609
    +#define Z_BATCH 3990                /* number of words in a batch */
    
    610
    +#define Z_BATCH_ZEROS 0xa10d3d0c    /* computed from Z_BATCH = 3990 */
    
    611
    +#define Z_BATCH_MIN 800             /* fewest words in a final batch */
    
    202 612
     
    
    203
    -/* ========================================================================= */
    
    204 613
     unsigned long ZEXPORT crc32_z(
    
    205 614
         unsigned long crc,
    
    206 615
         const unsigned char FAR *buf,
    
    207 616
         z_size_t len)
    
    208 617
     {
    
    209
    -    if (buf == Z_NULL) return 0UL;
    
    618
    +    z_crc_t val;
    
    619
    +    z_word_t crc1, crc2;
    
    620
    +    const z_word_t *word;
    
    621
    +    z_word_t val0, val1, val2;
    
    622
    +    z_size_t last, last2, i;
    
    623
    +    z_size_t num;
    
    624
    +
    
    625
    +    /* Return initial CRC, if requested. */
    
    626
    +    if (buf == Z_NULL) return 0;
    
    210 627
     
    
    211 628
     #ifdef DYNAMIC_CRC_TABLE
    
    212
    -    if (crc_table_empty)
    
    213
    -        make_crc_table();
    
    629
    +    once(&made, make_crc_table);
    
    214 630
     #endif /* DYNAMIC_CRC_TABLE */
    
    215 631
     
    
    216
    -#ifdef BYFOUR
    
    217
    -    if (sizeof(void *) == sizeof(ptrdiff_t)) {
    
    218
    -        z_crc_t endian;
    
    632
    +    /* Pre-condition the CRC */
    
    633
    +    crc ^= 0xffffffff;
    
    219 634
     
    
    220
    -        endian = 1;
    
    221
    -        if (*((unsigned char *)(&endian)))
    
    222
    -            return crc32_little(crc, buf, len);
    
    223
    -        else
    
    224
    -            return crc32_big(crc, buf, len);
    
    635
    +    /* Compute the CRC up to a word boundary. */
    
    636
    +    while (len && ((z_size_t)buf & 7) != 0) {
    
    637
    +        len--;
    
    638
    +        val = *buf++;
    
    639
    +        __asm__ volatile("crc32b %w0, %w0, %w1" : "+r"(crc) : "r"(val));
    
    225 640
         }
    
    226
    -#endif /* BYFOUR */
    
    227
    -    crc = crc ^ 0xffffffffUL;
    
    228
    -    while (len >= 8) {
    
    229
    -        DO8;
    
    230
    -        len -= 8;
    
    641
    +
    
    642
    +    /* Prepare to compute the CRC on full 64-bit words word[0..num-1]. */
    
    643
    +    word = (z_word_t const *)buf;
    
    644
    +    num = len >> 3;
    
    645
    +    len &= 7;
    
    646
    +
    
    647
    +    /* Do three interleaved CRCs to realize the throughput of one crc32x
    
    648
    +       instruction per cycle. Each CRC is calcuated on Z_BATCH words. The three
    
    649
    +       CRCs are combined into a single CRC after each set of batches. */
    
    650
    +    while (num >= 3 * Z_BATCH) {
    
    651
    +        crc1 = 0;
    
    652
    +        crc2 = 0;
    
    653
    +        for (i = 0; i < Z_BATCH; i++) {
    
    654
    +            val0 = word[i];
    
    655
    +            val1 = word[i + Z_BATCH];
    
    656
    +            val2 = word[i + 2 * Z_BATCH];
    
    657
    +            __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc) : "r"(val0));
    
    658
    +            __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc1) : "r"(val1));
    
    659
    +            __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc2) : "r"(val2));
    
    660
    +        }
    
    661
    +        word += 3 * Z_BATCH;
    
    662
    +        num -= 3 * Z_BATCH;
    
    663
    +        crc = multmodp(Z_BATCH_ZEROS, crc) ^ crc1;
    
    664
    +        crc = multmodp(Z_BATCH_ZEROS, crc) ^ crc2;
    
    231 665
         }
    
    232
    -    if (len) do {
    
    233
    -        DO1;
    
    234
    -    } while (--len);
    
    235
    -    return crc ^ 0xffffffffUL;
    
    236
    -}
    
    237 666
     
    
    238
    -/* ========================================================================= */
    
    239
    -unsigned long ZEXPORT crc32(
    
    240
    -    unsigned long crc,
    
    241
    -    const unsigned char FAR *buf,
    
    242
    -    uInt len)
    
    243
    -{
    
    244
    -    return crc32_z(crc, buf, len);
    
    667
    +    /* Do one last smaller batch with the remaining words, if there are enough
    
    668
    +       to pay for the combination of CRCs. */
    
    669
    +    last = num / 3;
    
    670
    +    if (last >= Z_BATCH_MIN) {
    
    671
    +        last2 = last << 1;
    
    672
    +        crc1 = 0;
    
    673
    +        crc2 = 0;
    
    674
    +        for (i = 0; i < last; i++) {
    
    675
    +            val0 = word[i];
    
    676
    +            val1 = word[i + last];
    
    677
    +            val2 = word[i + last2];
    
    678
    +            __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc) : "r"(val0));
    
    679
    +            __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc1) : "r"(val1));
    
    680
    +            __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc2) : "r"(val2));
    
    681
    +        }
    
    682
    +        word += 3 * last;
    
    683
    +        num -= 3 * last;
    
    684
    +        val = x2nmodp(last, 6);
    
    685
    +        crc = multmodp(val, crc) ^ crc1;
    
    686
    +        crc = multmodp(val, crc) ^ crc2;
    
    687
    +    }
    
    688
    +
    
    689
    +    /* Compute the CRC on any remaining words. */
    
    690
    +    for (i = 0; i < num; i++) {
    
    691
    +        val0 = word[i];
    
    692
    +        __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc) : "r"(val0));
    
    693
    +    }
    
    694
    +    word += num;
    
    695
    +
    
    696
    +    /* Complete the CRC on any remaining bytes. */
    
    697
    +    buf = (const unsigned char FAR *)word;
    
    698
    +    while (len) {
    
    699
    +        len--;
    
    700
    +        val = *buf++;
    
    701
    +        __asm__ volatile("crc32b %w0, %w0, %w1" : "+r"(crc) : "r"(val));
    
    702
    +    }
    
    703
    +
    
    704
    +    /* Return the CRC, post-conditioned. */
    
    705
    +    return crc ^ 0xffffffff;
    
    245 706
     }
    
    246 707
     
    
    247
    -#ifdef BYFOUR
    
    708
    +#else
    
    709
    +
    
    710
    +#ifdef W
    
    248 711
     
    
    249 712
     /*
    
    250
    -   This BYFOUR code accesses the passed unsigned char * buffer with a 32-bit
    
    251
    -   integer pointer type. This violates the strict aliasing rule, where a
    
    252
    -   compiler can assume, for optimization purposes, that two pointers to
    
    253
    -   fundamentally different types won't ever point to the same memory. This can
    
    254
    -   manifest as a problem only if one of the pointers is written to. This code
    
    255
    -   only reads from those pointers. So long as this code remains isolated in
    
    256
    -   this compilation unit, there won't be a problem. For this reason, this code
    
    257
    -   should not be copied and pasted into a compilation unit in which other code
    
    258
    -   writes to the buffer that is passed to these routines.
    
    713
    +  Return the CRC of the W bytes in the word_t data, taking the
    
    714
    +  least-significant byte of the word as the first byte of data, without any pre
    
    715
    +  or post conditioning. This is used to combine the CRCs of each braid.
    
    259 716
      */
    
    717
    +local z_crc_t crc_word(
    
    718
    +    z_word_t data)
    
    719
    +{
    
    720
    +    int k;
    
    721
    +    for (k = 0; k < W; k++)
    
    722
    +        data = (data >> 8) ^ crc_table[data & 0xff];
    
    723
    +    return (z_crc_t)data;
    
    724
    +}
    
    260 725
     
    
    261
    -/* ========================================================================= */
    
    262
    -#define DOLIT4 c ^= *buf4++; \
    
    263
    -        c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \
    
    264
    -            crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24]
    
    265
    -#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4
    
    726
    +local z_word_t crc_word_big(
    
    727
    +    z_word_t data)
    
    728
    +{
    
    729
    +    int k;
    
    730
    +    for (k = 0; k < W; k++)
    
    731
    +        data = (data << 8) ^
    
    732
    +            crc_big_table[(data >> ((W - 1) << 3)) & 0xff];
    
    733
    +    return data;
    
    734
    +}
    
    735
    +
    
    736
    +#endif
    
    266 737
     
    
    267 738
     /* ========================================================================= */
    
    268
    -local unsigned long crc32_little(
    
    739
    +unsigned long ZEXPORT crc32_z(
    
    269 740
         unsigned long crc,
    
    270 741
         const unsigned char FAR *buf,
    
    271 742
         z_size_t len)
    
    272 743
     {
    
    273
    -    register z_crc_t c;
    
    274
    -    register const z_crc_t FAR *buf4;
    
    744
    +    /* Return initial CRC, if requested. */
    
    745
    +    if (buf == Z_NULL) return 0;
    
    275 746
     
    
    276
    -    c = (z_crc_t)crc;
    
    277
    -    c = ~c;
    
    278
    -    while (len && ((ptrdiff_t)buf & 3)) {
    
    279
    -        c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
    
    280
    -        len--;
    
    281
    -    }
    
    747
    +#ifdef DYNAMIC_CRC_TABLE
    
    748
    +    once(&made, make_crc_table);
    
    749
    +#endif /* DYNAMIC_CRC_TABLE */
    
    282 750
     
    
    283
    -    buf4 = (const z_crc_t FAR *)(const void FAR *)buf;
    
    284
    -    while (len >= 32) {
    
    285
    -        DOLIT32;
    
    286
    -        len -= 32;
    
    287
    -    }
    
    288
    -    while (len >= 4) {
    
    289
    -        DOLIT4;
    
    290
    -        len -= 4;
    
    291
    -    }
    
    292
    -    buf = (const unsigned char FAR *)buf4;
    
    751
    +    /* Pre-condition the CRC */
    
    752
    +    crc ^= 0xffffffff;
    
    293 753
     
    
    294
    -    if (len) do {
    
    295
    -        c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
    
    296
    -    } while (--len);
    
    297
    -    c = ~c;
    
    298
    -    return (unsigned long)c;
    
    299
    -}
    
    754
    +#ifdef W
    
    300 755
     
    
    301
    -/* ========================================================================= */
    
    302
    -#define DOBIG4 c ^= *buf4++; \
    
    303
    -        c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \
    
    304
    -            crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24]
    
    305
    -#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
    
    756
    +    /* If provided enough bytes, do a braided CRC calculation. */
    
    757
    +    if (len >= N * W + W - 1) {
    
    758
    +        z_size_t blks;
    
    759
    +        z_word_t const *words;
    
    760
    +        unsigned endian;
    
    761
    +        int k;
    
    306 762
     
    
    307
    -/* ========================================================================= */
    
    308
    -local unsigned long crc32_big(
    
    309
    -    unsigned long crc,
    
    310
    -    const unsigned char FAR *buf,
    
    311
    -    z_size_t len)
    
    312
    -{
    
    313
    -    register z_crc_t c;
    
    314
    -    register const z_crc_t FAR *buf4;
    
    763
    +        /* Compute the CRC up to a z_word_t boundary. */
    
    764
    +        while (len && ((z_size_t)buf & (W - 1)) != 0) {
    
    765
    +            len--;
    
    766
    +            crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
    
    767
    +        }
    
    315 768
     
    
    316
    -    c = ZSWAP32((z_crc_t)crc);
    
    317
    -    c = ~c;
    
    318
    -    while (len && ((ptrdiff_t)buf & 3)) {
    
    319
    -        c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
    
    320
    -        len--;
    
    769
    +        /* Compute the CRC on as many N z_word_t blocks as are available. */
    
    770
    +        blks = len / (N * W);
    
    771
    +        len -= blks * N * W;
    
    772
    +        words = (z_word_t const *)buf;
    
    773
    +
    
    774
    +        /* Do endian check at execution time instead of compile time, since ARM
    
    775
    +           processors can change the endianess at execution time. If the
    
    776
    +           compiler knows what the endianess will be, it can optimize out the
    
    777
    +           check and the unused branch. */
    
    778
    +        endian = 1;
    
    779
    +        if (*(unsigned char *)&endian) {
    
    780
    +            /* Little endian. */
    
    781
    +
    
    782
    +            z_crc_t crc0;
    
    783
    +            z_word_t word0;
    
    784
    +#if N > 1
    
    785
    +            z_crc_t crc1;
    
    786
    +            z_word_t word1;
    
    787
    +#if N > 2
    
    788
    +            z_crc_t crc2;
    
    789
    +            z_word_t word2;
    
    790
    +#if N > 3
    
    791
    +            z_crc_t crc3;
    
    792
    +            z_word_t word3;
    
    793
    +#if N > 4
    
    794
    +            z_crc_t crc4;
    
    795
    +            z_word_t word4;
    
    796
    +#if N > 5
    
    797
    +            z_crc_t crc5;
    
    798
    +            z_word_t word5;
    
    799
    +#endif
    
    800
    +#endif
    
    801
    +#endif
    
    802
    +#endif
    
    803
    +#endif
    
    804
    +
    
    805
    +            /* Initialize the CRC for each braid. */
    
    806
    +            crc0 = crc;
    
    807
    +#if N > 1
    
    808
    +            crc1 = 0;
    
    809
    +#if N > 2
    
    810
    +            crc2 = 0;
    
    811
    +#if N > 3
    
    812
    +            crc3 = 0;
    
    813
    +#if N > 4
    
    814
    +            crc4 = 0;
    
    815
    +#if N > 5
    
    816
    +            crc5 = 0;
    
    817
    +#endif
    
    818
    +#endif
    
    819
    +#endif
    
    820
    +#endif
    
    821
    +#endif
    
    822
    +
    
    823
    +            /*
    
    824
    +              Process the first blks-1 blocks, computing the CRCs on each braid
    
    825
    +              independently.
    
    826
    +             */
    
    827
    +            while (--blks) {
    
    828
    +                /* Load the word for each braid into registers. */
    
    829
    +                word0 = crc0 ^ words[0];
    
    830
    +#if N > 1
    
    831
    +                word1 = crc1 ^ words[1];
    
    832
    +#if N > 2
    
    833
    +                word2 = crc2 ^ words[2];
    
    834
    +#if N > 3
    
    835
    +                word3 = crc3 ^ words[3];
    
    836
    +#if N > 4
    
    837
    +                word4 = crc4 ^ words[4];
    
    838
    +#if N > 5
    
    839
    +                word5 = crc5 ^ words[5];
    
    840
    +#endif
    
    841
    +#endif
    
    842
    +#endif
    
    843
    +#endif
    
    844
    +#endif
    
    845
    +                words += N;
    
    846
    +
    
    847
    +                /* Compute and update the CRC for each word. The loop should
    
    848
    +                   get unrolled. */
    
    849
    +                crc0 = crc_braid_table[0][word0 & 0xff];
    
    850
    +#if N > 1
    
    851
    +                crc1 = crc_braid_table[0][word1 & 0xff];
    
    852
    +#if N > 2
    
    853
    +                crc2 = crc_braid_table[0][word2 & 0xff];
    
    854
    +#if N > 3
    
    855
    +                crc3 = crc_braid_table[0][word3 & 0xff];
    
    856
    +#if N > 4
    
    857
    +                crc4 = crc_braid_table[0][word4 & 0xff];
    
    858
    +#if N > 5
    
    859
    +                crc5 = crc_braid_table[0][word5 & 0xff];
    
    860
    +#endif
    
    861
    +#endif
    
    862
    +#endif
    
    863
    +#endif
    
    864
    +#endif
    
    865
    +                for (k = 1; k < W; k++) {
    
    866
    +                    crc0 ^= crc_braid_table[k][(word0 >> (k << 3)) & 0xff];
    
    867
    +#if N > 1
    
    868
    +                    crc1 ^= crc_braid_table[k][(word1 >> (k << 3)) & 0xff];
    
    869
    +#if N > 2
    
    870
    +                    crc2 ^= crc_braid_table[k][(word2 >> (k << 3)) & 0xff];
    
    871
    +#if N > 3
    
    872
    +                    crc3 ^= crc_braid_table[k][(word3 >> (k << 3)) & 0xff];
    
    873
    +#if N > 4
    
    874
    +                    crc4 ^= crc_braid_table[k][(word4 >> (k << 3)) & 0xff];
    
    875
    +#if N > 5
    
    876
    +                    crc5 ^= crc_braid_table[k][(word5 >> (k << 3)) & 0xff];
    
    877
    +#endif
    
    878
    +#endif
    
    879
    +#endif
    
    880
    +#endif
    
    881
    +#endif
    
    882
    +                }
    
    883
    +            }
    
    884
    +
    
    885
    +            /*
    
    886
    +              Process the last block, combining the CRCs of the N braids at the
    
    887
    +              same time.
    
    888
    +             */
    
    889
    +            crc = crc_word(crc0 ^ words[0]);
    
    890
    +#if N > 1
    
    891
    +            crc = crc_word(crc1 ^ words[1] ^ crc);
    
    892
    +#if N > 2
    
    893
    +            crc = crc_word(crc2 ^ words[2] ^ crc);
    
    894
    +#if N > 3
    
    895
    +            crc = crc_word(crc3 ^ words[3] ^ crc);
    
    896
    +#if N > 4
    
    897
    +            crc = crc_word(crc4 ^ words[4] ^ crc);
    
    898
    +#if N > 5
    
    899
    +            crc = crc_word(crc5 ^ words[5] ^ crc);
    
    900
    +#endif
    
    901
    +#endif
    
    902
    +#endif
    
    903
    +#endif
    
    904
    +#endif
    
    905
    +            words += N;
    
    906
    +        }
    
    907
    +        else {
    
    908
    +            /* Big endian. */
    
    909
    +
    
    910
    +            z_word_t crc0, word0, comb;
    
    911
    +#if N > 1
    
    912
    +            z_word_t crc1, word1;
    
    913
    +#if N > 2
    
    914
    +            z_word_t crc2, word2;
    
    915
    +#if N > 3
    
    916
    +            z_word_t crc3, word3;
    
    917
    +#if N > 4
    
    918
    +            z_word_t crc4, word4;
    
    919
    +#if N > 5
    
    920
    +            z_word_t crc5, word5;
    
    921
    +#endif
    
    922
    +#endif
    
    923
    +#endif
    
    924
    +#endif
    
    925
    +#endif
    
    926
    +
    
    927
    +            /* Initialize the CRC for each braid. */
    
    928
    +            crc0 = byte_swap(crc);
    
    929
    +#if N > 1
    
    930
    +            crc1 = 0;
    
    931
    +#if N > 2
    
    932
    +            crc2 = 0;
    
    933
    +#if N > 3
    
    934
    +            crc3 = 0;
    
    935
    +#if N > 4
    
    936
    +            crc4 = 0;
    
    937
    +#if N > 5
    
    938
    +            crc5 = 0;
    
    939
    +#endif
    
    940
    +#endif
    
    941
    +#endif
    
    942
    +#endif
    
    943
    +#endif
    
    944
    +
    
    945
    +            /*
    
    946
    +              Process the first blks-1 blocks, computing the CRCs on each braid
    
    947
    +              independently.
    
    948
    +             */
    
    949
    +            while (--blks) {
    
    950
    +                /* Load the word for each braid into registers. */
    
    951
    +                word0 = crc0 ^ words[0];
    
    952
    +#if N > 1
    
    953
    +                word1 = crc1 ^ words[1];
    
    954
    +#if N > 2
    
    955
    +                word2 = crc2 ^ words[2];
    
    956
    +#if N > 3
    
    957
    +                word3 = crc3 ^ words[3];
    
    958
    +#if N > 4
    
    959
    +                word4 = crc4 ^ words[4];
    
    960
    +#if N > 5
    
    961
    +                word5 = crc5 ^ words[5];
    
    962
    +#endif
    
    963
    +#endif
    
    964
    +#endif
    
    965
    +#endif
    
    966
    +#endif
    
    967
    +                words += N;
    
    968
    +
    
    969
    +                /* Compute and update the CRC for each word. The loop should
    
    970
    +                   get unrolled. */
    
    971
    +                crc0 = crc_braid_big_table[0][word0 & 0xff];
    
    972
    +#if N > 1
    
    973
    +                crc1 = crc_braid_big_table[0][word1 & 0xff];
    
    974
    +#if N > 2
    
    975
    +                crc2 = crc_braid_big_table[0][word2 & 0xff];
    
    976
    +#if N > 3
    
    977
    +                crc3 = crc_braid_big_table[0][word3 & 0xff];
    
    978
    +#if N > 4
    
    979
    +                crc4 = crc_braid_big_table[0][word4 & 0xff];
    
    980
    +#if N > 5
    
    981
    +                crc5 = crc_braid_big_table[0][word5 & 0xff];
    
    982
    +#endif
    
    983
    +#endif
    
    984
    +#endif
    
    985
    +#endif
    
    986
    +#endif
    
    987
    +                for (k = 1; k < W; k++) {
    
    988
    +                    crc0 ^= crc_braid_big_table[k][(word0 >> (k << 3)) & 0xff];
    
    989
    +#if N > 1
    
    990
    +                    crc1 ^= crc_braid_big_table[k][(word1 >> (k << 3)) & 0xff];
    
    991
    +#if N > 2
    
    992
    +                    crc2 ^= crc_braid_big_table[k][(word2 >> (k << 3)) & 0xff];
    
    993
    +#if N > 3
    
    994
    +                    crc3 ^= crc_braid_big_table[k][(word3 >> (k << 3)) & 0xff];
    
    995
    +#if N > 4
    
    996
    +                    crc4 ^= crc_braid_big_table[k][(word4 >> (k << 3)) & 0xff];
    
    997
    +#if N > 5
    
    998
    +                    crc5 ^= crc_braid_big_table[k][(word5 >> (k << 3)) & 0xff];
    
    999
    +#endif
    
    1000
    +#endif
    
    1001
    +#endif
    
    1002
    +#endif
    
    1003
    +#endif
    
    1004
    +                }
    
    1005
    +            }
    
    1006
    +
    
    1007
    +            /*
    
    1008
    +              Process the last block, combining the CRCs of the N braids at the
    
    1009
    +              same time.
    
    1010
    +             */
    
    1011
    +            comb = crc_word_big(crc0 ^ words[0]);
    
    1012
    +#if N > 1
    
    1013
    +            comb = crc_word_big(crc1 ^ words[1] ^ comb);
    
    1014
    +#if N > 2
    
    1015
    +            comb = crc_word_big(crc2 ^ words[2] ^ comb);
    
    1016
    +#if N > 3
    
    1017
    +            comb = crc_word_big(crc3 ^ words[3] ^ comb);
    
    1018
    +#if N > 4
    
    1019
    +            comb = crc_word_big(crc4 ^ words[4] ^ comb);
    
    1020
    +#if N > 5
    
    1021
    +            comb = crc_word_big(crc5 ^ words[5] ^ comb);
    
    1022
    +#endif
    
    1023
    +#endif
    
    1024
    +#endif
    
    1025
    +#endif
    
    1026
    +#endif
    
    1027
    +            words += N;
    
    1028
    +            crc = byte_swap(comb);
    
    1029
    +        }
    
    1030
    +
    
    1031
    +        /*
    
    1032
    +          Update the pointer to the remaining bytes to process.
    
    1033
    +         */
    
    1034
    +        buf = (unsigned char const *)words;
    
    321 1035
         }
    
    322 1036
     
    
    323
    -    buf4 = (const z_crc_t FAR *)(const void FAR *)buf;
    
    324
    -    while (len >= 32) {
    
    325
    -        DOBIG32;
    
    326
    -        len -= 32;
    
    1037
    +#endif /* W */
    
    1038
    +
    
    1039
    +    /* Complete the computation of the CRC on any remaining bytes. */
    
    1040
    +    while (len >= 8) {
    
    1041
    +        len -= 8;
    
    1042
    +        crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
    
    1043
    +        crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
    
    1044
    +        crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
    
    1045
    +        crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
    
    1046
    +        crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
    
    1047
    +        crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
    
    1048
    +        crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
    
    1049
    +        crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
    
    327 1050
         }
    
    328
    -    while (len >= 4) {
    
    329
    -        DOBIG4;
    
    330
    -        len -= 4;
    
    1051
    +    while (len) {
    
    1052
    +        len--;
    
    1053
    +        crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff];
    
    331 1054
         }
    
    332
    -    buf = (const unsigned char FAR *)buf4;
    
    333 1055
     
    
    334
    -    if (len) do {
    
    335
    -        c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
    
    336
    -    } while (--len);
    
    337
    -    c = ~c;
    
    338
    -    return (unsigned long)(ZSWAP32(c));
    
    1056
    +    /* Return the CRC, post-conditioned. */
    
    1057
    +    return crc ^ 0xffffffff;
    
    339 1058
     }
    
    340 1059
     
    
    341
    -#endif /* BYFOUR */
    
    342
    -
    
    343
    -#define GF2_DIM 32      /* dimension of GF(2) vectors (length of CRC) */
    
    1060
    +#endif
    
    344 1061
     
    
    345 1062
     /* ========================================================================= */
    
    346
    -local unsigned long gf2_matrix_times(
    
    347
    -    unsigned long *mat,
    
    348
    -    unsigned long vec)
    
    1063
    +unsigned long ZEXPORT crc32(
    
    1064
    +    unsigned long crc,
    
    1065
    +    const unsigned char FAR *buf,
    
    1066
    +    uInt len)
    
    349 1067
     {
    
    350
    -    unsigned long sum;
    
    351
    -
    
    352
    -    sum = 0;
    
    353
    -    while (vec) {
    
    354
    -        if (vec & 1)
    
    355
    -            sum ^= *mat;
    
    356
    -        vec >>= 1;
    
    357
    -        mat++;
    
    358
    -    }
    
    359
    -    return sum;
    
    1068
    +    return crc32_z(crc, buf, len);
    
    360 1069
     }
    
    361 1070
     
    
    362 1071
     /* ========================================================================= */
    
    363
    -local void gf2_matrix_square(
    
    364
    -    unsigned long *square,
    
    365
    -    unsigned long *mat)
    
    1072
    +uLong ZEXPORT crc32_combine64(
    
    1073
    +    uLong crc1,
    
    1074
    +    uLong crc2,
    
    1075
    +    z_off64_t len2)
    
    366 1076
     {
    
    367
    -    int n;
    
    368
    -
    
    369
    -    for (n = 0; n < GF2_DIM; n++)
    
    370
    -        square[n] = gf2_matrix_times(mat, mat[n]);
    
    1077
    +#ifdef DYNAMIC_CRC_TABLE
    
    1078
    +    once(&made, make_crc_table);
    
    1079
    +#endif /* DYNAMIC_CRC_TABLE */
    
    1080
    +    return multmodp(x2nmodp(len2, 3), crc1) ^ crc2;
    
    371 1081
     }
    
    372 1082
     
    
    373 1083
     /* ========================================================================= */
    
    374
    -local uLong crc32_combine_(
    
    1084
    +uLong ZEXPORT crc32_combine(
    
    375 1085
         uLong crc1,
    
    376 1086
         uLong crc2,
    
    377
    -    z_off64_t len2)
    
    1087
    +    z_off_t len2)
    
    378 1088
     {
    
    379
    -    int n;
    
    380
    -    unsigned long row;
    
    381
    -    unsigned long even[GF2_DIM];    /* even-power-of-two zeros operator */
    
    382
    -    unsigned long odd[GF2_DIM];     /* odd-power-of-two zeros operator */
    
    383
    -
    
    384
    -    /* degenerate case (also disallow negative lengths) */
    
    385
    -    if (len2 <= 0)
    
    386
    -        return crc1;
    
    387
    -
    
    388
    -    /* put operator for one zero bit in odd */
    
    389
    -    odd[0] = 0xedb88320UL;          /* CRC-32 polynomial */
    
    390
    -    row = 1;
    
    391
    -    for (n = 1; n < GF2_DIM; n++) {
    
    392
    -        odd[n] = row;
    
    393
    -        row <<= 1;
    
    394
    -    }
    
    1089
    +    return crc32_combine64(crc1, crc2, len2);
    
    1090
    +}
    
    395 1091
     
    
    396
    -    /* put operator for two zero bits in even */
    
    397
    -    gf2_matrix_square(even, odd);
    
    398
    -
    
    399
    -    /* put operator for four zero bits in odd */
    
    400
    -    gf2_matrix_square(odd, even);
    
    401
    -
    
    402
    -    /* apply len2 zeros to crc1 (first square will put the operator for one
    
    403
    -       zero byte, eight zero bits, in even) */
    
    404
    -    do {
    
    405
    -        /* apply zeros operator for this bit of len2 */
    
    406
    -        gf2_matrix_square(even, odd);
    
    407
    -        if (len2 & 1)
    
    408
    -            crc1 = gf2_matrix_times(even, crc1);
    
    409
    -        len2 >>= 1;
    
    410
    -
    
    411
    -        /* if no more bits set, then done */
    
    412
    -        if (len2 == 0)
    
    413
    -            break;
    
    414
    -
    
    415
    -        /* another iteration of the loop with odd and even swapped */
    
    416
    -        gf2_matrix_square(odd, even);
    
    417
    -        if (len2 & 1)
    
    418
    -            crc1 = gf2_matrix_times(odd, crc1);
    
    419
    -        len2 >>= 1;
    
    420
    -
    
    421
    -        /* if no more bits set, then done */
    
    422
    -    } while (len2 != 0);
    
    423
    -
    
    424
    -    /* return combined crc */
    
    425
    -    crc1 ^= crc2;
    
    426
    -    return crc1;
    
    1092
    +/* ========================================================================= */
    
    1093
    +uLong ZEXPORT crc32_combine_gen64(
    
    1094
    +    z_off64_t len2)
    
    1095
    +{
    
    1096
    +#ifdef DYNAMIC_CRC_TABLE
    
    1097
    +    once(&made, make_crc_table);
    
    1098
    +#endif /* DYNAMIC_CRC_TABLE */
    
    1099
    +    return x2nmodp(len2, 3);
    
    427 1100
     }
    
    428 1101
     
    
    429 1102
     /* ========================================================================= */
    
    430
    -uLong ZEXPORT crc32_combine(
    
    431
    -    uLong crc1,
    
    432
    -    uLong crc2,
    
    1103
    +uLong ZEXPORT crc32_combine_gen(
    
    433 1104
         z_off_t len2)
    
    434 1105
     {
    
    435
    -    return crc32_combine_(crc1, crc2, len2);
    
    1106
    +    return crc32_combine_gen64(len2);
    
    436 1107
     }
    
    437 1108
     
    
    438
    -uLong ZEXPORT crc32_combine64(
    
    1109
    +/* ========================================================================= */
    
    1110
    +uLong crc32_combine_op(
    
    439 1111
         uLong crc1,
    
    440 1112
         uLong crc2,
    
    441
    -    z_off64_t len2)
    
    1113
    +    uLong op)
    
    442 1114
     {
    
    443
    -    return crc32_combine_(crc1, crc2, len2);
    
    1115
    +    return multmodp(op, crc1) ^ crc2;
    
    444 1116
     }

  • src/gzip/crc32.h The diff for this file was not included because it is too large.
  • src/gzip/gzguts.h
    1 1
     /* gzguts.h -- zlib internal header definitions for gz* operations
    
    2
    - * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler
    
    2
    + * Copyright (C) 2004-2019 Mark Adler
    
    3 3
      * For conditions of distribution and use, see copyright notice in zlib.h
    
    4 4
      */
    
    5 5
     
    
    ... ... @@ -39,7 +39,7 @@
    39 39
     #  include <io.h>
    
    40 40
     #endif
    
    41 41
     
    
    42
    -#if defined(_WIN32) || defined(__CYGWIN__)
    
    42
    +#if defined(_WIN32)
    
    43 43
     #  define WIDECHAR
    
    44 44
     #endif
    
    45 45
     
    
    ... ... @@ -190,6 +190,7 @@ typedef struct {
    190 190
             /* just for writing */
    
    191 191
         int level;              /* compression level */
    
    192 192
         int strategy;           /* compression strategy */
    
    193
    +    int reset;              /* true if a reset is pending after a Z_FINISH */
    
    193 194
             /* seek request */
    
    194 195
         z_off64_t skip;         /* amount to skip (already rewound if backwards) */
    
    195 196
         int seek;               /* true if seek request pending */
    

  • src/gzip/infback.c
    1 1
     /* infback.c -- inflate using a call-back interface
    
    2
    - * Copyright (C) 1995-2016 Mark Adler
    
    2
    + * Copyright (C) 1995-2022 Mark Adler
    
    3 3
      * For conditions of distribution and use, see copyright notice in zlib.h
    
    4 4
      */
    
    5 5
     
    
    ... ... @@ -477,6 +477,7 @@ int ZEXPORT inflateBack(
    477 477
                 }
    
    478 478
                 Tracev((stderr, "inflate:       codes ok\n"));
    
    479 479
                 state->mode = LEN;
    
    480
    +                /* fallthrough */
    
    480 481
     
    
    481 482
             case LEN:
    
    482 483
                 /* use inflate_fast() if we have enough input and output */
    

  • src/gzip/inffast.c
    ... ... @@ -70,7 +70,7 @@ void ZLIB_INTERNAL inflate_fast(
    70 70
         code const FAR *dcode;      /* local strm->distcode */
    
    71 71
         unsigned lmask;             /* mask for first level of length codes */
    
    72 72
         unsigned dmask;             /* mask for first level of distance codes */
    
    73
    -    code here;                  /* retrieved table entry */
    
    73
    +    code const *here;           /* retrieved table entry */
    
    74 74
         unsigned op;                /* code bits, operation, extra bits, or */
    
    75 75
                                     /*  window position, window bytes to copy */
    
    76 76
         unsigned len;               /* match length, unused bytes */
    
    ... ... @@ -107,20 +107,20 @@ void ZLIB_INTERNAL inflate_fast(
    107 107
                 hold += (unsigned long)(*in++) << bits;
    
    108 108
                 bits += 8;
    
    109 109
             }
    
    110
    -        here = lcode[hold & lmask];
    
    110
    +        here = lcode + (hold & lmask);
    
    111 111
           dolen:
    
    112
    -        op = (unsigned)(here.bits);
    
    112
    +        op = (unsigned)(here->bits);
    
    113 113
             hold >>= op;
    
    114 114
             bits -= op;
    
    115
    -        op = (unsigned)(here.op);
    
    115
    +        op = (unsigned)(here->op);
    
    116 116
             if (op == 0) {                          /* literal */
    
    117
    -            Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
    
    117
    +            Tracevv((stderr, here->val >= 0x20 && here->val < 0x7f ?
    
    118 118
                         "inflate:         literal '%c'\n" :
    
    119
    -                    "inflate:         literal 0x%02x\n", here.val));
    
    120
    -            *out++ = (unsigned char)(here.val);
    
    119
    +                    "inflate:         literal 0x%02x\n", here->val));
    
    120
    +            *out++ = (unsigned char)(here->val);
    
    121 121
             }
    
    122 122
             else if (op & 16) {                     /* length base */
    
    123
    -            len = (unsigned)(here.val);
    
    123
    +            len = (unsigned)(here->val);
    
    124 124
                 op &= 15;                           /* number of extra bits */
    
    125 125
                 if (op) {
    
    126 126
                     if (bits < op) {
    
    ... ... @@ -138,14 +138,14 @@ void ZLIB_INTERNAL inflate_fast(
    138 138
                     hold += (unsigned long)(*in++) << bits;
    
    139 139
                     bits += 8;
    
    140 140
                 }
    
    141
    -            here = dcode[hold & dmask];
    
    141
    +            here = dcode + (hold & dmask);
    
    142 142
               dodist:
    
    143
    -            op = (unsigned)(here.bits);
    
    143
    +            op = (unsigned)(here->bits);
    
    144 144
                 hold >>= op;
    
    145 145
                 bits -= op;
    
    146
    -            op = (unsigned)(here.op);
    
    146
    +            op = (unsigned)(here->op);
    
    147 147
                 if (op & 16) {                      /* distance base */
    
    148
    -                dist = (unsigned)(here.val);
    
    148
    +                dist = (unsigned)(here->val);
    
    149 149
                     op &= 15;                       /* number of extra bits */
    
    150 150
                     if (bits < op) {
    
    151 151
                         hold += (unsigned long)(*in++) << bits;
    
    ... ... @@ -264,7 +264,7 @@ void ZLIB_INTERNAL inflate_fast(
    264 264
                     }
    
    265 265
                 }
    
    266 266
                 else if ((op & 64) == 0) {          /* 2nd level distance code */
    
    267
    -                here = dcode[here.val + (hold & ((1U << op) - 1))];
    
    267
    +                here = dcode + here->val + (hold & ((1U << op) - 1));
    
    268 268
                     goto dodist;
    
    269 269
                 }
    
    270 270
                 else {
    
    ... ... @@ -274,7 +274,7 @@ void ZLIB_INTERNAL inflate_fast(
    274 274
                 }
    
    275 275
             }
    
    276 276
             else if ((op & 64) == 0) {              /* 2nd level length code */
    
    277
    -            here = lcode[here.val + (hold & ((1U << op) - 1))];
    
    277
    +            here = lcode + here->val + (hold & ((1U << op) - 1));
    
    278 278
                 goto dolen;
    
    279 279
             }
    
    280 280
             else if (op & 32) {                     /* end-of-block */
    

  • src/gzip/inflate.c
    1 1
     /* inflate.c -- zlib decompression
    
    2
    - * Copyright (C) 1995-2016 Mark Adler
    
    2
    + * Copyright (C) 1995-2022 Mark Adler
    
    3 3
      * For conditions of distribution and use, see copyright notice in zlib.h
    
    4 4
      */
    
    5 5
     
    
    ... ... @@ -132,6 +132,7 @@ int ZEXPORT inflateResetKeep(
    132 132
         state->mode = HEAD;
    
    133 133
         state->last = 0;
    
    134 134
         state->havedict = 0;
    
    135
    +    state->flags = -1;
    
    135 136
         state->dmax = 32768U;
    
    136 137
         state->head = Z_NULL;
    
    137 138
         state->hold = 0;
    
    ... ... @@ -269,7 +270,7 @@ int ZEXPORT inflatePrime(
    269 270
         return Z_OK;
    
    270 271
     }
    
    271 272
     
    
    272
    -#endif  /* Z_FREETYPE */
    
    273
    +#endif  /* !Z_FREETYPE */
    
    273 274
     
    
    274 275
     /*
    
    275 276
        Return state with length and distance decoding tables and index sizes set to
    
    ... ... @@ -453,10 +454,10 @@ local int updatewindow(
    453 454
     
    
    454 455
     /* check function to use adler32() for zlib or crc32() for gzip */
    
    455 456
     #ifdef GUNZIP
    
    456
    -#  define UPDATE(check, buf, len) \
    
    457
    +#  define UPDATE_CHECK(check, buf, len) \
    
    457 458
         (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
    
    458 459
     #else
    
    459
    -#  define UPDATE(check, buf, len) adler32(check, buf, len)
    
    460
    +#  define UPDATE_CHECK(check, buf, len) adler32(check, buf, len)
    
    460 461
     #endif
    
    461 462
     
    
    462 463
     /* check macros for header crc */
    
    ... ... @@ -676,7 +677,6 @@ int ZEXPORT inflate(
    676 677
                     state->mode = FLAGS;
    
    677 678
                     break;
    
    678 679
                 }
    
    679
    -            state->flags = 0;           /* expect zlib header */
    
    680 680
                 if (state->head != Z_NULL)
    
    681 681
                     state->head->done = -1;
    
    682 682
                 if (!(state->wrap & 1) ||   /* check if zlib header allowed */
    
    ... ... @@ -703,6 +703,7 @@ int ZEXPORT inflate(
    703 703
                     break;
    
    704 704
                 }
    
    705 705
                 state->dmax = 1U << len;
    
    706
    +            state->flags = 0;               /* indicate zlib header */
    
    706 707
                 Tracev((stderr, "inflate:   zlib header ok\n"));
    
    707 708
                 strm->adler = state->check = adler32(0L, Z_NULL, 0);
    
    708 709
                 state->mode = hold & 0x200 ? DICTID : TYPE;
    
    ... ... @@ -728,6 +729,7 @@ int ZEXPORT inflate(
    728 729
                     CRC2(state->check, hold);
    
    729 730
                 INITBITS();
    
    730 731
                 state->mode = TIME;
    
    732
    +                /* fallthrough */
    
    731 733
             case TIME:
    
    732 734
                 NEEDBITS(32);
    
    733 735
                 if (state->head != Z_NULL)
    
    ... ... @@ -736,6 +738,7 @@ int ZEXPORT inflate(
    736 738
                     CRC4(state->check, hold);
    
    737 739
                 INITBITS();
    
    738 740
                 state->mode = OS;
    
    741
    +                /* fallthrough */
    
    739 742
             case OS:
    
    740 743
                 NEEDBITS(16);
    
    741 744
                 if (state->head != Z_NULL) {
    
    ... ... @@ -746,6 +749,7 @@ int ZEXPORT inflate(
    746 749
                     CRC2(state->check, hold);
    
    747 750
                 INITBITS();
    
    748 751
                 state->mode = EXLEN;
    
    752
    +                /* fallthrough */
    
    749 753
             case EXLEN:
    
    750 754
                 if (state->flags & 0x0400) {
    
    751 755
                     NEEDBITS(16);
    
    ... ... @@ -759,6 +763,7 @@ int ZEXPORT inflate(
    759 763
                 else if (state->head != Z_NULL)
    
    760 764
                     state->head->extra = Z_NULL;
    
    761 765
                 state->mode = EXTRA;
    
    766
    +                /* fallthrough */
    
    762 767
             case EXTRA:
    
    763 768
                 if (state->flags & 0x0400) {
    
    764 769
                     copy = state->length;
    
    ... ... @@ -781,6 +786,7 @@ int ZEXPORT inflate(
    781 786
                 }
    
    782 787
                 state->length = 0;
    
    783 788
                 state->mode = NAME;
    
    789
    +                /* fallthrough */
    
    784 790
             case NAME:
    
    785 791
                 if (state->flags & 0x0800) {
    
    786 792
                     if (have == 0) goto inf_leave;
    
    ... ... @@ -802,6 +808,7 @@ int ZEXPORT inflate(
    802 808
                     state->head->name = Z_NULL;
    
    803 809
                 state->length = 0;
    
    804 810
                 state->mode = COMMENT;
    
    811
    +                /* fallthrough */
    
    805 812
             case COMMENT:
    
    806 813
                 if (state->flags & 0x1000) {
    
    807 814
                     if (have == 0) goto inf_leave;
    
    ... ... @@ -822,6 +829,7 @@ int ZEXPORT inflate(
    822 829
                 else if (state->head != Z_NULL)
    
    823 830
                     state->head->comment = Z_NULL;
    
    824 831
                 state->mode = HCRC;
    
    832
    +                /* fallthrough */
    
    825 833
             case HCRC:
    
    826 834
                 if (state->flags & 0x0200) {
    
    827 835
                     NEEDBITS(16);
    
    ... ... @@ -845,6 +853,7 @@ int ZEXPORT inflate(
    845 853
                 strm->adler = state->check = ZSWAP32(hold);
    
    846 854
                 INITBITS();
    
    847 855
                 state->mode = DICT;
    
    856
    +                /* fallthrough */
    
    848 857
             case DICT:
    
    849 858
                 if (state->havedict == 0) {
    
    850 859
                     RESTORE();
    
    ... ... @@ -852,8 +861,10 @@ int ZEXPORT inflate(
    852 861
                 }
    
    853 862
                 strm->adler = state->check = adler32(0L, Z_NULL, 0);
    
    854 863
                 state->mode = TYPE;
    
    864
    +                /* fallthrough */
    
    855 865
             case TYPE:
    
    856 866
                 if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
    
    867
    +                /* fallthrough */
    
    857 868
             case TYPEDO:
    
    858 869
                 if (state->last) {
    
    859 870
                     BYTEBITS();
    
    ... ... @@ -904,8 +915,10 @@ int ZEXPORT inflate(
    904 915
                 INITBITS();
    
    905 916
                 state->mode = COPY_;
    
    906 917
                 if (flush == Z_TREES) goto inf_leave;
    
    918
    +                /* fallthrough */
    
    907 919
             case COPY_:
    
    908 920
                 state->mode = COPY;
    
    921
    +                /* fallthrough */
    
    909 922
             case COPY:
    
    910 923
                 copy = state->length;
    
    911 924
                 if (copy) {
    
    ... ... @@ -941,6 +954,7 @@ int ZEXPORT inflate(
    941 954
                 Tracev((stderr, "inflate:       table sizes ok\n"));
    
    942 955
                 state->have = 0;
    
    943 956
                 state->mode = LENLENS;
    
    957
    +                /* fallthrough */
    
    944 958
             case LENLENS:
    
    945 959
                 while (state->have < state->ncode) {
    
    946 960
                     NEEDBITS(3);
    
    ... ... @@ -962,6 +976,7 @@ int ZEXPORT inflate(
    962 976
                 Tracev((stderr, "inflate:       code lengths ok\n"));
    
    963 977
                 state->have = 0;
    
    964 978
                 state->mode = CODELENS;
    
    979
    +                /* fallthrough */
    
    965 980
             case CODELENS:
    
    966 981
                 while (state->have < state->nlen + state->ndist) {
    
    967 982
                     for (;;) {
    
    ... ... @@ -1045,8 +1060,10 @@ int ZEXPORT inflate(
    1045 1060
                 Tracev((stderr, "inflate:       codes ok\n"));
    
    1046 1061
                 state->mode = LEN_;
    
    1047 1062
                 if (flush == Z_TREES) goto inf_leave;
    
    1063
    +                /* fallthrough */
    
    1048 1064
             case LEN_:
    
    1049 1065
                 state->mode = LEN;
    
    1066
    +                /* fallthrough */
    
    1050 1067
             case LEN:
    
    1051 1068
                 if (have >= 6 && left >= 258) {
    
    1052 1069
                     RESTORE();
    
    ... ... @@ -1096,6 +1113,7 @@ int ZEXPORT inflate(
    1096 1113
                 }
    
    1097 1114
                 state->extra = (unsigned)(here.op) & 15;
    
    1098 1115
                 state->mode = LENEXT;
    
    1116
    +                /* fallthrough */
    
    1099 1117
             case LENEXT:
    
    1100 1118
                 if (state->extra) {
    
    1101 1119
                     NEEDBITS(state->extra);
    
    ... ... @@ -1106,6 +1124,7 @@ int ZEXPORT inflate(
    1106 1124
                 Tracevv((stderr, "inflate:         length %u\n", state->length));
    
    1107 1125
                 state->was = state->length;
    
    1108 1126
                 state->mode = DIST;
    
    1127
    +                /* fallthrough */
    
    1109 1128
             case DIST:
    
    1110 1129
                 for (;;) {
    
    1111 1130
                     here = state->distcode[BITS(state->distbits)];
    
    ... ... @@ -1133,6 +1152,7 @@ int ZEXPORT inflate(
    1133 1152
                 state->offset = (unsigned)here.val;
    
    1134 1153
                 state->extra = (unsigned)(here.op) & 15;
    
    1135 1154
                 state->mode = DISTEXT;
    
    1155
    +                /* fallthrough */
    
    1136 1156
             case DISTEXT:
    
    1137 1157
                 if (state->extra) {
    
    1138 1158
                     NEEDBITS(state->extra);
    
    ... ... @@ -1149,6 +1169,7 @@ int ZEXPORT inflate(
    1149 1169
     #endif
    
    1150 1170
                 Tracevv((stderr, "inflate:         distance %u\n", state->offset));
    
    1151 1171
                 state->mode = MATCH;
    
    1172
    +                /* fallthrough */
    
    1152 1173
             case MATCH:
    
    1153 1174
                 if (left == 0) goto inf_leave;
    
    1154 1175
                 copy = out - left;
    
    ... ... @@ -1208,7 +1229,7 @@ int ZEXPORT inflate(
    1208 1229
                     state->total += out;
    
    1209 1230
                     if ((state->wrap & 4) && out)
    
    1210 1231
                         strm->adler = state->check =
    
    1211
    -                        UPDATE(state->check, put - out, out);
    
    1232
    +                        UPDATE_CHECK(state->check, put - out, out);
    
    1212 1233
                     out = left;
    
    1213 1234
                     if ((state->wrap & 4) && (
    
    1214 1235
     #ifdef GUNZIP
    
    ... ... @@ -1224,10 +1245,11 @@ int ZEXPORT inflate(
    1224 1245
                 }
    
    1225 1246
     #ifdef GUNZIP
    
    1226 1247
                 state->mode = LENGTH;
    
    1248
    +                /* fallthrough */
    
    1227 1249
             case LENGTH:
    
    1228 1250
                 if (state->wrap && state->flags) {
    
    1229 1251
                     NEEDBITS(32);
    
    1230
    -                if (hold != (state->total & 0xffffffffUL)) {
    
    1252
    +                if ((state->wrap & 4) && hold != (state->total & 0xffffffff)) {
    
    1231 1253
                         strm->msg = (char *)"incorrect length check";
    
    1232 1254
                         state->mode = BAD;
    
    1233 1255
                         break;
    
    ... ... @@ -1237,6 +1259,7 @@ int ZEXPORT inflate(
    1237 1259
                 }
    
    1238 1260
     #endif
    
    1239 1261
                 state->mode = DONE;
    
    1262
    +                /* fallthrough */
    
    1240 1263
             case DONE:
    
    1241 1264
                 ret = Z_STREAM_END;
    
    1242 1265
                 goto inf_leave;
    
    ... ... @@ -1246,6 +1269,7 @@ int ZEXPORT inflate(
    1246 1269
             case MEM:
    
    1247 1270
                 return Z_MEM_ERROR;
    
    1248 1271
             case SYNC:
    
    1272
    +                /* fallthrough */
    
    1249 1273
             default:
    
    1250 1274
                 return Z_STREAM_ERROR;
    
    1251 1275
             }
    
    ... ... @@ -1271,7 +1295,7 @@ int ZEXPORT inflate(
    1271 1295
         state->total += out;
    
    1272 1296
         if ((state->wrap & 4) && out)
    
    1273 1297
             strm->adler = state->check =
    
    1274
    -            UPDATE(state->check, strm->next_out - out, out);
    
    1298
    +            UPDATE_CHECK(state->check, strm->next_out - out, out);
    
    1275 1299
         strm->data_type = (int)state->bits + (state->last ? 64 : 0) +
    
    1276 1300
                           (state->mode == TYPE ? 128 : 0) +
    
    1277 1301
                           (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
    
    ... ... @@ -1409,6 +1433,7 @@ int ZEXPORT inflateSync(
    1409 1433
         z_streamp strm)
    
    1410 1434
     {
    
    1411 1435
         unsigned len;               /* number of bytes to look at or looked at */
    
    1436
    +    int flags;                  /* temporary to save header status */
    
    1412 1437
         unsigned long in, out;      /* temporary to save total_in and total_out */
    
    1413 1438
         unsigned char buf[4];       /* to restore bit buffer to byte string */
    
    1414 1439
         struct inflate_state FAR *state;
    
    ... ... @@ -1441,9 +1466,15 @@ int ZEXPORT inflateSync(
    1441 1466
     
    
    1442 1467
         /* return no joy or set up to restart inflate() on a new block */
    
    1443 1468
         if (state->have != 4) return Z_DATA_ERROR;
    
    1469
    +    if (state->flags == -1)
    
    1470
    +        state->wrap = 0;    /* if no header yet, treat as raw */
    
    1471
    +    else
    
    1472
    +        state->wrap &= ~4;  /* no point in computing a check value now */
    
    1473
    +    flags = state->flags;
    
    1444 1474
         in = strm->total_in;  out = strm->total_out;
    
    1445 1475
         inflateReset(strm);
    
    1446 1476
         strm->total_in = in;  strm->total_out = out;
    
    1477
    +    state->flags = flags;
    
    1447 1478
         state->mode = TYPE;
    
    1448 1479
         return Z_OK;
    
    1449 1480
     }
    
    ... ... @@ -1468,7 +1499,7 @@ int ZEXPORT inflateSyncPoint(
    1468 1499
         return state->mode == STORED && state->bits == 0;
    
    1469 1500
     }
    
    1470 1501
     
    
    1471
    -#if !Z_FREETYPE
    
    1502
    +#ifndef Z_FREETYPE
    
    1472 1503
     
    
    1473 1504
     int ZEXPORT inflateCopy(
    
    1474 1505
         z_streamp dest,
    
    ... ... @@ -1545,7 +1576,7 @@ int ZEXPORT inflateValidate(
    1545 1576
     
    
    1546 1577
         if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
    
    1547 1578
         state = (struct inflate_state FAR *)strm->state;
    
    1548
    -    if (check)
    
    1579
    +    if (check && state->wrap)
    
    1549 1580
             state->wrap |= 4;
    
    1550 1581
         else
    
    1551 1582
             state->wrap &= ~4;
    

  • src/gzip/inflate.h
    1 1
     /* inflate.h -- internal inflate state definition
    
    2
    - * Copyright (C) 1995-2016 Mark Adler
    
    2
    + * Copyright (C) 1995-2019 Mark Adler
    
    3 3
      * For conditions of distribution and use, see copyright notice in zlib.h
    
    4 4
      */
    
    5 5
     
    
    ... ... @@ -89,7 +89,8 @@ struct inflate_state {
    89 89
         int wrap;                   /* bit 0 true for zlib, bit 1 true for gzip,
    
    90 90
                                        bit 2 true to validate check value */
    
    91 91
         int havedict;               /* true if dictionary provided */
    
    92
    -    int flags;                  /* gzip header method and flags (0 if zlib) */
    
    92
    +    int flags;                  /* gzip header method and flags, 0 if zlib, or
    
    93
    +                                   -1 if raw or no header yet */
    
    93 94
         unsigned dmax;              /* zlib header max distance (INFLATE_STRICT) */
    
    94 95
         unsigned long check;        /* protected copy of check value */
    
    95 96
         unsigned long total;        /* protected copy of output count */
    

  • src/gzip/inftrees.c
    1 1
     /* inftrees.c -- generate Huffman trees for efficient decoding
    
    2
    - * Copyright (C) 1995-2017 Mark Adler
    
    2
    + * Copyright (C) 1995-2022 Mark Adler
    
    3 3
      * For conditions of distribution and use, see copyright notice in zlib.h
    
    4 4
      */
    
    5 5
     
    
    ... ... @@ -9,7 +9,7 @@
    9 9
     #define MAXBITS 15
    
    10 10
     
    
    11 11
     const char inflate_copyright[] =
    
    12
    -   " inflate 1.2.11 Copyright 1995-2017 Mark Adler ";
    
    12
    +   " inflate 1.2.12 Copyright 1995-2022 Mark Adler ";
    
    13 13
     /*
    
    14 14
       If you use the zlib library in a product, an acknowledgment is welcome
    
    15 15
       in the documentation of your product. If for some reason you cannot
    
    ... ... @@ -62,7 +62,7 @@ int ZLIB_INTERNAL inflate_table(
    62 62
             35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
    
    63 63
         static const unsigned short lext[31] = { /* Length codes 257..285 extra */
    
    64 64
             16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
    
    65
    -        19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 77, 202};
    
    65
    +        19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 199, 202};
    
    66 66
         static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
    
    67 67
             1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
    
    68 68
             257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
    

  • src/gzip/patches/freetype-zlib.diff
    ... ... @@ -6,8 +6,6 @@ are compiled as part of `src/gzip/ftgzip.c`.
    6 6
     * src/gzip/adler32.c: Do not define unused functions when `Z_FREETYPE`
    
    7 7
     is set.
    
    8 8
     
    
    9
    -* src/gzip/crc32.c (DO1, DO8): Undefine.  Already defined in `adler32.c`.
    
    10
    -
    
    11 9
     * src/gzip/gzguts.h (COPY): Rename to...
    
    12 10
     (COPY__): ... this since `COPY` and `COPY_` conflict with enum values,
    
    13 11
     which have the same name in `zlib.h`.
    
    ... ... @@ -25,10 +23,10 @@ Omit unused function declarations when `Z_FREETYPE` is defined.
    25 23
     * src/gzip/inflate.h, src/gzip/inftrees.h: Add header guard macros to
    
    26 24
     prevent compiler errors.
    
    27 25
     
    
    28
    -diff --git b/src/gzip/adler32.c a/src/gzip/adler32.c
    
    26
    +diff --git a/src/gzip/adler32.c b/src/gzip/adler32.c
    
    29 27
     index be5e8a247..aa032e1dd 100644
    
    30
    ---- b/src/gzip/adler32.c
    
    31
    -+++ a/src/gzip/adler32.c
    
    28
    +--- a/src/gzip/adler32.c
    
    29
    ++++ b/src/gzip/adler32.c
    
    32 30
     @@ -7,7 +7,9 @@
    
    33 31
      
    
    34 32
      #include "zutil.h"
    
    ... ... @@ -54,23 +52,10 @@ index be5e8a247..aa032e1dd 100644
    54 52
      }
    
    55 53
     +
    
    56 54
     +#endif  /* !Z_FREETYPE */
    
    57
    -diff --git b/src/gzip/crc32.c a/src/gzip/crc32.c
    
    58
    -index 3e3eb1794..ffced1ea7 100644
    
    59
    ---- b/src/gzip/crc32.c
    
    60
    -+++ a/src/gzip/crc32.c
    
    61
    -@@ -195,6 +195,8 @@ const z_crc_t FAR * ZEXPORT get_crc_table()
    
    62
    - }
    
    63
    - 
    
    64
    - /* ========================================================================= */
    
    65
    -+#undef DO1
    
    66
    -+#undef DO8
    
    67
    - #define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
    
    68
    - #define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
    
    69
    - 
    
    70
    -diff --git b/src/gzip/gzguts.h a/src/gzip/gzguts.h
    
    71
    -index 990a4d251..c81f8f392 100644
    
    72
    ---- b/src/gzip/gzguts.h
    
    73
    -+++ a/src/gzip/gzguts.h
    
    55
    +diff --git a/src/gzip/gzguts.h b/src/gzip/gzguts.h
    
    56
    +index 57faf3716..4f09a52a7 100644
    
    57
    +--- a/src/gzip/gzguts.h
    
    58
    ++++ b/src/gzip/gzguts.h
    
    74 59
     @@ -163,7 +163,7 @@
    
    75 60
      
    
    76 61
      /* values for gz_state how */
    
    ... ... @@ -80,10 +65,10 @@ index 990a4d251..c81f8f392 100644
    80 65
      #define GZIP 2      /* decompress a gzip stream */
    
    81 66
      
    
    82 67
      /* internal gzip file state data structure */
    
    83
    -diff --git b/src/gzip/inflate.c a/src/gzip/inflate.c
    
    84
    -index 3f7ea647b..7387e6f57 100644
    
    85
    ---- b/src/gzip/inflate.c
    
    86
    -+++ a/src/gzip/inflate.c
    
    68
    +diff --git a/src/gzip/inflate.c b/src/gzip/inflate.c
    
    69
    +index 4375557b4..5bf5b815e 100644
    
    70
    +--- a/src/gzip/inflate.c
    
    71
    ++++ b/src/gzip/inflate.c
    
    87 72
     @@ -99,8 +99,10 @@ local int updatewindow OF((z_streamp strm, const unsigned char FAR *end,
    
    88 73
      #ifdef BUILDFIXED
    
    89 74
         void makefixed OF((void));
    
    ... ... @@ -95,7 +80,7 @@ index 3f7ea647b..7387e6f57 100644
    95 80
      
    
    96 81
      local int inflateStateCheck(
    
    97 82
          z_streamp strm)
    
    98
    -@@ -244,6 +246,8 @@ int ZEXPORT inflateInit_(
    
    83
    +@@ -245,6 +247,8 @@ int ZEXPORT inflateInit_(
    
    99 84
          return inflateInit2_(strm, DEF_WBITS, version, stream_size);
    
    100 85
      }
    
    101 86
      
    
    ... ... @@ -104,16 +89,16 @@ index 3f7ea647b..7387e6f57 100644
    104 89
      int ZEXPORT inflatePrime(
    
    105 90
          z_streamp strm,
    
    106 91
          int bits,
    
    107
    -@@ -265,6 +269,8 @@ int ZEXPORT inflatePrime(
    
    92
    +@@ -266,6 +270,8 @@ int ZEXPORT inflatePrime(
    
    108 93
          return Z_OK;
    
    109 94
      }
    
    110 95
      
    
    111
    -+#endif  /* Z_FREETYPE */
    
    96
    ++#endif  /* !Z_FREETYPE */
    
    112 97
     +
    
    113 98
      /*
    
    114 99
         Return state with length and distance decoding tables and index sizes set to
    
    115 100
         fixed code decoding.  Normally this returns fixed tables from inffixed.h.
    
    116
    -@@ -1288,6 +1294,8 @@ int ZEXPORT inflateEnd(
    
    101
    +@@ -1312,6 +1318,8 @@ int ZEXPORT inflateEnd(
    
    117 102
          return Z_OK;
    
    118 103
      }
    
    119 104
      
    
    ... ... @@ -122,7 +107,7 @@ index 3f7ea647b..7387e6f57 100644
    122 107
      int ZEXPORT inflateGetDictionary(
    
    123 108
          z_streamp strm,
    
    124 109
          Bytef *dictionary,
    
    125
    -@@ -1440,6 +1448,8 @@ int ZEXPORT inflateSync(
    
    110
    +@@ -1471,6 +1479,8 @@ int ZEXPORT inflateSync(
    
    126 111
          return Z_OK;
    
    127 112
      }
    
    128 113
      
    
    ... ... @@ -131,16 +116,16 @@ index 3f7ea647b..7387e6f57 100644
    131 116
      /*
    
    132 117
         Returns true if inflate is currently at the end of a block generated by
    
    133 118
         Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
    
    134
    -@@ -1458,6 +1468,8 @@ int ZEXPORT inflateSyncPoint(
    
    119
    +@@ -1489,6 +1499,8 @@ int ZEXPORT inflateSyncPoint(
    
    135 120
          return state->mode == STORED && state->bits == 0;
    
    136 121
      }
    
    137 122
      
    
    138
    -+#if !Z_FREETYPE
    
    123
    ++#ifndef Z_FREETYPE
    
    139 124
     +
    
    140 125
      int ZEXPORT inflateCopy(
    
    141 126
          z_streamp dest,
    
    142 127
          z_streamp source)
    
    143
    -@@ -1505,6 +1517,8 @@ int ZEXPORT inflateCopy(
    
    128
    +@@ -1536,6 +1548,8 @@ int ZEXPORT inflateCopy(
    
    144 129
          return Z_OK;
    
    145 130
      }
    
    146 131
      
    
    ... ... @@ -149,7 +134,7 @@ index 3f7ea647b..7387e6f57 100644
    149 134
      int ZEXPORT inflateUndermine(
    
    150 135
          z_streamp strm,
    
    151 136
          int subvert)
    
    152
    -@@ -1538,6 +1552,8 @@ int ZEXPORT inflateValidate(
    
    137
    +@@ -1569,6 +1583,8 @@ int ZEXPORT inflateValidate(
    
    153 138
          return Z_OK;
    
    154 139
      }
    
    155 140
      
    
    ... ... @@ -158,16 +143,16 @@ index 3f7ea647b..7387e6f57 100644
    158 143
      long ZEXPORT inflateMark(
    
    159 144
          z_streamp strm)
    
    160 145
      {
    
    161
    -@@ -1559,3 +1575,5 @@ unsigned long ZEXPORT inflateCodesUsed(
    
    146
    +@@ -1590,3 +1606,5 @@ unsigned long ZEXPORT inflateCodesUsed(
    
    162 147
          state = (struct inflate_state FAR *)strm->state;
    
    163 148
          return (unsigned long)(state->next - state->codes);
    
    164 149
      }
    
    165 150
     +
    
    166 151
     +#endif  /* !Z_FREETYPE */
    
    167
    -diff --git b/src/gzip/inflate.h a/src/gzip/inflate.h
    
    168
    -index a46cce6b6..92ea758e2 100644
    
    169
    ---- b/src/gzip/inflate.h
    
    170
    -+++ a/src/gzip/inflate.h
    
    152
    +diff --git a/src/gzip/inflate.h b/src/gzip/inflate.h
    
    153
    +index f127b6b1f..c6f5a52e1 100644
    
    154
    +--- a/src/gzip/inflate.h
    
    155
    ++++ b/src/gzip/inflate.h
    
    171 156
     @@ -3,6 +3,9 @@
    
    172 157
       * For conditions of distribution and use, see copyright notice in zlib.h
    
    173 158
       */
    
    ... ... @@ -178,16 +163,16 @@ index a46cce6b6..92ea758e2 100644
    178 163
      /* WARNING: this file should *not* be used by applications. It is
    
    179 164
         part of the implementation of the compression library and is
    
    180 165
         subject to change. Applications should only use zlib.h.
    
    181
    -@@ -123,3 +126,5 @@ struct inflate_state {
    
    166
    +@@ -124,3 +127,5 @@ struct inflate_state {
    
    182 167
          int back;                   /* bits back of last unprocessed length/lit */
    
    183 168
          unsigned was;               /* initial length of match */
    
    184 169
      };
    
    185 170
     +
    
    186 171
     +#endif  /* INFLATE_H */
    
    187
    -diff --git b/src/gzip/inftrees.h a/src/gzip/inftrees.h
    
    172
    +diff --git a/src/gzip/inftrees.h b/src/gzip/inftrees.h
    
    188 173
     index baa53a0b1..c94eb78b5 100644
    
    189
    ---- b/src/gzip/inftrees.h
    
    190
    -+++ a/src/gzip/inftrees.h
    
    174
    +--- a/src/gzip/inftrees.h
    
    175
    ++++ b/src/gzip/inftrees.h
    
    191 176
     @@ -3,6 +3,9 @@
    
    192 177
       * For conditions of distribution and use, see copyright notice in zlib.h
    
    193 178
       */
    
    ... ... @@ -204,10 +189,10 @@ index baa53a0b1..c94eb78b5 100644
    204 189
                                   unsigned FAR *bits, unsigned short FAR *work));
    
    205 190
     +
    
    206 191
     +#endif  /* INFTREES_H_ */
    
    207
    -diff --git b/src/gzip/zlib.h a/src/gzip/zlib.h
    
    208
    -index f09cdaf1e..1807c0645 100644
    
    209
    ---- b/src/gzip/zlib.h
    
    210
    -+++ a/src/gzip/zlib.h
    
    192
    +diff --git a/src/gzip/zlib.h b/src/gzip/zlib.h
    
    193
    +index 4a98e38bf..d760140c2 100644
    
    194
    +--- a/src/gzip/zlib.h
    
    195
    ++++ b/src/gzip/zlib.h
    
    211 196
     @@ -31,7 +31,7 @@
    
    212 197
      #ifndef ZLIB_H
    
    213 198
      #define ZLIB_H
    
    ... ... @@ -251,7 +236,7 @@ index f09cdaf1e..1807c0645 100644
    251 236
      /*
    
    252 237
      ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
    
    253 238
                                           int  level,
    
    254
    -@@ -954,6 +958,8 @@ ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
    
    239
    +@@ -956,6 +960,8 @@ ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
    
    255 240
         destination.
    
    256 241
      */
    
    257 242
      
    
    ... ... @@ -260,7 +245,7 @@ index f09cdaf1e..1807c0645 100644
    260 245
      ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
    
    261 246
      /*
    
    262 247
           This function is equivalent to inflateEnd followed by inflateInit,
    
    263
    -@@ -978,6 +984,8 @@ ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm,
    
    248
    +@@ -980,6 +986,8 @@ ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm,
    
    264 249
         the windowBits parameter is invalid.
    
    265 250
      */
    
    266 251
      
    
    ... ... @@ -269,7 +254,7 @@ index f09cdaf1e..1807c0645 100644
    269 254
      ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
    
    270 255
                                           int bits,
    
    271 256
                                           int value));
    
    272
    -@@ -1067,6 +1075,8 @@ ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
    
    257
    +@@ -1069,6 +1077,8 @@ ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
    
    273 258
         stream state was inconsistent.
    
    274 259
      */
    
    275 260
      
    
    ... ... @@ -278,7 +263,7 @@ index f09cdaf1e..1807c0645 100644
    278 263
      /*
    
    279 264
      ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
    
    280 265
                                              unsigned char FAR *window));
    
    281
    -@@ -1093,6 +1103,8 @@ typedef unsigned (*in_func) OF((void FAR *,
    
    266
    +@@ -1095,6 +1105,8 @@ typedef unsigned (*in_func) OF((void FAR *,
    
    282 267
                                      z_const unsigned char FAR * FAR *));
    
    283 268
      typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
    
    284 269
      
    
    ... ... @@ -287,7 +272,7 @@ index f09cdaf1e..1807c0645 100644
    287 272
      ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
    
    288 273
                                          in_func in, void FAR *in_desc,
    
    289 274
                                          out_func out, void FAR *out_desc));
    
    290
    -@@ -1212,6 +1224,8 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
    
    275
    +@@ -1214,6 +1226,8 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
    
    291 276
           27-31: 0 (reserved)
    
    292 277
       */
    
    293 278
      
    
    ... ... @@ -296,16 +281,16 @@ index f09cdaf1e..1807c0645 100644
    296 281
      #ifndef Z_SOLO
    
    297 282
      
    
    298 283
                              /* utility functions */
    
    299
    -@@ -1739,6 +1753,8 @@ ZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));
    
    284
    +@@ -1742,6 +1756,8 @@ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
    
    300 285
           if (crc != original_crc) error();
    
    301 286
      */
    
    302 287
      
    
    303 288
     +#ifndef Z_FREETYPE
    
    304 289
     +
    
    305
    - ZEXTERN uLong ZEXPORT crc32_z OF((uLong adler, const Bytef *buf,
    
    290
    + ZEXTERN uLong ZEXPORT crc32_z OF((uLong crc, const Bytef *buf,
    
    306 291
                                        z_size_t len));
    
    307 292
      /*
    
    308
    -@@ -1805,6 +1821,19 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
    
    293
    +@@ -1822,6 +1838,19 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
    
    309 294
                                 ZLIB_VERSION, (int)sizeof(z_stream))
    
    310 295
      #endif
    
    311 296
      
    
    ... ... @@ -325,13 +310,14 @@ index f09cdaf1e..1807c0645 100644
    325 310
      #ifndef Z_SOLO
    
    326 311
      
    
    327 312
      /* gzgetc() macro and its supporting function and exposed data structure.  Note
    
    328
    -@@ -1879,12 +1908,15 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file));  /* backward compatibility */
    
    313
    +@@ -1901,13 +1930,16 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file));  /* backward compatibility */
    
    329 314
      
    
    330 315
      #else /* Z_SOLO */
    
    331 316
      
    
    332 317
     +#ifndef Z_FREETYPE
    
    333 318
         ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
    
    334 319
         ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
    
    320
    +    ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t));
    
    335 321
     +#endif
    
    336 322
      
    
    337 323
      #endif /* !Z_SOLO */
    
    ... ... @@ -341,7 +327,7 @@ index f09cdaf1e..1807c0645 100644
    341 327
      ZEXTERN const char   * ZEXPORT zError           OF((int));
    
    342 328
      ZEXTERN int            ZEXPORT inflateSyncPoint OF((z_streamp));
    
    343 329
      ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table    OF((void));
    
    344
    -@@ -1904,6 +1936,7 @@ ZEXTERN int            ZEXPORTVA gzvprintf Z_ARG((gzFile file,
    
    330
    +@@ -1927,6 +1959,7 @@ ZEXTERN int            ZEXPORTVA gzvprintf Z_ARG((gzFile file,
    
    345 331
                                                        va_list va));
    
    346 332
      #  endif
    
    347 333
      #endif
    
    ... ... @@ -349,21 +335,11 @@ index f09cdaf1e..1807c0645 100644
    349 335
      
    
    350 336
      #ifdef __cplusplus
    
    351 337
      }
    
    352
    -diff --git b/src/gzip/zutil.h a/src/gzip/zutil.h
    
    353
    -index b079ea6a8..2d734a835 100644
    
    354
    ---- b/src/gzip/zutil.h
    
    355
    -+++ a/src/gzip/zutil.h
    
    356
    -@@ -30,7 +30,9 @@
    
    357
    - #endif
    
    358
    - 
    
    359
    - #ifdef Z_SOLO
    
    360
    -+#  ifndef Z_FREETYPE
    
    361
    -    typedef long ptrdiff_t;  /* guess -- will be caught if guess is wrong */
    
    362
    -+#  endif
    
    363
    - #endif
    
    364
    - 
    
    365
    - #ifndef local
    
    366
    -@@ -185,6 +187,8 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
    
    338
    +diff --git a/src/gzip/zutil.h b/src/gzip/zutil.h
    
    339
    +index d9a20ae1b..14f0f1a85 100644
    
    340
    +--- a/src/gzip/zutil.h
    
    341
    ++++ b/src/gzip/zutil.h
    
    342
    +@@ -188,6 +188,8 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
    
    367 343
        #pragma warn -8066
    
    368 344
      #endif
    
    369 345
      
    
    ... ... @@ -372,7 +348,7 @@ index b079ea6a8..2d734a835 100644
    372 348
      /* provide prototypes for these when building zlib without LFS */
    
    373 349
      #if !defined(_WIN32) && \
    
    374 350
          (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
    
    375
    -@@ -192,6 +196,8 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
    
    351
    +@@ -195,6 +197,8 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
    
    376 352
          ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
    
    377 353
      #endif
    
    378 354
      
    
    ... ... @@ -381,7 +357,7 @@ index b079ea6a8..2d734a835 100644
    381 357
              /* common defaults */
    
    382 358
      
    
    383 359
      #ifndef OS_CODE
    
    384
    -@@ -223,9 +229,9 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
    
    360
    +@@ -226,9 +230,9 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
    
    385 361
      #    define zmemcmp _fmemcmp
    
    386 362
      #    define zmemzero(dest, len) _fmemset(dest, 0, len)
    
    387 363
      #  else
    

  • src/gzip/zlib.h
    1 1
     /* zlib.h -- interface of the 'zlib' general purpose compression library
    
    2
    -  version 1.2.11, January 15th, 2017
    
    2
    +  version 1.2.12, March 11th, 2022
    
    3 3
     
    
    4
    -  Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
    
    4
    +  Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler
    
    5 5
     
    
    6 6
       This software is provided 'as-is', without any express or implied
    
    7 7
       warranty.  In no event will the authors be held liable for any damages
    
    ... ... @@ -37,11 +37,11 @@
    37 37
     extern "C" {
    
    38 38
     #endif
    
    39 39
     
    
    40
    -#define ZLIB_VERSION "1.2.11"
    
    41
    -#define ZLIB_VERNUM 0x12b0
    
    40
    +#define ZLIB_VERSION "1.2.12"
    
    41
    +#define ZLIB_VERNUM 0x12c0
    
    42 42
     #define ZLIB_VER_MAJOR 1
    
    43 43
     #define ZLIB_VER_MINOR 2
    
    44
    -#define ZLIB_VER_REVISION 11
    
    44
    +#define ZLIB_VER_REVISION 12
    
    45 45
     #define ZLIB_VER_SUBREVISION 0
    
    46 46
     
    
    47 47
     /*
    
    ... ... @@ -547,8 +547,7 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
    547 547
                                          int  strategy));
    
    548 548
     
    
    549 549
          This is another version of deflateInit with more compression options.  The
    
    550
    -   fields next_in, zalloc, zfree and opaque must be initialized before by the
    
    551
    -   caller.
    
    550
    +   fields zalloc, zfree and opaque must be initialized before by the caller.
    
    552 551
     
    
    553 552
          The method parameter is the compression method.  It must be Z_DEFLATED in
    
    554 553
        this version of the library.
    
    ... ... @@ -716,11 +715,12 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
    716 715
        used to switch between compression and straight copy of the input data, or
    
    717 716
        to switch to a different kind of input data requiring a different strategy.
    
    718 717
        If the compression approach (which is a function of the level) or the
    
    719
    -   strategy is changed, and if any input has been consumed in a previous
    
    720
    -   deflate() call, then the input available so far is compressed with the old
    
    721
    -   level and strategy using deflate(strm, Z_BLOCK).  There are three approaches
    
    722
    -   for the compression levels 0, 1..3, and 4..9 respectively.  The new level
    
    723
    -   and strategy will take effect at the next call of deflate().
    
    718
    +   strategy is changed, and if there have been any deflate() calls since the
    
    719
    +   state was initialized or reset, then the input available so far is
    
    720
    +   compressed with the old level and strategy using deflate(strm, Z_BLOCK).
    
    721
    +   There are three approaches for the compression levels 0, 1..3, and 4..9
    
    722
    +   respectively.  The new level and strategy will take effect at the next call
    
    723
    +   of deflate().
    
    724 724
     
    
    725 725
          If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does
    
    726 726
        not have enough output space to complete, then the parameter change will not
    
    ... ... @@ -869,9 +869,11 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
    869 869
        detection, or add 16 to decode only the gzip format (the zlib format will
    
    870 870
        return a Z_DATA_ERROR).  If a gzip stream is being decoded, strm->adler is a
    
    871 871
        CRC-32 instead of an Adler-32.  Unlike the gunzip utility and gzread() (see
    
    872
    -   below), inflate() will not automatically decode concatenated gzip streams.
    
    873
    -   inflate() will return Z_STREAM_END at the end of the gzip stream.  The state
    
    874
    -   would need to be reset to continue decoding a subsequent gzip stream.
    
    872
    +   below), inflate() will *not* automatically decode concatenated gzip members.
    
    873
    +   inflate() will return Z_STREAM_END at the end of the gzip member.  The state
    
    874
    +   would need to be reset to continue decoding a subsequent gzip member.  This
    
    875
    +   *must* be done if there is more data after a gzip member, in order for the
    
    876
    +   decompression to be compliant with the gzip standard (RFC 1952).
    
    875 877
     
    
    876 878
          inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
    
    877 879
        memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
    
    ... ... @@ -1316,14 +1318,14 @@ typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */
    1316 1318
     /*
    
    1317 1319
     ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
    
    1318 1320
     
    
    1319
    -     Opens a gzip (.gz) file for reading or writing.  The mode parameter is as
    
    1320
    -   in fopen ("rb" or "wb") but can also include a compression level ("wb9") or
    
    1321
    -   a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only
    
    1322
    -   compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F'
    
    1323
    -   for fixed code compression as in "wb9F".  (See the description of
    
    1324
    -   deflateInit2 for more information about the strategy parameter.)  'T' will
    
    1325
    -   request transparent writing or appending with no compression and not using
    
    1326
    -   the gzip format.
    
    1321
    +     Open the gzip (.gz) file at path for reading and decompressing, or
    
    1322
    +   compressing and writing.  The mode parameter is as in fopen ("rb" or "wb")
    
    1323
    +   but can also include a compression level ("wb9") or a strategy: 'f' for
    
    1324
    +   filtered data as in "wb6f", 'h' for Huffman-only compression as in "wb1h",
    
    1325
    +   'R' for run-length encoding as in "wb1R", or 'F' for fixed code compression
    
    1326
    +   as in "wb9F".  (See the description of deflateInit2 for more information
    
    1327
    +   about the strategy parameter.)  'T' will request transparent writing or
    
    1328
    +   appending with no compression and not using the gzip format.
    
    1327 1329
     
    
    1328 1330
          "a" can be used instead of "w" to request that the gzip stream that will
    
    1329 1331
        be written be appended to the file.  "+" will result in an error, since
    
    ... ... @@ -1353,9 +1355,9 @@ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
    1353 1355
     
    
    1354 1356
     ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
    
    1355 1357
     /*
    
    1356
    -     gzdopen associates a gzFile with the file descriptor fd.  File descriptors
    
    1357
    -   are obtained from calls like open, dup, creat, pipe or fileno (if the file
    
    1358
    -   has been previously opened with fopen).  The mode parameter is as in gzopen.
    
    1358
    +     Associate a gzFile with the file descriptor fd.  File descriptors are
    
    1359
    +   obtained from calls like open, dup, creat, pipe or fileno (if the file has
    
    1360
    +   been previously opened with fopen).  The mode parameter is as in gzopen.
    
    1359 1361
     
    
    1360 1362
          The next call of gzclose on the returned gzFile will also close the file
    
    1361 1363
        descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor
    
    ... ... @@ -1376,13 +1378,13 @@ ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
    1376 1378
     
    
    1377 1379
     ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
    
    1378 1380
     /*
    
    1379
    -     Set the internal buffer size used by this library's functions.  The
    
    1380
    -   default buffer size is 8192 bytes.  This function must be called after
    
    1381
    -   gzopen() or gzdopen(), and before any other calls that read or write the
    
    1382
    -   file.  The buffer memory allocation is always deferred to the first read or
    
    1383
    -   write.  Three times that size in buffer space is allocated.  A larger buffer
    
    1384
    -   size of, for example, 64K or 128K bytes will noticeably increase the speed
    
    1385
    -   of decompression (reading).
    
    1381
    +     Set the internal buffer size used by this library's functions for file to
    
    1382
    +   size.  The default buffer size is 8192 bytes.  This function must be called
    
    1383
    +   after gzopen() or gzdopen(), and before any other calls that read or write
    
    1384
    +   the file.  The buffer memory allocation is always deferred to the first read
    
    1385
    +   or write.  Three times that size in buffer space is allocated.  A larger
    
    1386
    +   buffer size of, for example, 64K or 128K bytes will noticeably increase the
    
    1387
    +   speed of decompression (reading).
    
    1386 1388
     
    
    1387 1389
          The new buffer size also affects the maximum length for gzprintf().
    
    1388 1390
     
    
    ... ... @@ -1392,9 +1394,9 @@ ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
    1392 1394
     
    
    1393 1395
     ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
    
    1394 1396
     /*
    
    1395
    -     Dynamically update the compression level or strategy.  See the description
    
    1396
    -   of deflateInit2 for the meaning of these parameters.  Previously provided
    
    1397
    -   data is flushed before the parameter change.
    
    1397
    +     Dynamically update the compression level and strategy for file.  See the
    
    1398
    +   description of deflateInit2 for the meaning of these parameters. Previously
    
    1399
    +   provided data is flushed before applying the parameter changes.
    
    1398 1400
     
    
    1399 1401
          gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not
    
    1400 1402
        opened for writing, Z_ERRNO if there is an error writing the flushed data,
    
    ... ... @@ -1403,7 +1405,7 @@ ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
    1403 1405
     
    
    1404 1406
     ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
    
    1405 1407
     /*
    
    1406
    -     Reads the given number of uncompressed bytes from the compressed file.  If
    
    1408
    +     Read and decompress up to len uncompressed bytes from file into buf.  If
    
    1407 1409
        the input file is not in gzip format, gzread copies the given number of
    
    1408 1410
        bytes into the buffer directly from the file.
    
    1409 1411
     
    
    ... ... @@ -1434,11 +1436,11 @@ ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
    1434 1436
     ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems,
    
    1435 1437
                                          gzFile file));
    
    1436 1438
     /*
    
    1437
    -     Read up to nitems items of size size from file to buf, otherwise operating
    
    1438
    -   as gzread() does.  This duplicates the interface of stdio's fread(), with
    
    1439
    -   size_t request and return types.  If the library defines size_t, then
    
    1440
    -   z_size_t is identical to size_t.  If not, then z_size_t is an unsigned
    
    1441
    -   integer type that can contain a pointer.
    
    1439
    +     Read and decompress up to nitems items of size size from file into buf,
    
    1440
    +   otherwise operating as gzread() does.  This duplicates the interface of
    
    1441
    +   stdio's fread(), with size_t request and return types.  If the library
    
    1442
    +   defines size_t, then z_size_t is identical to size_t.  If not, then z_size_t
    
    1443
    +   is an unsigned integer type that can contain a pointer.
    
    1442 1444
     
    
    1443 1445
          gzfread() returns the number of full items read of size size, or zero if
    
    1444 1446
        the end of the file was reached and a full item could not be read, or if
    
    ... ... @@ -1457,18 +1459,16 @@ ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems,
    1457 1459
        file, reseting and retrying on end-of-file, when size is not 1.
    
    1458 1460
     */
    
    1459 1461
     
    
    1460
    -ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
    
    1461
    -                                voidpc buf, unsigned len));
    
    1462
    +ZEXTERN int ZEXPORT gzwrite OF((gzFile file, voidpc buf, unsigned len));
    
    1462 1463
     /*
    
    1463
    -     Writes the given number of uncompressed bytes into the compressed file.
    
    1464
    -   gzwrite returns the number of uncompressed bytes written or 0 in case of
    
    1465
    -   error.
    
    1464
    +     Compress and write the len uncompressed bytes at buf to file. gzwrite
    
    1465
    +   returns the number of uncompressed bytes written or 0 in case of error.
    
    1466 1466
     */
    
    1467 1467
     
    
    1468 1468
     ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size,
    
    1469 1469
                                           z_size_t nitems, gzFile file));
    
    1470 1470
     /*
    
    1471
    -     gzfwrite() writes nitems items of size size from buf to file, duplicating
    
    1471
    +     Compress and write nitems items of size size from buf to file, duplicating
    
    1472 1472
        the interface of stdio's fwrite(), with size_t request and return types.  If
    
    1473 1473
        the library defines size_t, then z_size_t is identical to size_t.  If not,
    
    1474 1474
        then z_size_t is an unsigned integer type that can contain a pointer.
    
    ... ... @@ -1481,22 +1481,22 @@ ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size,
    1481 1481
     
    
    1482 1482
     ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...));
    
    1483 1483
     /*
    
    1484
    -     Converts, formats, and writes the arguments to the compressed file under
    
    1485
    -   control of the format string, as in fprintf.  gzprintf returns the number of
    
    1484
    +     Convert, format, compress, and write the arguments (...) to file under
    
    1485
    +   control of the string format, as in fprintf.  gzprintf returns the number of
    
    1486 1486
        uncompressed bytes actually written, or a negative zlib error code in case
    
    1487 1487
        of error.  The number of uncompressed bytes written is limited to 8191, or
    
    1488 1488
        one less than the buffer size given to gzbuffer().  The caller should assure
    
    1489 1489
        that this limit is not exceeded.  If it is exceeded, then gzprintf() will
    
    1490 1490
        return an error (0) with nothing written.  In this case, there may also be a
    
    1491 1491
        buffer overflow with unpredictable consequences, which is possible only if
    
    1492
    -   zlib was compiled with the insecure functions sprintf() or vsprintf()
    
    1492
    +   zlib was compiled with the insecure functions sprintf() or vsprintf(),
    
    1493 1493
        because the secure snprintf() or vsnprintf() functions were not available.
    
    1494 1494
        This can be determined using zlibCompileFlags().
    
    1495 1495
     */
    
    1496 1496
     
    
    1497 1497
     ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
    
    1498 1498
     /*
    
    1499
    -     Writes the given null-terminated string to the compressed file, excluding
    
    1499
    +     Compress and write the given null-terminated string s to file, excluding
    
    1500 1500
        the terminating null character.
    
    1501 1501
     
    
    1502 1502
          gzputs returns the number of characters written, or -1 in case of error.
    
    ... ... @@ -1504,11 +1504,12 @@ ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
    1504 1504
     
    
    1505 1505
     ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
    
    1506 1506
     /*
    
    1507
    -     Reads bytes from the compressed file until len-1 characters are read, or a
    
    1508
    -   newline character is read and transferred to buf, or an end-of-file
    
    1509
    -   condition is encountered.  If any characters are read or if len == 1, the
    
    1510
    -   string is terminated with a null character.  If no characters are read due
    
    1511
    -   to an end-of-file or len < 1, then the buffer is left untouched.
    
    1507
    +     Read and decompress bytes from file into buf, until len-1 characters are
    
    1508
    +   read, or until a newline character is read and transferred to buf, or an
    
    1509
    +   end-of-file condition is encountered.  If any characters are read or if len
    
    1510
    +   is one, the string is terminated with a null character.  If no characters
    
    1511
    +   are read due to an end-of-file or len is less than one, then the buffer is
    
    1512
    +   left untouched.
    
    1512 1513
     
    
    1513 1514
          gzgets returns buf which is a null-terminated string, or it returns NULL
    
    1514 1515
        for end-of-file or in case of error.  If there was an error, the contents at
    
    ... ... @@ -1517,13 +1518,13 @@ ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
    1517 1518
     
    
    1518 1519
     ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
    
    1519 1520
     /*
    
    1520
    -     Writes c, converted to an unsigned char, into the compressed file.  gzputc
    
    1521
    +     Compress and write c, converted to an unsigned char, into file.  gzputc
    
    1521 1522
        returns the value that was written, or -1 in case of error.
    
    1522 1523
     */
    
    1523 1524
     
    
    1524 1525
     ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
    
    1525 1526
     /*
    
    1526
    -     Reads one byte from the compressed file.  gzgetc returns this byte or -1
    
    1527
    +     Read and decompress one byte from file.  gzgetc returns this byte or -1
    
    1527 1528
        in case of end of file or error.  This is implemented as a macro for speed.
    
    1528 1529
        As such, it does not do all of the checking the other functions do.  I.e.
    
    1529 1530
        it does not check to see if file is NULL, nor whether the structure file
    
    ... ... @@ -1532,8 +1533,8 @@ ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
    1532 1533
     
    
    1533 1534
     ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
    
    1534 1535
     /*
    
    1535
    -     Push one character back onto the stream to be read as the first character
    
    1536
    -   on the next read.  At least one character of push-back is allowed.
    
    1536
    +     Push c back onto the stream for file to be read as the first character on
    
    1537
    +   the next read.  At least one character of push-back is always allowed.
    
    1537 1538
        gzungetc() returns the character pushed, or -1 on failure.  gzungetc() will
    
    1538 1539
        fail if c is -1, and may fail if a character has been pushed but not read
    
    1539 1540
        yet.  If gzungetc is used immediately after gzopen or gzdopen, at least the
    
    ... ... @@ -1544,9 +1545,9 @@ ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
    1544 1545
     
    
    1545 1546
     ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
    
    1546 1547
     /*
    
    1547
    -     Flushes all pending output into the compressed file.  The parameter flush
    
    1548
    -   is as in the deflate() function.  The return value is the zlib error number
    
    1549
    -   (see function gzerror below).  gzflush is only permitted when writing.
    
    1548
    +     Flush all pending output to file.  The parameter flush is as in the
    
    1549
    +   deflate() function.  The return value is the zlib error number (see function
    
    1550
    +   gzerror below).  gzflush is only permitted when writing.
    
    1550 1551
     
    
    1551 1552
          If the flush parameter is Z_FINISH, the remaining data is written and the
    
    1552 1553
        gzip stream is completed in the output.  If gzwrite() is called again, a new
    
    ... ... @@ -1561,8 +1562,8 @@ ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
    1561 1562
     ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
    
    1562 1563
                                        z_off_t offset, int whence));
    
    1563 1564
     
    
    1564
    -     Sets the starting position for the next gzread or gzwrite on the given
    
    1565
    -   compressed file.  The offset represents a number of bytes in the
    
    1565
    +     Set the starting position to offset relative to whence for the next gzread
    
    1566
    +   or gzwrite on file.  The offset represents a number of bytes in the
    
    1566 1567
        uncompressed data stream.  The whence parameter is defined as in lseek(2);
    
    1567 1568
        the value SEEK_END is not supported.
    
    1568 1569
     
    
    ... ... @@ -1579,18 +1580,18 @@ ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
    1579 1580
     
    
    1580 1581
     ZEXTERN int ZEXPORT    gzrewind OF((gzFile file));
    
    1581 1582
     /*
    
    1582
    -     Rewinds the given file. This function is supported only for reading.
    
    1583
    +     Rewind file. This function is supported only for reading.
    
    1583 1584
     
    
    1584
    -     gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
    
    1585
    +     gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET).
    
    1585 1586
     */
    
    1586 1587
     
    
    1587 1588
     /*
    
    1588 1589
     ZEXTERN z_off_t ZEXPORT    gztell OF((gzFile file));
    
    1589 1590
     
    
    1590
    -     Returns the starting position for the next gzread or gzwrite on the given
    
    1591
    -   compressed file.  This position represents a number of bytes in the
    
    1592
    -   uncompressed data stream, and is zero when starting, even if appending or
    
    1593
    -   reading a gzip stream from the middle of a file using gzdopen().
    
    1591
    +     Return the starting position for the next gzread or gzwrite on file.
    
    1592
    +   This position represents a number of bytes in the uncompressed data stream,
    
    1593
    +   and is zero when starting, even if appending or reading a gzip stream from
    
    1594
    +   the middle of a file using gzdopen().
    
    1594 1595
     
    
    1595 1596
          gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
    
    1596 1597
     */
    
    ... ... @@ -1598,22 +1599,22 @@ ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
    1598 1599
     /*
    
    1599 1600
     ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));
    
    1600 1601
     
    
    1601
    -     Returns the current offset in the file being read or written.  This offset
    
    1602
    -   includes the count of bytes that precede the gzip stream, for example when
    
    1603
    -   appending or when using gzdopen() for reading.  When reading, the offset
    
    1604
    -   does not include as yet unused buffered input.  This information can be used
    
    1605
    -   for a progress indicator.  On error, gzoffset() returns -1.
    
    1602
    +     Return the current compressed (actual) read or write offset of file.  This
    
    1603
    +   offset includes the count of bytes that precede the gzip stream, for example
    
    1604
    +   when appending or when using gzdopen() for reading.  When reading, the
    
    1605
    +   offset does not include as yet unused buffered input.  This information can
    
    1606
    +   be used for a progress indicator.  On error, gzoffset() returns -1.
    
    1606 1607
     */
    
    1607 1608
     
    
    1608 1609
     ZEXTERN int ZEXPORT gzeof OF((gzFile file));
    
    1609 1610
     /*
    
    1610
    -     Returns true (1) if the end-of-file indicator has been set while reading,
    
    1611
    -   false (0) otherwise.  Note that the end-of-file indicator is set only if the
    
    1612
    -   read tried to go past the end of the input, but came up short.  Therefore,
    
    1613
    -   just like feof(), gzeof() may return false even if there is no more data to
    
    1614
    -   read, in the event that the last read request was for the exact number of
    
    1615
    -   bytes remaining in the input file.  This will happen if the input file size
    
    1616
    -   is an exact multiple of the buffer size.
    
    1611
    +     Return true (1) if the end-of-file indicator for file has been set while
    
    1612
    +   reading, false (0) otherwise.  Note that the end-of-file indicator is set
    
    1613
    +   only if the read tried to go past the end of the input, but came up short.
    
    1614
    +   Therefore, just like feof(), gzeof() may return false even if there is no
    
    1615
    +   more data to read, in the event that the last read request was for the exact
    
    1616
    +   number of bytes remaining in the input file.  This will happen if the input
    
    1617
    +   file size is an exact multiple of the buffer size.
    
    1617 1618
     
    
    1618 1619
          If gzeof() returns true, then the read functions will return no more data,
    
    1619 1620
        unless the end-of-file indicator is reset by gzclearerr() and the input file
    
    ... ... @@ -1622,7 +1623,7 @@ ZEXTERN int ZEXPORT gzeof OF((gzFile file));
    1622 1623
     
    
    1623 1624
     ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
    
    1624 1625
     /*
    
    1625
    -     Returns true (1) if file is being copied directly while reading, or false
    
    1626
    +     Return true (1) if file is being copied directly while reading, or false
    
    1626 1627
        (0) if file is a gzip stream being decompressed.
    
    1627 1628
     
    
    1628 1629
          If the input file is empty, gzdirect() will return true, since the input
    
    ... ... @@ -1643,8 +1644,8 @@ ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
    1643 1644
     
    
    1644 1645
     ZEXTERN int ZEXPORT    gzclose OF((gzFile file));
    
    1645 1646
     /*
    
    1646
    -     Flushes all pending output if necessary, closes the compressed file and
    
    1647
    -   deallocates the (de)compression state.  Note that once file is closed, you
    
    1647
    +     Flush all pending output for file, if necessary, close file and
    
    1648
    +   deallocate the (de)compression state.  Note that once file is closed, you
    
    1648 1649
        cannot call gzerror with file, since its structures have been deallocated.
    
    1649 1650
        gzclose must not be called more than once on the same file, just as free
    
    1650 1651
        must not be called more than once on the same allocation.
    
    ... ... @@ -1668,10 +1669,10 @@ ZEXTERN int ZEXPORT gzclose_w OF((gzFile file));
    1668 1669
     
    
    1669 1670
     ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
    
    1670 1671
     /*
    
    1671
    -     Returns the error message for the last error which occurred on the given
    
    1672
    -   compressed file.  errnum is set to zlib error number.  If an error occurred
    
    1673
    -   in the file system and not in the compression library, errnum is set to
    
    1674
    -   Z_ERRNO and the application may consult errno to get the exact error code.
    
    1672
    +     Return the error message for the last error which occurred on file.
    
    1673
    +   errnum is set to zlib error number.  If an error occurred in the file system
    
    1674
    +   and not in the compression library, errnum is set to Z_ERRNO and the
    
    1675
    +   application may consult errno to get the exact error code.
    
    1675 1676
     
    
    1676 1677
          The application must not modify the returned string.  Future calls to
    
    1677 1678
        this function may invalidate the previously returned string.  If file is
    
    ... ... @@ -1684,7 +1685,7 @@ ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
    1684 1685
     
    
    1685 1686
     ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
    
    1686 1687
     /*
    
    1687
    -     Clears the error and end-of-file flags for file.  This is analogous to the
    
    1688
    +     Clear the error and end-of-file flags for file.  This is analogous to the
    
    1688 1689
        clearerr() function in stdio.  This is useful for continuing to read a gzip
    
    1689 1690
        file that is being written concurrently.
    
    1690 1691
     */
    
    ... ... @@ -1702,8 +1703,9 @@ ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
    1702 1703
     ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
    
    1703 1704
     /*
    
    1704 1705
          Update a running Adler-32 checksum with the bytes buf[0..len-1] and
    
    1705
    -   return the updated checksum.  If buf is Z_NULL, this function returns the
    
    1706
    -   required initial value for the checksum.
    
    1706
    +   return the updated checksum. An Adler-32 value is in the range of a 32-bit
    
    1707
    +   unsigned integer. If buf is Z_NULL, this function returns the required
    
    1708
    +   initial value for the checksum.
    
    1707 1709
     
    
    1708 1710
          An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed
    
    1709 1711
        much faster.
    
    ... ... @@ -1736,12 +1738,13 @@ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
    1736 1738
        negative, the result has no meaning or utility.
    
    1737 1739
     */
    
    1738 1740
     
    
    1739
    -ZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));
    
    1741
    +ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
    
    1740 1742
     /*
    
    1741 1743
          Update a running CRC-32 with the bytes buf[0..len-1] and return the
    
    1742
    -   updated CRC-32.  If buf is Z_NULL, this function returns the required
    
    1743
    -   initial value for the crc.  Pre- and post-conditioning (one's complement) is
    
    1744
    -   performed within this function so it shouldn't be done by the application.
    
    1744
    +   updated CRC-32. A CRC-32 value is in the range of a 32-bit unsigned integer.
    
    1745
    +   If buf is Z_NULL, this function returns the required initial value for the
    
    1746
    +   crc. Pre- and post-conditioning (one's complement) is performed within this
    
    1747
    +   function so it shouldn't be done by the application.
    
    1745 1748
     
    
    1746 1749
        Usage example:
    
    1747 1750
     
    
    ... ... @@ -1755,7 +1758,7 @@ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
    1755 1758
     
    
    1756 1759
     #ifndef Z_FREETYPE
    
    1757 1760
     
    
    1758
    -ZEXTERN uLong ZEXPORT crc32_z OF((uLong adler, const Bytef *buf,
    
    1761
    +ZEXTERN uLong ZEXPORT crc32_z OF((uLong crc, const Bytef *buf,
    
    1759 1762
                                       z_size_t len));
    
    1760 1763
     /*
    
    1761 1764
          Same as crc32(), but with a size_t length.
    
    ... ... @@ -1771,6 +1774,20 @@ ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
    1771 1774
        len2.
    
    1772 1775
     */
    
    1773 1776
     
    
    1777
    +/*
    
    1778
    +ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t len2));
    
    1779
    +
    
    1780
    +     Return the operator corresponding to length len2, to be used with
    
    1781
    +   crc32_combine_op().
    
    1782
    +*/
    
    1783
    +
    
    1784
    +ZEXTERN uLong ZEXPORT crc32_combine_op OF((uLong crc1, uLong crc2, uLong op));
    
    1785
    +/*
    
    1786
    +     Give the same result as crc32_combine(), using op in place of len2. op is
    
    1787
    +   is generated from len2 by crc32_combine_gen(). This will be faster than
    
    1788
    +   crc32_combine() if the generated op is used more than once.
    
    1789
    +*/
    
    1790
    +
    
    1774 1791
     
    
    1775 1792
                             /* various hacks, don't look :) */
    
    1776 1793
     
    
    ... ... @@ -1871,6 +1888,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
    1871 1888
        ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
    
    1872 1889
        ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));
    
    1873 1890
        ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));
    
    1891
    +   ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off64_t));
    
    1874 1892
     #endif
    
    1875 1893
     
    
    1876 1894
     #if !defined(ZLIB_INTERNAL) && defined(Z_WANT64)
    
    ... ... @@ -1881,6 +1899,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
    1881 1899
     #    define z_gzoffset z_gzoffset64
    
    1882 1900
     #    define z_adler32_combine z_adler32_combine64
    
    1883 1901
     #    define z_crc32_combine z_crc32_combine64
    
    1902
    +#    define z_crc32_combine_gen z_crc32_combine_gen64
    
    1884 1903
     #  else
    
    1885 1904
     #    define gzopen gzopen64
    
    1886 1905
     #    define gzseek gzseek64
    
    ... ... @@ -1888,6 +1907,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
    1888 1907
     #    define gzoffset gzoffset64
    
    1889 1908
     #    define adler32_combine adler32_combine64
    
    1890 1909
     #    define crc32_combine crc32_combine64
    
    1910
    +#    define crc32_combine_gen crc32_combine_gen64
    
    1891 1911
     #  endif
    
    1892 1912
     #  ifndef Z_LARGE64
    
    1893 1913
          ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
    
    ... ... @@ -1896,6 +1916,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
    1896 1916
          ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile));
    
    1897 1917
          ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
    
    1898 1918
          ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
    
    1919
    +     ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off_t));
    
    1899 1920
     #  endif
    
    1900 1921
     #else
    
    1901 1922
        ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));
    
    ... ... @@ -1904,6 +1925,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
    1904 1925
        ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));
    
    1905 1926
        ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
    
    1906 1927
        ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
    
    1928
    +   ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t));
    
    1907 1929
     #endif
    
    1908 1930
     
    
    1909 1931
     #else /* Z_SOLO */
    
    ... ... @@ -1911,6 +1933,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
    1911 1933
     #ifndef Z_FREETYPE
    
    1912 1934
        ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
    
    1913 1935
        ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
    
    1936
    +   ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t));
    
    1914 1937
     #endif
    
    1915 1938
     
    
    1916 1939
     #endif /* !Z_SOLO */
    
    ... ... @@ -1925,7 +1948,7 @@ ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int));
    1925 1948
     ZEXTERN unsigned long  ZEXPORT inflateCodesUsed OF ((z_streamp));
    
    1926 1949
     ZEXTERN int            ZEXPORT inflateResetKeep OF((z_streamp));
    
    1927 1950
     ZEXTERN int            ZEXPORT deflateResetKeep OF((z_streamp));
    
    1928
    -#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO)
    
    1951
    +#if defined(_WIN32) && !defined(Z_SOLO)
    
    1929 1952
     ZEXTERN gzFile         ZEXPORT gzopen_w OF((const wchar_t *path,
    
    1930 1953
                                                 const char *mode));
    
    1931 1954
     #endif
    

  • src/gzip/zutil.c
    ... ... @@ -136,8 +136,8 @@ const char * ZEXPORT zError(
    136 136
         return ERR_MSG(err);
    
    137 137
     }
    
    138 138
     
    
    139
    -#if defined(_WIN32_WCE)
    
    140
    -    /* The Microsoft C Run-Time Library for Windows CE doesn't have
    
    139
    +#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
    
    140
    +    /* The older Microsoft C Run-Time Library for Windows CE doesn't have
    
    141 141
          * errno.  We define it as a global variable to simplify porting.
    
    142 142
          * Its value is always 0 and should not be used.
    
    143 143
          */
    

  • src/gzip/zutil.h
    1 1
     /* zutil.h -- internal interface and configuration of the compression library
    
    2
    - * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
    
    2
    + * Copyright (C) 1995-2022 Jean-loup Gailly, Mark Adler
    
    3 3
      * For conditions of distribution and use, see copyright notice in zlib.h
    
    4 4
      */
    
    5 5
     
    
    ... ... @@ -29,12 +29,6 @@
    29 29
     #  include <stdlib.h>
    
    30 30
     #endif
    
    31 31
     
    
    32
    -#ifdef Z_SOLO
    
    33
    -#  ifndef Z_FREETYPE
    
    34
    -   typedef long ptrdiff_t;  /* guess -- will be caught if guess is wrong */
    
    35
    -#  endif
    
    36
    -#endif
    
    37
    -
    
    38 32
     #ifndef local
    
    39 33
     #  define local static
    
    40 34
     #endif
    
    ... ... @@ -48,6 +42,17 @@ typedef unsigned short ush;
    48 42
     typedef ush FAR ushf;
    
    49 43
     typedef unsigned long  ulg;
    
    50 44
     
    
    45
    +#if !defined(Z_U8) && !defined(Z_SOLO) && defined(STDC)
    
    46
    +#  include <limits.h>
    
    47
    +#  if (ULONG_MAX == 0xffffffffffffffff)
    
    48
    +#    define Z_U8 unsigned long
    
    49
    +#  elif (ULLONG_MAX == 0xffffffffffffffff)
    
    50
    +#    define Z_U8 unsigned long long
    
    51
    +#  elif (UINT_MAX == 0xffffffffffffffff)
    
    52
    +#    define Z_U8 unsigned
    
    53
    +#  endif
    
    54
    +#endif
    
    55
    +
    
    51 56
     extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
    
    52 57
     /* (size given to avoid silly warnings with Visual C++) */
    
    53 58
     
    
    ... ... @@ -172,10 +177,6 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
    172 177
     #if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
    
    173 178
     #  if defined(_WIN32_WCE)
    
    174 179
     #    define fdopen(fd,mode) NULL /* No fdopen() */
    
    175
    -#    ifndef _PTRDIFF_T_DEFINED
    
    176
    -       typedef int ptrdiff_t;
    
    177
    -#      define _PTRDIFF_T_DEFINED
    
    178
    -#    endif
    
    179 180
     #  else
    
    180 181
     #    define fdopen(fd,type)  _fdopen(fd,type)
    
    181 182
     #  endif
    


  • reply via email to

    [Prev in Thread] Current Thread [Next in Thread]