version 1.1.1.2, 2013/10/14 07:51:14
|
version 1.1.1.3, 2021/03/17 00:32:36
|
Line 10
|
Line 10
|
|
|
#ifndef ASMINF |
#ifndef ASMINF |
|
|
/* Allow machine dependent optimization for post-increment or pre-increment. |
|
Based on testing to date, |
|
Pre-increment preferred for: |
|
- PowerPC G3 (Adler) |
|
- MIPS R5000 (Randers-Pehrson) |
|
Post-increment preferred for: |
|
- none |
|
No measurable difference: |
|
- Pentium III (Anderson) |
|
- M68060 (Nikl) |
|
*/ |
|
#ifdef POSTINC |
|
# define OFF 0 |
|
# define PUP(a) *(a)++ |
|
#else |
|
# define OFF 1 |
|
# define PUP(a) *++(a) |
|
#endif |
|
|
|
/* |
/* |
Decode literal, length, and distance codes and write out the resulting |
Decode literal, length, and distance codes and write out the resulting |
literal and match bytes until either not enough input or output is |
literal and match bytes until either not enough input or output is |
Line 96 unsigned start; /* inflate()'s starting value
|
Line 77 unsigned start; /* inflate()'s starting value
|
|
|
/* copy state to local variables */ |
/* copy state to local variables */ |
state = (struct inflate_state FAR *)strm->state; |
state = (struct inflate_state FAR *)strm->state; |
in = strm->next_in - OFF; | in = strm->next_in; |
last = in + (strm->avail_in - 5); |
last = in + (strm->avail_in - 5); |
out = strm->next_out - OFF; | out = strm->next_out; |
beg = out - (start - strm->avail_out); |
beg = out - (start - strm->avail_out); |
end = out + (strm->avail_out - 257); |
end = out + (strm->avail_out - 257); |
#ifdef INFLATE_STRICT |
#ifdef INFLATE_STRICT |
Line 119 unsigned start; /* inflate()'s starting value
|
Line 100 unsigned start; /* inflate()'s starting value
|
input data or output space */ |
input data or output space */ |
do { |
do { |
if (bits < 15) { |
if (bits < 15) { |
hold += (unsigned long)(PUP(in)) << bits; | hold += (unsigned long)(*in++) << bits; |
bits += 8; |
bits += 8; |
hold += (unsigned long)(PUP(in)) << bits; | hold += (unsigned long)(*in++) << bits; |
bits += 8; |
bits += 8; |
} |
} |
here = lcode[hold & lmask]; |
here = lcode[hold & lmask]; |
Line 134 unsigned start; /* inflate()'s starting value
|
Line 115 unsigned start; /* inflate()'s starting value
|
Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? |
Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? |
"inflate: literal '%c'\n" : |
"inflate: literal '%c'\n" : |
"inflate: literal 0x%02x\n", here.val)); |
"inflate: literal 0x%02x\n", here.val)); |
PUP(out) = (unsigned char)(here.val); | *out++ = (unsigned char)(here.val); |
} |
} |
else if (op & 16) { /* length base */ |
else if (op & 16) { /* length base */ |
len = (unsigned)(here.val); |
len = (unsigned)(here.val); |
op &= 15; /* number of extra bits */ |
op &= 15; /* number of extra bits */ |
if (op) { |
if (op) { |
if (bits < op) { |
if (bits < op) { |
hold += (unsigned long)(PUP(in)) << bits; | hold += (unsigned long)(*in++) << bits; |
bits += 8; |
bits += 8; |
} |
} |
len += (unsigned)hold & ((1U << op) - 1); |
len += (unsigned)hold & ((1U << op) - 1); |
Line 150 unsigned start; /* inflate()'s starting value
|
Line 131 unsigned start; /* inflate()'s starting value
|
} |
} |
Tracevv((stderr, "inflate: length %u\n", len)); |
Tracevv((stderr, "inflate: length %u\n", len)); |
if (bits < 15) { |
if (bits < 15) { |
hold += (unsigned long)(PUP(in)) << bits; | hold += (unsigned long)(*in++) << bits; |
bits += 8; |
bits += 8; |
hold += (unsigned long)(PUP(in)) << bits; | hold += (unsigned long)(*in++) << bits; |
bits += 8; |
bits += 8; |
} |
} |
here = dcode[hold & dmask]; |
here = dcode[hold & dmask]; |
Line 165 unsigned start; /* inflate()'s starting value
|
Line 146 unsigned start; /* inflate()'s starting value
|
dist = (unsigned)(here.val); |
dist = (unsigned)(here.val); |
op &= 15; /* number of extra bits */ |
op &= 15; /* number of extra bits */ |
if (bits < op) { |
if (bits < op) { |
hold += (unsigned long)(PUP(in)) << bits; | hold += (unsigned long)(*in++) << bits; |
bits += 8; |
bits += 8; |
if (bits < op) { |
if (bits < op) { |
hold += (unsigned long)(PUP(in)) << bits; | hold += (unsigned long)(*in++) << bits; |
bits += 8; |
bits += 8; |
} |
} |
} |
} |
Line 196 unsigned start; /* inflate()'s starting value
|
Line 177 unsigned start; /* inflate()'s starting value
|
#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR |
#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR |
if (len <= op - whave) { |
if (len <= op - whave) { |
do { |
do { |
PUP(out) = 0; | *out++ = 0; |
} while (--len); |
} while (--len); |
continue; |
continue; |
} |
} |
len -= op - whave; |
len -= op - whave; |
do { |
do { |
PUP(out) = 0; | *out++ = 0; |
} while (--op > whave); |
} while (--op > whave); |
if (op == 0) { |
if (op == 0) { |
from = out - dist; |
from = out - dist; |
do { |
do { |
PUP(out) = PUP(from); | *out++ = *from++; |
} while (--len); |
} while (--len); |
continue; |
continue; |
} |
} |
#endif |
#endif |
} |
} |
from = window - OFF; | from = window; |
if (wnext == 0) { /* very common case */ |
if (wnext == 0) { /* very common case */ |
from += wsize - op; |
from += wsize - op; |
if (op < len) { /* some from window */ |
if (op < len) { /* some from window */ |
len -= op; |
len -= op; |
do { |
do { |
PUP(out) = PUP(from); | *out++ = *from++; |
} while (--op); |
} while (--op); |
from = out - dist; /* rest from output */ |
from = out - dist; /* rest from output */ |
} |
} |
Line 230 unsigned start; /* inflate()'s starting value
|
Line 211 unsigned start; /* inflate()'s starting value
|
if (op < len) { /* some from end of window */ |
if (op < len) { /* some from end of window */ |
len -= op; |
len -= op; |
do { |
do { |
PUP(out) = PUP(from); | *out++ = *from++; |
} while (--op); |
} while (--op); |
from = window - OFF; | from = window; |
if (wnext < len) { /* some from start of window */ |
if (wnext < len) { /* some from start of window */ |
op = wnext; |
op = wnext; |
len -= op; |
len -= op; |
do { |
do { |
PUP(out) = PUP(from); | *out++ = *from++; |
} while (--op); |
} while (--op); |
from = out - dist; /* rest from output */ |
from = out - dist; /* rest from output */ |
} |
} |
Line 248 unsigned start; /* inflate()'s starting value
|
Line 229 unsigned start; /* inflate()'s starting value
|
if (op < len) { /* some from window */ |
if (op < len) { /* some from window */ |
len -= op; |
len -= op; |
do { |
do { |
PUP(out) = PUP(from); | *out++ = *from++; |
} while (--op); |
} while (--op); |
from = out - dist; /* rest from output */ |
from = out - dist; /* rest from output */ |
} |
} |
} |
} |
while (len > 2) { |
while (len > 2) { |
PUP(out) = PUP(from); | *out++ = *from++; |
PUP(out) = PUP(from); | *out++ = *from++; |
PUP(out) = PUP(from); | *out++ = *from++; |
len -= 3; |
len -= 3; |
} |
} |
if (len) { |
if (len) { |
PUP(out) = PUP(from); | *out++ = *from++; |
if (len > 1) |
if (len > 1) |
PUP(out) = PUP(from); | *out++ = *from++; |
} |
} |
} |
} |
else { |
else { |
from = out - dist; /* copy direct from output */ |
from = out - dist; /* copy direct from output */ |
do { /* minimum length is three */ |
do { /* minimum length is three */ |
PUP(out) = PUP(from); | *out++ = *from++; |
PUP(out) = PUP(from); | *out++ = *from++; |
PUP(out) = PUP(from); | *out++ = *from++; |
len -= 3; |
len -= 3; |
} while (len > 2); |
} while (len > 2); |
if (len) { |
if (len) { |
PUP(out) = PUP(from); | *out++ = *from++; |
if (len > 1) |
if (len > 1) |
PUP(out) = PUP(from); | *out++ = *from++; |
} |
} |
} |
} |
} |
} |
Line 313 unsigned start; /* inflate()'s starting value
|
Line 294 unsigned start; /* inflate()'s starting value
|
hold &= (1U << bits) - 1; |
hold &= (1U << bits) - 1; |
|
|
/* update state and return */ |
/* update state and return */ |
strm->next_in = in + OFF; | strm->next_in = in; |
strm->next_out = out + OFF; | strm->next_out = out; |
strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last)); |
strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last)); |
strm->avail_out = (unsigned)(out < end ? |
strm->avail_out = (unsigned)(out < end ? |
257 + (end - out) : 257 - (out - end)); |
257 + (end - out) : 257 - (out - end)); |