Splint fiddles.
authorjbj <devnull@localhost>
Sat, 8 Mar 2003 23:18:09 +0000 (23:18 +0000)
committerjbj <devnull@localhost>
Sat, 8 Mar 2003 23:18:09 +0000 (23:18 +0000)
CVS patchset: 6665
CVS date: 2003/03/08 23:18:09

17 files changed:
zlib/.splintrc
zlib/Makefile.am
zlib/contrib/inflate86/inffast.S [new file with mode: 0644]
zlib/crc32.c
zlib/crc32.h
zlib/deflate.h
zlib/gzio.c
zlib/infback.c
zlib/inffast.c
zlib/inffast.h
zlib/inflate.c
zlib/inftrees.c
zlib/inftrees.h
zlib/trees.c
zlib/trees.h
zlib/zlib.h
zlib/zutil.h

index 1919ecf..78da9da 100644 (file)
@@ -3,7 +3,6 @@
 +partial
 +forcehints
 
-
 -warnunixlib
 -warnposix
 
 +strict                        # lclint level
 
 # --- in progress
--abstract
+-abstract              # 4
 -aliasunique
+-assignexpose
 -branchstate
--casebreak
+-bufferoverflowhigh
 -castfcnptr
--commenterror
 -compdef
 -compmempass
--dependenttrans
--evalorder
--globs
+-evalorder             # 2
 -globstate
--immediatetrans
--infloopsuncon
--internalglobs
--kepttrans
--looploopbreak
--looploopcontinue
--loopswitchbreak
 -modfilesys
--modnomods
--modobserveruncon
--moduncon
--modunconnomods
+-mods                  # 13
 -mustmod
--noeffect
--noeffectuncon         # 22
--nullderef
--nullpass
--nullret
--nullstate             # 36
--observertrans
--oldstyle
--paramuse
+-noeffectuncon         # 10
+-nullderef             # 9
+-nullpass              # 24
+-nullptrarith
+-nullret               # 13
 -protoparammatch       # 22
--readonlytrans
--redef
--retalias
+-redef                 # 4
+-retalias              # 4
 -retvalint             # painful
--sizeoftype            # 110
+-sizeoftype            # 106
+-type
+-usereleased           # 38
+
+-dependenttrans        # 2
+-immediatetrans
+-kepttrans
+-observertrans
+-readonlytrans
 -statictrans
--switchswitchbreak
 -temptrans
--type
 -unqualifiedtrans
--unsignedcompare
--usereleased
+
+-casebreak
+-looploopbreak
+-looploopcontinue
+-loopswitchbreak
+-switchswitchbreak
 -whileempty
 
 # --- +partial artifacts
index bdc0253..a140bc1 100644 (file)
@@ -17,7 +17,7 @@ libz_la_SOURCES = \
        infback.c inffast.c inflate.c inftrees.c \
        trees.c uncompr.c zutil.c
 
-noinst_PROGRAMS = example minigzip
+noinst_PROGRAMS = example minigzip ung
 
 example_SOURCES = example.c
 example_LDFLAGS = -L. -lz
@@ -25,6 +25,9 @@ example_LDFLAGS = -L. -lz
 minigzip_SOURCES = minigzip.c
 minigzip_LDFLAGS = -L. -lz
 
+ung_SOURCES = ung.c
+ung_LDFLAGS = -L. -lz
+
 #BUILT_SOURCES = Doxyfile zlib.lcd
 
 zlib.lcd: Makefile.am ${libz_la_SOURCES} ${noinst_HEADERS}
