components/zlib/patches/perf.patch
author Rich Burridge <rich.burridge@oracle.com>
Tue, 02 May 2017 17:33:26 -0700
changeset 7964 d9801318ed3d
parent 7718 9960a50bc6cf
permissions -rw-r--r--
25981468 Build ilmbase and openexr with the GNU compilers

Patch origin: in-house
Patch status: inffast.c part: accepted, will be in next version
Patch status: deflate.c part: Solaris-specific; not suitable for upstream

https://github.com/madler/zlib/commit/60a5ecc62b18d1e2391993b1fcfc10e100720642

--- zlib-1.2.8/inffast.c	2013-03-24 22:47:59.000000000 -0700
+++ zlib-1.2.8/inffast.c	2014-02-28 01:57:57.075708259 -0800
@@ -68,7 +68,7 @@
     code const FAR *dcode;      /* local strm->distcode */
     unsigned lmask;             /* mask for first level of length codes */
     unsigned dmask;             /* mask for first level of distance codes */
-    code here;                  /* retrieved table entry */
+    code *here;                 /* retrieved table entry */
     unsigned op;                /* code bits, operation, extra bits, or */
                                 /*  window position, window bytes to copy */
     unsigned len;               /* match length, unused bytes */
@@ -105,20 +105,20 @@
             hold += (unsigned long)(*in++) << bits;
             bits += 8;
         }
-        here = lcode[hold & lmask];
+        here = (code *)(&(lcode[hold & lmask]));
       dolen:
-        op = (unsigned)(here.bits);
+        op = (unsigned)(here->bits);
         hold >>= op;
         bits -= op;
-        op = (unsigned)(here.op);
+        op = (unsigned)(here->op);
         if (op == 0) {                          /* literal */
-            Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
+            Tracevv((stderr, here->val >= 0x20 && here->val < 0x7f ?
                     "inflate:         literal '%c'\n" :
-                    "inflate:         literal 0x%02x\n", here.val));
-            *out++ = (unsigned char)(here.val);
+                    "inflate:         literal 0x%02x\n", here->val));
+            *out++ = (unsigned char)(here->val);
         }
         else if (op & 16) {                     /* length base */
-            len = (unsigned)(here.val);
+            len = (unsigned)(here->val);
             op &= 15;                           /* number of extra bits */
             if (op) {
                 if (bits < op) {
@@ -136,14 +136,14 @@
                 hold += (unsigned long)(*in++) << bits;
                 bits += 8;
             }
-            here = dcode[hold & dmask];
+            here = (code *)(&(dcode[hold & dmask]));
           dodist:
-            op = (unsigned)(here.bits);
+            op = (unsigned)(here->bits);
             hold >>= op;
             bits -= op;
-            op = (unsigned)(here.op);
+            op = (unsigned)(here->op);
             if (op & 16) {                      /* distance base */
-                dist = (unsigned)(here.val);
+                dist = (unsigned)(here->val);
                 op &= 15;                       /* number of extra bits */
                 if (bits < op) {
                     hold += (unsigned long)(*in++) << bits;
@@ -262,7 +262,7 @@
                 }
             }
             else if ((op & 64) == 0) {          /* 2nd level distance code */
-                here = dcode[here.val + (hold & ((1U << op) - 1))];
+                here = (code *)(&(dcode[here->val + (hold & ((1U << op) - 1))]));
                 goto dodist;
             }
             else {
@@ -272,7 +272,7 @@
             }
         }
         else if ((op & 64) == 0) {              /* 2nd level length code */
-            here = lcode[here.val + (hold & ((1U << op) - 1))];
+            here = (code *)(&(lcode[here->val + (hold & ((1U << op) - 1))]));
             goto dolen;
         }
         else if (op & 32) {                     /* end-of-block */
--- zlib-1.2.8/deflate.c	2013-04-28 15:57:10.000000000 -0700
+++ zlib-1.2.8/deflate.c	2014-02-28 02:32:02.517988885 -0800
@@ -60,6 +60,7 @@
   copyright string in the executable of your product.
  */
 
+#ifndef LONGEST_MATCH_ONLY
 /* ===========================================================================
  *  Function prototypes.
  */
@@ -91,13 +92,18 @@
       void match_init OF((void)); /* asm code initialization */
       uInt longest_match  OF((deflate_state *s, IPos cur_match));
 #else
+#ifdef ORIG_LONGEST_MATCH
 local uInt longest_match  OF((deflate_state *s, IPos cur_match));
+#else
+uInt longest_match  OF((deflate_state *s, IPos cur_match));
+#endif
 #endif
 
 #ifdef ZLIB_DEBUG
 local  void check_match OF((deflate_state *s, IPos start, IPos match,
                             int length));
 #endif
+#endif /* ! LONGEST_MATCH_ONLY */
 
 /* ===========================================================================
  * Local data
@@ -106,6 +112,7 @@
 #define NIL 0
 /* Tail of hash chains */
 
+#ifndef LONGEST_MATCH_ONLY
 #ifndef TOO_FAR
 #  define TOO_FAR 4096
 #endif
@@ -1217,7 +1224,9 @@
 #endif
 #endif
 }
+#endif /* ! LONGEST_MATCH_ONLY */
 
+#if defined(ORIG_LONGEST_MATCH) || defined(ORIG_LONGEST_MATCH_GLOBAL)
 #ifndef FASTEST
 /* ===========================================================================
  * Set match_start to the longest match starting at the given string and
@@ -1232,7 +1241,11 @@
 /* For 80x86 and 680x0, an optimized version will be provided in match.asm or
  * match.S. The code will be functionally equivalent.
  */
+#ifdef ORIG_LONGEST_MATCH_GLOBAL
+uInt longest_match(s, cur_match)
+#else
 local uInt longest_match(s, cur_match)
+#endif
     deflate_state *s;
     IPos cur_match;                             /* current match */
 {
@@ -1375,6 +1388,7 @@
     return s->lookahead;
 }
 #endif /* ASMV */
+#endif /* ORIG_LONGEST_MATCHT */
 
 #else /* FASTEST */
 
@@ -1436,6 +1450,7 @@
 
 #endif /* FASTEST */
 
+#ifndef LONGEST_MATCH_ONLY
 #ifdef ZLIB_DEBUG
 
 #define EQUAL 0
@@ -2154,3 +2169,4 @@
         FLUSH_BLOCK(s, 0);
     return block_done;
 }
+#endif /* ! LONGEST_MATCH_ONLY */