linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] 2.4.21 zlib merge #1 turboc
@ 2003-06-14 13:47 Jörn Engel
  2003-06-14 13:48 ` [PATCH] 2.4.21 zlib merge #2 return Jörn Engel
  0 siblings, 1 reply; 5+ messages in thread
From: Jörn Engel @ 2003-06-14 13:47 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: linux-kernel

Hi Marcelo!

This patchset hat already made it into Linus' tree.  It merges the
interesting bits from zlib 1.1.4 into the kernel zlib, which is based
on 1.1.3.

Remove Turbo C workaround and fix modulo operation.

Jörn

-- 
If you're willing to restrict the flexibility of your approach,
you can almost always do something better.
-- John Carmack

--- linux-2.4.20/lib/zlib_inflate/infcodes.c~zlib_merge_turboc	2002-11-29 00:53:15.000000000 +0100
+++ linux-2.4.20/lib/zlib_inflate/infcodes.c	2003-06-10 16:59:38.000000000 +0200
@@ -146,15 +146,9 @@
       DUMPBITS(j)
       c->mode = COPY;
     case COPY:          /* o: copying bytes in window, waiting for space */
-#ifndef __TURBOC__ /* Turbo C bug for following expression */
-      f = (uInt)(q - s->window) < c->sub.copy.dist ?
-          s->end - (c->sub.copy.dist - (q - s->window)) :
-          q - c->sub.copy.dist;
-#else
       f = q - c->sub.copy.dist;
-      if ((uInt)(q - s->window) < c->sub.copy.dist)
-        f = s->end - (c->sub.copy.dist - (uInt)(q - s->window));
-#endif
+      while (f < s->window)             /* modulo window size-"while" instead */
+        f += s->end - s->window;        /* of "if" handles invalid distances */
       while (c->len)
       {
         NEEDOUT

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] 2.4.21 zlib merge #2 return
  2003-06-14 13:47 [PATCH] 2.4.21 zlib merge #1 turboc Jörn Engel
@ 2003-06-14 13:48 ` Jörn Engel
  2003-06-14 13:49   ` [PATCH] 2.4.21 zlib merge #3 inffast Jörn Engel
  0 siblings, 1 reply; 5+ messages in thread
From: Jörn Engel @ 2003-06-14 13:48 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: linux-kernel

Fix one return code in huft_build.

Jörn

-- 
Those who come seeking peace without a treaty are plotting.
-- Sun Tzu

--- linux-2.4.20/lib/zlib_inflate/inftrees.c~zlib_merge_return	2002-11-29 00:53:15.000000000 +0100
+++ linux-2.4.20/lib/zlib_inflate/inftrees.c	2003-06-10 17:00:25.000000000 +0200
@@ -228,7 +228,7 @@
 
         /* allocate new table */
         if (*hn + z > MANY)     /* (note: doesn't matter for fixed) */
-          return Z_MEM_ERROR;   /* not enough memory */
+          return Z_DATA_ERROR;  /* overflow of MANY */
         u[h] = q = hp + *hn;
         *hn += z;
 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] 2.4.21 zlib merge #3 inffast
  2003-06-14 13:48 ` [PATCH] 2.4.21 zlib merge #2 return Jörn Engel
@ 2003-06-14 13:49   ` Jörn Engel
  2003-06-14 13:50     ` [PATCH] 2.4.21 zlib merge #4 windowBits Jörn Engel
  0 siblings, 1 reply; 5+ messages in thread
From: Jörn Engel @ 2003-06-14 13:49 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: linux-kernel

Reformat zlib_inflate_fast a bit, change one conditional into a loop
and fix one of three conditional cases.

Jörn

-- 
Beware of bugs in the above code; I have only proved it correct, but
not tried it.
-- Donald Knuth

--- linux-2.4.20/lib/zlib_inflate/inffast.c~zlib_merge_inffast	2002-11-29 00:53:15.000000000 +0100
+++ linux-2.4.20/lib/zlib_inflate/inffast.c	2003-06-10 17:00:43.000000000 +0200
@@ -88,28 +88,41 @@
 
             /* do the copy */
             m -= c;
-            if ((uInt)(q - s->window) >= d)     /* offset before dest */
-            {                                   /*  just copy */
-              r = q - d;
-              *q++ = *r++;  c--;        /* minimum count is three, */
-              *q++ = *r++;  c--;        /*  so unroll loop a little */
-            }
-            else                        /* else offset after destination */
+            r = q - d;
+            if (r < s->window)                  /* wrap if needed */
             {
-              e = d - (uInt)(q - s->window); /* bytes from offset to end */
-              r = s->end - e;           /* pointer to offset */
-              if (c > e)                /* if source crosses, */
+              do {
+                r += s->end - s->window;        /* force pointer in window */
+              } while (r < s->window);          /* covers invalid distances */
+              e = s->end - r;
+              if (c > e)
               {
-                c -= e;                 /* copy to end of window */
+                c -= e;                         /* wrapped copy */
                 do {
-                  *q++ = *r++;
+                    *q++ = *r++;
                 } while (--e);
-                r = s->window;          /* copy rest from start of window */
+                r = s->window;
+                do {
+                    *q++ = *r++;
+                } while (--c);
+              }
+              else                              /* normal copy */
+              {
+                *q++ = *r++;  c--;
+                *q++ = *r++;  c--;
+                do {
+                    *q++ = *r++;
+                } while (--c);
               }
             }