diff --git a/zlib/contrib/inflate86/inffast.S b/zlib/contrib/inflate86/inffast.S
new file mode 100644 (file)
index 0000000..d1e80ef
--- /dev/null
@@ -0,0 +1,1095 @@
+/*\r
+ * inffast.S is a hand tuned assembler version of:\r
+ *\r
+ * inffast.c -- fast decoding\r
+ * Copyright (C) 1995-2003 Mark Adler\r
+ * For conditions of distribution and use, see copyright notice in zlib.h \r
+ *\r
+ * Copyright (C) 2003 Chris Anderson <christop@charm.net>\r
+ * Please use the copyright conditions above.\r
+ * \r
+ * This version (Jan-23-2003) of inflate_fast was coded and tested under\r
+ * GNU/Linux on a pentium 3, using the gcc-3.2 compiler distribution.  On that\r
+ * machine, I found that gzip style archives decompressed about 20% faster than\r
+ * the gcc-3.2 -O3 -fomit-frame-pointer compiled version.  Your results will\r
+ * depend on how large of a buffer is used for z_stream.next_in & next_out\r
+ * (8K-32K worked best for my 256K cpu cache) and how much overhead there is in\r
+ * stream processing I/O and crc32/addler32.  In my case, this routine used\r
+ * 70% of the cpu time and crc32 used 20%.\r
+ *\r
+ * I am confident that this version will work in the general case, but I have\r
+ * not tested a wide variety of datasets or a wide variety of platforms.\r
+ *\r
+ * Jan-24-2003 -- Added -DUSE_MMX define for slightly faster inflating.\r
+ * It should be a runtime flag instead of compile time flag...\r
+ */\r
+\r
+.file "inffast.S"\r
+\r
+.globl inflate_fast\r
+\r
+.text\r
+.align 4,0\r
+.L_invalid_literal_length_code_msg:\r
+.string "invalid literal/length code"\r
+\r
+.align 4,0\r
+.L_invalid_distance_code_msg:\r
+.string "invalid distance code"\r
+\r
+.align 4,0\r
+.L_invalid_distance_too_far_msg:\r
+.string "invalid distance too far back"\r
+\r
+#if defined( USE_MMX )\r
+.align 4,0\r
+.L_mask: /* mask[N] = ( 1 << N ) - 1 */\r
+.long 0\r
+.long 1\r
+.long 3\r
+.long 7\r
+.long 15\r
+.long 31\r
+.long 63\r
+.long 127\r
+.long 255\r
+.long 511\r
+.long 1023\r
+.long 2047\r
+.long 4095\r
+.long 8191\r
+.long 16383\r
+.long 32767\r
+.long 65535\r
+.long 131071\r
+.long 262143\r
+.long 524287\r
+.long 1048575\r
+.long 2097151\r
+.long 4194303\r
+.long 8388607\r
+.long 16777215\r
+.long 33554431\r
+.long 67108863\r
+.long 134217727\r
+.long 268435455\r
+.long 536870911\r
+.long 1073741823\r
+.long 2147483647\r
+.long 4294967295\r
+#endif\r
+\r
+.text\r
+\r
+/*\r
+ * struct z_stream offsets, in zlib.h\r
+ */\r
+#define next_in_strm   0   /* strm->next_in */\r
+#define avail_in_strm  4   /* strm->avail_in */\r
+#define next_out_strm  12  /* strm->next_out */\r
+#define avail_out_strm 16  /* strm->avail_out */\r
+#define msg_strm       24  /* strm->msg */\r
+#define state_strm     28  /* strm->state */\r
+\r
+/*\r
+ * struct inflate_state offsets, in inflate.h\r
+ */\r
+#define mode_state     0   /* state->mode */\r
+#define wsize_state    32  /* state->wsize */\r
+#define write_state    36  /* state->write */\r
+#define window_state   40  /* state->window */\r
+#define hold_state     44  /* state->hold */\r
+#define bits_state     48  /* state->bits */\r
+#define lencode_state  64  /* state->lencode */\r
+#define distcode_state 68  /* state->distcode */\r
+#define lenbits_state  72  /* state->lenbits */\r
+#define distbits_state 76  /* state->distbits */\r
+\r
+/*\r
+ * inflate_fast's activation record\r
+ */\r
+#define local_var_size 56 /* how much local space for vars */\r
+#define strm_sp        80 /* first arg: z_stream * (local_var_size + 24) */\r
+#define start_sp       84 /* second arg: unsigned int (local_var_size + 28) */\r
+\r
+/*\r
+ * offsets for local vars on stack\r
+ */\r
+#define out            52  /* unsigned char* */\r
+#define window         48  /* unsigned char* */\r
+#define wsize          44  /* unsigned int */\r
+#define write          40  /* unsigned int */\r
+#define in             36  /* unsigned char* */\r
+#define beg            32  /* unsigned char* */\r
+#define dist           28  /* unsigned int */\r
+#define len            24  /* unsigned int */\r
+#define last           20  /* unsigned char* */\r
+#define end            16  /* unsigned char* */\r
+#define dcode          12  /* code* */\r
+#define lcode           8  /* code* */\r
+#define dmask           4  /* unsigned int */\r
+#define lmask           0  /* unsigned int */\r
+\r
+/*\r
+ * typedef enum inflate_mode consts, in inflate.h\r
+ */\r
+#ifndef NO_GUNZIP\r
+#define GUNZIP\r
+#endif\r
+\r
+#ifdef GUNZIP\r
+#define INFLATE_MODE_TYPE 11  /* state->mode flags enum-ed in inflate.h */\r
+#define INFLATE_MODE_BAD  26\r
+#else\r
+#define INFLATE_MODE_TYPE 3\r
+#define INFLATE_MODE_BAD  17\r
+#endif\r
+\r
+\r
+.align 16,0x90\r
+inflate_fast:\r
+        pushl   %edi\r
+        pushl   %esi\r
+        pushl   %ebp\r
+        pushl   %ebx\r
+        pushf   /* save eflags (strm_sp, state_sp assumes this is 32 bits) */\r
+        subl    $local_var_size, %esp\r
+        cld\r
+#if defined( USE_MMX )\r
+        emms\r
+#endif\r
+\r
+#define strm_r  %esi\r
+#define state_r %edi\r
+\r
+        movl    strm_sp(%esp), strm_r\r
+        movl    state_strm(strm_r), state_r\r
+\r
+        /* in = strm->next_in;\r
+         * out = strm->next_out;\r
+         * last = in + strm->avail_in - 5;\r
+         * beg = out - (start - strm->avail_out);\r
+         * end = out + (strm->avail_out - 257);\r
+         */\r
+        movl    next_in_strm(strm_r), %eax\r
+        movl    next_out_strm(strm_r), %ebx\r
+        movl    avail_in_strm(strm_r), %edx\r
+        movl    avail_out_strm(strm_r), %ecx\r
+        movl    start_sp(%esp), %ebp\r
+\r
+        addl    %eax, %edx      /* avail_in += next_in */\r
+        subl    $5, %edx        /* avail_in -= 5 */\r
+\r
+        subl    %ecx, %ebp      /* start -= avail_out */\r
+        negl    %ebp            /* start = -start */\r
+        addl    %ebx, %ebp      /* start += next_out */\r
+\r
+        subl    $257, %ecx      /* avail_out -= 257 */\r
+        addl    %ebx, %ecx      /* avail_out += out */\r
+\r
+        movl    %eax, in(%esp)\r
+        movl    %ebx, out(%esp)\r
+        movl    %edx, last(%esp)\r
+        movl    %ebp, beg(%esp)\r
+        movl    %ecx, end(%esp)\r
+\r
+        /* wsize = state->wsize;\r
+         * write = state->write;\r
+         * window = state->window;\r
+         * hold = state->hold;\r
+         * bits = state->bits;\r
+         * lcode = state->lencode;\r
+         * dcode = state->distcode;\r
+         * lmask = ( 1 << state->lenbits ) - 1;\r
+         * dmask = ( 1 << state->distbits ) - 1;\r
+         */\r
+\r
+        movl    lencode_state(state_r), %eax\r
+        movl    distcode_state(state_r), %ecx\r
+\r
+        movl    %eax, lcode(%esp)\r
+        movl    %ecx, dcode(%esp)\r
+\r
+        movl    $1, %eax\r
+        movl    lenbits_state(state_r), %ecx\r
+        shll    %cl, %eax\r
+        decl    %eax\r
+        movl    %eax, lmask(%esp)\r
+\r
+        movl    $1, %eax\r
+        movl    distbits_state(state_r), %ecx\r
+        shll    %cl, %eax\r
+        decl    %eax\r
+        movl    %eax, dmask(%esp)\r
+\r
+        movl    wsize_state(state_r), %eax\r
+        movl    write_state(state_r), %ecx\r
+        movl    window_state(state_r), %edx\r
+\r
+        movl    %eax, wsize(%esp)\r
+        movl    %ecx, write(%esp)\r
+        movl    %edx, window(%esp)\r
+\r
+#if ! defined( USE_MMX )\r
+\r
+#define hold_r     %ebp\r
+#define bits_r     %bl\r
+#define bitslong_r %ebx\r
+\r
+        movl    hold_state(state_r), hold_r\r
+        movl    bits_state(state_r), bitslong_r\r
+\r
+#else /* USE_MMX */\r
+\r
+#define hold_mm    %mm0\r
+#define bits_r     %ebp\r
+#define bitslong_r %ebp\r
+\r
+        movl    hold_state(state_r), %ebx\r
+        movl    bits_state(state_r), bitslong_r\r
+\r
+#endif\r
+\r
+#undef strm_r\r
+#undef state_r\r
+#define in_r       %esi\r
+#define from_r     %esi\r
+#define out_r      %edi\r
+\r
+        movl    in(%esp), in_r\r
+\r
+#if ! defined ( USE_MMX )\r
+\r
+        /* align in_r on word boundary */\r
+        testl   $1, in_r\r
+        jz      .L_is_aligned\r
+        xorl    %eax, %eax\r
+        movb    (in_r), %al\r
+        incl    in_r\r
+        movb    bits_r, %cl\r
+        addb    $8, bits_r\r
+        shll    %cl, %eax\r
+        orl     %eax, hold_r\r
+\r
+#else\r
+        /* align in_r on long boundary */\r
+.L_align_long:\r
+        testl   $3, in_r\r
+        jz      .L_is_aligned\r
+        xorl    %eax, %eax\r
+        movb    (in_r), %al\r
+        incl    in_r\r
+        movl    bits_r, %ecx\r
+        addl    $8, bits_r\r
+        shll    %cl, %eax\r
+        orl     %eax, %ebx\r
+        jmp     .L_align_long\r
+\r
+#endif\r
+\r
+.L_is_aligned:\r
+        movl    out(%esp), out_r\r
+\r
+#if defined ( USE_MMX )\r
+\r
+#define used_mm   %mm1\r
+#define dmask2_mm %mm2\r
+#define lmask2_mm %mm3\r
+#define lmask_mm  %mm4\r
+#define dmask_mm  %mm5\r
+#define tmp_mm    %mm6\r
+\r
+        movl    out(%esp), out_r\r
+        movd    lmask(%esp), lmask_mm \r
+        movq    lmask_mm, lmask2_mm\r
+        movd    dmask(%esp), dmask_mm\r
+        movq    dmask_mm, dmask2_mm\r
+        movd    %ebx, hold_mm\r
+        pxor    used_mm, used_mm\r
+        movl    lcode(%esp), %ebx       /* ebx = lcode */\r
+#endif\r
+\r
+        jmp     .L_do_loop\r
+\r
+.align 16,0x90\r
+\r
+#if ! defined ( USE_MMX )\r
+\r
+.L_do_loop:\r
+        /* regs: %esi = in, %ebp = hold, %bl = bits, %edi = out\r
+         *\r
+         * do { \r
+         *   if (bits < 15) {\r
+         *     hold |= *((unsigned short *)in)++ << bits;\r
+         *     bits += 16\r
+         *   }\r
+         *   this = lcode[hold & lmask]\r
+         */\r
+        cmpb    $15, bits_r\r
+        ja      .L_get_length_code      /* if (15 < bits) */\r
+\r
+        xorl    %eax, %eax\r
+        lodsw                           /* al = *(ushort *)in++ */\r
+        movb    bits_r, %cl             /* cl = bits, needs it for shifting */\r
+        addb    $16, bits_r             /* bits += 16 */\r
+        shll    %cl, %eax\r
+        orl     %eax, hold_r            /* hold |= *((ushort *)in)++ << bits */\r
+\r
+.L_get_length_code:\r
+        movl    lmask(%esp), %edx       /* edx = lmask */\r
+        movl    lcode(%esp), %ecx       /* ecx = lcode */\r
+        andl    hold_r, %edx            /* edx &= hold */\r
+        movl    (%ecx,%edx,4), %eax     /* eax = lcode[hold & lmask] */\r
+\r
+#else /* USE_MMX */\r
+\r
+.L_do_loop:\r
+        psrlq   used_mm, hold_mm        /* hold_mm >>= last bit length */\r
+\r
+        cmpl    $32, bits_r\r
+        ja      .L_get_length_code      /* if (32 < bits) */\r
+\r
+        movd    bits_r, tmp_mm\r
+        movd    (in_r), %mm7\r
+        addl    $4, in_r\r
+        psllq   tmp_mm, %mm7\r
+        addl    $32, bits_r\r
+        por     %mm7, hold_mm           /* hold_mm |= *((uint *)in)++ << bits */\r
+\r
+.L_get_length_code:\r
+        pand    hold_mm, lmask_mm\r
+        movd    lmask_mm, %eax\r
+        movq    lmask2_mm, lmask_mm\r
+        movl    (%ebx,%eax,4), %eax     /* eax = lcode[hold & lmask] */\r
+\r
+#endif\r
+\r
+#if ! defined( USE_MMX )\r
+\r
+.L_dolen:\r
+        /* regs: %esi = in, %ebp = hold, %bl = bits, %edi = out\r
+         *\r
+         * dolen:\r
+         *    bits -= this.bits;\r
+         *    hold >>= this.bits\r
+         */\r
+        movb    %ah, %cl                /* cl = this.bits */\r
+        subb    %ah, bits_r             /* bits -= this.bits */\r
+        shrl    %cl, hold_r             /* hold >>= this.bits */\r
+\r
+        /* check if op is a literal\r
+         * if (op == 0) {\r
+         *    PUP(out) = this.val;\r
+         *  }\r
+         */\r
+        testb   %al, %al\r
+        jnz     .L_test_for_length_base /* if (op != 0) 45.7% */\r
+\r
+        shrl    $16, %eax               /* output this.val char */\r
+        stosb\r
+\r
+#else /* USE_MMX */\r
+\r
+#define len_r  %edx\r
+\r
+.L_dolen:\r
+        movzbl  %ah, %ecx               /* ecx = this.bits */\r
+        movl    %eax, len_r             /* len = this */\r
+        shrl    $16, len_r              /* len = this.val */\r
+        movd    %ecx, used_mm\r
+        subl    %ecx, bits_r            /* bits -= this.bits */\r
+\r
+        testb   %al, %al\r
+        jnz     .L_test_for_length_base /* if (op != 0) 45.7% */\r
+\r
+        movb    %dl, (out_r)\r
+        incl    out_r\r
+\r
+#endif\r
+\r
+.L_while_test:\r
+        /* while (in < last && out < end)\r
+         */\r
+        cmpl    out_r, end(%esp)\r
+        jbe     .L_break_loop           /* if (out >= end) */\r
+\r
+        cmpl    in_r, last(%esp)\r
+        ja      .L_do_loop              /* if (in < last) */\r
+        jmp     .L_break_loop\r
+\r
+#if ! defined( USE_MMX )\r
+\r
+.L_test_for_length_base:\r
+        /* regs: %esi = in, %ebp = hold, %bl = bits, %edi = out, %edx = len\r
+         *\r
+         * else if (op & 16) {\r
+         *   len = this.val\r
+         *   op &= 15\r
+         *   if (op) {\r
+         *     if (op > bits) {\r
+         *       hold |= *((unsigned short *)in)++ << bits;\r
+         *       bits += 16\r
+         *     }\r
+         *     len += hold & mask[op];\r
+         *     bits -= op;\r
+         *     hold >>= op;\r
+         *   }\r
+         */\r
+#define len_r %edx\r
+        movl    %eax, len_r             /* len = this */\r
+        shrl    $16, len_r              /* len = this.val */\r
+        movb    %al, %cl\r
+\r
+        testb   $16, %al\r
+        jz      .L_test_for_second_level_length /* if ((op & 16) == 0) 8% */\r
+        andb    $15, %cl                /* op &= 15 */\r
+        jz      .L_save_len             /* if (!op) */\r
+        cmpb    %cl, bits_r\r
+        jae     .L_add_bits_to_len      /* if (op <= bits) */\r
+\r
+        movb    %cl, %ch                /* stash op in ch, freeing cl */\r
+        xorl    %eax, %eax\r
+        lodsw                           /* al = *(ushort *)in++ */\r
+        movb    bits_r, %cl             /* cl = bits, needs it for shifting */\r
+        addb    $16, bits_r             /* bits += 16 */\r
+        shll    %cl, %eax\r
+        orl     %eax, hold_r            /* hold |= *((ushort *)in)++ << bits */\r
+        movb    %ch, %cl                /* move op back to ecx */\r
+\r
+.L_add_bits_to_len:\r
+        movl    $1, %eax\r
+        shll    %cl, %eax\r
+        decl    %eax\r
+        subb    %cl, bits_r\r
+        andl    hold_r, %eax            /* eax &= hold */\r
+        shrl    %cl, hold_r\r
+        addl    %eax, len_r             /* len += hold & mask[op] */\r
+\r
+.L_save_len:\r
+        movl    len_r, len(%esp)        /* save len */\r
+#undef  len_r\r
+\r
+.L_decode_distance:\r
+        /* regs: %esi = in, %ebp = hold, %bl = bits, %edi = out, %edx = dist\r
+         *\r
+         *   if (bits < 15) {\r
+         *     hold |= *((unsigned short *)in)++ << bits;\r
+         *     bits += 16\r
+         *   }\r
+         *   this = dcode[hold & dmask];\r
+         * dodist:\r
+         *   bits -= this.bits;\r
+         *   hold >>= this.bits;\r
+         *   op = this.op;\r
+         */\r
+\r
+        cmpb    $15, bits_r\r
+        ja      .L_get_distance_code    /* if (15 < bits) */\r
+\r
+        xorl    %eax, %eax\r
+        lodsw                           /* al = *(ushort *)in++ */\r
+        movb    bits_r, %cl             /* cl = bits, needs it for shifting */\r
+        addb    $16, bits_r             /* bits += 16 */\r
+        shll    %cl, %eax\r
+        orl     %eax, hold_r            /* hold |= *((ushort *)in)++ << bits */\r
+\r
+.L_get_distance_code:\r
+        movl    dmask(%esp), %edx       /* edx = dmask */\r
+        movl    dcode(%esp), %ecx       /* ecx = dcode */\r
+        andl    hold_r, %edx            /* edx &= hold */\r
+        movl    (%ecx,%edx,4), %eax     /* eax = dcode[hold & dmask] */\r
+\r
+#else /* USE_MMX */\r
+\r
+.L_test_for_length_base:\r
+        testb   $16, %al\r
+        jz      .L_test_for_second_level_length /* if ((op & 16) == 0) 8% */\r
+        andl    $15, %eax               /* op &= 15 */\r
+        jz      .L_decode_distance      /* if (!op) */\r
+\r
+        psrlq   used_mm, hold_mm        /* hold_mm >>= last bit length */\r
+        movd    %eax, used_mm\r
+        movd    hold_mm, %ecx\r
+        subl    %eax, bits_r\r
+        andl    .L_mask(,%eax,4), %ecx\r
+        addl    %ecx, len_r             /* len += hold & mask[op] */\r
+\r
+.L_decode_distance:\r
+\r
+        psrlq   used_mm, hold_mm        /* hold_mm >>= last bit length */\r
+\r
+        cmpl    $32, bits_r\r
+        ja      .L_get_dist_code        /* if (32 < bits) */\r
+\r
+        movd    bits_r, tmp_mm\r
+        movd    (in_r), %mm7\r
+        addl    $4, in_r\r
+        psllq   tmp_mm, %mm7\r
+        addl    $32, bits_r\r
+        por     %mm7, hold_mm           /* hold_mm |= *((uint *)in)++ << bits */\r
+\r
+.L_get_dist_code:\r
+        movl    dcode(%esp), %ebx       /* ebx = dcode */\r
+        pand    hold_mm, dmask_mm\r
+        movd    dmask_mm, %eax\r
+        movq    dmask2_mm, dmask_mm\r
+        movl    (%ebx,%eax,4), %eax     /* eax = dcode[hold & lmask] */\r
+\r
+#endif\r
+\r
+#if ! defined( USE_MMX )\r
+\r
+#define dist_r %edx\r
+.L_dodist:\r
+        movl    %eax, dist_r            /* dist = this */\r
+        shrl    $16, dist_r             /* dist = this.val */\r
+        movb    %ah, %cl\r
+        subb    %ah, bits_r             /* bits -= this.bits */\r
+        shrl    %cl, hold_r             /* hold >>= this.bits */\r
+\r
+        /* if (op & 16) {\r
+         *   dist = this.val\r
+         *   op &= 15\r
+         *   if (op > bits) {\r
+         *     hold |= *((unsigned short *)in)++ << bits;\r
+         *     bits += 16\r
+         *   }\r
+         *   dist += hold & mask[op];\r
+         *   bits -= op;\r
+         *   hold >>= op;\r
+         */\r
+        movb    %al, %cl                /* cl = this.op */\r
+\r
+        testb   $16, %al                /* if ((op & 16) == 0) */\r
+        jz      .L_test_for_second_level_dist\r
+        andb    $15, %cl                /* op &= 15 */\r
+        jz      .L_check_dist_one\r
+        cmpb    %cl, bits_r\r
+        jae     .L_add_bits_to_dist     /* if (op <= bits) 97.6% */\r
+\r
+        movb    %cl, %ch                /* stash op in ch, freeing cl */\r
+        xorl    %eax, %eax\r
+        lodsw                           /* al = *(ushort *)in++ */\r
+        movb    bits_r, %cl             /* cl = bits, needs it for shifting */\r
+        addb    $16, bits_r             /* bits += 16 */\r
+        shll    %cl, %eax\r
+        orl     %eax, hold_r            /* hold |= *((ushort *)in)++ << bits */\r
+        movb    %ch, %cl                /* move op back to ecx */\r
+\r
+.L_add_bits_to_dist:\r
+        movl    $1, %eax\r
+        shll    %cl, %eax\r
+        decl    %eax                    /* (1 << op) - 1 */\r
+        subb    %cl, bits_r\r
+        andl    hold_r, %eax            /* eax &= hold */\r
+        shrl    %cl, hold_r\r
+        addl    %eax, dist_r            /* dist += hold & ((1 << op) - 1) */\r
+        jmp     .L_check_window\r
+\r
+#else /* USE_MMX */\r
+\r
+#define dist_r %ebx\r
+.L_dodist:\r
+        movzbl  %ah, %ecx               /* ecx = this.bits */\r
+        movl    %eax, dist_r\r
+        shrl    $16, dist_r             /* dist  = this.val */\r
+        subl    %ecx, bits_r            /* bits -= this.bits */\r
+        movd    %ecx, used_mm\r
+\r
+        testb   $16, %al                /* if ((op & 16) == 0) */\r
+        jz      .L_test_for_second_level_dist \r
+        andl    $15, %eax               /* op &= 15 */\r
+        jz      .L_check_dist_one\r
+\r
+.L_add_bits_to_dist:\r
+        psrlq   used_mm, hold_mm        /* hold_mm >>= last bit length */\r
+        movd    %eax, used_mm           /* save bit length of current op */\r
+        movd    hold_mm, %ecx           /* get the next bits on input stream */\r
+        subl    %eax, bits_r            /* bits -= op bits */\r
+        andl    .L_mask(,%eax,4), %ecx  /* ecx   = hold & mask[op] */\r
+        addl    %ecx, dist_r            /* dist += hold & mask[op] */\r
+        jmp     .L_check_window\r
+\r
+#endif\r
+\r
+.align 16,0x90\r
+\r
+.L_check_dist_one:\r
+        cmpl    $1, dist_r\r
+        jne     .L_check_window\r
+        cmpl    out_r, beg(%esp)\r
+        je      .L_check_window\r
+\r
+        decl    out_r\r
+#if ! defined( USE_MMX )\r
+        movl    len(%esp), %ecx\r
+#else\r
+        movl    len_r, %ecx\r
+#endif\r
+        movb    (out_r), %al\r
+        subl    $3, %ecx\r
+\r
+        movb    %al, 1(out_r)\r
+        movb    %al, 2(out_r)\r
+        movb    %al, 3(out_r)\r
+        addl    $4, out_r\r
+        rep     stosb\r
+\r
+#if defined( USE_MMX )\r
+        movl    lcode(%esp), %ebx       /* move lcode back to %ebx, toss dist */\r
+#endif\r
+        jmp     .L_while_test\r
+\r
+.align 16,0x90\r
+\r
+.L_check_window:\r
+        /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist\r
+         *       %ecx = nbytes\r
+         *\r
+         * nbytes = out - beg;\r
+         * if (dist <= nbytes) {\r
+         *   from = out - dist;\r
+         *   do {\r
+         *     PUP(out) = PUP(from);\r
+         *   } while (--len > 0) {\r
+         * }\r
+         */\r
+\r
+        movl    in_r, in(%esp)          /* save in so from can use it's reg */\r
+        movl    out_r, %eax\r
+        subl    beg(%esp), %eax         /* nbytes = out - beg */\r
+\r
+        cmpl    dist_r, %eax\r
+        jb      .L_clip_window          /* if (dist > nbytes) 4.2% */\r
+\r
+#if ! defined( USE_MMX )\r
+        movl    len(%esp), %ecx\r
+#else\r
+        movl    len_r, %ecx\r
+#endif\r
+        movl    out_r, from_r\r
+        subl    dist_r, from_r          /* from = out - dist */\r
+\r
+        subl    $3, %ecx\r
+        movb    (from_r), %al\r
+        movb    %al, (out_r)\r
+        movb    1(from_r), %al\r
+        movb    2(from_r), %dl\r
+        addl    $3, from_r\r
+        movb    %al, 1(out_r)\r
+        movb    %dl, 2(out_r)\r
+        addl    $3, out_r\r
+        rep     movsb\r
+\r
+        movl    in(%esp), in_r          /* move in back to %esi, toss from */\r
+#if defined( USE_MMX )\r
+        movl    lcode(%esp), %ebx       /* move lcode back to %ebx, toss dist */\r
+#endif\r
+        jmp     .L_while_test\r
+\r
+.align 16,0x90\r
+\r
+#if ! defined( USE_MMX )\r
+\r
+.L_test_for_second_level_length:\r
+        /* else if ((op & 64) == 0) {\r
+         *   this = lcode[this.val + (hold & mask[op])];\r
+         * }\r
+         */\r
+        testb   $64, %al\r
+        jnz     .L_test_for_end_of_block  /* if ((op & 64) != 0) */\r
+\r
+        movl    $1, %eax\r
+        shll    %cl, %eax\r
+        decl    %eax\r
+        andl    hold_r, %eax            /* eax &= hold */\r
+        addl    %edx, %eax              /* eax += this.val */\r
+        movl    lcode(%esp), %edx       /* edx = lcode */\r
+        movl    (%edx,%eax,4), %eax     /* eax = lcode[val + (hold&mask[op])] */\r
+        jmp     .L_dolen\r
+\r
+#else /* USE_MMX */\r
+\r
+.L_test_for_second_level_length: \r
+        testb   $64, %al\r
+        jnz     .L_test_for_end_of_block  /* if ((op & 64) != 0) */\r
+\r
+        andl    $15, %eax\r
+        psrlq   used_mm, hold_mm        /* hold_mm >>= last bit length */\r
+        movd    hold_mm, %ecx\r
+        andl    .L_mask(,%eax,4), %ecx\r
+        addl    len_r, %ecx\r
+        movl    (%ebx,%ecx,4), %eax     /* eax = lcode[hold & lmask] */\r
+        jmp     .L_dolen\r
+\r
+#endif\r
+\r
+.align 16,0x90\r
+\r
+#if ! defined( USE_MMX )\r
+\r
+.L_test_for_second_level_dist:\r
+        /* else if ((op & 64) == 0) {\r
+         *   this = dcode[this.val + (hold & mask[op])];\r
+         * }\r
+         */\r
+        testb   $64, %al\r
+        jnz     .L_invalid_distance_code  /* if ((op & 64) != 0) */\r
+\r
+        movl    $1, %eax\r
+        shll    %cl, %eax\r
+        decl    %eax\r
+        andl    hold_r, %eax            /* eax &= hold */\r
+        addl    %edx, %eax              /* eax += this.val */\r
+        movl    dcode(%esp), %edx       /* edx = dcode */\r
+        movl    (%edx,%eax,4), %eax     /* eax = dcode[val + (hold&mask[op])] */\r
+        jmp     .L_dodist\r
+\r
+#else /* USE_MMX */\r
+\r
+.L_test_for_second_level_dist:\r
+        testb   $64, %al\r
+        jnz     .L_invalid_distance_code  /* if ((op & 64) != 0) */\r
+\r
+        andl    $15, %eax\r
+        psrlq   used_mm, hold_mm        /* hold_mm >>= last bit length */\r
+        movd    hold_mm, %ecx\r
+        andl    .L_mask(,%eax,4), %ecx\r
+        movl    dcode(%esp), %eax       /* ecx = dcode */\r
+        addl    dist_r, %ecx\r
+        movl    (%eax,%ecx,4), %eax     /* eax = lcode[hold & lmask] */\r
+        jmp     .L_dodist\r
+\r
+#endif\r
+\r
+.align 16,0x90\r
+.L_clip_window:\r
+        /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist\r
+         *       %ecx = nbytes\r
+         *\r
+         * else {\r
+         *   if (dist > wsize) {\r
+         *     invalid distance\r
+         *   }\r
+         *   from = window;\r
+         *   nbytes = dist - nbytes;\r
+         *   if (write == 0) {\r
+         *     from += wsize - nbytes;\r
+         */\r
+#define nbytes_r %ecx\r
+\r
+        movl    %eax, nbytes_r\r
+        movl    wsize(%esp), %eax       /* prepare for dist compare */\r
+        negl    nbytes_r                /* nbytes = -nbytes */\r
+        movl    window(%esp), from_r    /* from = window */\r
+\r
+        cmpl    dist_r, %eax\r
+        jb      .L_invalid_distance_too_far /* if (dist > wsize) */\r
+\r
+        addl    dist_r, nbytes_r        /* nbytes = dist - nbytes */\r
+        cmpl    $0, write(%esp)\r
+        jne     .L_wrap_around_window   /* if (write != 0) */\r
+\r
+        subl    nbytes_r, %eax\r
+        addl    %eax, from_r            /* from += wsize - nbytes */\r
+\r
+        /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist\r
+         *       %ecx = nbytes, %eax = len\r
+         *\r
+         *     if (nbytes < len) {\r
+         *       len -= nbytes;\r
+         *       do {\r
+         *         PUP(out) = PUP(from);\r
+         *       } while (--nbytes);\r
+         *       from = out - dist;\r
+         *     }\r
+         *   }\r
+         */\r
+\r
+#if ! defined( USE_MMX )\r
+#define len_r %eax\r
+        movl    len(%esp), len_r\r
+#endif\r
+        cmpl    nbytes_r, len_r\r
+        jbe     .L_do_copy1             /* if (nbytes >= len) */\r
+\r
+        subl    nbytes_r, len_r         /* len -= nbytes */\r
+        rep     movsb\r
+        movl    out_r, from_r\r
+        subl    dist_r, from_r          /* from = out - dist */\r
+        jmp     .L_do_copy1\r
+\r
+        cmpl    nbytes_r, len_r\r
+        jbe     .L_do_copy1             /* if (nbytes >= len) */\r
+\r
+        subl    nbytes_r, len_r         /* len -= nbytes */\r
+        rep     movsb\r
+        movl    out_r, from_r\r
+        subl    dist_r, from_r          /* from = out - dist */\r
+        jmp     .L_do_copy1\r
+\r
+.L_wrap_around_window:\r
+        /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist\r
+         *       %ecx = nbytes, %eax = write, %eax = len\r
+         *\r
+         *   else if (write < nbytes) {\r
+         *     from += wsize + write - nbytes;\r
+         *     nbytes -= write;\r
+         *     if (nbytes < len) {\r
+         *       len -= nbytes;\r
+         *       do {\r
+         *         PUP(out) = PUP(from);\r
+         *       } while (--nbytes);\r
+         *       from = window;\r
+         *       nbytes = write;\r
+         *       if (nbytes < len) {\r
+         *         len -= nbytes;\r
+         *         do {\r
+         *           PUP(out) = PUP(from);\r
+         *         } while(--nbytes);\r
+         *         from = out - dist;\r
+         *       }\r
+         *     }\r
+         *   }\r
+         */\r
+#define write_r %eax\r
+\r
+        movl    write(%esp), write_r\r
+        cmpl    write_r, nbytes_r\r
+        jbe     .L_contiguous_in_window /* if (write >= nbytes) */\r
+\r
+        addl    wsize(%esp), from_r\r
+        addl    write_r, from_r\r
+        subl    nbytes_r, from_r        /* from += wsize + write - nbytes */\r
+        subl    write_r, nbytes_r       /* nbytes -= write */\r
+#undef write_r\r
+\r
+#if ! defined( USE_MMX )\r
+        movl    len(%esp), len_r\r
+#endif\r
+        cmpl    nbytes_r, len_r\r
+        jbe     .L_do_copy1             /* if (nbytes >= len) */\r
+\r
+        subl    nbytes_r, len_r         /* len -= nbytes */\r
+        rep     movsb\r
+        movl    window(%esp), from_r    /* from = window */\r
+        movl    write(%esp), nbytes_r   /* nbytes = write */\r
+        cmpl    nbytes_r, len_r\r
+        jbe     .L_do_copy1             /* if (nbytes >= len) */\r
+\r
+        subl    nbytes_r, len_r         /* len -= nbytes */\r
+        rep     movsb\r
+        movl    out_r, from_r\r
+        subl    dist_r, from_r          /* from = out - dist */\r
+        jmp     .L_do_copy1\r
+\r
+.L_contiguous_in_window:\r
+        /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist\r
+         *       %ecx = nbytes, %eax = write, %eax = len\r
+         *\r
+         *   else {\r
+         *     from += write - nbytes;\r
+         *     if (nbytes < len) {\r
+         *       len -= nbytes;\r
+         *       do {\r
+         *         PUP(out) = PUP(from);\r
+         *       } while (--nbytes);\r
+         *       from = out - dist;\r
+         *     }\r
+         *   }\r
+         */\r
+#define write_r %eax\r
+\r
+        addl    write_r, from_r\r
+        subl    nbytes_r, from_r        /* from += write - nbytes */\r
+#undef write_r\r
+\r
+#if ! defined( USE_MMX )\r
+        movl    len(%esp), len_r\r
+#endif\r
+        cmpl    nbytes_r, len_r\r
+        jbe     .L_do_copy1             /* if (nbytes >= len) */\r
+\r
+        subl    nbytes_r, len_r         /* len -= nbytes */\r
+        rep     movsb\r
+        movl    out_r, from_r\r
+        subl    dist_r, from_r          /* from = out - dist */\r
+\r
+.L_do_copy1:\r
+        /* regs: %esi = from, %esi = in, %ebp = hold, %bl = bits, %edi = out\r
+         *       %eax = len\r
+         *\r
+         *     while (len > 0) {\r
+         *       PUP(out) = PUP(from);\r
+         *       len--;\r
+         *     }\r
+         *   }\r
+         * } while (in < last && out < end);\r
+         */\r
+#undef nbytes_r\r
+#define in_r %esi\r
+\r
+        movl    len_r, %ecx\r
+        rep     movsb\r
+\r
+        movl    in(%esp), in_r          /* move in back to %esi, toss from */\r
+#if defined( USE_MMX )\r
+        movl    lcode(%esp), %ebx       /* move lcode back to %ebx, toss dist */\r
+#endif\r
+        jmp     .L_while_test\r
+\r
+#undef len_r\r
+#undef from_r\r
+#undef dist_r\r
+\r
+.L_invalid_distance_code:\r
+        /* else {\r
+         *   strm->msg = "invalid distance code";\r
+         *   state->mode = BAD;\r
+         * }\r
+         */\r
+        movl    $.L_invalid_distance_code_msg, %ecx\r
+        movl    $INFLATE_MODE_BAD, %edx\r
+        jmp     .L_update_stream_state\r
+\r
+.L_test_for_end_of_block:\r
+        /* else if (op & 32) {\r
+         *   state->mode = TYPE;\r
+         *   break;\r
+         * }\r
+         */\r
+        testb   $32, %al\r
+        jz      .L_invalid_literal_length_code  /* if ((op & 32) == 0) */\r
+\r
+        movl    $0, %ecx\r
+        movl    $INFLATE_MODE_TYPE, %edx\r
+        jmp     .L_update_stream_state\r
+\r
+.L_invalid_literal_length_code:\r
+        /* else {\r
+         *   strm->msg = "invalid literal/length code";\r
+         *   state->mode = BAD;\r
+         * }\r
+         */\r
+        movl    $.L_invalid_literal_length_code_msg, %ecx\r
+        movl    $INFLATE_MODE_BAD, %edx\r
+        jmp     .L_update_stream_state\r
+\r
+.L_invalid_distance_too_far:\r
+        /* strm->msg = "invalid distance too far back";\r
+         * state->mode = BAD;\r
+         */\r
+        movl    in(%esp), in_r          /* from_r has in's reg, put in back */\r
+        movl    $.L_invalid_distance_too_far_msg, %ecx\r
+        movl    $INFLATE_MODE_BAD, %edx\r
+        jmp     .L_update_stream_state\r
+\r
+.L_update_stream_state:\r
+        /* set strm->msg = %ecx, strm->state->mode = %edx */\r
+        movl    strm_sp(%esp), %eax\r
+        testl   %ecx, %ecx              /* if (msg != NULL) */\r
+        jz      .L_skip_msg\r
+        movl    %ecx, msg_strm(%eax)    /* strm->msg = msg */\r
+.L_skip_msg:\r
+        movl    state_strm(%eax), %eax  /* state = strm->state */\r
+        movl    %edx, mode_state(%eax)  /* state->mode = edx (BAD | TYPE) */\r
+\r
+.L_break_loop:\r
+\r
+#define strm_r  %eax\r
+#define state_r %edx\r
+\r
+        /* len = bits >> 3;\r
+         * in -= len;\r
+         * bits -= len << 3;\r
+         * hold &= (1U << bits) - 1;\r
+         * state->hold = hold;\r
+         * state->bits = bits;\r
+         * strm->next_in = in;\r
+         * strm->next_out = out;\r
+         */\r
+        movl    strm_sp(%esp), strm_r\r
+        movl    bitslong_r, %ecx\r
+        movl    state_strm(strm_r), state_r\r
+        shrl    $3, %ecx\r
+        subl    %ecx, in_r\r
+        shll    $3, %ecx\r
+        subl    %ecx, bitslong_r\r
+        movl    out_r, next_out_strm(strm_r)\r
+        movl    in_r, next_in_strm(strm_r)\r
+        movl    bitslong_r, bits_state(state_r)\r
+\r
+        movl    bitslong_r, %ecx\r
+        movl    $1, %ebx                /* overwrites bitslong_r, %bl */\r
+        shll    %cl, %ebx\r
+        decl    %ebx\r
+\r
+#undef bits_r\r
+#undef bitslong_r\r
+\r
+#if ! defined( USE_MMX )\r
+\r
+        andl    %ebx, hold_r\r
+        movl    hold_r, hold_state(state_r)\r
+\r
+#else /* USE_MMX */\r
+\r
+        psrlq   used_mm, hold_mm        /* hold_mm >>= last bit length */\r
+        movd    hold_mm, %ecx\r
+        andl    %ebx, %ecx\r
+        movl    %ecx, hold_state(state_r)\r
+\r
+#endif\r
+\r
+#define last_r %ebx\r
+\r
+        /* strm->avail_in = in < last ? 5 + (last - in) : 5 - (in - last) */\r
+        movl    last(%esp), last_r\r
+        cmpl    in_r, last_r\r
+        jbe     .L_last_is_smaller     /* if (in >= last) */\r
+\r
+        subl    in_r, last_r           /* last -= in */\r
+        addl    $5, last_r             /* last += 5 */\r
+        movl    last_r, avail_in_strm(strm_r)\r
+        jmp     .L_fixup_out\r
+.L_last_is_smaller:\r
+        subl    last_r, in_r           /* in -= last */\r
+        negl    in_r                   /* in = -in */\r
+        addl    $5, in_r               /* in += 5 */\r
+        movl    in_r, avail_in_strm(strm_r)\r
+\r
+#undef last_r\r
+#define end_r %ebx\r
+\r
+.L_fixup_out:\r
+        /* strm->avail_out = out < end ? 257 + (end - out) : 257 - (out - end)*/\r
+        movl    end(%esp), end_r\r
+        cmpl    out_r, end_r\r
+        jbe     .L_end_is_smaller      /* if (out >= end) */\r
+\r
+        subl    out_r, end_r           /* end -= out */\r
+        addl    $257, end_r            /* end += 257 */\r
+        movl    end_r, avail_out_strm(strm_r)\r
+        jmp     .L_done\r
+.L_end_is_smaller:\r
+        subl    end_r, out_r           /* out -= end */\r
+        negl    out_r                  /* out = -out */\r
+        addl    $257, out_r            /* out += 257 */\r
+        movl    out_r, avail_out_strm(strm_r)\r
+\r
+#undef end_r\r
+\r
+.L_done:\r
+#if defined( USE_MMX )\r
+        emms\r
+#endif\r
+        addl    $local_var_size, %esp\r
+        popf\r
+        popl    %ebx\r
+        popl    %ebp\r
+        popl    %esi\r
+        popl    %edi\r
+        ret\r
+\r
+.type inflate_fast,@function\r
+.size inflate_fast,.-inflate_fast\r
index 0caa44a..167fd83 100644 (file)
@@ -9,7 +9,7 @@
  * increase in speed on a Power PC using gcc -O3.
  */
 
-/* @(#) $Id$ */
+/* @(#) $Id: crc32.c,v 1.9 2003/03/08 21:47:46 jbj Exp $ */
 
 #ifdef MAKECRCH
 #  include <stdio.h>
@@ -186,10 +186,8 @@ const unsigned long FAR * ZEXPORT get_crc_table()
 #define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
 
 /* ========================================================================= */
-unsigned long ZEXPORT crc32(crc, buf, len)
-    unsigned long crc;
-    const unsigned char FAR *buf;
-    unsigned len;
+unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf,
+               unsigned len)
 {
     if (buf == Z_NULL) return 0UL;
 
index 8053b61..cc8e8e7 100644 (file)
@@ -2,6 +2,7 @@
  * Generated automatically by crc32.c
  */
 
+/*@unchecked@*/
 local const unsigned long FAR crc_table[TBLS][256] =
 {
   {
index b950501..c05affa 100644 (file)
@@ -271,7 +271,8 @@ typedef struct internal_state {
 
         /* in trees.c */
 void _tr_init         OF((deflate_state *s))
-       /*@modifies *s @*/;
+       /*@globals internalState @*/
+       /*@modifies *s, internalState @*/;
 int  _tr_tally        OF((deflate_state *s, unsigned dist, unsigned lc))
        /*@modifies *s @*/;
 void _tr_flush_block  OF((deflate_state *s, charf *buf, ulg stored_len,
@@ -279,8 +280,8 @@ void _tr_flush_block  OF((deflate_state *s, charf *buf, ulg stored_len,
        /*@modifies *s @*/;
 void _tr_align        OF((deflate_state *s))
        /*@modifies *s @*/;
-void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
-                          int eof))
+void _tr_stored_block OF((deflate_state *s, /*@null@*/ charf *buf,
+               ulg stored_len, int eof))
        /*@modifies *s @*/;
 
 #define d_code(dist) \
index a52dcf1..eeec8a2 100644 (file)
@@ -5,7 +5,7 @@
  * Compile this file with -DNO_DEFLATE to avoid the compression code.
  */
 
-/* @(#) $Id: gzio.c,v 1.9 2002/03/17 15:46:23 jbj Exp $ */
+/* @(#) $Id: gzio.c,v 1.10 2002/10/07 09:05:07 jbj Exp $ */
 
 #include <stdio.h>
 
@@ -42,11 +42,16 @@ typedef struct gz_stream {
     z_stream stream;
     int      z_err;   /*!< error code for last stream operation */
     int      z_eof;   /*!< set if end of input file */
+/*@null@*/
     FILE     *file;   /*!< .gz file */
+/*@null@*/
     Byte     *inbuf;  /*!< input buffer */
+/*@null@*/
     Byte     *outbuf; /*!< output buffer */
     uLong    crc;     /*!< crc32 of uncompressed data */
+/*@null@*/
     char     *msg;    /*!< error message */
+/*@null@*/
     char     *path;   /*!< path name for debugging only */
     int      transparent; /*!< 1 if input file is not a .gz file */
     char     mode;    /*!< 'w' or 'r' */
@@ -55,8 +60,8 @@ typedef struct gz_stream {
 
 
 local gzFile gz_open      OF((const char *path, const char *mode, int  fd))
-       /*@globals errno, fileSystem @*/
-       /*@modifies errno, fileSystem @*/;
+       /*@globals errno, fileSystem, internalState @*/
+       /*@modifies errno, fileSystem, internalState @*/;
 local int do_flush        OF((gzFile file, int flush))
        /*@globals fileSystem @*/
        /*@modifies fileSystem @*/;
index 2209f61..5e8d9cc 100644 (file)
@@ -16,7 +16,8 @@
 #include "inffast.h"
 
 /* function prototypes */
-local void fixedtables OF((struct inflate_state FAR *state));
+local void fixedtables OF((struct inflate_state FAR *state))
+       /*@modifies state @*/;
 
 /*
    strm provides memory allocation functions in zalloc and zfree, or
@@ -25,12 +26,8 @@ local void fixedtables OF((struct inflate_state FAR *state));
    windowBits is in the range 8..15, and window is a user-supplied
    window and output buffer that is 2**windowBits bytes.
  */
-int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size)
-z_stream FAR *strm;
-int windowBits;
-unsigned char FAR *window;
-const char *version;
-int stream_size;
+int ZEXPORT inflateBackInit_(z_stream FAR *strm, int windowBits,
+               unsigned char FAR *window, const char *version, int stream_size)
 {
     struct inflate_state FAR *state;
 
@@ -68,8 +65,7 @@ int stream_size;
    used for threaded applications, since the rewriting of the tables and virgin
    may not be thread-safe.
  */
-local void fixedtables(state)
-struct inflate_state FAR *state;
+local void fixedtables(struct inflate_state FAR *state)
 {
 #ifdef BUILDFIXED
     static int virgin = 1;
@@ -235,11 +231,8 @@ struct inflate_state FAR *state;
    inflateBack() can also return Z_STREAM_ERROR if the input parameters
    are not correct, i.e. strm is Z_NULL or the state was not initialized.
  */
-int ZEXPORT inflateBack(strm, in, out, opaque)
-z_stream FAR *strm;
-in_func in;
-out_func out;
-void FAR *opaque;
+int ZEXPORT inflateBack(z_stream FAR *strm, in_func in, out_func out,
+               void FAR *opaque)
 {
     struct inflate_state FAR *state;
     unsigned char *next, *put; /* next input and output */
@@ -598,8 +591,7 @@ void FAR *opaque;
     return ret;
 }
 
-int ZEXPORT inflateBackEnd(strm)
-z_stream FAR *strm;
+int ZEXPORT inflateBackEnd(z_stream FAR *strm)
 {
     struct inflate_state FAR *state;
 
index 3a5e6f1..d1db74c 100644 (file)
@@ -61,9 +61,7 @@
       requires strm->avail_out >= 258 for each loop to avoid checking for
       output space.
  */
-void inflate_fast(strm, start)
-z_streamp strm;
-unsigned start;                /* inflate()'s starting value for strm->avail_out */
+void inflate_fast(z_streamp strm, unsigned start)
 {
     struct inflate_state FAR *state;
     unsigned char FAR *in;     /* local strm->next_in */
index 977101b..75aef97 100644 (file)
@@ -8,4 +8,5 @@
    subject to change. Applications should only use zlib.h.
  */
 
-void inflate_fast OF((z_streamp strm, unsigned start));
+void inflate_fast OF((z_streamp strm, unsigned start))
+       /*@modifies strm @*/;
index 2e9d134..44f4e78 100644 (file)
 #endif
 
 /* function prototypes */
-local void fixedtables OF((struct inflate_state FAR *state));
-local int updatewindow OF((z_streamp strm, unsigned out));
+local void fixedtables OF((struct inflate_state FAR *state))
+       /*@modifies state @*/;
+local int updatewindow OF((z_streamp strm, unsigned out))
+       /*@*/;
 #ifdef BUILDFIXED
-   void makefixed OF((void));
+   void makefixed OF((void))
+       /*@*/;
 #endif
 local unsigned syncsearch OF((unsigned *have, unsigned char FAR *buf,
-                              unsigned len));
+                              unsigned len))
+       /*@modifies *have @*/;
 
-int ZEXPORT inflateReset(strm)
-z_streamp strm;
+int ZEXPORT inflateReset(z_streamp strm)
 {
     struct inflate_state FAR *state;
 
@@ -111,11 +114,8 @@ z_streamp strm;
     return Z_OK;
 }
 
-int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size)
-z_streamp strm;
-int windowBits;
-const char *version;
-int stream_size;
+int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, const char *version,
+               int stream_size)
 {
     struct inflate_state FAR *state;
 
@@ -150,10 +150,7 @@ int stream_size;
     return inflateReset(strm);
 }
 
-int ZEXPORT inflateInit_(strm, version, stream_size)
-z_streamp strm;
-const char *version;
-int stream_size;
+int ZEXPORT inflateInit_(z_streamp strm, const char *version, int stream_size)
 {
     return inflateInit2_(strm, DEF_WBITS, version, stream_size);
 }
@@ -168,8 +165,7 @@ int stream_size;
    used for threaded applications, since the rewriting of the tables and virgin
    may not be thread-safe.
  */
-local void fixedtables(state)
-struct inflate_state FAR *state;
+local void fixedtables(struct inflate_state FAR *state)
 {
 #ifdef BUILDFIXED
     static int virgin = 1;
@@ -232,7 +228,7 @@ struct inflate_state FAR *state;
 
     a.out > inffixed.h
  */
-void makefixed()
+void makefixed(void)
 {
     unsigned low, size;
     struct inflate_state state;
@@ -286,9 +282,7 @@ void makefixed()
    output will fall in the output data, making match copies simpler and faster.
    The advantage may be dependent on the size of the processor's data caches.
  */
-local int updatewindow(strm, out)
-z_streamp strm;
-unsigned out;
+local int updatewindow(z_streamp strm, unsigned out)
 {
     struct inflate_state FAR *state;
     unsigned copy, dist;
@@ -513,9 +507,7 @@ unsigned out;
    will return Z_BUF_ERROR if it has not reached the end of the stream.
  */
 
-int ZEXPORT inflate(strm, flush)
-z_streamp strm;
-int flush;
+int ZEXPORT inflate(z_streamp strm, int flush)
 {
     struct inflate_state FAR *state;
     unsigned char *next, *put; /* next input and output */
@@ -1054,8 +1046,7 @@ int flush;
     return ret;
 }
 
-int ZEXPORT inflateEnd(strm)
-z_streamp strm;
+int ZEXPORT inflateEnd(z_streamp strm)
 {
     struct inflate_state FAR *state;
     if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == Z_NULL)
@@ -1068,10 +1059,8 @@ z_streamp strm;
     return Z_OK;
 }
 
-int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
-z_streamp strm;
-const Bytef *dictionary;
-uInt dictLength;
+int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary,
+               uInt dictLength)
 {
     struct inflate_state FAR *state;
     unsigned long id;
@@ -1113,10 +1102,7 @@ uInt dictLength;
    called again with more data and the *have state.  *have is initialized to
    zero for the first call.
  */
-local unsigned syncsearch(have, buf, len)
-unsigned *have;
-unsigned char FAR *buf;
-unsigned len;
+local unsigned syncsearch(unsigned *have, unsigned char FAR *buf, unsigned len)
 {
     unsigned got;
     unsigned next;
@@ -1136,8 +1122,7 @@ unsigned len;
     return next;
 }
 
-int ZEXPORT inflateSync(strm)
-z_streamp strm;
+int ZEXPORT inflateSync(z_streamp strm)
 {
     unsigned len;              /* number of bytes to look at or looked at */
     unsigned long in, out;     /* temporary to save total_in and total_out */
@@ -1187,8 +1172,7 @@ z_streamp strm;
    block. When decompressing, PPP checks that at the end of input packet,
    inflate is waiting for these length bytes.
  */
-int ZEXPORT inflateSyncPoint(strm)
-z_streamp strm;
+int ZEXPORT inflateSyncPoint(z_streamp strm)
 {
     struct inflate_state FAR *state;
 
@@ -1197,9 +1181,7 @@ z_streamp strm;
     return state->mode == STORED && state->bits == 0;
 }
 
-int ZEXPORT inflateCopy(dest, source)
-z_streamp dest;
-z_streamp source;
+int ZEXPORT inflateCopy(z_streamp dest, z_streamp source)
 {
     struct inflate_state FAR *state;
     struct inflate_state FAR *copy;
index 33073c6..3899710 100644 (file)
@@ -29,13 +29,8 @@ const char inflate_copyright[] =
    table index bits.  It will differ if the request is greater than the
    longest code or if it is less than the shortest code.
  */
-int inflate_table(type, lens, codes, table, bits, work)
-codetype type;
-unsigned short FAR *lens;
-unsigned codes;
-code * FAR *table;
-unsigned *bits;
-unsigned short FAR *work;
+int inflate_table(codetype type, unsigned short FAR *lens, unsigned codes,
+               code * FAR *table, unsigned *bits, unsigned short FAR *work)
 {
     unsigned len;              /* a code's length in bits */
     unsigned sym;              /* index of code symbols */
index e49c147..0c4fc37 100644 (file)
@@ -52,4 +52,5 @@ typedef enum {
 
 extern int inflate_table OF((codetype type, unsigned short FAR *lens,
                              unsigned codes, code * FAR *table, unsigned *bits,
-                             unsigned short FAR *work));
+                             unsigned short FAR *work))
+       /*@*/;
index 80db721..2c1430e 100644 (file)
@@ -34,7 +34,7 @@
  *          Addison-Wesley, 1983. ISBN 0-201-06672-6.
  */
 
-/* @(#) $Id: trees.c,v 1.8 2002/03/17 15:46:23 jbj Exp $ */
+/* @(#) $Id: trees.c,v 1.9 2002/06/22 18:51:58 jbj Exp $ */
 
 /* #define GEN_TREES_H */
 
@@ -98,6 +98,7 @@ local const uch bl_order[BL_CODES]
 #if defined(GEN_TREES_H) || !defined(STDC)
 /* non ANSI compilers may not accept trees.h */
 
+/*@unchecked@*/
 local ct_data static_ltree[L_CODES+2];
 /*!< The static literal tree. Since the bit lengths are imposed, there is no
  * need for the L_CODES extra codes used during heap construction. However
@@ -105,17 +106,20 @@ local ct_data static_ltree[L_CODES+2];
  * below).
  */
 
+/*@unchecked@*/
 local ct_data static_dtree[D_CODES];
 /*!< The static distance tree. (Actually a trivial tree since all codes use
  * 5 bits.)
  */
 
+/*@unchecked@*/
 uch _dist_code[DIST_CODE_LEN];
 /*!< Distance codes. The first 256 values correspond to the distances
  * 3 .. 258, the last 256 values correspond to the top 8 bits of
  * the 15 bit distances.
  */
 
+/*@unchecked@*/
 uch _length_code[MAX_MATCH-MIN_MATCH+1];
 /*!< length code for each normalized match length (0 == MIN_MATCH) */
 
@@ -159,7 +163,8 @@ local static_tree_desc  static_bl_desc =
  */
 
 local void tr_static_init OF((void))
-       /*@*/;
+       /*@globals internalState @*/
+       /*@modifies internalState @*/;
 local void init_block     OF((deflate_state *s))
        /*@modifies *s @*/;
 local void pqdownheap     OF((deflate_state *s, ct_data *tree, int k))
@@ -190,8 +195,8 @@ local void bi_windup      OF((deflate_state *s))
        /*@modifies *s @*/;
 local void bi_flush       OF((deflate_state *s))
        /*@modifies *s @*/;
-local void copy_block     OF((deflate_state *s, charf *buf, unsigned len,
-                              int header))
+local void copy_block     OF((deflate_state *s, /*@null@*/ charf *buf,
+               unsigned len, int header))
        /*@modifies *s @*/;
 
 #ifdef GEN_TREES_H
index 72facf9..7eab165 100644 (file)
@@ -1,5 +1,6 @@
 /* header created automatically with -DGEN_TREES_H */
 
+/*@observer@*/ /*@unchecked@*/
 local const ct_data static_ltree[L_CODES+2] = {
 {{ 12},{  8}}, {{140},{  8}}, {{ 76},{  8}}, {{204},{  8}}, {{ 44},{  8}},
 {{172},{  8}}, {{108},{  8}}, {{236},{  8}}, {{ 28},{  8}}, {{156},{  8}},
@@ -61,6 +62,7 @@ local const ct_data static_ltree[L_CODES+2] = {
 {{163},{  8}}, {{ 99},{  8}}, {{227},{  8}}
 };
 
+/*@observer@*/ /*@unchecked@*/
 local const ct_data static_dtree[D_CODES] = {
 {{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}},
 {{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}},
@@ -70,6 +72,7 @@ local const ct_data static_dtree[D_CODES] = {
 {{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
 };
 
+/*@observer@*/ /*@unchecked@*/
 const uch _dist_code[DIST_CODE_LEN] = {
  0,  1,  2,  3,  4,  4,  5,  5,  6,  6,  6,  6,  7,  7,  7,  7,  8,  8,  8,  8,
  8,  8,  8,  8,  9,  9,  9,  9,  9,  9,  9,  9, 10, 10, 10, 10, 10, 10, 10, 10,
@@ -99,6 +102,7 @@ const uch _dist_code[DIST_CODE_LEN] = {
 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
 };
 
+/*@observer@*/ /*@unchecked@*/
 const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {
  0,  1,  2,  3,  4,  5,  6,  7,  8,  8,  9,  9, 10, 10, 11, 11, 12, 12, 12, 12,
 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
@@ -115,11 +119,13 @@ const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {
 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
 };
 
+/*@observer@*/ /*@unchecked@*/
 local const int base_length[LENGTH_CODES] = {
 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
 64, 80, 96, 112, 128, 160, 192, 224, 0
 };
 
+/*@observer@*/ /*@unchecked@*/
 local const int base_dist[D_CODES] = {
     0,     1,     2,     3,     4,     6,     8,    12,    16,    24,
    32,    48,    64,    96,   128,   192,   256,   384,   512,   768,
index 49d0904..05d5594 100644 (file)
@@ -69,20 +69,26 @@ typedef void   (*free_func)  OF((voidpf opaque, voidpf address))
 struct internal_state;
 
 typedef struct z_stream_s {
+/*@null@*/
     Bytef    *next_in;  /* next input byte */
     uInt     avail_in;  /* number of bytes available at next_in */
     uLong    total_in;  /* total nb of input bytes read so far */
 
+/*@null@*/
     Bytef    *next_out; /* next output byte should be put there */
     uInt     avail_out; /* remaining free space at next_out */
     uLong    total_out; /* total nb of bytes output so far */
 
-/*@observer@*/
+/*@observer@*/ /*@null@*/
     char     *msg;      /* last error message, NULL if no error */
+/*@null@*/
     struct internal_state FAR *state; /* not visible by applications */
 
+/*@null@*/
     alloc_func zalloc;  /* used to allocate the internal state */
+/*@null@*/
     free_func  zfree;   /* used to free the internal state */
+/*@null@*/
     voidpf     opaque;  /* private data object passed to zalloc and zfree */
 
     int     data_type;  /* best guess about the data type: ascii or binary */
@@ -507,7 +513,8 @@ ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
 */
 
 ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm))
-       /*@modifies strm @*/;
+       /*@globals internalState @*/
+       /*@modifies strm, internalState @*/;
 /*
      This function is equivalent to deflateEnd followed by deflateInit,
    but does not free and reallocate all the internal compression state.
@@ -741,7 +748,8 @@ ZEXTERN int ZEXPORT inflateBackEnd(z_stream FAR *strm)
 
 ZEXTERN int ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,
                                  const Bytef *source, uLong sourceLen))
-       /*@modifies *dest, *destLen @*/;
+       /*@globals internalState @*/
+       /*@modifies *dest, *destLen, internalState @*/;
 /*
      Compresses the source buffer into the destination buffer.  sourceLen is
    the byte length of the source buffer. Upon entry, destLen is the total
@@ -758,7 +766,8 @@ ZEXTERN int ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,
 ZEXTERN int ZEXPORT compress2 OF((Bytef *dest,   uLongf *destLen,
                                   const Bytef *source, uLong sourceLen,
                                   int level))
-       /*@modifies *dest, *destLen @*/;
+       /*@globals internalState @*/
+       /*@modifies *dest, *destLen, internalState @*/;
 /*
      Compresses the source buffer into the destination buffer. The level
    parameter has the same meaning as in deflateInit.  sourceLen is the byte
@@ -794,8 +803,8 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,
 typedef voidp gzFile;
 
 ZEXTERN gzFile ZEXPORT gzopen  OF((const char *path, const char *mode))
-       /*@globals fileSystem @*/
-       /*@modifies fileSystem @*/;
+       /*@globals fileSystem, internalState @*/
+       /*@modifies fileSystem, internalState @*/;
 /*
      Opens a gzip (.gz) file for reading or writing. The mode parameter
    is as in fopen ("rb" or "wb") but can also include a compression level
@@ -812,8 +821,8 @@ ZEXTERN gzFile ZEXPORT gzopen  OF((const char *path, const char *mode))
    zlib error is Z_MEM_ERROR).  */
 
 ZEXTERN gzFile ZEXPORT gzdopen  OF((int fd, const char *mode))
-       /*@globals fileSystem @*/
-       /*@modifies fileSystem @*/;
+       /*@globals fileSystem, internalState @*/
+       /*@modifies fileSystem, internalState @*/;
 /*
      gzdopen() associates a gzFile with the file descriptor fd.  File
    descriptors are obtained from calls like open, dup, creat, pipe or
@@ -987,7 +996,8 @@ ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum))
    compression library.
 */
 
-ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len))
+ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, /*@null@*/ const Bytef *buf,
+               uInt len))
        /*@*/;
 
 /*
@@ -1005,7 +1015,8 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len))
      if (adler != original_adler) error();
 */
 
-ZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len))
+ZEXTERN uLong ZEXPORT crc32   OF((uLong crc, /*@null@*/ const Bytef *buf,
+               uInt len))
        /*@*/;
 /*
      Update a running crc with the bytes buf[0..len-1] and return the updated
@@ -1030,7 +1041,8 @@ ZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len))
  */
 ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
                                      const char *version, int stream_size))
-       /*@modifies strm @*/;
+       /*@globals internalState @*/
+       /*@modifies strm, internalState @*/;
 ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
                                      const char *version, int stream_size))
        /*@modifies strm @*/;
@@ -1038,7 +1050,8 @@ ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int  level, int  method,
                                       int windowBits, int memLevel,
                                       int strategy, const char *version,
                                       int stream_size))
-       /*@modifies strm @*/;
+       /*@globals internalState @*/
+       /*@modifies strm, internalState @*/;
 ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int  windowBits,
                                       const char *version, int stream_size))
        /*@modifies strm @*/;
index 00740fb..0a6c0c9 100644 (file)
@@ -8,7 +8,7 @@
    subject to change. Applications should only use zlib.h.
  */
 
-/* @(#) $Id: zutil.h,v 1.7 2002/03/17 15:46:23 jbj Exp $ */
+/* @(#) $Id: zutil.h,v 1.8 2002/10/07 09:05:07 jbj Exp $ */
 
 #ifndef _Z_UTIL_H
 #define _Z_UTIL_H
@@ -37,6 +37,7 @@ typedef unsigned short ush;
 typedef ush FAR ushf;
 typedef unsigned long  ulg;
 
+/*@unchecked@*/
 extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
 /* (size given to avoid silly warnings with Visual C++) */