diff options
author | Richard Purdie <rpurdie@rpsys.net> | 2006-06-22 17:47:34 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-22 18:05:58 -0400 |
commit | 4f3865fb57a04db7cca068fed1c15badc064a302 (patch) | |
tree | 4c923c72b6ac9b633c87cc73b55a75c7cfd0f044 /lib/zlib_inflate/inflate.h | |
parent | 4f1bcaf094ccc512c23e10104c05a6f8e5b7a9e4 (diff) |
[PATCH] zlib_inflate: Upgrade library code to a recent version
Upgrade the zlib_inflate implementation in the kernel from a patched
version 1.1.3/4 to a patched 1.2.3.
The code in the kernel is about seven years old and I noticed that the
external zlib library's inflate performance was significantly faster (~50%)
than the code in the kernel on ARM (and faster again on x86_32).
For comparison the newer deflate code is 20% slower on ARM and 50% slower
on x86_32 but gives an approx 1% compression ratio improvement. I don't
consider this to be an improvement for kernel use so have no plans to
change the zlib_deflate code.
Various changes have been made to the zlib code in the kernel, the most
significant being the extra functions/flush option used by ppp_deflate.
This update reimplements the features PPP needs to ensure it continues to
work.
This code has been tested on ARM under both JFFS2 (with zlib compression
enabled) and ppp_deflate and on x86_32. JFFS2 sees an approx. 10% real
world file read speed improvement.
This patch also removes ZLIB_VERSION as it no longer has a correct value.
We don't need version checks anyway as the kernel's module handling will
take care of that for us. This removal is also more in keeping with the
zlib author's wishes (http://www.zlib.net/zlib_faq.html#faq24) and I've
added something to the zlib.h header to note its a modified version.
Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Acked-by: Joern Engel <joern@wh.fh-wedel.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'lib/zlib_inflate/inflate.h')
-rw-r--r-- | lib/zlib_inflate/inflate.h | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/lib/zlib_inflate/inflate.h b/lib/zlib_inflate/inflate.h new file mode 100644 index 000000000000..df8a6c92052d --- /dev/null +++ b/lib/zlib_inflate/inflate.h | |||
@@ -0,0 +1,107 @@ | |||
1 | /* inflate.h -- internal inflate state definition | ||
2 | * Copyright (C) 1995-2004 Mark Adler | ||
3 | * For conditions of distribution and use, see copyright notice in zlib.h | ||
4 | */ | ||
5 | |||
6 | /* WARNING: this file should *not* be used by applications. It is | ||
7 | part of the implementation of the compression library and is | ||
8 | subject to change. Applications should only use zlib.h. | ||
9 | */ | ||
10 | |||
11 | /* Possible inflate modes between inflate() calls */ | ||
12 | typedef enum { | ||
13 | HEAD, /* i: waiting for magic header */ | ||
14 | FLAGS, /* i: waiting for method and flags (gzip) */ | ||
15 | TIME, /* i: waiting for modification time (gzip) */ | ||
16 | OS, /* i: waiting for extra flags and operating system (gzip) */ | ||
17 | EXLEN, /* i: waiting for extra length (gzip) */ | ||
18 | EXTRA, /* i: waiting for extra bytes (gzip) */ | ||
19 | NAME, /* i: waiting for end of file name (gzip) */ | ||
20 | COMMENT, /* i: waiting for end of comment (gzip) */ | ||
21 | HCRC, /* i: waiting for header crc (gzip) */ | ||
22 | DICTID, /* i: waiting for dictionary check value */ | ||
23 | DICT, /* waiting for inflateSetDictionary() call */ | ||
24 | TYPE, /* i: waiting for type bits, including last-flag bit */ | ||
25 | TYPEDO, /* i: same, but skip check to exit inflate on new block */ | ||
26 | STORED, /* i: waiting for stored size (length and complement) */ | ||
27 | COPY, /* i/o: waiting for input or output to copy stored block */ | ||
28 | TABLE, /* i: waiting for dynamic block table lengths */ | ||
29 | LENLENS, /* i: waiting for code length code lengths */ | ||
30 | CODELENS, /* i: waiting for length/lit and distance code lengths */ | ||
31 | LEN, /* i: waiting for length/lit code */ | ||
32 | LENEXT, /* i: waiting for length extra bits */ | ||
33 | DIST, /* i: waiting for distance code */ | ||
34 | DISTEXT, /* i: waiting for distance extra bits */ | ||
35 | MATCH, /* o: waiting for output space to copy string */ | ||
36 | LIT, /* o: waiting for output space to write literal */ | ||
37 | CHECK, /* i: waiting for 32-bit check value */ | ||
38 | LENGTH, /* i: waiting for 32-bit length (gzip) */ | ||
39 | DONE, /* finished check, done -- remain here until reset */ | ||
40 | BAD, /* got a data error -- remain here until reset */ | ||
41 | MEM, /* got an inflate() memory error -- remain here until reset */ | ||
42 | SYNC /* looking for synchronization bytes to restart inflate() */ | ||
43 | } inflate_mode; | ||
44 | |||
45 | /* | ||
46 | State transitions between above modes - | ||
47 | |||
48 | (most modes can go to the BAD or MEM mode -- not shown for clarity) | ||
49 | |||
50 | Process header: | ||
51 | HEAD -> (gzip) or (zlib) | ||
52 | (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME | ||
53 | NAME -> COMMENT -> HCRC -> TYPE | ||
54 | (zlib) -> DICTID or TYPE | ||
55 | DICTID -> DICT -> TYPE | ||
56 | Read deflate blocks: | ||
57 | TYPE -> STORED or TABLE or LEN or CHECK | ||
58 | STORED -> COPY -> TYPE | ||
59 | TABLE -> LENLENS -> CODELENS -> LEN | ||
60 | Read deflate codes: | ||
61 | LEN -> LENEXT or LIT or TYPE | ||
62 | LENEXT -> DIST -> DISTEXT -> MATCH -> LEN | ||
63 | LIT -> LEN | ||
64 | Process trailer: | ||
65 | CHECK -> LENGTH -> DONE | ||
66 | */ | ||
67 | |||
68 | /* state maintained between inflate() calls. Approximately 7K bytes. */ | ||
69 | struct inflate_state { | ||
70 | inflate_mode mode; /* current inflate mode */ | ||
71 | int last; /* true if processing last block */ | ||
72 | int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ | ||
73 | int havedict; /* true if dictionary provided */ | ||
74 | int flags; /* gzip header method and flags (0 if zlib) */ | ||
75 | unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ | ||
76 | unsigned long check; /* protected copy of check value */ | ||
77 | unsigned long total; /* protected copy of output count */ | ||
78 | /* gz_headerp head; */ /* where to save gzip header information */ | ||
79 | /* sliding window */ | ||
80 | unsigned wbits; /* log base 2 of requested window size */ | ||
81 | unsigned wsize; /* window size or zero if not using window */ | ||
82 | unsigned whave; /* valid bytes in the window */ | ||
83 | unsigned write; /* window write index */ | ||
84 | unsigned char *window; /* allocated sliding window, if needed */ | ||
85 | /* bit accumulator */ | ||
86 | unsigned long hold; /* input bit accumulator */ | ||
87 | unsigned bits; /* number of bits in "in" */ | ||
88 | /* for string and stored block copying */ | ||
89 | unsigned length; /* literal or length of data to copy */ | ||
90 | unsigned offset; /* distance back to copy string from */ | ||
91 | /* for table and code decoding */ | ||
92 | unsigned extra; /* extra bits needed */ | ||
93 | /* fixed and dynamic code tables */ | ||
94 | code const *lencode; /* starting table for length/literal codes */ | ||
95 | code const *distcode; /* starting table for distance codes */ | ||
96 | unsigned lenbits; /* index bits for lencode */ | ||
97 | unsigned distbits; /* index bits for distcode */ | ||
98 | /* dynamic table building */ | ||
99 | unsigned ncode; /* number of code length code lengths */ | ||
100 | unsigned nlen; /* number of length code lengths */ | ||
101 | unsigned ndist; /* number of distance code lengths */ | ||
102 | unsigned have; /* number of code lengths in lens[] */ | ||
103 | code *next; /* next available space in codes[] */ | ||
104 | unsigned short lens[320]; /* temporary storage for code lengths */ | ||
105 | unsigned short work[288]; /* work area for code table building */ | ||
106 | code codes[ENOUGH]; /* space for code tables */ | ||
107 | }; | ||