-            do {                        /* copy all or what's left */
-              *q++ = *r++;
-            } while (--c);
+            else                                /* normal copy */
+            {
+              *q++ = *r++;  c--;
+              *q++ = *r++;  c--;
+              do {
+                *q++ = *r++;
+              } while (--c);
+            }
             break;
           }
           else if ((e & 64) == 0)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] 2.4.21 zlib merge #4 windowBits
  2003-06-14 13:49   ` [PATCH] 2.4.21 zlib merge #3 inffast Jörn Engel
@ 2003-06-14 13:50     ` Jörn Engel
  2003-06-14 13:51       ` [PATCH] 2.4.21 zlib changes #1 memlevel Jörn Engel
  0 siblings, 1 reply; 5+ messages in thread
From: Jörn Engel @ 2003-06-14 13:50 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: linux-kernel

Disallow windowBits <9 (windowBits=9 would hit a bug) for deflate and
do the same for ppp.

Jörn

-- 
Anything that can go wrong, will.
-- Finagle's Law

--- linux-2.4.20/lib/zlib_deflate/deflate.c~zlib_merge_magic	2003-06-10 12:37:17.000000000 +0200
+++ linux-2.4.20/lib/zlib_deflate/deflate.c	2003-06-10 17:01:02.000000000 +0200
@@ -215,7 +215,7 @@
         windowBits = -windowBits;
     }
     if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
-        windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
+        windowBits < 9 || windowBits > 15 || level < 0 || level > 9 ||
 	strategy < 0 || strategy > Z_HUFFMAN_ONLY) {
         return Z_STREAM_ERROR;
     }
--- linux-2.4.20/include/linux/ppp-comp.h~zlib_merge_magic	1999-08-06 19:44:11.000000000 +0200
+++ linux-2.4.20/include/linux/ppp-comp.h	2003-06-10 17:01:02.000000000 +0200
@@ -177,7 +177,7 @@
 #define CI_DEFLATE_DRAFT	24	/* value used in original draft RFC */
 #define CILEN_DEFLATE		4	/* length of its config option */
 
-#define DEFLATE_MIN_SIZE	8
+#define DEFLATE_MIN_SIZE	9
 #define DEFLATE_MAX_SIZE	15
 #define DEFLATE_METHOD_VAL	8
 #define DEFLATE_SIZE(x)		(((x) >> 4) + DEFLATE_MIN_SIZE)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] 2.4.21 zlib changes #1 memlevel
  2003-06-14 13:50     ` [PATCH] 2.4.21 zlib merge #4 windowBits Jörn Engel
@ 2003-06-14 13:51       ` Jörn Engel
  0 siblings, 0 replies; 5+ messages in thread
From: Jörn Engel @ 2003-06-14 13:51 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: linux-kernel

Reduce MAX_MEM_LEVEL to 8.  This reduces zlib memory consumption by
128k (from ~400k to ~270k) at the theoretical cost of worse
compression.  No code currently in the kernel actually uses the better
compression, so the practical cost is zero.

Jörn

-- 
A victorious army first wins and then seeks battle.
-- Sun Tzu

--- linux-2.4.20/include/linux/zconf.h~zlib_memlevel	2002-11-29 00:53:15.000000000 +0100
+++ linux-2.4.20/include/linux/zconf.h	2003-06-10 17:01:16.000000000 +0200
@@ -35,7 +35,7 @@
 
 /* Maximum value for memLevel in deflateInit2 */
 #ifndef MAX_MEM_LEVEL
-#  define MAX_MEM_LEVEL 9
+#  define MAX_MEM_LEVEL 8
 #endif
 
 /* Maximum value for windowBits in deflateInit2 and inflateInit2.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-06-14 13:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-14 13:47 [PATCH] 2.4.21 zlib merge #1 turboc Jörn Engel
2003-06-14 13:48 ` [PATCH] 2.4.21 zlib merge #2 return Jörn Engel
2003-06-14 13:49   ` [PATCH] 2.4.21 zlib merge #3 inffast Jörn Engel
2003-06-14 13:50     ` [PATCH] 2.4.21 zlib merge #4 windowBits Jörn Engel
2003-06-14 13:51       ` [PATCH] 2.4.21 zlib changes #1 memlevel Jörn Engel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).