adenilson / rpms / zlib

Forked from rpms/zlib 8 months ago
Clone
864312
--- a/compress.c
864312
+++ b/compress.c
864312
@@ -5,9 +5,15 @@
864312
 
864312
 /* @(#) $Id$ */
864312
 
864312
-#define ZLIB_INTERNAL
864312
+#include "zutil.h"
864312
 #include "zlib.h"
864312
 
864312
+#ifdef DFLTCC
864312
+#  include "contrib/s390/dfltcc.h"
864312
+#else
864312
+#define DEFLATE_BOUND_COMPLEN(source_len) 0
864312
+#endif
864312
+
864312
 /* ===========================================================================
864312
      Compresses the source buffer into the destination buffer. The level
864312
    parameter has the same meaning as in deflateInit.  sourceLen is the byte
864312
@@ -81,6 +87,12 @@ int ZEXPORT compress (dest, destLen, source, sourceLen)
864312
 uLong ZEXPORT compressBound (sourceLen)
864312
     uLong sourceLen;
864312
 {
864312
+    uLong complen = DEFLATE_BOUND_COMPLEN(sourceLen);
864312
+
864312
+    if (complen > 0)
864312
+	/* Architecture-specific code provided an upper bound. */
864312
+	return complen + ZLIB_WRAPLEN;
864312
+
864312
     return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
864312
            (sourceLen >> 25) + 13;
864312
 }
864312
--- a/contrib/s390/dfltcc.h
864312
+++ b/contrib/s390/dfltcc.h
864312
@@ -12,6 +12,28 @@ void ZLIB_INTERNAL dfltcc_reset OF((z_streamp strm, uInt size));
864312
 voidpf ZLIB_INTERNAL dfltcc_alloc_window OF((z_streamp strm, uInt items,
864312
                                              uInt size));
864312
 void ZLIB_INTERNAL dfltcc_free_window OF((z_streamp strm, voidpf w));
864312
+#define DFLTCC_BLOCK_HEADER_BITS 3
864312
+#define DFLTCC_HLITS_COUNT_BITS 5
864312
+#define DFLTCC_HDISTS_COUNT_BITS 5
864312
+#define DFLTCC_HCLENS_COUNT_BITS 4
864312
+#define DFLTCC_MAX_HCLENS 19
864312
+#define DFLTCC_HCLEN_BITS 3
864312
+#define DFLTCC_MAX_HLITS 286
864312
+#define DFLTCC_MAX_HDISTS 30
864312
+#define DFLTCC_MAX_HLIT_HDIST_BITS 7
864312
+#define DFLTCC_MAX_SYMBOL_BITS 16
864312
+#define DFLTCC_MAX_EOBS_BITS 15
864312
+#define DFLTCC_MAX_PADDING_BITS 7
864312
+#define DEFLATE_BOUND_COMPLEN(source_len) \
864312
+    ((DFLTCC_BLOCK_HEADER_BITS + \
864312
+      DFLTCC_HLITS_COUNT_BITS + \
864312
+      DFLTCC_HDISTS_COUNT_BITS + \
864312
+      DFLTCC_HCLENS_COUNT_BITS + \
864312
+      DFLTCC_MAX_HCLENS * DFLTCC_HCLEN_BITS + \
864312
+      (DFLTCC_MAX_HLITS + DFLTCC_MAX_HDISTS) * DFLTCC_MAX_HLIT_HDIST_BITS + \
864312
+      (source_len) * DFLTCC_MAX_SYMBOL_BITS + \
864312
+      DFLTCC_MAX_EOBS_BITS + \
864312
+      DFLTCC_MAX_PADDING_BITS) >> 3)
864312
 int ZLIB_INTERNAL dfltcc_can_inflate OF((z_streamp strm));
864312
 typedef enum {
864312
     DFLTCC_INFLATE_CONTINUE,
864312
diff --git a/contrib/s390/dfltcc_deflate.h b/contrib/s390/dfltcc_deflate.h
864312
index 03f7f53..46acfc5 100644
864312
--- a/contrib/s390/dfltcc_deflate.h
864312
+++ b/contrib/s390/dfltcc_deflate.h
864312
@@ -46,8 +46,7 @@ int ZLIB_INTERNAL dfltcc_deflate_get_dictionary OF((z_streamp strm,
864312
 #define DEFLATE_BOUND_ADJUST_COMPLEN(strm, complen, source_len) \
864312
     do { \
864312
         if (dfltcc_can_deflate((strm))) \
864312
-            (complen) = (3 + 5 + 5 + 4 + 19 * 3 + (286 + 30) * 7 + \
864312
-                         (source_len) * 16 + 15 + 7) >> 3; \
864312
+            (complen) = DEFLATE_BOUND_COMPLEN(source_len); \
864312
     } while (0)
864312
 #define DEFLATE_NEED_CONSERVATIVE_BOUND(strm) (dfltcc_can_deflate((strm)))
864312
 #define DEFLATE_HOOK dfltcc_deflate
864312
diff --git a/zutil.h b/zutil.h
864312
index 14277bc..cf90e49 100644
864312
--- a/zutil.h
864312
+++ b/zutil.h
864312
@@ -87,6 +87,8 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
864312
 
864312
 #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
864312
 
864312
+#define ZLIB_WRAPLEN 6 /* zlib format overhead */
864312
+
864312
         /* target dependencies */
864312
 
864312
 #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))