|
|
b5844f |
diff --git a/Makefile.am b/Makefile.am
|
|
|
b5844f |
index 025c914..8b4120c 100644
|
|
|
b5844f |
--- a/Makefile.am
|
|
|
b5844f |
+++ b/Makefile.am
|
|
|
b5844f |
@@ -55,6 +55,9 @@ gzip_SOURCES = \
|
|
|
b5844f |
trees.c unlzh.c unlzw.c unpack.c unzip.c util.c zip.c
|
|
|
b5844f |
gzip_LDADD = libver.a lib/libgzip.a
|
|
|
b5844f |
gzip_LDADD += $(LIB_CLOCK_GETTIME)
|
|
|
b5844f |
+if IBM_Z_DFLTCC
|
|
|
b5844f |
+gzip_SOURCES += dfltcc.c
|
|
|
b5844f |
+endif
|
|
|
b5844f |
|
|
|
b5844f |
BUILT_SOURCES += version.c
|
|
|
b5844f |
version.c: Makefile
|
|
|
b5844f |
diff --git a/bits.c b/bits.c
|
|
|
b5844f |
index b0df2fe..9effc32 100644
|
|
|
b5844f |
--- a/bits.c
|
|
|
b5844f |
+++ b/bits.c
|
|
|
b5844f |
@@ -78,7 +78,7 @@
|
|
|
b5844f |
|
|
|
b5844f |
local file_t zfile; /* output gzip file */
|
|
|
b5844f |
|
|
|
b5844f |
-local unsigned short bi_buf;
|
|
|
b5844f |
+unsigned short bi_buf;
|
|
|
b5844f |
/* Output buffer. bits are inserted starting at the bottom (least significant
|
|
|
b5844f |
* bits).
|
|
|
b5844f |
*/
|
|
|
b5844f |
@@ -88,7 +88,7 @@ local unsigned short bi_buf;
|
|
|
b5844f |
* more than 16 bits on some systems.)
|
|
|
b5844f |
*/
|
|
|
b5844f |
|
|
|
b5844f |
-local int bi_valid;
|
|
|
b5844f |
+int bi_valid;
|
|
|
b5844f |
/* Number of valid bits in bi_buf. All bits above the last valid bit
|
|
|
b5844f |
* are always zero.
|
|
|
b5844f |
*/
|
|
|
b5844f |
diff --git a/configure.ac b/configure.ac
|
|
|
b5844f |
index 9a2b635..76ac26f 100644
|
|
|
b5844f |
--- a/configure.ac
|
|
|
b5844f |
+++ b/configure.ac
|
|
|
b5844f |
@@ -78,6 +78,16 @@ AC_ARG_ENABLE([gcc-warnings],
|
|
|
b5844f |
fi]
|
|
|
b5844f |
)
|
|
|
b5844f |
|
|
|
b5844f |
+AC_ARG_ENABLE([dfltcc],
|
|
|
b5844f |
+ [AS_HELP_STRING([--enable-dfltcc],
|
|
|
b5844f |
+ [use DEFLATE COMPRESSION CALL instruction on IBM Z])],
|
|
|
b5844f |
+ [case $enableval in
|
|
|
b5844f |
+ yes|no) gl_dfltcc=$enableval ;;
|
|
|
b5844f |
+ *) AC_MSG_ERROR([bad value $enableval for dfltcc option]) ;;
|
|
|
b5844f |
+ esac],
|
|
|
b5844f |
+ [gl_dfltcc=no]
|
|
|
b5844f |
+)
|
|
|
b5844f |
+
|
|
|
b5844f |
# gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
|
|
|
b5844f |
# ------------------------------------------------
|
|
|
b5844f |
# If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND.
|
|
|
b5844f |
@@ -188,6 +198,12 @@ if test "$gl_gcc_warnings" = yes; then
|
|
|
b5844f |
AC_SUBST([GNULIB_WARN_CFLAGS])
|
|
|
b5844f |
fi
|
|
|
b5844f |
|
|
|
b5844f |
+if test "$gl_dfltcc" = yes; then
|
|
|
b5844f |
+ AC_DEFINE([IBM_Z_DFLTCC], ,
|
|
|
b5844f |
+ [Use DEFLATE COMPRESSION CALL instruction on IBM Z machines.])
|
|
|
b5844f |
+fi
|
|
|
b5844f |
+AM_CONDITIONAL([IBM_Z_DFLTCC], [test "$gl_dfltcc" = yes])
|
|
|
b5844f |
+
|
|
|
b5844f |
# cc -E produces incorrect asm files on SVR4, so postprocess it.
|
|
|
b5844f |
ASCPPPOST="sed '/^ *\\#/d; s,//.*,,; s/% /%/g; s/\\. /./g'"
|
|
|
b5844f |
AC_SUBST([ASCPPPOST])
|
|
|
b5844f |
diff --git a/deflate.c b/deflate.c
|
|
|
b5844f |
index 8ffff3a..869b902 100644
|
|
|
b5844f |
--- a/deflate.c
|
|
|
b5844f |
+++ b/deflate.c
|
|
|
b5844f |
@@ -123,10 +123,6 @@
|
|
|
b5844f |
#define NIL 0
|
|
|
b5844f |
/* Tail of hash chains */
|
|
|
b5844f |
|
|
|
b5844f |
-#define FAST 4
|
|
|
b5844f |
-#define SLOW 2
|
|
|
b5844f |
-/* speed options for the general purpose bit flag */
|
|
|
b5844f |
-
|
|
|
b5844f |
#ifndef TOO_FAR
|
|
|
b5844f |
# define TOO_FAR 4096
|
|
|
b5844f |
#endif
|
|
|
b5844f |
@@ -215,9 +211,6 @@ local unsigned int max_lazy_match;
|
|
|
b5844f |
* max_insert_length is used only for compression levels <= 3.
|
|
|
b5844f |
*/
|
|
|
b5844f |
|
|
|
b5844f |
-local int compr_level;
|
|
|
b5844f |
-/* compression level (1..9) */
|
|
|
b5844f |
-
|
|
|
b5844f |
unsigned good_match;
|
|
|
b5844f |
/* Use a faster search when the previous match is longer than this */
|
|
|
b5844f |
|
|
|
b5844f |
@@ -308,14 +301,12 @@ local void check_match (IPos start, IPos match, int length);
|
|
|
b5844f |
/* ===========================================================================
|
|
|
b5844f |
* Initialize the "longest match" routines for a new file
|
|
|
b5844f |
*/
|
|
|
b5844f |
-void lm_init (pack_level, flags)
|
|
|
b5844f |
+void lm_init (pack_level)
|
|
|
b5844f |
int pack_level; /* 0: store, 1: best speed, 9: best compression */
|
|
|
b5844f |
- ush *flags; /* general purpose bit flag */
|
|
|
b5844f |
{
|
|
|
b5844f |
register unsigned j;
|
|
|
b5844f |
|
|
|
b5844f |
if (pack_level < 1 || pack_level > 9) gzip_error ("bad pack level");
|
|
|
b5844f |
- compr_level = pack_level;
|
|
|
b5844f |
|
|
|
b5844f |
/* Initialize the hash table. */
|
|
|
b5844f |
#if defined MAXSEG_64K && HASH_BITS == 15
|
|
|
b5844f |
@@ -337,11 +328,6 @@ void lm_init (pack_level, flags)
|
|
|
b5844f |
nice_match = configuration_table[pack_level].nice_length;
|
|
|
b5844f |
#endif
|
|
|
b5844f |
max_chain_length = configuration_table[pack_level].max_chain;
|
|
|
b5844f |
- if (pack_level == 1) {
|
|
|
b5844f |
- *flags |= FAST;
|
|
|
b5844f |
- } else if (pack_level == 9) {
|
|
|
b5844f |
- *flags |= SLOW;
|
|
|
b5844f |
- }
|
|
|
b5844f |
/* ??? reduce max_chain_length for binary files */
|
|
|
b5844f |
|
|
|
b5844f |
strstart = 0;
|
|
|
b5844f |
@@ -732,7 +718,7 @@ local off_t deflate_fast()
|
|
|
b5844f |
* evaluation for matches: a match is finally adopted only if there is
|
|
|
b5844f |
* no better match at the next window position.
|
|
|
b5844f |
*/
|
|
|
b5844f |
-off_t deflate()
|
|
|
b5844f |
+off_t deflate(int pack_level)
|
|
|
b5844f |
{
|
|
|
b5844f |
IPos hash_head; /* head of hash chain */
|
|
|
b5844f |
IPos prev_match; /* previous match */
|
|
|
b5844f |
@@ -740,7 +726,8 @@ off_t deflate()
|
|
|
b5844f |
int match_available = 0; /* set if previous match exists */
|
|
|
b5844f |
register unsigned match_length = MIN_MATCH-1; /* length of best match */
|
|
|
b5844f |
|
|
|
b5844f |
- if (compr_level <= 3) return deflate_fast(); /* optimized for speed */
|
|
|
b5844f |
+ lm_init(pack_level);
|
|
|
b5844f |
+ if (pack_level <= 3) return deflate_fast(); /* optimized for speed */
|
|
|
b5844f |
|
|
|
b5844f |
/* Process the input block. */
|
|
|
b5844f |
while (lookahead != 0) {
|
|
|
b5844f |
diff --git a/dfltcc.c b/dfltcc.c
|
|
|
b5844f |
new file mode 100644
|
|
|
b5844f |
index 0000000..9010475
|
|
|
b5844f |
--- /dev/null
|
|
|
b5844f |
+++ b/dfltcc.c
|
|
|
b5844f |
@@ -0,0 +1,429 @@
|
|
|
b5844f |
+/* dfltcc.c -- compress data using IBM Z DEFLATE COMPRESSION CALL
|
|
|
b5844f |
+
|
|
|
b5844f |
+ Copyright (C) 2019 Free Software Foundation, Inc.
|
|
|
b5844f |
+
|
|
|
b5844f |
+ This program is free software; you can redistribute it and/or modify
|
|
|
b5844f |
+ it under the terms of the GNU General Public License as published by
|
|
|
b5844f |
+ the Free Software Foundation; either version 3, or (at your option)
|
|
|
b5844f |
+ any later version.
|
|
|
b5844f |
+
|
|
|
b5844f |
+ This program is distributed in the hope that it will be useful,
|
|
|
b5844f |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
b5844f |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
b5844f |
+ GNU General Public License for more details.
|
|
|
b5844f |
+
|
|
|
b5844f |
+ You should have received a copy of the GNU General Public License
|
|
|
b5844f |
+ along with this program; if not, write to the Free Software Foundation,
|
|
|
b5844f |
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
|
|
b5844f |
+
|
|
|
b5844f |
+#include <config.h>
|
|
|
b5844f |
+#include <stdlib.h>
|
|
|
b5844f |
+#ifdef DFLTCC_USDT
|
|
|
b5844f |
+#include <sys/sdt.h>
|
|
|
b5844f |
+#endif
|
|
|
b5844f |
+
|
|
|
b5844f |
+#include "tailor.h"
|
|
|
b5844f |
+#include "gzip.h"
|
|
|
b5844f |
+
|
|
|
b5844f |
+#ifdef DYN_ALLOC
|
|
|
b5844f |
+ error: DYN_ALLOC is not supported by DFLTCC
|
|
|
b5844f |
+#endif
|
|
|
b5844f |
+
|
|
|
b5844f |
+/* ===========================================================================
|
|
|
b5844f |
+ * C wrappers for the DEFLATE CONVERSION CALL instruction.
|
|
|
b5844f |
+ */
|
|
|
b5844f |
+
|
|
|
b5844f |
+typedef enum
|
|
|
b5844f |
+{
|
|
|
b5844f |
+ DFLTCC_CC_OK = 0,
|
|
|
b5844f |
+ DFLTCC_CC_OP1_TOO_SHORT = 1,
|
|
|
b5844f |
+ DFLTCC_CC_OP2_TOO_SHORT = 2,
|
|
|
b5844f |
+ DFLTCC_CC_OP2_CORRUPT = 2,
|
|
|
b5844f |
+ DFLTCC_CC_AGAIN = 3,
|
|
|
b5844f |
+} dfltcc_cc;
|
|
|
b5844f |
+
|
|
|
b5844f |
+#define DFLTCC_QAF 0
|
|
|
b5844f |
+#define DFLTCC_GDHT 1
|
|
|
b5844f |
+#define DFLTCC_CMPR 2
|
|
|
b5844f |
+#define DFLTCC_XPND 4
|
|
|
b5844f |
+#define HBT_CIRCULAR (1 << 7)
|
|
|
b5844f |
+//#define HB_BITS 15
|
|
|
b5844f |
+//#define HB_SIZE (1 << HB_BITS)
|
|
|
b5844f |
+#define DFLTCC_FACILITY 151
|
|
|
b5844f |
+#define DFLTCC_FMT0 0
|
|
|
b5844f |
+#define CVT_CRC32 0
|
|
|
b5844f |
+#define HTT_FIXED 0
|
|
|
b5844f |
+#define HTT_DYNAMIC 1
|
|
|
b5844f |
+
|
|
|
b5844f |
+struct dfltcc_qaf_param
|
|
|
b5844f |
+{
|
|
|
b5844f |
+ char fns[16];
|
|
|
b5844f |
+ char reserved1[8];
|
|
|
b5844f |
+ char fmts[2];
|
|
|
b5844f |
+ char reserved2[6];
|
|
|
b5844f |
+};
|
|
|
b5844f |
+
|
|
|
b5844f |
+struct dfltcc_param_v0
|
|
|
b5844f |
+{
|
|
|
b5844f |
+ unsigned short pbvn; /* Parameter-Block-Version Number */
|
|
|
b5844f |
+ unsigned char mvn; /* Model-Version Number */
|
|
|
b5844f |
+ unsigned char ribm; /* Reserved for IBM use */
|
|
|
b5844f |
+ unsigned reserved32 : 31;
|
|
|
b5844f |
+ unsigned cf : 1; /* Continuation Flag */
|
|
|
b5844f |
+ unsigned char reserved64[8];
|
|
|
b5844f |
+ unsigned nt : 1; /* New Task */
|
|
|
b5844f |
+ unsigned reserved129 : 1;
|
|
|
b5844f |
+ unsigned cvt : 1; /* Check Value Type */
|
|
|
b5844f |
+ unsigned reserved131 : 1;
|
|
|
b5844f |
+ unsigned htt : 1; /* Huffman-Table Type */
|
|
|
b5844f |
+ unsigned bcf : 1; /* Block-Continuation Flag */
|
|
|
b5844f |
+ unsigned bcc : 1; /* Block Closing Control */
|
|
|
b5844f |
+ unsigned bhf : 1; /* Block Header Final */
|
|
|
b5844f |
+ unsigned reserved136 : 1;
|
|
|
b5844f |
+ unsigned reserved137 : 1;
|
|
|
b5844f |
+ unsigned dhtgc : 1; /* DHT Generation Control */
|
|
|
b5844f |
+ unsigned reserved139 : 5;
|
|
|
b5844f |
+ unsigned reserved144 : 5;
|
|
|
b5844f |
+ unsigned sbb : 3; /* Sub-Byte Boundary */
|
|
|
b5844f |
+ unsigned char oesc; /* Operation-Ending-Supplemental Code */
|
|
|
b5844f |
+ unsigned reserved160 : 12;
|
|
|
b5844f |
+ unsigned ifs : 4; /* Incomplete-Function Status */
|
|
|
b5844f |
+ unsigned short ifl; /* Incomplete-Function Length */
|
|
|
b5844f |
+ unsigned char reserved192[8];
|
|
|
b5844f |
+ unsigned char reserved256[8];
|
|
|
b5844f |
+ unsigned char reserved320[4];
|
|
|
b5844f |
+ unsigned short hl; /* History Length */
|
|
|
b5844f |
+ unsigned reserved368 : 1;
|
|
|
b5844f |
+ unsigned short ho : 15; /* History Offset */
|
|
|
b5844f |
+ unsigned int cv; /* Check Value */
|
|
|
b5844f |
+ unsigned eobs : 15; /* End-of-block Symbol */
|
|
|
b5844f |
+ unsigned reserved431 : 1;
|
|
|
b5844f |
+ unsigned char eobl : 4; /* End-of-block Length */
|
|
|
b5844f |
+ unsigned reserved436 : 12;
|
|
|
b5844f |
+ unsigned reserved448 : 4;
|
|
|
b5844f |
+ unsigned short cdhtl : 12; /* Compressed-Dynamic-Huffman Table
|
|
|
b5844f |
+ Length */
|
|
|
b5844f |
+ unsigned char reserved464[6];
|
|
|
b5844f |
+ unsigned char cdht[288];
|
|
|
b5844f |
+ unsigned char reserved[32];
|
|
|
b5844f |
+ unsigned char csb[1152];
|
|
|
b5844f |
+};
|
|
|
b5844f |
+
|
|
|
b5844f |
+static int is_bit_set(const char *bits, int n)
|
|
|
b5844f |
+{
|
|
|
b5844f |
+ return bits[n / 8] & (1 << (7 - (n % 8)));
|
|
|
b5844f |
+}
|
|
|
b5844f |
+
|
|
|
b5844f |
+static int is_dfltcc_enabled(void)
|
|
|
b5844f |
+{
|
|
|
b5844f |
+ const char *env;
|
|
|
b5844f |
+ char facilities[((DFLTCC_FACILITY / 64) + 1) * 8];
|
|
|
b5844f |
+ register int r0 __asm__("r0");
|
|
|
b5844f |
+
|
|
|
b5844f |
+ env = getenv("DFLTCC");
|
|
|
b5844f |
+ if (env && !strcmp(env, "0")) {
|
|
|
b5844f |
+ return 0;
|
|
|
b5844f |
+ }
|
|
|
b5844f |
+
|
|
|
b5844f |
+ r0 = sizeof(facilities) / 8;
|
|
|
b5844f |
+ __asm__("stfle %[facilities]\n"
|
|
|
b5844f |
+ : [facilities] "=Q"(facilities) : [r0] "r"(r0) : "cc", "memory");
|
|
|
b5844f |
+ return is_bit_set((const char *) facilities, DFLTCC_FACILITY);
|
|
|
b5844f |
+}
|
|
|
b5844f |
+
|
|
|
b5844f |
+static dfltcc_cc dfltcc(int fn, void *param,
|
|
|
b5844f |
+ uch **op1, size_t *len1,
|
|
|
b5844f |
+ const uch **op2, size_t *len2,
|
|
|
b5844f |
+ void *hist)
|
|
|
b5844f |
+{
|
|
|
b5844f |
+ uch *t2 = op1 ? *op1 : NULL;
|
|
|
b5844f |
+ size_t t3 = len1 ? *len1 : 0;
|
|
|
b5844f |
+ const uch *t4 = op2 ? *op2 : NULL;
|
|
|
b5844f |
+ size_t t5 = len2 ? *len2 : 0;
|
|
|
b5844f |
+ register int r0 __asm__("r0") = fn;
|
|
|
b5844f |
+ register void *r1 __asm__("r1") = param;
|
|
|
b5844f |
+ register uch *r2 __asm__("r2") = t2;
|
|
|
b5844f |
+ register size_t r3 __asm__("r3") = t3;
|
|
|
b5844f |
+ register const uch *r4 __asm__("r4") = t4;
|
|
|
b5844f |
+ register size_t r5 __asm__("r5") = t5;
|
|
|
b5844f |
+ int cc;
|
|
|
b5844f |
+
|
|
|
b5844f |
+ __asm__ volatile(
|
|
|
b5844f |
+#ifdef DFLTCC_USDT
|
|
|
b5844f |
+ STAP_PROBE_ASM(zlib, dfltcc_entry,
|
|
|
b5844f |
+ STAP_PROBE_ASM_TEMPLATE(5))
|
|
|
b5844f |
+#endif
|
|
|
b5844f |
+ ".insn rrf,0xb9390000,%[r2],%[r4],%[hist],0\n"
|
|
|
b5844f |
+#ifdef DFLTCC_USDT
|
|
|
b5844f |
+ STAP_PROBE_ASM(zlib, dfltcc_exit,
|
|
|
b5844f |
+ STAP_PROBE_ASM_TEMPLATE(5))
|
|
|
b5844f |
+#endif
|
|
|
b5844f |
+ "ipm %[cc]\n"
|
|
|
b5844f |
+ : [r2] "+r" (r2)
|
|
|
b5844f |
+ , [r3] "+r" (r3)
|
|
|
b5844f |
+ , [r4] "+r" (r4)
|
|
|
b5844f |
+ , [r5] "+r" (r5)
|
|
|
b5844f |
+ , [cc] "=r" (cc)
|
|
|
b5844f |
+ : [r0] "r" (r0)
|
|
|
b5844f |
+ , [r1] "r" (r1)
|
|
|
b5844f |
+ , [hist] "r" (hist)
|
|
|
b5844f |
+#ifdef DFLTCC_USDT
|
|
|
b5844f |
+ , STAP_PROBE_ASM_OPERANDS(5, r2, r3, r4, r5, hist)
|
|
|
b5844f |
+#endif
|
|
|
b5844f |
+ : "cc", "memory");
|
|
|
b5844f |
+ t2 = r2; t3 = r3; t4 = r4; t5 = r5;
|
|
|
b5844f |
+
|
|
|
b5844f |
+ if (op1)
|
|
|
b5844f |
+ *op1 = t2;
|
|
|
b5844f |
+ if (len1)
|
|
|
b5844f |
+ *len1 = t3;
|
|
|
b5844f |
+ if (op2)
|
|
|
b5844f |
+ *op2 = t4;
|
|
|
b5844f |
+ if (len2)
|
|
|
b5844f |
+ *len2 = t5;
|
|
|
b5844f |
+ return (cc >> 28) & 3;
|
|
|
b5844f |
+}
|
|
|
b5844f |
+
|
|
|
b5844f |
+static void dfltcc_qaf(struct dfltcc_qaf_param *param)
|
|
|
b5844f |
+{
|
|
|
b5844f |
+ dfltcc(DFLTCC_QAF, param, NULL, NULL, NULL, NULL, NULL);
|
|
|
b5844f |
+}
|
|
|
b5844f |
+
|
|
|
b5844f |
+static void dfltcc_gdht(struct dfltcc_param_v0 *param)
|
|
|
b5844f |
+{
|
|
|
b5844f |
+ const uch *next_in = inbuf + inptr;
|
|
|
b5844f |
+ size_t avail_in = insize - inptr;
|
|
|
b5844f |
+
|
|
|
b5844f |
+ dfltcc(DFLTCC_GDHT, param, NULL, NULL, &next_in, &avail_in, NULL);
|
|
|
b5844f |
+}
|
|
|
b5844f |
+
|
|
|
b5844f |
+static off_t total_in;
|
|
|
b5844f |
+
|
|
|
b5844f |
+static dfltcc_cc dfltcc_cmpr_xpnd(struct dfltcc_param_v0 *param, int fn)
|
|
|
b5844f |
+{
|
|
|
b5844f |
+ uch *next_out = outbuf + outcnt;
|
|
|
b5844f |
+ size_t avail_out = OUTBUFSIZ - outcnt;
|
|
|
b5844f |
+ const uch *next_in = inbuf + inptr;
|
|
|
b5844f |
+ size_t avail_in = insize - inptr;
|
|
|
b5844f |
+ off_t consumed_in;
|
|
|
b5844f |
+ dfltcc_cc cc;
|
|
|
b5844f |
+
|
|
|
b5844f |
+ cc = dfltcc(fn | HBT_CIRCULAR, param,
|
|
|
b5844f |
+ &next_out, &avail_out,
|
|
|
b5844f |
+ &next_in, &avail_in,
|
|
|
b5844f |
+ window);
|
|
|
b5844f |
+ consumed_in = next_in - (inbuf + inptr);
|
|
|
b5844f |
+ inptr += consumed_in;
|
|
|
b5844f |
+ total_in += consumed_in;
|
|
|
b5844f |
+ outcnt += ((OUTBUFSIZ - outcnt) - avail_out);
|
|
|
b5844f |
+ return cc;
|
|
|
b5844f |
+}
|
|
|
b5844f |
+
|
|
|
b5844f |
+__attribute__((aligned(8)))
|
|
|
b5844f |
+static struct context
|
|
|
b5844f |
+{
|
|
|
b5844f |
+ union
|
|
|
b5844f |
+ {
|
|
|
b5844f |
+ struct dfltcc_qaf_param af;
|
|
|
b5844f |
+ struct dfltcc_param_v0 param;
|
|
|
b5844f |
+ };
|
|
|
b5844f |
+} ctx;
|
|
|
b5844f |
+
|
|
|
b5844f |
+static struct dfltcc_param_v0 *init_param(struct dfltcc_param_v0 *param)
|
|
|
b5844f |
+{
|
|
|
b5844f |
+ const char *s;
|
|
|
b5844f |
+
|
|
|
b5844f |
+ memset(param, 0, sizeof(*param));
|
|
|
b5844f |
+#ifndef DFLTCC_RIBM
|
|
|
b5844f |
+#define DFLTCC_RIBM 0
|
|
|
b5844f |
+#endif
|
|
|
b5844f |
+ s = getenv("DFLTCC_RIBM");
|
|
|
b5844f |
+ param->ribm = (s && *s) ? strtoul(s, NULL, 0) : DFLTCC_RIBM;
|
|
|
b5844f |
+ param->nt = 1;
|
|
|
b5844f |
+ param->cvt = CVT_CRC32;
|
|
|
b5844f |
+ param->cv = __builtin_bswap32(getcrc());
|
|
|
b5844f |
+ return param;
|
|
|
b5844f |
+}
|
|
|
b5844f |
+
|
|
|
b5844f |
+static void bi_close_block(struct dfltcc_param_v0 *param)
|
|
|
b5844f |
+{
|
|
|
b5844f |
+ bi_valid = param->sbb;
|
|
|
b5844f |
+ bi_buf = bi_valid == 0 ? 0 : outbuf[outcnt] & ((1 << bi_valid) - 1);
|
|
|
b5844f |
+ send_bits(
|
|
|
b5844f |
+ bi_reverse(param->eobs >> (15 - param->eobl), param->eobl),
|
|
|
b5844f |
+ param->eobl);
|
|
|
b5844f |
+ param->bcf = 0;
|
|
|
b5844f |
+}
|
|
|
b5844f |
+
|
|
|
b5844f |
+static void close_block(struct dfltcc_param_v0 *param)
|
|
|
b5844f |
+{
|
|
|
b5844f |
+ bi_close_block(param);
|
|
|
b5844f |
+ bi_windup();
|
|
|
b5844f |
+ param->sbb = (param->sbb + param->eobl) % 8;
|
|
|
b5844f |
+ if (param->sbb != 0) {
|
|
|
b5844f |
+ Assert(outcnt > 0, "outbuf must have enough space for EOBS");
|
|
|
b5844f |
+ outcnt--;
|
|
|
b5844f |
+ }
|
|
|
b5844f |
+}
|
|
|
b5844f |
+
|
|
|
b5844f |
+static void close_stream(struct dfltcc_param_v0 *param)
|
|
|
b5844f |
+{
|
|
|
b5844f |
+ if (param->bcf) {
|
|
|
b5844f |
+ bi_close_block(param);
|
|
|
b5844f |
+ }
|
|
|
b5844f |
+ send_bits(1, 3); /* BFINAL=1, BTYPE=00 */
|
|
|
b5844f |
+ bi_windup();
|
|
|
b5844f |
+ put_short(0x0000);
|
|
|
b5844f |
+ put_short(0xFFFF);
|
|
|
b5844f |
+}
|
|
|
b5844f |
+
|
|
|
b5844f |
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
|
|
b5844f |
+
|
|
|
b5844f |
+/* ===========================================================================
|
|
|
b5844f |
+ * Compress ifd into ofd in hardware or fall back to software.
|
|
|
b5844f |
+ */
|
|
|
b5844f |
+int dfltcc_deflate(int pack_level)
|
|
|
b5844f |
+{
|
|
|
b5844f |
+ const char *s;
|
|
|
b5844f |
+ unsigned long level_mask;
|
|
|
b5844f |
+ unsigned long block_size;
|
|
|
b5844f |
+ off_t block_threshold;
|
|
|
b5844f |
+ struct dfltcc_param_v0 *param;
|
|
|
b5844f |
+ int extra;
|
|
|
b5844f |
+
|
|
|
b5844f |
+ /* Check whether we can use hardware compression */
|
|
|
b5844f |
+ if (!is_dfltcc_enabled() || getenv("SOURCE_DATE_EPOCH")) {
|
|
|
b5844f |
+ return deflate(pack_level);
|
|
|
b5844f |
+ }
|
|
|
b5844f |
+#ifndef DFLTCC_LEVEL_MASK
|
|
|
b5844f |
+#define DFLTCC_LEVEL_MASK 0x2
|
|
|
b5844f |
+#endif
|
|
|
b5844f |
+ s = getenv("DFLTCC_LEVEL_MASK");
|
|
|
b5844f |
+ level_mask = (s && *s) ? strtoul(s, NULL, 0) : DFLTCC_LEVEL_MASK;
|
|
|
b5844f |
+ if ((level_mask & (1 << pack_level)) == 0) {
|
|
|
b5844f |
+ return deflate(pack_level);
|
|
|
b5844f |
+ }
|
|
|
b5844f |
+ dfltcc_qaf(&ctx.af);
|
|
|
b5844f |
+ if (!is_bit_set(ctx.af.fns, DFLTCC_CMPR) ||
|
|
|
b5844f |
+ !is_bit_set(ctx.af.fns, DFLTCC_GDHT) ||
|
|
|
b5844f |
+ !is_bit_set(ctx.af.fmts, DFLTCC_FMT0)) {
|
|
|
b5844f |
+ return deflate(pack_level);
|
|
|
b5844f |
+ }
|
|
|
b5844f |
+
|
|
|
b5844f |
+ /* Initialize tuning parameters */
|
|
|
b5844f |
+#ifndef DFLTCC_BLOCK_SIZE
|
|
|
b5844f |
+#define DFLTCC_BLOCK_SIZE 1048576
|
|
|
b5844f |
+#endif
|
|
|
b5844f |
+ s = getenv("DFLTCC_BLOCK_SIZE");
|
|
|
b5844f |
+ block_size = (s && *s) ? strtoul(s, NULL, 0) : DFLTCC_BLOCK_SIZE;
|
|
|
b5844f |
+ (void)block_size;
|
|
|
b5844f |
+#ifndef DFLTCC_FIRST_FHT_BLOCK_SIZE
|
|
|
b5844f |
+#define DFLTCC_FIRST_FHT_BLOCK_SIZE 4096
|
|
|
b5844f |
+#endif
|
|
|
b5844f |
+ s = getenv("DFLTCC_FIRST_FHT_BLOCK_SIZE");
|
|
|
b5844f |
+ block_threshold = (s && *s) ? strtoul(s, NULL, 0) :
|
|
|
b5844f |
+ DFLTCC_FIRST_FHT_BLOCK_SIZE;
|
|
|
b5844f |
+
|
|
|
b5844f |
+ /* Compress ifd into ofd in a loop */
|
|
|
b5844f |
+ param = init_param(&ctx.param);
|
|
|
b5844f |
+ while (1) {
|
|
|
b5844f |
+ /* Flush the output data */
|
|
|
b5844f |
+ if (outcnt > OUTBUFSIZ - 8) {
|
|
|
b5844f |
+ flush_outbuf();
|
|
|
b5844f |
+ }
|
|
|
b5844f |
+
|
|
|
b5844f |
+ /* Close the block */
|
|
|
b5844f |
+ if (param->bcf && total_in == block_threshold && !param->cf) {
|
|
|
b5844f |
+ close_block(param);
|
|
|
b5844f |
+ block_threshold += block_size;
|
|
|
b5844f |
+ }
|
|
|
b5844f |
+
|
|
|
b5844f |
+ /* Read the input data */
|
|
|
b5844f |
+ if (inptr == insize) {
|
|
|
b5844f |
+ if (fill_inbuf(1) == EOF && !param->cf) {
|
|
|
b5844f |
+ break;
|
|
|
b5844f |
+ }
|
|
|
b5844f |
+ inptr = 0;
|
|
|
b5844f |
+ }
|
|
|
b5844f |
+
|
|
|
b5844f |
+ /* Temporarily mask some input data */
|
|
|
b5844f |
+ extra = MAX(0, total_in + (insize - inptr) - block_threshold);
|
|
|
b5844f |
+ insize -= extra;
|
|
|
b5844f |
+
|
|
|
b5844f |
+ /* Start a new block */
|
|
|
b5844f |
+ if (!param->bcf) {
|
|
|
b5844f |
+ if (total_in == 0 && block_threshold > 0) {
|
|
|
b5844f |
+ param->htt = HTT_FIXED;
|
|
|
b5844f |
+ } else {
|
|
|
b5844f |
+ param->htt = HTT_DYNAMIC;
|
|
|
b5844f |
+ dfltcc_gdht(param);
|
|
|
b5844f |
+ }
|
|
|
b5844f |
+ }
|
|
|
b5844f |
+
|
|
|
b5844f |
+ /* Compress inbuf into outbuf */
|
|
|
b5844f |
+ dfltcc_cmpr_xpnd(param, DFLTCC_CMPR);
|
|
|
b5844f |
+
|
|
|
b5844f |
+ /* Unmask the input data */
|
|
|
b5844f |
+ insize += extra;
|
|
|
b5844f |
+
|
|
|
b5844f |
+ /* Continue the block */
|
|
|
b5844f |
+ param->bcf = 1;
|
|
|
b5844f |
+ }
|
|
|
b5844f |
+ close_stream(param);
|
|
|
b5844f |
+ setcrc(__builtin_bswap32(param->cv));
|
|
|
b5844f |
+ return 0;
|
|
|
b5844f |
+}
|
|
|
b5844f |
+
|
|
|
b5844f |
+/* ===========================================================================
|
|
|
b5844f |
+ * Decompress ifd into ofd in hardware or fall back to software.
|
|
|
b5844f |
+ */
|
|
|
b5844f |
+int dfltcc_inflate(void)
|
|
|
b5844f |
+{
|
|
|
b5844f |
+ struct dfltcc_param_v0 *param;
|
|
|
b5844f |
+ dfltcc_cc cc;
|
|
|
b5844f |
+
|
|
|
b5844f |
+ /* Check whether we can use hardware decompression */
|
|
|
b5844f |
+ if (!is_dfltcc_enabled()) {
|
|
|
b5844f |
+ return inflate();
|
|
|
b5844f |
+ }
|
|
|
b5844f |
+ dfltcc_qaf(&ctx.af);
|
|
|
b5844f |
+ if (!is_bit_set(ctx.af.fns, DFLTCC_XPND)) {
|
|
|
b5844f |
+ return inflate();
|
|
|
b5844f |
+ }
|
|
|
b5844f |
+
|
|
|
b5844f |
+ /* Decompress ifd into ofd in a loop */
|
|
|
b5844f |
+ param = init_param(&ctx.param);
|
|
|
b5844f |
+ while (1) {
|
|
|
b5844f |
+ /* Perform I/O */
|
|
|
b5844f |
+ if (outcnt == OUTBUFSIZ) {
|
|
|
b5844f |
+ flush_outbuf();
|
|
|
b5844f |
+ }
|
|
|
b5844f |
+ if (inptr == insize) {
|
|
|
b5844f |
+ if (fill_inbuf(1) == EOF) {
|
|
|
b5844f |
+ /* Premature EOF */
|
|
|
b5844f |
+ return 2;
|
|
|
b5844f |
+ }
|
|
|
b5844f |
+ inptr = 0;
|
|
|
b5844f |
+ }
|
|
|
b5844f |
+ /* Decompress inbuf into outbuf */
|
|
|
b5844f |
+ cc = dfltcc_cmpr_xpnd(param, DFLTCC_XPND);
|
|
|
b5844f |
+ if (cc == DFLTCC_CC_OK) {
|
|
|
b5844f |
+ /* The entire deflate stream has been successfully decompressed */
|
|
|
b5844f |
+ break;
|
|
|
b5844f |
+ }
|
|
|
b5844f |
+ if (cc == DFLTCC_CC_OP2_CORRUPT && param->oesc != 0) {
|
|
|
b5844f |
+ /* The deflate stream is corrupted */
|
|
|
b5844f |
+ return 2;
|
|
|
b5844f |
+ }
|
|
|
b5844f |
+ /* There must be more data to decompress */
|
|
|
b5844f |
+ }
|
|
|
b5844f |
+ if (param->sbb != 0) {
|
|
|
b5844f |
+ /* The deflate stream has ended in the middle of a byte - go to the next
|
|
|
b5844f |
+ * byte boundary, so that unzip() can read CRC and length.
|
|
|
b5844f |
+ */
|
|
|
b5844f |
+ inptr++;
|
|
|
b5844f |
+ }
|
|
|
b5844f |
+ setcrc(__builtin_bswap32(param->cv)); /* set CRC value for unzip() */
|
|
|
b5844f |
+ flush_outbuf(); /* update bytes_out for unzip() */
|
|
|
b5844f |
+ return 0;
|
|
|
b5844f |
+}
|
|
|
b5844f |
diff --git a/gzip.c b/gzip.c
|
|
|
b5844f |
index 3ddfb7f..4fffc4f 100644
|
|
|
b5844f |
--- a/gzip.c
|
|
|
b5844f |
+++ b/gzip.c
|
|
|
b5844f |
@@ -128,9 +128,21 @@ static char const *const license_msg[] = {
|
|
|
b5844f |
|
|
|
b5844f |
/* global buffers */
|
|
|
b5844f |
|
|
|
b5844f |
+#ifdef IBM_Z_DFLTCC
|
|
|
b5844f |
+/* DEFLATE COMPRESSION CALL works faster with page-aligned input buffers */
|
|
|
b5844f |
+__attribute__((aligned(4096)))
|
|
|
b5844f |
+#endif
|
|
|
b5844f |
DECLARE(uch, inbuf, INBUFSIZ +INBUF_EXTRA);
|
|
|
b5844f |
+#ifdef IBM_Z_DFLTCC
|
|
|
b5844f |
+/* DEFLATE COMPRESSION CALL works faster with page-aligned output buffers */
|
|
|
b5844f |
+__attribute__((aligned(4096)))
|
|
|
b5844f |
+#endif
|
|
|
b5844f |
DECLARE(uch, outbuf, OUTBUFSIZ+OUTBUF_EXTRA);
|
|
|
b5844f |
DECLARE(ush, d_buf, DIST_BUFSIZE);
|
|
|
b5844f |
+#ifdef IBM_Z_DFLTCC
|
|
|
b5844f |
+/* DEFLATE COMPRESSION CALL works only with page-aligned windows */
|
|
|
b5844f |
+__attribute__((aligned(4096)))
|
|
|
b5844f |
+#endif
|
|
|
b5844f |
DECLARE(uch, window, 2L*WSIZE);
|
|
|
b5844f |
#ifndef MAXSEG_64K
|
|
|
b5844f |
DECLARE(ush, tab_prefix, 1L<
|
|
|
b5844f |
diff --git a/gzip.h b/gzip.h
|
|
|
b5844f |
index 46bbac9..0c59cc2 100644
|
|
|
b5844f |
--- a/gzip.h
|
|
|
b5844f |
+++ b/gzip.h
|
|
|
b5844f |
@@ -74,7 +74,10 @@ extern int method; /* compression method * /
|
|
|
b5844f |
*/
|
|
|
b5844f |
|
|
|
b5844f |
#ifndef INBUFSIZ
|
|
|
b5844f |
-# ifdef SMALL_MEM
|
|
|
b5844f |
+# ifdef IBM_Z_DFLTCC
|
|
|
b5844f |
+/* DEFLATE COMPRESSION CALL works faster with larger input buffers */
|
|
|
b5844f |
+# define INBUFSIZ 0x40000
|
|
|
b5844f |
+# elif defined SMALL_MEM
|
|
|
b5844f |
# define INBUFSIZ 0x2000 /* input buffer size */
|
|
|
b5844f |
# else
|
|
|
b5844f |
# define INBUFSIZ 0x8000 /* input buffer size */
|
|
|
b5844f |
@@ -83,7 +86,10 @@ extern int method; /* compression method */
|
|
|
b5844f |
#define INBUF_EXTRA 64 /* required by unlzw() */
|
|
|
b5844f |
|
|
|
b5844f |
#ifndef OUTBUFSIZ
|
|
|
b5844f |
-# ifdef SMALL_MEM
|
|
|
b5844f |
+# ifdef IBM_Z_DFLTCC
|
|
|
b5844f |
+/* DEFLATE COMPRESSION CALL works faster with larger output buffers */
|
|
|
b5844f |
+# define OUTBUFSIZ 0x40000
|
|
|
b5844f |
+# elif defined SMALL_MEM
|
|
|
b5844f |
# define OUTBUFSIZ 8192 /* output buffer size */
|
|
|
b5844f |
# else
|
|
|
b5844f |
# define OUTBUFSIZ 16384 /* output buffer size */
|
|
|
b5844f |
@@ -275,8 +281,8 @@ extern int unlzh (int in, int out);
|
|
|
b5844f |
extern noreturn void abort_gzip (void);
|
|
|
b5844f |
|
|
|
b5844f |
/* in deflate.c */
|
|
|
b5844f |
-extern void lm_init (int pack_level, ush *flags);
|
|
|
b5844f |
-extern off_t deflate (void);
|
|
|
b5844f |
+extern void lm_init (int pack_level);
|
|
|
b5844f |
+extern off_t deflate (int pack_level);
|
|
|
b5844f |
|
|
|
b5844f |
/* in trees.c */
|
|
|
b5844f |
extern void ct_init (ush *attr, int *method);
|
|
|
b5844f |
@@ -284,6 +290,8 @@ extern int ct_tally (int dist, int lc);
|
|
|
b5844f |
extern off_t flush_block (char *buf, ulg stored_len, int pad, int eof);
|
|
|
b5844f |
|
|
|
b5844f |
/* in bits.c */
|
|
|
b5844f |
+extern unsigned short bi_buf;
|
|
|
b5844f |
+extern int bi_valid;
|
|
|
b5844f |
extern void bi_init (file_t zipfile);
|
|
|
b5844f |
extern void send_bits (int value, int length);
|
|
|
b5844f |
extern unsigned bi_reverse (unsigned value, int length) _GL_ATTRIBUTE_CONST;
|
|
|
b5844f |
@@ -293,7 +301,9 @@ extern int (*read_buf) (char *buf, unsigned size);
|
|
|
b5844f |
|
|
|
b5844f |
/* in util.c: */
|
|
|
b5844f |
extern int copy (int in, int out);
|
|
|
b5844f |
-extern ulg updcrc (uch *s, unsigned n);
|
|
|
b5844f |
+extern ulg updcrc (const uch *s, unsigned n);
|
|
|
b5844f |
+extern ulg getcrc (void) _GL_ATTRIBUTE_PURE;
|
|
|
b5844f |
+extern void setcrc (ulg c);
|
|
|
b5844f |
extern void clear_bufs (void);
|
|
|
b5844f |
extern int fill_inbuf (int eof_ok);
|
|
|
b5844f |
extern void flush_outbuf (void);
|
|
|
b5844f |
@@ -315,3 +325,9 @@ extern void fprint_off (FILE *, off_t, int);
|
|
|
b5844f |
|
|
|
b5844f |
/* in inflate.c */
|
|
|
b5844f |
extern int inflate (void);
|
|
|
b5844f |
+
|
|
|
b5844f |
+ /* in dfltcc.c */
|
|
|
b5844f |
+#ifdef IBM_Z_DFLTCC
|
|
|
b5844f |
+extern int dfltcc_deflate (int pack_level);
|
|
|
b5844f |
+extern int dfltcc_inflate (void);
|
|
|
b5844f |
+#endif
|
|
|
b5844f |
diff --git a/tests/znew-k b/tests/znew-k
|
|
|
b5844f |
index eeb7b29..d43246b 100755
|
|
|
b5844f |
--- a/tests/znew-k
|
|
|
b5844f |
+++ b/tests/znew-k
|
|
|
b5844f |
@@ -29,12 +29,13 @@ chmod +x compress || framework_failure_
|
|
|
b5844f |
# Note that the basename must have a length of 6 or greater.
|
|
|
b5844f |
# Otherwise, "test -f $name" below would fail.
|
|
|
b5844f |
name=123456.Z
|
|
|
b5844f |
+gzname=123456.gz
|
|
|
b5844f |
|
|
|
b5844f |
printf '%1012977s' ' ' | gzip -c > $name || framework_failure_
|
|
|
b5844f |
|
|
|
b5844f |
fail=0
|
|
|
b5844f |
|
|
|
b5844f |
znew -K $name || fail=1
|
|
|
b5844f |
-test -f $name || fail=1
|
|
|
b5844f |
+test -f $name || test -f $gzname || fail=1
|
|
|
b5844f |
|
|
|
b5844f |
Exit $fail
|
|
|
b5844f |
diff --git a/unzip.c b/unzip.c
|
|
|
b5844f |
index a7255d4..86ef664 100644
|
|
|
b5844f |
--- a/unzip.c
|
|
|
b5844f |
+++ b/unzip.c
|
|
|
b5844f |
@@ -129,7 +129,11 @@ int unzip(in, out)
|
|
|
b5844f |
/* Decompress */
|
|
|
b5844f |
if (method == DEFLATED) {
|
|
|
b5844f |
|
|
|
b5844f |
+#ifdef IBM_Z_DFLTCC
|
|
|
b5844f |
+ int res = dfltcc_inflate();
|
|
|
b5844f |
+#else
|
|
|
b5844f |
int res = inflate();
|
|
|
b5844f |
+#endif
|
|
|
b5844f |
|
|
|
b5844f |
if (res == 3) {
|
|
|
b5844f |
xalloc_die ();
|
|
|
b5844f |
diff --git a/util.c b/util.c
|
|
|
b5844f |
index 41e50d7..dc00f4a 100644
|
|
|
b5844f |
--- a/util.c
|
|
|
b5844f |
+++ b/util.c
|
|
|
b5844f |
@@ -96,6 +96,11 @@ static const ulg crc_32_tab[] = {
|
|
|
b5844f |
0x2d02ef8dL
|
|
|
b5844f |
};
|
|
|
b5844f |
|
|
|
b5844f |
+/* ========================================================================
|
|
|
b5844f |
+ * Shift register contents
|
|
|
b5844f |
+ */
|
|
|
b5844f |
+static ulg crc = (ulg)0xffffffffL;
|
|
|
b5844f |
+
|
|
|
b5844f |
/* ===========================================================================
|
|
|
b5844f |
* Copy input to output unchanged: zcat == cat with --force.
|
|
|
b5844f |
* IN assertion: insize bytes have already been read in inbuf and inptr bytes
|
|
|
b5844f |
@@ -126,13 +131,11 @@ int copy(in, out)
|
|
|
b5844f |
* Return the current crc in either case.
|
|
|
b5844f |
*/
|
|
|
b5844f |
ulg updcrc(s, n)
|
|
|
b5844f |
- uch *s; /* pointer to bytes to pump through */
|
|
|
b5844f |
+ const uch *s; /* pointer to bytes to pump through */
|
|
|
b5844f |
unsigned n; /* number of bytes in s[] */
|
|
|
b5844f |
{
|
|
|
b5844f |
register ulg c; /* temporary variable */
|
|
|
b5844f |
|
|
|
b5844f |
- static ulg crc = (ulg)0xffffffffL; /* shift register contents */
|
|
|
b5844f |
-
|
|
|
b5844f |
if (s == NULL) {
|
|
|
b5844f |
c = 0xffffffffL;
|
|
|
b5844f |
} else {
|
|
|
b5844f |
@@ -145,6 +148,23 @@ ulg updcrc(s, n)
|
|
|
b5844f |
return c ^ 0xffffffffL; /* (instead of ~c for 64-bit machines) */
|
|
|
b5844f |
}
|
|
|
b5844f |
|
|
|
b5844f |
+/* ===========================================================================
|
|
|
b5844f |
+ * Return a current CRC value.
|
|
|
b5844f |
+ */
|
|
|
b5844f |
+ulg getcrc()
|
|
|
b5844f |
+{
|
|
|
b5844f |
+ return crc ^ 0xffffffffL;
|
|
|
b5844f |
+}
|
|
|
b5844f |
+
|
|
|
b5844f |
+/* ===========================================================================
|
|
|
b5844f |
+ * Set a new CRC value.
|
|
|
b5844f |
+ */
|
|
|
b5844f |
+void setcrc(c)
|
|
|
b5844f |
+ ulg c;
|
|
|
b5844f |
+{
|
|
|
b5844f |
+ crc = c ^ 0xffffffffL;
|
|
|
b5844f |
+}
|
|
|
b5844f |
+
|
|
|
b5844f |
/* ===========================================================================
|
|
|
b5844f |
* Clear input and output buffers
|
|
|
b5844f |
*/
|
|
|
b5844f |
@@ -238,7 +258,9 @@ void flush_outbuf()
|
|
|
b5844f |
{
|
|
|
b5844f |
if (outcnt == 0) return;
|
|
|
b5844f |
|
|
|
b5844f |
- write_buf(ofd, (char *)outbuf, outcnt);
|
|
|
b5844f |
+ if (!test) {
|
|
|
b5844f |
+ write_buf(ofd, (char *)outbuf, outcnt);
|
|
|
b5844f |
+ }
|
|
|
b5844f |
bytes_out += (off_t)outcnt;
|
|
|
b5844f |
outcnt = 0;
|
|
|
b5844f |
}
|
|
|
b5844f |
diff --git a/zip.c b/zip.c
|
|
|
b5844f |
index 1bd4c78..ace7e5e 100644
|
|
|
b5844f |
--- a/zip.c
|
|
|
b5844f |
+++ b/zip.c
|
|
|
b5844f |
@@ -23,9 +23,12 @@
|
|
|
b5844f |
#include "tailor.h"
|
|
|
b5844f |
#include "gzip.h"
|
|
|
b5844f |
|
|
|
b5844f |
-local ulg crc; /* crc on uncompressed file data */
|
|
|
b5844f |
off_t header_bytes; /* number of bytes in gzip header */
|
|
|
b5844f |
|
|
|
b5844f |
+#define FAST 4
|
|
|
b5844f |
+#define SLOW 2
|
|
|
b5844f |
+/* speed options for the general purpose bit flag */
|
|
|
b5844f |
+
|
|
|
b5844f |
/* ===========================================================================
|
|
|
b5844f |
* Deflate in to out.
|
|
|
b5844f |
* IN assertions: the input and output buffers are cleared.
|
|
|
b5844f |
@@ -68,11 +71,15 @@ int zip(in, out)
|
|
|
b5844f |
put_long (stamp);
|
|
|
b5844f |
|
|
|
b5844f |
/* Write deflated file to zip file */
|
|
|
b5844f |
- crc = updcrc(0, 0);
|
|
|
b5844f |
+ updcrc(NULL, 0);
|
|
|
b5844f |
|
|
|
b5844f |
bi_init(out);
|
|
|
b5844f |
ct_init(&attr, &method);
|
|
|
b5844f |
- lm_init(level, &deflate_flags);
|
|
|
b5844f |
+ if (level == 1) {
|
|
|
b5844f |
+ deflate_flags |= FAST;
|
|
|
b5844f |
+ } else if (level == 9) {
|
|
|
b5844f |
+ deflate_flags |= SLOW;
|
|
|
b5844f |
+ }
|
|
|
b5844f |
|
|
|
b5844f |
put_byte((uch)deflate_flags); /* extra flags */
|
|
|
b5844f |
put_byte(OS_CODE); /* OS identifier */
|
|
|
b5844f |
@@ -85,7 +92,11 @@ int zip(in, out)
|
|
|
b5844f |
}
|
|
|
b5844f |
header_bytes = (off_t)outcnt;
|
|
|
b5844f |
|
|
|
b5844f |
- (void)deflate();
|
|
|
b5844f |
+#ifdef IBM_Z_DFLTCC
|
|
|
b5844f |
+ (void)dfltcc_deflate(level);
|
|
|
b5844f |
+#else
|
|
|
b5844f |
+ (void)deflate(level);
|
|
|
b5844f |
+#endif
|
|
|
b5844f |
|
|
|
b5844f |
#ifndef NO_SIZE_CHECK
|
|
|
b5844f |
/* Check input size
|
|
|
b5844f |
@@ -98,7 +109,7 @@ int zip(in, out)
|
|
|
b5844f |
#endif
|
|
|
b5844f |
|
|
|
b5844f |
/* Write the crc and uncompressed size */
|
|
|
b5844f |
- put_long(crc);
|
|
|
b5844f |
+ put_long(getcrc());
|
|
|
b5844f |
put_long((ulg)bytes_in);
|
|
|
b5844f |
header_bytes += 2*4;
|
|
|
b5844f |
|
|
|
b5844f |
@@ -126,7 +137,7 @@ int file_read(buf, size)
|
|
|
b5844f |
return EOF;
|
|
|
b5844f |
}
|
|
|
b5844f |
|
|
|
b5844f |
- crc = updcrc((uch*)buf, len);
|
|
|
b5844f |
+ updcrc((uch*)buf, len);
|
|
|
b5844f |
bytes_in += (off_t)len;
|
|
|
b5844f |
return (int)len;
|
|
|
b5844f |
}
|
|
|
b5844f |
2.21.0
|