xref: /xnu-8792.81.2/libkern/zlib/inffast.c (revision 19c3b8c28c31cb8130e034cfb5df6bf9ba342d90)
1*19c3b8c2SApple OSS Distributions /*
2*19c3b8c2SApple OSS Distributions  * Copyright (c) 2008-2016, 2020 Apple Inc. All rights reserved.
3*19c3b8c2SApple OSS Distributions  *
4*19c3b8c2SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5*19c3b8c2SApple OSS Distributions  *
6*19c3b8c2SApple OSS Distributions  * This file contains Original Code and/or Modifications of Original Code
7*19c3b8c2SApple OSS Distributions  * as defined in and that are subject to the Apple Public Source License
8*19c3b8c2SApple OSS Distributions  * Version 2.0 (the 'License'). You may not use this file except in
9*19c3b8c2SApple OSS Distributions  * compliance with the License. The rights granted to you under the License
10*19c3b8c2SApple OSS Distributions  * may not be used to create, or enable the creation or redistribution of,
11*19c3b8c2SApple OSS Distributions  * unlawful or unlicensed copies of an Apple operating system, or to
12*19c3b8c2SApple OSS Distributions  * circumvent, violate, or enable the circumvention or violation of, any
13*19c3b8c2SApple OSS Distributions  * terms of an Apple operating system software license agreement.
14*19c3b8c2SApple OSS Distributions  *
15*19c3b8c2SApple OSS Distributions  * Please obtain a copy of the License at
16*19c3b8c2SApple OSS Distributions  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17*19c3b8c2SApple OSS Distributions  *
18*19c3b8c2SApple OSS Distributions  * The Original Code and all software distributed under the License are
19*19c3b8c2SApple OSS Distributions  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20*19c3b8c2SApple OSS Distributions  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21*19c3b8c2SApple OSS Distributions  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22*19c3b8c2SApple OSS Distributions  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23*19c3b8c2SApple OSS Distributions  * Please see the License for the specific language governing rights and
24*19c3b8c2SApple OSS Distributions  * limitations under the License.
25*19c3b8c2SApple OSS Distributions  *
26*19c3b8c2SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27*19c3b8c2SApple OSS Distributions  */
28*19c3b8c2SApple OSS Distributions /* inffast.c -- fast decoding
29*19c3b8c2SApple OSS Distributions  * Copyright (C) 1995-2004 Mark Adler
30*19c3b8c2SApple OSS Distributions  * For conditions of distribution and use, see copyright notice in zlib.h
31*19c3b8c2SApple OSS Distributions  */
32*19c3b8c2SApple OSS Distributions 
33*19c3b8c2SApple OSS Distributions 
34*19c3b8c2SApple OSS Distributions #include "zutil.h"
35*19c3b8c2SApple OSS Distributions #include "inftrees.h"
36*19c3b8c2SApple OSS Distributions #include "inflate.h"
37*19c3b8c2SApple OSS Distributions #include "inffast.h"
38*19c3b8c2SApple OSS Distributions 
39*19c3b8c2SApple OSS Distributions #ifndef ASMINF
40*19c3b8c2SApple OSS Distributions 
41*19c3b8c2SApple OSS Distributions /*
42*19c3b8c2SApple OSS Distributions    Decode literal, length, and distance codes and write out the resulting
43*19c3b8c2SApple OSS Distributions    literal and match bytes until either not enough input or output is
44*19c3b8c2SApple OSS Distributions    available, an end-of-block is encountered, or a data error is encountered.
45*19c3b8c2SApple OSS Distributions    When large enough input and output buffers are supplied to inflate(), for
46*19c3b8c2SApple OSS Distributions    example, a 16K input buffer and a 64K output buffer, more than 95% of the
47*19c3b8c2SApple OSS Distributions    inflate execution time is spent in this routine.
48*19c3b8c2SApple OSS Distributions 
49*19c3b8c2SApple OSS Distributions    Entry assumptions:
50*19c3b8c2SApple OSS Distributions 
51*19c3b8c2SApple OSS Distributions         state->mode == LEN
52*19c3b8c2SApple OSS Distributions         strm->avail_in >= 6
53*19c3b8c2SApple OSS Distributions         strm->avail_out >= 258
54*19c3b8c2SApple OSS Distributions         start >= strm->avail_out
55*19c3b8c2SApple OSS Distributions         state->bits < 8
56*19c3b8c2SApple OSS Distributions 
57*19c3b8c2SApple OSS Distributions    On return, state->mode is one of:
58*19c3b8c2SApple OSS Distributions 
59*19c3b8c2SApple OSS Distributions         LEN -- ran out of enough output space or enough available input
60*19c3b8c2SApple OSS Distributions         TYPE -- reached end of block code, inflate() to interpret next block
61*19c3b8c2SApple OSS Distributions         BAD -- error in block data
62*19c3b8c2SApple OSS Distributions 
63*19c3b8c2SApple OSS Distributions    Notes:
64*19c3b8c2SApple OSS Distributions 
65*19c3b8c2SApple OSS Distributions     - The maximum input bits used by a length/distance pair is 15 bits for the
66*19c3b8c2SApple OSS Distributions       length code, 5 bits for the length extra, 15 bits for the distance code,
67*19c3b8c2SApple OSS Distributions       and 13 bits for the distance extra.  This totals 48 bits, or six bytes.
68*19c3b8c2SApple OSS Distributions       Therefore if strm->avail_in >= 6, then there is enough input to avoid
69*19c3b8c2SApple OSS Distributions       checking for available input while decoding.
70*19c3b8c2SApple OSS Distributions 
71*19c3b8c2SApple OSS Distributions     - The maximum bytes that a single length/distance pair can output is 258
72*19c3b8c2SApple OSS Distributions       bytes, which is the maximum length that can be coded.  inflate_fast()
73*19c3b8c2SApple OSS Distributions       requires strm->avail_out >= 258 for each loop to avoid checking for
74*19c3b8c2SApple OSS Distributions       output space.
75*19c3b8c2SApple OSS Distributions 
76*19c3b8c2SApple OSS Distributions       @param start inflate()'s starting value for strm->avail_out
77*19c3b8c2SApple OSS Distributions  */
78*19c3b8c2SApple OSS Distributions void
inflate_fast(z_streamp strm,unsigned start)79*19c3b8c2SApple OSS Distributions inflate_fast(z_streamp strm, unsigned start)
80*19c3b8c2SApple OSS Distributions {
81*19c3b8c2SApple OSS Distributions     struct inflate_state FAR *state;
82*19c3b8c2SApple OSS Distributions     unsigned char FAR *in;      /* local strm->next_in */
83*19c3b8c2SApple OSS Distributions     unsigned char FAR *last;    /* while in < last, enough input available */
84*19c3b8c2SApple OSS Distributions     unsigned char FAR *out;     /* local strm->next_out */
85*19c3b8c2SApple OSS Distributions     unsigned char FAR *beg;     /* inflate()'s initial strm->next_out */
86*19c3b8c2SApple OSS Distributions     unsigned char FAR *end;     /* while out < end, enough space available */
87*19c3b8c2SApple OSS Distributions #ifdef INFLATE_STRICT
88*19c3b8c2SApple OSS Distributions     unsigned dmax;              /* maximum distance from zlib header */
89*19c3b8c2SApple OSS Distributions #endif
90*19c3b8c2SApple OSS Distributions     unsigned wsize;             /* window size or zero if not using window */
91*19c3b8c2SApple OSS Distributions     unsigned whave;             /* valid bytes in the window */
92*19c3b8c2SApple OSS Distributions     unsigned write;             /* window write index */
93*19c3b8c2SApple OSS Distributions     unsigned char FAR *window;  /* allocated sliding window, if wsize != 0 */
94*19c3b8c2SApple OSS Distributions     unsigned long hold;         /* local strm->hold */
95*19c3b8c2SApple OSS Distributions     unsigned bits;              /* local strm->bits */
96*19c3b8c2SApple OSS Distributions     code const FAR *lcode;      /* local strm->lencode */
97*19c3b8c2SApple OSS Distributions     code const FAR *dcode;      /* local strm->distcode */
98*19c3b8c2SApple OSS Distributions     unsigned lmask;             /* mask for first level of length codes */
99*19c3b8c2SApple OSS Distributions     unsigned dmask;             /* mask for first level of distance codes */
100*19c3b8c2SApple OSS Distributions     code this;                  /* retrieved table entry */
101*19c3b8c2SApple OSS Distributions     unsigned op;                /* code bits, operation, extra bits, or */
102*19c3b8c2SApple OSS Distributions                                 /*  window position, window bytes to copy */
103*19c3b8c2SApple OSS Distributions     unsigned len;               /* match length, unused bytes */
104*19c3b8c2SApple OSS Distributions     unsigned dist;              /* match distance */
105*19c3b8c2SApple OSS Distributions     unsigned char FAR *from;    /* where to copy match from */
106*19c3b8c2SApple OSS Distributions 
107*19c3b8c2SApple OSS Distributions     /* copy state to local variables */
108*19c3b8c2SApple OSS Distributions     state = (struct inflate_state FAR *)strm->state;
109*19c3b8c2SApple OSS Distributions     in = strm->next_in;
110*19c3b8c2SApple OSS Distributions     last = in + (strm->avail_in - 5);
111*19c3b8c2SApple OSS Distributions     out = strm->next_out;
112*19c3b8c2SApple OSS Distributions     beg = out - (start - strm->avail_out);
113*19c3b8c2SApple OSS Distributions     end = out + (strm->avail_out - 257);
114*19c3b8c2SApple OSS Distributions #ifdef INFLATE_STRICT
115*19c3b8c2SApple OSS Distributions     dmax = state->dmax;
116*19c3b8c2SApple OSS Distributions #endif
117*19c3b8c2SApple OSS Distributions     wsize = state->wsize;
118*19c3b8c2SApple OSS Distributions     whave = state->whave;
119*19c3b8c2SApple OSS Distributions     write = state->write;
120*19c3b8c2SApple OSS Distributions     window = state->window;
121*19c3b8c2SApple OSS Distributions     hold = state->hold;
122*19c3b8c2SApple OSS Distributions     bits = state->bits;
123*19c3b8c2SApple OSS Distributions     lcode = state->lencode;
124*19c3b8c2SApple OSS Distributions     dcode = state->distcode;
125*19c3b8c2SApple OSS Distributions     lmask = (1U << state->lenbits) - 1;
126*19c3b8c2SApple OSS Distributions     dmask = (1U << state->distbits) - 1;
127*19c3b8c2SApple OSS Distributions 
128*19c3b8c2SApple OSS Distributions     /* decode literals and length/distances until end-of-block or not enough
129*19c3b8c2SApple OSS Distributions        input data or output space */
130*19c3b8c2SApple OSS Distributions     do {
131*19c3b8c2SApple OSS Distributions         if (bits < 15) {
132*19c3b8c2SApple OSS Distributions             hold += (unsigned long)(*in++) << bits;
133*19c3b8c2SApple OSS Distributions             bits += 8;
134*19c3b8c2SApple OSS Distributions             hold += (unsigned long)(*in++) << bits;
135*19c3b8c2SApple OSS Distributions             bits += 8;
136*19c3b8c2SApple OSS Distributions         }
137*19c3b8c2SApple OSS Distributions         this = lcode[hold & lmask];
138*19c3b8c2SApple OSS Distributions       dolen:
139*19c3b8c2SApple OSS Distributions         op = (unsigned)(this.bits);
140*19c3b8c2SApple OSS Distributions         hold >>= op;
141*19c3b8c2SApple OSS Distributions         bits -= op;
142*19c3b8c2SApple OSS Distributions         op = (unsigned)(this.op);
143*19c3b8c2SApple OSS Distributions         if (op == 0) {                          /* literal */
144*19c3b8c2SApple OSS Distributions             Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
145*19c3b8c2SApple OSS Distributions                     "inflate:         literal '%c'\n" :
146*19c3b8c2SApple OSS Distributions                     "inflate:         literal 0x%02x\n", this.val));
147*19c3b8c2SApple OSS Distributions             *out++ = (unsigned char)(this.val);
148*19c3b8c2SApple OSS Distributions         }
149*19c3b8c2SApple OSS Distributions         else if (op & 16) {                     /* length base */
150*19c3b8c2SApple OSS Distributions             len = (unsigned)(this.val);
151*19c3b8c2SApple OSS Distributions             op &= 15;                           /* number of extra bits */
152*19c3b8c2SApple OSS Distributions             if (op) {
153*19c3b8c2SApple OSS Distributions                 if (bits < op) {
154*19c3b8c2SApple OSS Distributions                     hold += (unsigned long)(*in++) << bits;
155*19c3b8c2SApple OSS Distributions                     bits += 8;
156*19c3b8c2SApple OSS Distributions                 }
157*19c3b8c2SApple OSS Distributions                 len += (unsigned)hold & ((1U << op) - 1);
158*19c3b8c2SApple OSS Distributions                 hold >>= op;
159*19c3b8c2SApple OSS Distributions                 bits -= op;
160*19c3b8c2SApple OSS Distributions             }
161*19c3b8c2SApple OSS Distributions             Tracevv((stderr, "inflate:         length %u\n", len));
162*19c3b8c2SApple OSS Distributions             if (bits < 15) {
163*19c3b8c2SApple OSS Distributions                 hold += (unsigned long)(*in++) << bits;
164*19c3b8c2SApple OSS Distributions                 bits += 8;
165*19c3b8c2SApple OSS Distributions                 hold += (unsigned long)(*in++) << bits;
166*19c3b8c2SApple OSS Distributions                 bits += 8;
167*19c3b8c2SApple OSS Distributions             }
168*19c3b8c2SApple OSS Distributions             this = dcode[hold & dmask];
169*19c3b8c2SApple OSS Distributions           dodist:
170*19c3b8c2SApple OSS Distributions             op = (unsigned)(this.bits);
171*19c3b8c2SApple OSS Distributions             hold >>= op;
172*19c3b8c2SApple OSS Distributions             bits -= op;
173*19c3b8c2SApple OSS Distributions             op = (unsigned)(this.op);
174*19c3b8c2SApple OSS Distributions             if (op & 16) {                      /* distance base */
175*19c3b8c2SApple OSS Distributions                 dist = (unsigned)(this.val);
176*19c3b8c2SApple OSS Distributions                 op &= 15;                       /* number of extra bits */
177*19c3b8c2SApple OSS Distributions                 if (bits < op) {
178*19c3b8c2SApple OSS Distributions                     hold += (unsigned long)(*in++) << bits;
179*19c3b8c2SApple OSS Distributions                     bits += 8;
180*19c3b8c2SApple OSS Distributions                     if (bits < op) {
181*19c3b8c2SApple OSS Distributions                         hold += (unsigned long)(*in++) << bits;
182*19c3b8c2SApple OSS Distributions                         bits += 8;
183*19c3b8c2SApple OSS Distributions                     }
184*19c3b8c2SApple OSS Distributions                 }
185*19c3b8c2SApple OSS Distributions                 dist += (unsigned)hold & ((1U << op) - 1);
186*19c3b8c2SApple OSS Distributions #ifdef INFLATE_STRICT
187*19c3b8c2SApple OSS Distributions                 if (dist > dmax) {
188*19c3b8c2SApple OSS Distributions                     strm->msg = (char *)"invalid distance too far back";
189*19c3b8c2SApple OSS Distributions                     state->mode = BAD;
190*19c3b8c2SApple OSS Distributions                     break;
191*19c3b8c2SApple OSS Distributions                 }
192*19c3b8c2SApple OSS Distributions #endif
193*19c3b8c2SApple OSS Distributions                 hold >>= op;
194*19c3b8c2SApple OSS Distributions                 bits -= op;
195*19c3b8c2SApple OSS Distributions                 Tracevv((stderr, "inflate:         distance %u\n", dist));
196*19c3b8c2SApple OSS Distributions                 op = (unsigned)(out - beg);     /* max distance in output */
197*19c3b8c2SApple OSS Distributions                 if (dist > op) {                /* see if copy from window */
198*19c3b8c2SApple OSS Distributions                     op = dist - op;             /* distance back in window */
199*19c3b8c2SApple OSS Distributions                     if (op > whave) {
200*19c3b8c2SApple OSS Distributions                         strm->msg = (char *)"invalid distance too far back";
201*19c3b8c2SApple OSS Distributions                         state->mode = BAD;
202*19c3b8c2SApple OSS Distributions                         break;
203*19c3b8c2SApple OSS Distributions                     }
204*19c3b8c2SApple OSS Distributions                     from = window;
205*19c3b8c2SApple OSS Distributions                     if (write == 0) {           /* very common case */
206*19c3b8c2SApple OSS Distributions                         from += wsize - op;
207*19c3b8c2SApple OSS Distributions                         if (op < len) {         /* some from window */
208*19c3b8c2SApple OSS Distributions                             len -= op;
209*19c3b8c2SApple OSS Distributions                             do {
210*19c3b8c2SApple OSS Distributions                                 *out++ = *from++;
211*19c3b8c2SApple OSS Distributions                             } while (--op);
212*19c3b8c2SApple OSS Distributions                             from = out - dist;  /* rest from output */
213*19c3b8c2SApple OSS Distributions                         }
214*19c3b8c2SApple OSS Distributions                     }
215*19c3b8c2SApple OSS Distributions                     else if (write < op) {      /* wrap around window */
216*19c3b8c2SApple OSS Distributions                         from += wsize + write - op;
217*19c3b8c2SApple OSS Distributions                         op -= write;
218*19c3b8c2SApple OSS Distributions                         if (op < len) {         /* some from end of window */
219*19c3b8c2SApple OSS Distributions                             len -= op;
220*19c3b8c2SApple OSS Distributions                             do {
221*19c3b8c2SApple OSS Distributions                                 *out++ = *from++;
222*19c3b8c2SApple OSS Distributions                             } while (--op);
223*19c3b8c2SApple OSS Distributions                             from = window;
224*19c3b8c2SApple OSS Distributions                             if (write < len) {  /* some from start of window */
225*19c3b8c2SApple OSS Distributions                                 op = write;
226*19c3b8c2SApple OSS Distributions                                 len -= op;
227*19c3b8c2SApple OSS Distributions                                 do {
228*19c3b8c2SApple OSS Distributions                                     *out++ = *from++;
229*19c3b8c2SApple OSS Distributions                                 } while (--op);
230*19c3b8c2SApple OSS Distributions                                 from = out - dist;      /* rest from output */
231*19c3b8c2SApple OSS Distributions                             }
232*19c3b8c2SApple OSS Distributions                         }
233*19c3b8c2SApple OSS Distributions                     }
234*19c3b8c2SApple OSS Distributions                     else {                      /* contiguous in window */
235*19c3b8c2SApple OSS Distributions                         from += write - op;
236*19c3b8c2SApple OSS Distributions                         if (op < len) {         /* some from window */
237*19c3b8c2SApple OSS Distributions                             len -= op;
238*19c3b8c2SApple OSS Distributions                             do {
239*19c3b8c2SApple OSS Distributions                                 *out++ = *from++;
240*19c3b8c2SApple OSS Distributions                             } while (--op);
241*19c3b8c2SApple OSS Distributions                             from = out - dist;  /* rest from output */
242*19c3b8c2SApple OSS Distributions                         }
243*19c3b8c2SApple OSS Distributions                     }
244*19c3b8c2SApple OSS Distributions                     while (len > 2) {
245*19c3b8c2SApple OSS Distributions                         *out++ = *from++;
246*19c3b8c2SApple OSS Distributions                         *out++ = *from++;
247*19c3b8c2SApple OSS Distributions                         *out++ = *from++;
248*19c3b8c2SApple OSS Distributions                         len -= 3;
249*19c3b8c2SApple OSS Distributions                     }
250*19c3b8c2SApple OSS Distributions                     if (len) {
251*19c3b8c2SApple OSS Distributions                         *out++ = *from++;
252*19c3b8c2SApple OSS Distributions                         if (len > 1)
253*19c3b8c2SApple OSS Distributions                             *out++ = *from++;
254*19c3b8c2SApple OSS Distributions                     }
255*19c3b8c2SApple OSS Distributions                 }
256*19c3b8c2SApple OSS Distributions                 else {
257*19c3b8c2SApple OSS Distributions                     from = out - dist;          /* copy direct from output */
258*19c3b8c2SApple OSS Distributions                     do {                        /* minimum length is three */
259*19c3b8c2SApple OSS Distributions                         *out++ = *from++;
260*19c3b8c2SApple OSS Distributions                         *out++ = *from++;
261*19c3b8c2SApple OSS Distributions                         *out++ = *from++;
262*19c3b8c2SApple OSS Distributions                         len -= 3;
263*19c3b8c2SApple OSS Distributions                     } while (len > 2);
264*19c3b8c2SApple OSS Distributions                     if (len) {
265*19c3b8c2SApple OSS Distributions                         *out++ = *from++;
266*19c3b8c2SApple OSS Distributions                         if (len > 1)
267*19c3b8c2SApple OSS Distributions                             *out++ = *from++;
268*19c3b8c2SApple OSS Distributions                     }
269*19c3b8c2SApple OSS Distributions                 }
270*19c3b8c2SApple OSS Distributions             }
271*19c3b8c2SApple OSS Distributions             else if ((op & 64) == 0) {          /* 2nd level distance code */
272*19c3b8c2SApple OSS Distributions                 this = dcode[this.val + (hold & ((1U << op) - 1))];
273*19c3b8c2SApple OSS Distributions                 goto dodist;
274*19c3b8c2SApple OSS Distributions             }
275*19c3b8c2SApple OSS Distributions             else {
276*19c3b8c2SApple OSS Distributions                 strm->msg = (char *)"invalid distance code";
277*19c3b8c2SApple OSS Distributions                 state->mode = BAD;
278*19c3b8c2SApple OSS Distributions                 break;
279*19c3b8c2SApple OSS Distributions             }
280*19c3b8c2SApple OSS Distributions         }
281*19c3b8c2SApple OSS Distributions         else if ((op & 64) == 0) {              /* 2nd level length code */
282*19c3b8c2SApple OSS Distributions             this = lcode[this.val + (hold & ((1U << op) - 1))];
283*19c3b8c2SApple OSS Distributions             goto dolen;
284*19c3b8c2SApple OSS Distributions         }
285*19c3b8c2SApple OSS Distributions         else if (op & 32) {                     /* end-of-block */
286*19c3b8c2SApple OSS Distributions             Tracevv((stderr, "inflate:         end of block\n"));
287*19c3b8c2SApple OSS Distributions             state->mode = TYPE;
288*19c3b8c2SApple OSS Distributions             break;
289*19c3b8c2SApple OSS Distributions         }
290*19c3b8c2SApple OSS Distributions         else {
291*19c3b8c2SApple OSS Distributions             strm->msg = (char *)"invalid literal/length code";
292*19c3b8c2SApple OSS Distributions             state->mode = BAD;
293*19c3b8c2SApple OSS Distributions             break;
294*19c3b8c2SApple OSS Distributions         }
295*19c3b8c2SApple OSS Distributions     } while (in < last && out < end);
296*19c3b8c2SApple OSS Distributions 
297*19c3b8c2SApple OSS Distributions     /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
298*19c3b8c2SApple OSS Distributions     len = bits >> 3;
299*19c3b8c2SApple OSS Distributions     in -= len;
300*19c3b8c2SApple OSS Distributions     bits -= len << 3;
301*19c3b8c2SApple OSS Distributions     hold &= (1U << bits) - 1;
302*19c3b8c2SApple OSS Distributions 
303*19c3b8c2SApple OSS Distributions     /* update state and return */
304*19c3b8c2SApple OSS Distributions     strm->next_in = in;
305*19c3b8c2SApple OSS Distributions     strm->next_out = out;
306*19c3b8c2SApple OSS Distributions     strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
307*19c3b8c2SApple OSS Distributions     strm->avail_out = (unsigned)(out < end ?
308*19c3b8c2SApple OSS Distributions                                  257 + (end - out) : 257 - (out - end));
309*19c3b8c2SApple OSS Distributions     state->hold = hold;
310*19c3b8c2SApple OSS Distributions     state->bits = bits;
311*19c3b8c2SApple OSS Distributions     return;
312*19c3b8c2SApple OSS Distributions }
313*19c3b8c2SApple OSS Distributions 
314*19c3b8c2SApple OSS Distributions /*
315*19c3b8c2SApple OSS Distributions    inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe):
316*19c3b8c2SApple OSS Distributions    - Using bit fields for code structure
317*19c3b8c2SApple OSS Distributions    - Different op definition to avoid & for extra bits (do & for table bits)
318*19c3b8c2SApple OSS Distributions    - Three separate decoding do-loops for direct, window, and write == 0
319*19c3b8c2SApple OSS Distributions    - Special case for distance > 1 copies to do overlapped load and store copy
320*19c3b8c2SApple OSS Distributions    - Explicit branch predictions (based on measured branch probabilities)
321*19c3b8c2SApple OSS Distributions    - Deferring match copy and interspersed it with decoding subsequent codes
322*19c3b8c2SApple OSS Distributions    - Swapping literal/length else
323*19c3b8c2SApple OSS Distributions    - Swapping window/direct else
324*19c3b8c2SApple OSS Distributions    - Larger unrolled copy loops (three is about right)
325*19c3b8c2SApple OSS Distributions    - Moving len -= 3 statement into middle of loop
326*19c3b8c2SApple OSS Distributions  */
327*19c3b8c2SApple OSS Distributions 
328*19c3b8c2SApple OSS Distributions #endif /* !ASMINF */
329