60c5b2
From be0c5581e38332b2ffa8a4cf92076cfde02872b4 Mon Sep 17 00:00:00 2001
60c5b2
From: Paul Eggert <eggert@cs.ucla.edu>
60c5b2
Date: Tue, 2 Apr 2019 10:26:30 -0700
60c5b2
Subject: Improve IBM Z patch
60c5b2
60c5b2
Most of this is minor changes to use GNU style and C99 constructs.
60c5b2
* NEWS: Mention IBM Z.
60c5b2
* bootstrap.conf (gnulib_modules): Add stdalign.
60c5b2
* dfltcc.c: Include stdalign.h, stdbool.h.
60c5b2
(union aligned_dfltcc_qaf_param, union aligned_dfltcc_param_v0):
60c5b2
New types, used for C11-style alignment.  All uses changed.
60c5b2
(init_param):
60c5b2
* gzip.c (BUFFER_ALIGNED): New macro.
60c5b2
(inbuf, outbuf, window): Use it, so buffers are aligned everywhere.
60c5b2
* gzip.h (INBUFSIZ, OUTBUFSIZE): Use big buffers everywhere,
60c5b2
unless SMALL_MEM.
60c5b2
* zip.c (SLOW, FAST): Now enums since they need not be macros:
60c5b2
---
60c5b2
 NEWS           |   4 +
60c5b2
 bootstrap.conf |   1 +
60c5b2
 deflate.c      |   8 +-
60c5b2
 dfltcc.c       | 632 +++++++++++++++++++++++++++++----------------------------
60c5b2
 gzip.c         |  27 ++-
60c5b2
 gzip.h         |  16 +-
60c5b2
 lib/.gitignore |   1 +
60c5b2
 m4/.gitignore  |   1 +
60c5b2
 unzip.c        |   2 +-
60c5b2
 util.c         |  30 ++-
60c5b2
 zip.c          |  24 +--
60c5b2
 11 files changed, 376 insertions(+), 370 deletions(-)
60c5b2
60c5b2
diff --git a/deflate.c b/deflate.c
60c5b2
index 869b902..eb697af 100644
60c5b2
--- a/deflate.c
60c5b2
+++ b/deflate.c
60c5b2
@@ -718,7 +718,8 @@ local off_t deflate_fast()
60c5b2
  * evaluation for matches: a match is finally adopted only if there is
60c5b2
  * no better match at the next window position.
60c5b2
  */
