aboutsummaryrefslogtreecommitdiffstats
path: root/lib/zlib_inflate/inflate_sync.c
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@rpsys.net>2006-06-22 17:47:34 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-22 18:05:58 -0400
commit4f3865fb57a04db7cca068fed1c15badc064a302 (patch)
tree4c923c72b6ac9b633c87cc73b55a75c7cfd0f044 /lib/zlib_inflate/inflate_sync.c
parent4f1bcaf094ccc512c23e10104c05a6f8e5b7a9e4 (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_sync.c')
-rw-r--r--lib/zlib_inflate/inflate_sync.c152
1 files changed, 0 insertions, 152 deletions
diff --git a/lib/zlib_inflate/inflate_sync.c b/lib/zlib_inflate/inflate_sync.c
deleted file mode 100644
index 61411ff89d61..000000000000
--- a/lib/zlib_inflate/inflate_sync.c
+++ /dev/null
@@ -1,152 +0,0 @@
1/* inflate.c -- zlib interface to inflate modules
2 * Copyright (C) 1995-1998 Mark Adler
3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */
5
6#include <linux/zutil.h>
7#include "infblock.h"
8#include "infutil.h"
9
10#if 0
11int zlib_inflateSync(
12 z_streamp z
13)
14{
15 uInt n; /* number of bytes to look at */
16 Byte *p; /* pointer to bytes */
17 uInt m; /* number of marker bytes found in a row */
18 uLong r, w; /* temporaries to save total_in and total_out */
19
20 /* set up */
21 if (z == NULL || z->state == NULL)
22 return Z_STREAM_ERROR;
23 if (z->state->mode != I_BAD)
24 {
25 z->state->mode = I_BAD;
26 z->state->sub.marker = 0;
27 }
28 if ((n = z->avail_in) == 0)
29 return Z_BUF_ERROR;
30 p = z->next_in;
31 m = z->state->sub.marker;
32
33 /* search */
34 while (n && m < 4)
35 {
36 static const Byte mark[4] = {0, 0, 0xff, 0xff};
37 if (*p == mark[m])
38 m++;
39 else if (*p)
40 m = 0;
41 else
42 m = 4 - m;
43 p++, n--;
44 }
45
46 /* restore */
47 z->total_in += p - z->next_in;
48 z->next_in = p;
49 z->avail_in = n;
50 z->state->sub.marker = m;
51
52 /* return no joy or set up to restart on a new block */
53 if (m != 4)
54 return Z_DATA_ERROR;
55 r = z->total_in; w = z->total_out;
56 zlib_inflateReset(z);
57 z->total_in = r; z->total_out = w;
58 z->state->mode = BLOCKS;
59 return Z_OK;
60}
61#endif /* 0 */
62
63
64/* Returns true if inflate is currently at the end of a block generated
65 * by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
66 * implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH
67 * but removes the length bytes of the resulting empty stored block. When
68 * decompressing, PPP checks that at the end of input packet, inflate is
69 * waiting for these length bytes.
70 */
71#if 0
72int zlib_inflateSyncPoint(
73 z_streamp z
74)
75{
76 if (z == NULL || z->state == NULL || z->state->blocks == NULL)
77 return Z_STREAM_ERROR;
78 return zlib_inflate_blocks_sync_point(z->state->blocks);
79}
80#endif /* 0 */
81
82/*
83 * This subroutine adds the data at next_in/avail_in to the output history
84 * without performing any output. The output buffer must be "caught up";
85 * i.e. no pending output (hence s->read equals s->write), and the state must
86 * be BLOCKS (i.e. we should be willing to see the start of a series of
87 * BLOCKS). On exit, the output will also be caught up, and the checksum
88 * will have been updated if need be.
89 */
90static int zlib_inflate_addhistory(inflate_blocks_statef *s,
91 z_stream *z)
92{
93 uLong b; /* bit buffer */ /* NOT USED HERE */
94 uInt k; /* bits in bit buffer */ /* NOT USED HERE */
95 uInt t; /* temporary storage */
96 Byte *p; /* input data pointer */
97 uInt n; /* bytes available there */
98 Byte *q; /* output window write pointer */
99 uInt m; /* bytes to end of window or read pointer */
100
101 if (s->read != s->write)
102 return Z_STREAM_ERROR;
103 if (s->mode != TYPE)
104 return Z_DATA_ERROR;
105
106 /* we're ready to rock */
107 LOAD
108 /* while there is input ready, copy to output buffer, moving
109 * pointers as needed.
110 */
111 while (n) {
112 t = n; /* how many to do */
113 /* is there room until end of buffer? */
114 if (t > m) t = m;
115 /* update check information */
116 if (s->checkfn != NULL)
117 s->check = (*s->checkfn)(s->check, q, t);
118 memcpy(q, p, t);
119 q += t;
120 p += t;
121 n -= t;
122 z->total_out += t;
123 s->read = q; /* drag read pointer forward */
124/* WWRAP */ /* expand WWRAP macro by hand to handle s->read */
125 if (q == s->end) {
126 s->read = q = s->window;
127 m = WAVAIL;
128 }
129 }
130 UPDATE
131 return Z_OK;
132}
133
134
135/*
136 * This subroutine adds the data at next_in/avail_in to the output history
137 * without performing any output. The output buffer must be "caught up";
138 * i.e. no pending output (hence s->read equals s->write), and the state must
139 * be BLOCKS (i.e. we should be willing to see the start of a series of
140 * BLOCKS). On exit, the output will also be caught up, and the checksum
141 * will have been updated if need be.
142 */
143
144int zlib_inflateIncomp(
145 z_stream *z
146
147)
148{
149 if (z->state->mode != BLOCKS)
150 return Z_DATA_ERROR;
151 return zlib_inflate_addhistory(z->state->blocks, z);
152}