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