60c5b2
-off_t deflate(int pack_level)
60c5b2
+off_t
60c5b2
+deflate (int pack_level)
60c5b2
 {
60c5b2
     IPos hash_head;          /* head of hash chain */
60c5b2
     IPos prev_match;         /* previous match */
60c5b2
@@ -726,8 +727,9 @@ off_t deflate(int pack_level)
60c5b2
     int match_available = 0; /* set if previous match exists */
60c5b2
     register unsigned match_length = MIN_MATCH-1; /* length of best match */
60c5b2
 
60c5b2
-    lm_init(pack_level);
60c5b2
-    if (pack_level <= 3) return deflate_fast(); /* optimized for speed */
60c5b2
+    lm_init (pack_level);
60c5b2
+    if (pack_level <= 3)
60c5b2
+      return deflate_fast();
60c5b2
 
60c5b2
     /* Process the input block. */
60c5b2
     while (lookahead != 0) {
60c5b2
diff --git a/dfltcc.c b/dfltcc.c
60c5b2
index 9010475..ba62968 100644
60c5b2
--- a/dfltcc.c
60c5b2
+++ b/dfltcc.c
60c5b2
@@ -17,16 +17,20 @@
60c5b2
    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
60c5b2
 
60c5b2
 #include <config.h>
60c5b2
+
60c5b2
+#include <stdalign.h>
60c5b2
+#include <stdbool.h>
60c5b2
 #include <stdlib.h>
60c5b2
+
60c5b2
 #ifdef DFLTCC_USDT
60c5b2
-#include <sys/sdt.h>
60c5b2
+# include <sys/sdt.h>
60c5b2
 #endif
60c5b2
 
60c5b2
 #include "tailor.h"
60c5b2
 #include "gzip.h"
60c5b2
 
60c5b2
 #ifdef DYN_ALLOC
60c5b2
-    error: DYN_ALLOC is not supported by DFLTCC
60c5b2
+# error "DYN_ALLOC is not supported by DFLTCC"
60c5b2
 #endif
60c5b2
 
60c5b2
 /* ===========================================================================
60c5b2
@@ -35,11 +39,11 @@
60c5b2
 
60c5b2
 typedef enum
60c5b2
 {
60c5b2
-    DFLTCC_CC_OK = 0,
60c5b2
-    DFLTCC_CC_OP1_TOO_SHORT = 1,
60c5b2
-    DFLTCC_CC_OP2_TOO_SHORT = 2,
60c5b2
-    DFLTCC_CC_OP2_CORRUPT = 2,
60c5b2
-    DFLTCC_CC_AGAIN = 3,
60c5b2
+ DFLTCC_CC_OK = 0,
60c5b2
+ DFLTCC_CC_OP1_TOO_SHORT = 1,
60c5b2
+ DFLTCC_CC_OP2_TOO_SHORT = 2,
60c5b2
+ DFLTCC_CC_OP2_CORRUPT = 2,
60c5b2
+ DFLTCC_CC_AGAIN = 3,
60c5b2
 } dfltcc_cc;
60c5b2
 
60c5b2
 #define DFLTCC_QAF 0
60c5b2
@@ -47,383 +51,391 @@ typedef enum
60c5b2
 #define DFLTCC_CMPR 2
60c5b2
 #define DFLTCC_XPND 4
60c5b2
 #define HBT_CIRCULAR (1 << 7)
60c5b2
-//#define HB_BITS 15
60c5b2
-//#define HB_SIZE (1 << HB_BITS)
60c5b2
+/* #define HB_BITS 15 */
60c5b2
+/* #define HB_SIZE (1 << HB_BITS) */
60c5b2
 #define DFLTCC_FACILITY 151
60c5b2
 #define DFLTCC_FMT0 0
60c5b2
 #define CVT_CRC32 0
60c5b2
 #define HTT_FIXED 0
60c5b2
 #define HTT_DYNAMIC 1
60c5b2
 
60c5b2
+#ifndef DFLTCC_BLOCK_SIZE
60c5b2
+# define DFLTCC_BLOCK_SIZE 1048576
60c5b2
+#endif
60c5b2
+#ifndef DFLTCC_FIRST_FHT_BLOCK_SIZE
60c5b2
+# define DFLTCC_FIRST_FHT_BLOCK_SIZE 4096
60c5b2
+#endif
60c5b2
+#ifndef DFLTCC_LEVEL_MASK
60c5b2
+# define DFLTCC_LEVEL_MASK 0x2
60c5b2
+#endif
60c5b2
+#ifndef DFLTCC_RIBM
60c5b2
+# define DFLTCC_RIBM 0
60c5b2
+#endif
60c5b2
+
60c5b2
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
60c5b2
+
60c5b2
 struct dfltcc_qaf_param
60c5b2
 {
60c5b2
-    char fns[16];
60c5b2
-    char reserved1[8];
60c5b2
-    char fmts[2];
60c5b2
-    char reserved2[6];
60c5b2
+  char fns[16];
60c5b2
+  char reserved1[8];
60c5b2
+  char fmts[2];
60c5b2
+  char reserved2[6];
60c5b2
+};
60c5b2
+
60c5b2
+union aligned_dfltcc_qaf_param
60c5b2
+{
60c5b2
+  struct dfltcc_qaf_param af;
60c5b2
+  char alignas (8) aligned;
60c5b2
 };
60c5b2
 
60c5b2
 struct dfltcc_param_v0
60c5b2
 {
60c5b2
-    unsigned short pbvn;               /* Parameter-Block-Version Number */
60c5b2
-    unsigned char mvn;                 /* Model-Version Number */
60c5b2
-    unsigned char ribm;                /* Reserved for IBM use */
60c5b2
-    unsigned reserved32 : 31;
60c5b2
-    unsigned cf : 1;                   /* Continuation Flag */
60c5b2
-    unsigned char reserved64[8];
60c5b2
-    unsigned nt : 1;                   /* New Task */
60c5b2
-    unsigned reserved129 : 1;
60c5b2
-    unsigned cvt : 1;                  /* Check Value Type */
60c5b2
-    unsigned reserved131 : 1;
60c5b2
-    unsigned htt : 1;                  /* Huffman-Table Type */
60c5b2
-    unsigned bcf : 1;                  /* Block-Continuation Flag */
60c5b2
-    unsigned bcc : 1;                  /* Block Closing Control */
60c5b2
-    unsigned bhf : 1;                  /* Block Header Final */
60c5b2
-    unsigned reserved136 : 1;
60c5b2
-    unsigned reserved137 : 1;
60c5b2
-    unsigned dhtgc : 1;                /* DHT Generation Control */
60c5b2
-    unsigned reserved139 : 5;
60c5b2
-    unsigned reserved144 : 5;
60c5b2
-    unsigned sbb : 3;                  /* Sub-Byte Boundary */
60c5b2
-    unsigned char oesc;                /* Operation-Ending-Supplemental Code */
60c5b2
-    unsigned reserved160 : 12;
60c5b2
-    unsigned ifs : 4;                  /* Incomplete-Function Status */
60c5b2
-    unsigned short ifl;                /* Incomplete-Function Length */
60c5b2
-    unsigned char reserved192[8];
60c5b2
-    unsigned char reserved256[8];
60c5b2
-    unsigned char reserved320[4];
60c5b2
-    unsigned short hl;                 /* History Length */
60c5b2
-    unsigned reserved368 : 1;
60c5b2
-    unsigned short ho : 15;            /* History Offset */
60c5b2
-    unsigned int cv;                   /* Check Value */
60c5b2
-    unsigned eobs : 15;                /* End-of-block Symbol */
60c5b2
-    unsigned reserved431 : 1;
60c5b2
-    unsigned char eobl : 4;            /* End-of-block Length */
60c5b2
-    unsigned reserved436 : 12;
60c5b2
-    unsigned reserved448 : 4;
60c5b2
-    unsigned short cdhtl : 12;         /* Compressed-Dynamic-Huffman Table
60c5b2
-                                          Length */
60c5b2
-    unsigned char reserved464[6];
60c5b2
-    unsigned char cdht[288];
60c5b2
-    unsigned char reserved[32];
60c5b2
-    unsigned char csb[1152];
60c5b2
+  unsigned short pbvn;               /* Parameter-Block-Version Number */
60c5b2
+  unsigned char mvn;                 /* Model-Version Number */
60c5b2
+  unsigned char ribm;                /* Reserved for IBM use */
60c5b2
+  unsigned reserved32 : 31;
60c5b2
+  unsigned cf : 1;                   /* Continuation Flag */
60c5b2
+  unsigned char reserved64[8];
60c5b2
+  unsigned nt : 1;                   /* New Task */
60c5b2
+  unsigned reserved129 : 1;
60c5b2
+  unsigned cvt : 1;                  /* Check Value Type */
60c5b2
+  unsigned reserved131 : 1;
60c5b2
+  unsigned htt : 1;                  /* Huffman-Table Type */
60c5b2
+  unsigned bcf : 1;                  /* Block-Continuation Flag */
60c5b2
+  unsigned bcc : 1;                  /* Block Closing Control */
60c5b2
+  unsigned bhf : 1;                  /* Block Header Final */
60c5b2
+  unsigned reserved136 : 1;
60c5b2
+  unsigned reserved137 : 1;
60c5b2
+  unsigned dhtgc : 1;                /* DHT Generation Control */
60c5b2
+  unsigned reserved139 : 5;
60c5b2
+  unsigned reserved144 : 5;
60c5b2
+  unsigned sbb : 3;                  /* Sub-Byte Boundary */
60c5b2
+  unsigned char oesc;                /* Operation-Ending-Supplemental Code */
60c5b2
+  unsigned reserved160 : 12;
60c5b2
+  unsigned ifs : 4;                  /* Incomplete-Function Status */
60c5b2
+  unsigned short ifl;                /* Incomplete-Function Length */
60c5b2
+  unsigned char reserved192[8];
60c5b2
+  unsigned char reserved256[8];
60c5b2
+  unsigned char reserved320[4];
60c5b2
+  unsigned short hl;                 /* History Length */
60c5b2
+  unsigned reserved368 : 1;
60c5b2
+  unsigned short ho : 15;            /* History Offset */
60c5b2
+  unsigned int cv;                   /* Check Value */
60c5b2
+  unsigned eobs : 15;                /* End-of-block Symbol */
60c5b2
+  unsigned reserved431 : 1;
60c5b2
+  unsigned char eobl : 4;            /* End-of-block Length */
60c5b2
+  unsigned reserved436 : 12;
60c5b2
+  unsigned reserved448 : 4;
60c5b2
+  unsigned short cdhtl : 12;         /* Compressed-Dynamic-Huffman Table
60c5b2
+                                        Length */
60c5b2
+  unsigned char reserved464[6];
60c5b2
+  unsigned char cdht[288];
60c5b2
+  unsigned char reserved[32];
60c5b2
+  unsigned char csb[1152];
60c5b2
 };
60c5b2
 
60c5b2
-static int is_bit_set(const char *bits, int n)
60c5b2
+union aligned_dfltcc_param_v0
60c5b2
 {
60c5b2
-    return bits[n / 8] & (1 << (7 - (n % 8)));
60c5b2
+  struct dfltcc_param_v0 param;
60c5b2
+  char alignas (8) aligned;
60c5b2
+};
60c5b2
+
60c5b2
+static int
60c5b2
+is_bit_set (const char *bits, int n)
60c5b2
+{
60c5b2
+  return bits[n / 8] & (1 << (7 - (n % 8)));
60c5b2
 }
60c5b2
 
60c5b2
-static int is_dfltcc_enabled(void)
60c5b2
+static int
60c5b2
+is_dfltcc_enabled (void)
60c5b2
 {
60c5b2
-    const char *env;
60c5b2
-    char facilities[((DFLTCC_FACILITY / 64) + 1) * 8];
60c5b2
-    register int r0 __asm__("r0");
60c5b2
+  char facilities[(DFLTCC_FACILITY / 64 + 1) * 8];
60c5b2
 
60c5b2
-    env = getenv("DFLTCC");
60c5b2
-    if (env && !strcmp(env, "0")) {
60c5b2
-        return 0;
60c5b2
-    }
60c5b2
+  char const *env = getenv ("DFLTCC");
60c5b2
+  if (env && !strcmp (env, "0"))
60c5b2
+    return 0;
60c5b2
 
60c5b2
-    r0 = sizeof(facilities) / 8;
60c5b2
-    __asm__("stfle %[facilities]\n"
60c5b2
-            : [facilities] "=Q"(facilities) : [r0] "r"(r0) : "cc", "memory");
60c5b2
-    return is_bit_set((const char *) facilities, DFLTCC_FACILITY);
60c5b2
+  register int r0 __asm__ ("r0") = sizeof facilities / 8;
60c5b2
+  __asm__ ("stfle %[facilities]\n"
60c5b2
+           : [facilities] "=Q"(facilities) : [r0] "r"(r0) : "cc", "memory");
60c5b2
+  return is_bit_set (facilities, DFLTCC_FACILITY);
60c5b2
 }
60c5b2
 
60c5b2
-static dfltcc_cc dfltcc(int fn, void *param,
60c5b2
-                        uch **op1, size_t *len1,
60c5b2
-                        const uch **op2, size_t *len2,
60c5b2
-                        void *hist)
60c5b2
+static dfltcc_cc
60c5b2
+dfltcc (int fn, void *param,
60c5b2
+        uch **op1, size_t *len1,
60c5b2
+        uch const **op2, size_t *len2,
60c5b2
+        void *hist)
60c5b2
 {
60c5b2
-    uch *t2 = op1 ? *op1 : NULL;
60c5b2
-    size_t t3 = len1 ? *len1 : 0;
60c5b2
-    const uch *t4 = op2 ? *op2 : NULL;
60c5b2
-    size_t t5 = len2 ? *len2 : 0;
60c5b2
-    register int r0 __asm__("r0") = fn;
60c5b2
-    register void *r1 __asm__("r1") = param;
60c5b2
-    register uch *r2 __asm__("r2") = t2;
60c5b2
-    register size_t r3 __asm__("r3") = t3;
60c5b2
-    register const uch *r4 __asm__("r4") = t4;
60c5b2
-    register size_t r5 __asm__("r5") = t5;
60c5b2
-    int cc;
60c5b2
-
60c5b2
-    __asm__ volatile(
60c5b2
+  uch *t2 = op1 ? *op1 : NULL;
60c5b2
+  size_t t3 = len1 ? *len1 : 0;
60c5b2
+  const uch *t4 = op2 ? *op2 : NULL;
60c5b2
+  size_t t5 = len2 ? *len2 : 0;
60c5b2
+  register int r0 __asm__ ("r0") = fn;
60c5b2
+  register void *r1 __asm__ ("r1") = param;
60c5b2
+  register uch *r2 __asm__ ("r2") = t2;
60c5b2
+  register size_t r3 __asm__ ("r3") = t3;
60c5b2
+  register const uch *r4 __asm__ ("r4") = t4;
60c5b2
+  register size_t r5 __asm__ ("r5") = t5;
60c5b2
+  int cc;
60c5b2
+
60c5b2
+  __asm__ volatile (
60c5b2
 #ifdef DFLTCC_USDT
60c5b2
-                     STAP_PROBE_ASM(zlib, dfltcc_entry,
60c5b2
-                                    STAP_PROBE_ASM_TEMPLATE(5))
60c5b2
+                    STAP_PROBE_ASM (zlib, dfltcc_entry,
60c5b2
+                                    STAP_PROBE_ASM_TEMPLATE (5))
60c5b2
 #endif
60c5b2
-                     ".insn rrf,0xb9390000,%[r2],%[r4],%[hist],0\n"
60c5b2
+                    ".insn rrf,0xb9390000,%[r2],%[r4],%[hist],0\n"
60c5b2
 #ifdef DFLTCC_USDT
60c5b2
-                     STAP_PROBE_ASM(zlib, dfltcc_exit,
60c5b2
-                                    STAP_PROBE_ASM_TEMPLATE(5))
60c5b2
+                    STAP_PROBE_ASM (zlib, dfltcc_exit,
60c5b2
+                                    STAP_PROBE_ASM_TEMPLATE (5))
60c5b2
 #endif
60c5b2
-                     "ipm %[cc]\n"
60c5b2
-                     : [r2] "+r" (r2)
60c5b2
-                     , [r3] "+r" (r3)
60c5b2
-                     , [r4] "+r" (r4)
60c5b2
-                     , [r5] "+r" (r5)
60c5b2
-                     , [cc] "=r" (cc)
60c5b2
-                     : [r0] "r" (r0)
60c5b2
-                     , [r1] "r" (r1)
60c5b2
-                     , [hist] "r" (hist)
60c5b2
+                    "ipm %[cc]\n"
60c5b2
+                    : [r2] "+r" (r2)
60c5b2
+                      , [r3] "+r" (r3)
60c5b2
+                      , [r4] "+r" (r4)
60c5b2
+                      , [r5] "+r" (r5)
60c5b2
+                      , [cc] "=r" (cc)
60c5b2
+                    : [r0] "r" (r0)
60c5b2
+                      , [r1] "r" (r1)
60c5b2
+                      , [hist] "r" (hist)
60c5b2
 #ifdef DFLTCC_USDT
60c5b2
-                     , STAP_PROBE_ASM_OPERANDS(5, r2, r3, r4, r5, hist)
60c5b2
+                      , STAP_PROBE_ASM_OPERANDS (5, r2, r3, r4, r5, hist)
60c5b2
 #endif
60c5b2
-                     : "cc", "memory");
60c5b2
-    t2 = r2; t3 = r3; t4 = r4; t5 = r5;
60c5b2
-
60c5b2
-    if (op1)
60c5b2
-        *op1 = t2;
60c5b2
-    if (len1)
60c5b2
-        *len1 = t3;
60c5b2
-    if (op2)
60c5b2
-        *op2 = t4;
60c5b2
-    if (len2)
60c5b2
-        *len2 = t5;
60c5b2
-    return (cc >> 28) & 3;
60c5b2
+                    : "cc", "memory");
60c5b2
+  t2 = r2; t3 = r3; t4 = r4; t5 = r5;
60c5b2
+
60c5b2
+  if (op1)
60c5b2
+    *op1 = t2;
60c5b2
+  if (len1)
60c5b2
+    *len1 = t3;
60c5b2
+  if (op2)
60c5b2
+    *op2 = t4;
60c5b2
+  if (len2)
60c5b2
+    *len2 = t5;
60c5b2
+  return (cc >> 28) & 3;
60c5b2
 }
60c5b2
 
60c5b2
-static void dfltcc_qaf(struct dfltcc_qaf_param *param)
60c5b2
+static void
60c5b2
+dfltcc_qaf (struct dfltcc_qaf_param *param)
60c5b2
 {
60c5b2
-    dfltcc(DFLTCC_QAF, param, NULL, NULL, NULL, NULL, NULL);
60c5b2
+  dfltcc (DFLTCC_QAF, param, NULL, NULL, NULL, NULL, NULL);
60c5b2
 }
60c5b2
 
60c5b2
-static void dfltcc_gdht(struct dfltcc_param_v0 *param)
60c5b2
+static void
60c5b2
+dfltcc_gdht (struct dfltcc_param_v0 *param)
60c5b2
 {
60c5b2
-    const uch *next_in = inbuf + inptr;
60c5b2
-    size_t avail_in = insize - inptr;
60c5b2
+  const uch *next_in = inbuf + inptr;
60c5b2
+  size_t avail_in = insize - inptr;
60c5b2
 
60c5b2
-    dfltcc(DFLTCC_GDHT, param, NULL, NULL, &next_in, &avail_in, NULL);
60c5b2
+  dfltcc (DFLTCC_GDHT, param, NULL, NULL, &next_in, &avail_in, NULL);
60c5b2
 }
60c5b2
 
60c5b2
 static off_t total_in;
60c5b2
 
60c5b2
-static dfltcc_cc dfltcc_cmpr_xpnd(struct dfltcc_param_v0 *param, int fn)
60c5b2
+static dfltcc_cc
60c5b2
+dfltcc_cmpr_xpnd (struct dfltcc_param_v0 *param, int fn)
60c5b2
 {
60c5b2
-    uch *next_out = outbuf + outcnt;
60c5b2
-    size_t avail_out = OUTBUFSIZ - outcnt;
60c5b2
-    const uch *next_in = inbuf + inptr;
60c5b2
-    size_t avail_in = insize - inptr;
60c5b2
-    off_t consumed_in;
60c5b2
-    dfltcc_cc cc;
60c5b2
-
60c5b2
-    cc = dfltcc(fn | HBT_CIRCULAR, param,
60c5b2
-                &next_out, &avail_out,
60c5b2
-                &next_in, &avail_in,
60c5b2
-                window);
60c5b2
-    consumed_in = next_in - (inbuf + inptr);
60c5b2
-    inptr += consumed_in;
60c5b2
-    total_in += consumed_in;
60c5b2
-    outcnt += ((OUTBUFSIZ - outcnt) - avail_out);
60c5b2
-    return cc;
60c5b2
+  uch *next_out = outbuf + outcnt;
60c5b2
+  size_t avail_out = OUTBUFSIZ - outcnt;
60c5b2
+  const uch *next_in = inbuf + inptr;
60c5b2
+  size_t avail_in = insize - inptr;
60c5b2
+  dfltcc_cc cc = dfltcc (fn | HBT_CIRCULAR, param,
60c5b2
+                         &next_out, &avail_out,
60c5b2
+                         &next_in, &avail_in,
60c5b2
+                         window);
60c5b2
+  off_t consumed_in = next_in - (inbuf + inptr);
60c5b2
+  inptr += consumed_in;
60c5b2
+  total_in += consumed_in;
60c5b2
+  outcnt += ((OUTBUFSIZ - outcnt) - avail_out);
60c5b2
+  return cc;
60c5b2
 }
60c5b2
 
60c5b2
-__attribute__((aligned(8)))
60c5b2
-static struct context
60c5b2
+static struct dfltcc_param_v0 *
60c5b2
+init_param (union aligned_dfltcc_param_v0 *ctx)
60c5b2
 {
60c5b2
-    union
60c5b2
-    {
60c5b2
-        struct dfltcc_qaf_param af;
60c5b2
-        struct dfltcc_param_v0 param;
60c5b2
-    };
60c5b2
-} ctx;
60c5b2
-
60c5b2
-static struct dfltcc_param_v0 *init_param(struct dfltcc_param_v0 *param)
60c5b2
-{
60c5b2
-    const char *s;
60c5b2
-
60c5b2
-    memset(param, 0, sizeof(*param));
60c5b2
-#ifndef DFLTCC_RIBM
60c5b2
-#define DFLTCC_RIBM 0
60c5b2
-#endif
60c5b2
-    s = getenv("DFLTCC_RIBM");
60c5b2
-    param->ribm = (s && *s) ? strtoul(s, NULL, 0) : DFLTCC_RIBM;
60c5b2
-    param->nt = 1;
60c5b2
-    param->cvt = CVT_CRC32;
60c5b2
-    param->cv = __builtin_bswap32(getcrc());
60c5b2
-    return param;
60c5b2
+  char const *s = getenv ("DFLTCC_RIBM");
60c5b2
+  struct dfltcc_param_v0 *param = &ctx->param;
60c5b2
+  memset (param, 0, sizeof *param);
60c5b2
+  param->ribm = s && *s ? strtoul (s, NULL, 0) : DFLTCC_RIBM;
60c5b2
+  param->nt = 1;
60c5b2
+  param->cvt = CVT_CRC32;
60c5b2
+  param->cv = __builtin_bswap32 (getcrc ());
60c5b2
+  return param;
60c5b2
 }
60c5b2
 
60c5b2
-static void bi_close_block(struct dfltcc_param_v0 *param)
60c5b2
+static void
60c5b2
+bi_close_block (struct dfltcc_param_v0 *param)
60c5b2
 {
60c5b2
-    bi_valid = param->sbb;
60c5b2
-    bi_buf = bi_valid == 0 ? 0 : outbuf[outcnt] & ((1 << bi_valid) - 1);
60c5b2
-    send_bits(
60c5b2
-        bi_reverse(param->eobs >> (15 - param->eobl), param->eobl),
60c5b2
-        param->eobl);
60c5b2
-    param->bcf = 0;
60c5b2
+  bi_valid = param->sbb;
60c5b2
+  bi_buf = bi_valid == 0 ? 0 : outbuf[outcnt] & ((1 << bi_valid) - 1);
60c5b2
+  send_bits (bi_reverse (param->eobs >> (15 - param->eobl), param->eobl),
60c5b2
+             param->eobl);
60c5b2
+  param->bcf = 0;
60c5b2
 }
60c5b2
 
60c5b2
-static void close_block(struct dfltcc_param_v0 *param)
60c5b2
+static void
60c5b2
+close_block (struct dfltcc_param_v0 *param)
60c5b2
 {
60c5b2
-    bi_close_block(param);
60c5b2
-    bi_windup();
60c5b2
-    param->sbb = (param->sbb + param->eobl) % 8;
60c5b2
-    if (param->sbb != 0) {
60c5b2
-        Assert(outcnt > 0, "outbuf must have enough space for EOBS");
60c5b2
-        outcnt--;
60c5b2
+  bi_close_block (param);
60c5b2
+  bi_windup ();
60c5b2
+  param->sbb = (param->sbb + param->eobl) % 8;
60c5b2
+  if (param->sbb != 0)
60c5b2
+    {
60c5b2
+      Assert (outcnt > 0, "outbuf must have enough space for EOBS");
60c5b2
+      outcnt--;
60c5b2
     }
60c5b2
 }
60c5b2
 
60c5b2
-static void close_stream(struct dfltcc_param_v0 *param)
60c5b2
+static void
60c5b2
+close_stream (struct dfltcc_param_v0 *param)
60c5b2
 {
60c5b2
-    if (param->bcf) {
60c5b2
-        bi_close_block(param);
60c5b2
-    }
60c5b2
-    send_bits(1, 3); /* BFINAL=1, BTYPE=00 */
60c5b2
-    bi_windup();
60c5b2
-    put_short(0x0000);
60c5b2
-    put_short(0xFFFF);
60c5b2
+  if (param->bcf)
60c5b2
+    bi_close_block (param);
60c5b2
+  send_bits (1, 3); /* BFINAL=1, BTYPE=00 */
60c5b2
+  bi_windup ();
60c5b2
+  put_short (0x0000);
60c5b2
+  put_short (0xFFFF);
60c5b2
 }
60c5b2
 
60c5b2
-#define MAX(a, b) ((a) > (b) ? (a) : (b))
60c5b2
+/* Compress ifd into ofd in hardware or fall back to software.  */
60c5b2
 
60c5b2
-/* ===========================================================================
60c5b2
- * Compress ifd into ofd in hardware or fall back to software.
60c5b2
- */
60c5b2
-int dfltcc_deflate(int pack_level)
60c5b2
+int
60c5b2
+dfltcc_deflate (int pack_level)
60c5b2
 {
60c5b2
-    const char *s;
60c5b2
-    unsigned long level_mask;
60c5b2
-    unsigned long block_size;
60c5b2
-    off_t block_threshold;
60c5b2
-    struct dfltcc_param_v0 *param;
60c5b2
-    int extra;
60c5b2
-
60c5b2
-    /* Check whether we can use hardware compression */
60c5b2
-    if (!is_dfltcc_enabled() || getenv("SOURCE_DATE_EPOCH")) {
60c5b2
-        return deflate(pack_level);
60c5b2
-    }
60c5b2
-#ifndef DFLTCC_LEVEL_MASK
60c5b2
-#define DFLTCC_LEVEL_MASK 0x2
60c5b2
-#endif
60c5b2
-    s = getenv("DFLTCC_LEVEL_MASK");
60c5b2
-    level_mask = (s && *s) ? strtoul(s, NULL, 0) : DFLTCC_LEVEL_MASK;
60c5b2
-    if ((level_mask & (1 << pack_level)) == 0) {
60c5b2
-        return deflate(pack_level);
60c5b2
-    }
60c5b2
-    dfltcc_qaf(&ctx.af);
60c5b2
-    if (!is_bit_set(ctx.af.fns, DFLTCC_CMPR) ||
60c5b2
-        !is_bit_set(ctx.af.fns, DFLTCC_GDHT) ||
60c5b2
-        !is_bit_set(ctx.af.fmts, DFLTCC_FMT0)) {
60c5b2
-        return deflate(pack_level);
60c5b2
-    }
60c5b2
-
60c5b2
-    /* Initialize tuning parameters */
60c5b2
-#ifndef DFLTCC_BLOCK_SIZE
60c5b2
-#define DFLTCC_BLOCK_SIZE 1048576
60c5b2
-#endif
60c5b2
-    s = getenv("DFLTCC_BLOCK_SIZE");
60c5b2
-    block_size = (s && *s) ? strtoul(s, NULL, 0) : DFLTCC_BLOCK_SIZE;
60c5b2
-    (void)block_size;
60c5b2
-#ifndef DFLTCC_FIRST_FHT_BLOCK_SIZE
60c5b2
-#define DFLTCC_FIRST_FHT_BLOCK_SIZE 4096
60c5b2
-#endif
60c5b2
-    s = getenv("DFLTCC_FIRST_FHT_BLOCK_SIZE");
60c5b2
-    block_threshold = (s && *s) ? strtoul(s, NULL, 0) :
60c5b2
-                                  DFLTCC_FIRST_FHT_BLOCK_SIZE;
60c5b2
-
60c5b2
-    /* Compress ifd into ofd in a loop */
60c5b2
-    param = init_param(&ctx.param);
60c5b2
-    while (1) {
60c5b2
-        /* Flush the output data */
60c5b2
-        if (outcnt > OUTBUFSIZ - 8) {
60c5b2
-            flush_outbuf();
60c5b2
-        }
60c5b2
-
60c5b2
-        /* Close the block */
60c5b2
-        if (param->bcf && total_in == block_threshold && !param->cf) {
60c5b2
-            close_block(param);
60c5b2
-            block_threshold += block_size;
60c5b2
+  /* Check whether we can use hardware compression.  */
60c5b2
+  if (!is_dfltcc_enabled () || getenv ("SOURCE_DATE_EPOCH"))
60c5b2
+    return deflate (pack_level);
60c5b2
+  char const *s = getenv ("DFLTCC_LEVEL_MASK");
60c5b2
+  unsigned long level_mask
60c5b2
+    = s && *s ? strtoul (s, NULL, 0) : DFLTCC_LEVEL_MASK;
60c5b2
+  if ((level_mask & (1 << pack_level)) == 0)
60c5b2
+    return deflate (pack_level);
60c5b2
+  union aligned_dfltcc_qaf_param ctx;
60c5b2
+  dfltcc_qaf (&ctx.af);
60c5b2
+  if (!is_bit_set (ctx.af.fns, DFLTCC_CMPR)
60c5b2
+      || !is_bit_set (ctx.af.fns, DFLTCC_GDHT)
60c5b2
+      || !is_bit_set (ctx.af.fmts, DFLTCC_FMT0))
60c5b2
+    return deflate (pack_level);
60c5b2
+
60c5b2
+  /* Initialize tuning parameters.  */
60c5b2
+  s = getenv ("DFLTCC_BLOCK_SIZE");
60c5b2
+  unsigned long block_size
60c5b2
+    = s && *s ? strtoul (s, NULL, 0) : DFLTCC_BLOCK_SIZE;
60c5b2
+
60c5b2
+  s = getenv ("DFLTCC_FIRST_FHT_BLOCK_SIZE");
60c5b2
+  off_t block_threshold
60c5b2
+    = s && *s ? strtoul (s, NULL, 0) : DFLTCC_FIRST_FHT_BLOCK_SIZE;
60c5b2
+
60c5b2
+  union aligned_dfltcc_param_v0 ctx_v0;
60c5b2
+  struct dfltcc_param_v0 *param = init_param (&ctx_v0);
60c5b2
+
60c5b2
+  /* Compress ifd into ofd in a loop.  */
60c5b2
+  while (true)
60c5b2
+    {
60c5b2
+      /* Flush the output data.  */
60c5b2
+      if (outcnt > OUTBUFSIZ - 8)
60c5b2
+        flush_outbuf ();
60c5b2
+
60c5b2
+      /* Close the block.  */
60c5b2
+      if (param->bcf && total_in == block_threshold && !param->cf)
60c5b2
+        {
60c5b2
+          close_block (param);
60c5b2
+          block_threshold += block_size;
60c5b2
         }
60c5b2
 
60c5b2
-        /* Read the input data */
60c5b2
-        if (inptr == insize) {
60c5b2
-            if (fill_inbuf(1) == EOF && !param->cf) {
60c5b2
-                break;
60c5b2
-            }
60c5b2
-            inptr = 0;
60c5b2
+      /* Read the input data.  */
60c5b2
+      if (inptr == insize)
60c5b2
+        {
60c5b2
+          if (fill_inbuf (1) == EOF && !param->cf)
60c5b2
+            break;
60c5b2
+          inptr = 0;
60c5b2
         }
60c5b2
 
60c5b2
-        /* Temporarily mask some input data */
60c5b2
-        extra = MAX(0, total_in + (insize - inptr) - block_threshold);
60c5b2
-        insize -= extra;
60c5b2
-
60c5b2
-        /* Start a new block */
60c5b2
-        if (!param->bcf) {
60c5b2
-            if (total_in == 0 && block_threshold > 0) {
60c5b2
-                param->htt = HTT_FIXED;
60c5b2
-            } else {
60c5b2
-                param->htt = HTT_DYNAMIC;
60c5b2
-                dfltcc_gdht(param);
60c5b2
-            }
60c5b2
+      /* Temporarily mask some input data.  */
60c5b2
+      int extra = MAX (0, total_in + (insize - inptr) - block_threshold);
60c5b2
+      insize -= extra;
60c5b2
+
60c5b2
+      /* Start a new block.  */
60c5b2
+      if (!param->bcf)
60c5b2
+        {
60c5b2
+          if (total_in == 0 && block_threshold > 0)
60c5b2
+            param->htt = HTT_FIXED;
60c5b2
+          else {
60c5b2
+            param->htt = HTT_DYNAMIC;
60c5b2
+            dfltcc_gdht (param);
60c5b2
+          }
60c5b2
         }
60c5b2
 
60c5b2
-        /* Compress inbuf into outbuf */
60c5b2
-        dfltcc_cmpr_xpnd(param, DFLTCC_CMPR);
60c5b2
+      /* Compress inbuf into outbuf.  */
60c5b2
+      dfltcc_cmpr_xpnd (param, DFLTCC_CMPR);
60c5b2
 
60c5b2
-        /* Unmask the input data */
60c5b2
-        insize += extra;
60c5b2
+      /* Unmask the input data.  */
60c5b2
+      insize += extra;
60c5b2
 
60c5b2
-        /* Continue the block */
60c5b2
-        param->bcf = 1;
60c5b2
+      /* Continue the block */
60c5b2
+      param->bcf = 1;
60c5b2
     }
60c5b2
-    close_stream(param);
60c5b2
-    setcrc(__builtin_bswap32(param->cv));
60c5b2
-    return 0;
60c5b2
+
60c5b2
+  close_stream (param);
60c5b2
+  setcrc (__builtin_bswap32 (param->cv));
60c5b2
+  return 0;
60c5b2
 }
60c5b2
 
60c5b2
-/* ===========================================================================
60c5b2
- * Decompress ifd into ofd in hardware or fall back to software.
60c5b2
- */
60c5b2
-int dfltcc_inflate(void)
60c5b2
+/* Decompress ifd into ofd in hardware or fall back to software.  */
60c5b2
+int
60c5b2
+dfltcc_inflate (void)
60c5b2
 {
60c5b2
-    struct dfltcc_param_v0 *param;
60c5b2
-    dfltcc_cc cc;
60c5b2
-
60c5b2
-    /* Check whether we can use hardware decompression */
60c5b2
-    if (!is_dfltcc_enabled()) {
60c5b2
-        return inflate();
60c5b2
-    }
60c5b2
-    dfltcc_qaf(&ctx.af);
60c5b2
-    if (!is_bit_set(ctx.af.fns, DFLTCC_XPND)) {
60c5b2
-        return inflate();
60c5b2
-    }
60c5b2
-
60c5b2
-    /* Decompress ifd into ofd in a loop */
60c5b2
-    param = init_param(&ctx.param);
60c5b2
-    while (1) {
60c5b2
-        /* Perform I/O */
60c5b2
-        if (outcnt == OUTBUFSIZ) {
60c5b2
-            flush_outbuf();
60c5b2
-        }
60c5b2
-        if (inptr == insize) {
60c5b2
-            if (fill_inbuf(1) == EOF) {
60c5b2
-                /* Premature EOF */
60c5b2
-                return 2;
60c5b2
+  /* Check whether we can use hardware decompression.  */
60c5b2
+  if (!is_dfltcc_enabled ())
60c5b2
+    return inflate ();
60c5b2
+  union aligned_dfltcc_qaf_param ctx;
60c5b2
+  dfltcc_qaf (&ctx.af);
60c5b2
+  if (!is_bit_set (ctx.af.fns, DFLTCC_XPND))
60c5b2
+    return inflate ();
60c5b2
+
60c5b2
+  union aligned_dfltcc_param_v0 ctx_v0;
60c5b2
+  struct dfltcc_param_v0 *param = init_param (&ctx_v0);
60c5b2
+
60c5b2
+  /* Decompress ifd into ofd in a loop.  */
60c5b2
+  while (true)
60c5b2
+    {
60c5b2
+      /* Perform I/O.  */
60c5b2
+      if (outcnt == OUTBUFSIZ)
60c5b2
+        flush_outbuf ();
60c5b2
+      if (inptr == insize)
60c5b2
+        {
60c5b2
+          if (fill_inbuf (1) == EOF)
60c5b2
+            {
60c5b2
+              /* Premature EOF.  */
60c5b2
+              return 2;
60c5b2
             }
60c5b2
-            inptr = 0;
60c5b2
+          inptr = 0;
60c5b2
         }
60c5b2
-        /* Decompress inbuf into outbuf */
60c5b2
-        cc = dfltcc_cmpr_xpnd(param, DFLTCC_XPND);
60c5b2
-        if (cc == DFLTCC_CC_OK) {
60c5b2
-            /* The entire deflate stream has been successfully decompressed */
60c5b2
+
60c5b2
+        /* Decompress inbuf into outbuf.  */
60c5b2
+        dfltcc_cc cc = dfltcc_cmpr_xpnd (param, DFLTCC_XPND);
60c5b2
+        if (cc == DFLTCC_CC_OK)
60c5b2
+          {
60c5b2
+            /* The entire deflate stream has been successfully decompressed.  */
60c5b2
             break;
60c5b2
-        }
60c5b2
-        if (cc == DFLTCC_CC_OP2_CORRUPT && param->oesc != 0) {
60c5b2
-            /* The deflate stream is corrupted */
60c5b2
+          }
60c5b2
+        if (cc == DFLTCC_CC_OP2_CORRUPT && param->oesc != 0)
60c5b2
+          {
60c5b2
+            /* The deflate stream is corrupted.  */
60c5b2
             return 2;
60c5b2
-        }
60c5b2
-        /* There must be more data to decompress */
60c5b2
+          }
60c5b2
+        /* There must be more data to decompress.  */
60c5b2
     }
60c5b2
-    if (param->sbb != 0) {
60c5b2
-        /* The deflate stream has ended in the middle of a byte - go to the next
60c5b2
-         * byte boundary, so that unzip() can read CRC and length.
60c5b2
-         */
60c5b2
-        inptr++;
60c5b2
+
60c5b2
+  if (param->sbb != 0)
60c5b2
+    {
60c5b2
+      /* The deflate stream has ended in the middle of a byte.  Go to
60c5b2
+        the next byte boundary, so that unzip can read CRC and length.  */
60c5b2
+      inptr++;
60c5b2
     }
60c5b2
-    setcrc(__builtin_bswap32(param->cv)); /* set CRC value for unzip() */
60c5b2
-    flush_outbuf(); /* update bytes_out for unzip() */
60c5b2
-    return 0;
60c5b2
+
60c5b2
+  /* Set CRC value and update bytes_out for unzip.  */
60c5b2
+  setcrc (__builtin_bswap32 (param->cv));
60c5b2
+  flush_outbuf ();
60c5b2
+  return 0;
60c5b2
 }
60c5b2
diff --git a/gzip.c b/gzip.c
60c5b2
index 4fffc4f..f29edaf 100644
60c5b2
--- a/gzip.c
60c5b2
+++ b/gzip.c
60c5b2
@@ -58,6 +58,7 @@ static char const *const license_msg[] = {
60c5b2
 #include <ctype.h>
60c5b2
 #include <sys/types.h>
60c5b2
 #include <signal.h>
60c5b2
+#include <stdalign.h>
60c5b2
 #include <stdbool.h>
60c5b2
 #include <stddef.h>
60c5b2
 #include <sys/stat.h>
60c5b2
@@ -128,22 +129,20 @@ static char const *const license_msg[] = {
60c5b2
 
60c5b2
                 /* global buffers */
60c5b2
 
60c5b2
-#ifdef IBM_Z_DFLTCC
60c5b2
-/* DEFLATE COMPRESSION CALL works faster with page-aligned input buffers */
60c5b2
-__attribute__((aligned(4096)))
60c5b2
-#endif
60c5b2
-DECLARE(uch, inbuf,  INBUFSIZ +INBUF_EXTRA);
60c5b2
-#ifdef IBM_Z_DFLTCC
60c5b2
-/* DEFLATE COMPRESSION CALL works faster with page-aligned output buffers */
60c5b2
-__attribute__((aligned(4096)))
60c5b2
+/* With IBM_Z_DFLTCC, DEFLATE COMPRESSION works faster with
60c5b2
+   page-aligned input and output buffers, and requires page-aligned
60c5b2
+   windows; the alignment requirement is 4096.  On other platforms
60c5b2
+   alignment doesn't hurt, and alignment up to 8192 is portable so
60c5b2
+   let's do that.  */
60c5b2
+#ifdef __alignas_is_defined
60c5b2
+# define BUFFER_ALIGNED alignas (8192)
60c5b2
+#else
60c5b2
+# define BUFFER_ALIGNED /**/
60c5b2
 #endif
60c5b2
-DECLARE(uch, outbuf, OUTBUFSIZ+OUTBUF_EXTRA);
60c5b2
+DECLARE(uch BUFFER_ALIGNED, inbuf,  INBUFSIZ +INBUF_EXTRA);
60c5b2
+DECLARE(uch BUFFER_ALIGNED, outbuf, OUTBUFSIZ+OUTBUF_EXTRA);
60c5b2
 DECLARE(ush, d_buf,  DIST_BUFSIZE);
60c5b2
-#ifdef IBM_Z_DFLTCC
60c5b2
-/* DEFLATE COMPRESSION CALL works only with page-aligned windows */
60c5b2
-__attribute__((aligned(4096)))
60c5b2
-#endif
60c5b2
-DECLARE(uch, window, 2L*WSIZE);
60c5b2
+DECLARE(uch BUFFER_ALIGNED, window, 2L*WSIZE);
60c5b2
 #ifndef MAXSEG_64K
60c5b2
     DECLARE(ush, tab_prefix, 1L<
60c5b2
 #else
60c5b2
diff --git a/gzip.h b/gzip.h
60c5b2
index 0c59cc2..9a2babd 100644
60c5b2
--- a/gzip.h
60c5b2
+++ b/gzip.h
60c5b2
@@ -74,25 +74,19 @@ extern int method;         /* compression method */
60c5b2
  */
60c5b2
 
60c5b2
 #ifndef	INBUFSIZ
60c5b2
-#  ifdef IBM_Z_DFLTCC
60c5b2
-/* DEFLATE COMPRESSION CALL works faster with larger input buffers */
60c5b2
-#    define INBUFSIZ  0x40000
60c5b2
-#  elif defined SMALL_MEM
60c5b2
+#  ifdef SMALL_MEM
60c5b2
 #    define INBUFSIZ  0x2000  /* input buffer size */
60c5b2
 #  else
60c5b2
-#    define INBUFSIZ  0x8000  /* input buffer size */
60c5b2
+#    define INBUFSIZ  0x40000 /* input buffer size */
60c5b2
 #  endif
60c5b2
 #endif
60c5b2
 #define INBUF_EXTRA  64     /* required by unlzw() */
60c5b2
 
60c5b2
 #ifndef	OUTBUFSIZ
60c5b2
-#  ifdef IBM_Z_DFLTCC
60c5b2
-/* DEFLATE COMPRESSION CALL works faster with larger output buffers */
60c5b2
-#    define OUTBUFSIZ   0x40000
60c5b2
-#  elif defined SMALL_MEM
60c5b2
+#  ifdef SMALL_MEM
60c5b2
 #    define OUTBUFSIZ   8192  /* output buffer size */
60c5b2
 #  else
60c5b2
-#    define OUTBUFSIZ  16384  /* output buffer size */
60c5b2
+#    define OUTBUFSIZ 0x40000 /* output buffer size */
60c5b2
 #  endif
60c5b2
 #endif
60c5b2
 #define OUTBUF_EXTRA 2048   /* required by unlzw() */
60c5b2
@@ -291,7 +285,7 @@ extern off_t flush_block (char *buf, ulg stored_len, int pad, int eof);
60c5b2
 
60c5b2
         /* in bits.c */
60c5b2
 extern unsigned short bi_buf;
60c5b2
-extern int            bi_valid;
60c5b2
+extern int bi_valid;
60c5b2
 extern void     bi_init    (file_t zipfile);
60c5b2
 extern void     send_bits  (int value, int length);
60c5b2
 extern unsigned bi_reverse (unsigned value, int length) _GL_ATTRIBUTE_CONST;
60c5b2
diff --git a/unzip.c b/unzip.c
60c5b2
index 86ef664..6d9bf68 100644
60c5b2
--- a/unzip.c
60c5b2
+++ b/unzip.c
60c5b2
@@ -130,7 +130,7 @@ int unzip(in, out)
60c5b2
     if (method == DEFLATED)  {
60c5b2
 
60c5b2
 #ifdef IBM_Z_DFLTCC
60c5b2
-        int res = dfltcc_inflate();
60c5b2
+        int res = dfltcc_inflate ();
60c5b2
 #else
60c5b2
         int res = inflate();
60c5b2
 #endif
60c5b2
diff --git a/util.c b/util.c
60c5b2
index dc00f4a..dc66b20 100644
60c5b2
--- a/util.c
60c5b2
+++ b/util.c
60c5b2
@@ -96,10 +96,8 @@ static const ulg crc_32_tab[] = {
60c5b2
   0x2d02ef8dL
60c5b2
 };
60c5b2
 
60c5b2
-/* ========================================================================
60c5b2
- * Shift register contents
60c5b2
- */
60c5b2
-static ulg crc = (ulg)0xffffffffL;
60c5b2
+/* Shift register contents.  */
60c5b2
+static ulg crc = 0xffffffffL;
60c5b2
 
60c5b2
 /* ===========================================================================
60c5b2
  * Copy input to output unchanged: zcat == cat with --force.
60c5b2
@@ -148,21 +146,18 @@ ulg updcrc(s, n)
60c5b2
     return c ^ 0xffffffffL;       /* (instead of ~c for 64-bit machines) */
60c5b2
 }
60c5b2
 
60c5b2
-/* ===========================================================================
60c5b2
- * Return a current CRC value.
60c5b2
- */
60c5b2
-ulg getcrc()
60c5b2
+/* Return a current CRC value.  */
60c5b2
+ulg
60c5b2
+getcrc (void)
60c5b2
 {
60c5b2
-    return crc ^ 0xffffffffL;
60c5b2
+  return crc ^ 0xffffffffL;
60c5b2
 }
60c5b2
 
60c5b2
-/* ===========================================================================
60c5b2
- * Set a new CRC value.
60c5b2
- */
60c5b2
-void setcrc(c)
60c5b2
-    ulg c;
60c5b2
+/* Set a new CRC value.  */
60c5b2
+void
60c5b2
+setcrc (ulg c)
60c5b2
 {
60c5b2
-    crc = c ^ 0xffffffffL;
60c5b2
+  crc = c ^ 0xffffffffL;
60c5b2
 }
60c5b2
 
60c5b2
 /* ===========================================================================
60c5b2
@@ -258,9 +253,8 @@ void flush_outbuf()
60c5b2
 {
60c5b2
     if (outcnt == 0) return;
60c5b2
 
60c5b2
-    if (!test) {
60c5b2
-        write_buf(ofd, (char *)outbuf, outcnt);
60c5b2
-    }
60c5b2
+    if (!test)
60c5b2
+      write_buf (ofd, outbuf, outcnt);
60c5b2
     bytes_out += (off_t)outcnt;
60c5b2
     outcnt = 0;
60c5b2
 }
60c5b2
diff --git a/zip.c b/zip.c
60c5b2
index ace7e5e..0f12d5e 100644
60c5b2
--- a/zip.c
60c5b2
+++ b/zip.c
60c5b2
@@ -25,9 +25,8 @@
60c5b2
 
60c5b2
 off_t header_bytes;   /* number of bytes in gzip header */
60c5b2
 
60c5b2
-#define FAST 4
60c5b2
-#define SLOW 2
60c5b2
-/* speed options for the general purpose bit flag */
60c5b2
+/* Speed options for the general purpose bit flag.  */
60c5b2
+enum { SLOW = 2, FAST = 4 };
60c5b2
 
60c5b2
 /* ===========================================================================
60c5b2
  * Deflate in to out.
60c5b2
@@ -71,15 +70,14 @@ int zip(in, out)
60c5b2
     put_long (stamp);
60c5b2
 
60c5b2
     /* Write deflated file to zip file */
60c5b2
-    updcrc(NULL, 0);
60c5b2
+    updcrc (NULL, 0);
60c5b2
 
60c5b2
     bi_init(out);
60c5b2
     ct_init(&attr, &method);
60c5b2
-    if (level == 1) {
60c5b2
-        deflate_flags |= FAST;
60c5b2
-    } else if (level == 9) {
60c5b2
-        deflate_flags |= SLOW;
60c5b2
-    }
60c5b2
+    if (level == 1)
60c5b2
+      deflate_flags |= FAST;
60c5b2
+    else if (level == 9)
60c5b2
+      deflate_flags |= SLOW;
60c5b2
 
60c5b2
     put_byte((uch)deflate_flags); /* extra flags */
60c5b2
     put_byte(OS_CODE);            /* OS identifier */
60c5b2
@@ -93,9 +91,9 @@ int zip(in, out)
60c5b2
     header_bytes = (off_t)outcnt;
60c5b2
 
60c5b2
 #ifdef IBM_Z_DFLTCC
60c5b2
-    (void)dfltcc_deflate(level);
60c5b2
+    dfltcc_deflate (level);
60c5b2
 #else
60c5b2
-    (void)deflate(level);
60c5b2
+    deflate (level);
60c5b2
 #endif
60c5b2
 
60c5b2
 #ifndef NO_SIZE_CHECK
60c5b2
@@ -109,7 +107,7 @@ int zip(in, out)
60c5b2
 #endif
60c5b2
 
60c5b2
     /* Write the crc and uncompressed size */
60c5b2
-    put_long(getcrc());
60c5b2
+    put_long (getcrc ());
60c5b2
     put_long((ulg)bytes_in);
60c5b2
     header_bytes += 2*4;
60c5b2
 
60c5b2
@@ -137,7 +135,7 @@ int file_read(buf, size)
60c5b2
         read_error();
60c5b2
     }
60c5b2
 
60c5b2
-    updcrc((uch*)buf, len);
60c5b2
+    updcrc ((uch *) buf, len);
60c5b2
     bytes_in += (off_t)len;
60c5b2
     return (int)len;
60c5b2
 }