]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
local -> static
authorMika Lindqvist <postmaster@raasu.org>
Sun, 22 Nov 2015 15:15:58 +0000 (17:15 +0200)
committerHans Kristian Rosbach <hk-git@circlestorm.org>
Mon, 30 Jan 2017 09:35:05 +0000 (10:35 +0100)
* local -> static
* Normalize and cleanup line-endings
* Fix warnings under Visual Studio.
* Whitespace cleanup

***
This patch has been edited to merge cleanly and to exclude type changes.
Based on 8d7a7c3b82c6e38734bd504dac800b148ab410d0 "Type Cleanup"

16 files changed:
CMakeLists.txt
arch/x86/crc_folding.c
arch/x86/deflate_quick.c
deflate.c
deflate.h
deflate_p.h
gzguts.h
gzlib.c
gzread.c
gzwrite.c
infback.c
inflate.c
trees.c
trees.h
zlib.h
zutil.h

index 7ca4a2e72318a710bf2fd466b9ea9e2c0a56f410..a099b6cc8433cce361a53e7941935ce032f97773 100644 (file)
@@ -78,6 +78,39 @@ endif()
 # Check for unistd.h
 #
 check_include_file(unistd.h Z_HAVE_UNISTD_H)
+check_include_file(stdarg.h Z_HAVE_STDARG_H)
+
+#
+# Check if we can hide zlib internal symbols that are linked between separate source files
+#
+check_c_source_compiles(
+    "#define ZLIB_INTERNAL __attribute__((visibility (\"hidden\")))
+    int ZLIB_INTERNAL foo;
+    int main()
+    {
+      return 0;
+    }"
+    HAVE_ATTRIBUTE_VISIBILITY_HIDDEN FAIL_REGEX "not supported")
+if(HAVE_ATTRIBUTE_VISIBILITY_HIDDEN)
+    add_definitions(-DHAVE_HIDDEN)
+endif()
+
+#
+# check for __builtin_ctzl() support in the compiler
+#
+check_c_source_compiles(
+    "int main(void)
+    {
+        unsigned int zero = 0;
+        long test = __builtin_ctzl(zero);
+        (void)test;
+        return 0;
+    }"
+    HAVE_BUILTIN_CTZL
+)
+if(HAVE_BUILTIN_CTZL)
+    add_definitions(-DHAVE_BUILTIN_CTZL)
+endif()
 
 if(MSVC)
     set(CMAKE_DEBUG_POSTFIX "d")
index b1fb6ec3a35a7ed52564043b720e2e7eec82e258..957754de5026d19b5e94cbc30560e2548b7a0bdb 100644 (file)
@@ -54,7 +54,7 @@ ZLIB_INTERNAL void crc_fold_init(deflate_state *const s) {
     s->strm->adler = 0;
 }
 
-local void fold_1(deflate_state *const s, __m128i *xmm_crc0, __m128i *xmm_crc1, __m128i *xmm_crc2, __m128i *xmm_crc3) {
+static void fold_1(deflate_state *const s, __m128i *xmm_crc0, __m128i *xmm_crc1, __m128i *xmm_crc2, __m128i *xmm_crc3) {
     const __m128i xmm_fold4 = _mm_set_epi32(
             0x00000001, 0x54442bd4,
             0x00000001, 0xc6e41596);
@@ -77,7 +77,7 @@ local void fold_1(deflate_state *const s, __m128i *xmm_crc0, __m128i *xmm_crc1,
     *xmm_crc3 = _mm_castps_si128(ps_res);
 }
 
-local void fold_2(deflate_state *const s, __m128i *xmm_crc0, __m128i *xmm_crc1, __m128i *xmm_crc2, __m128i *xmm_crc3) {
+static void fold_2(deflate_state *const s, __m128i *xmm_crc0, __m128i *xmm_crc1, __m128i *xmm_crc2, __m128i *xmm_crc3) {
     const __m128i xmm_fold4 = _mm_set_epi32(
             0x00000001, 0x54442bd4,
             0x00000001, 0xc6e41596);
@@ -108,7 +108,7 @@ local void fold_2(deflate_state *const s, __m128i *xmm_crc0, __m128i *xmm_crc1,
     *xmm_crc3 = _mm_castps_si128(ps_res31);
 }
 
-local void fold_3(deflate_state *const s, __m128i *xmm_crc0, __m128i *xmm_crc1, __m128i *xmm_crc2, __m128i *xmm_crc3) {
+static void fold_3(deflate_state *const s, __m128i *xmm_crc0, __m128i *xmm_crc1, __m128i *xmm_crc2, __m128i *xmm_crc3) {
     const __m128i xmm_fold4 = _mm_set_epi32(
             0x00000001, 0x54442bd4,
             0x00000001, 0xc6e41596);
@@ -145,7 +145,7 @@ local void fold_3(deflate_state *const s, __m128i *xmm_crc0, __m128i *xmm_crc1,
     *xmm_crc3 = _mm_castps_si128(ps_res32);
 }
 
-local void fold_4(deflate_state *const s, __m128i *xmm_crc0, __m128i *xmm_crc1, __m128i *xmm_crc2, __m128i *xmm_crc3) {
+static void fold_4(deflate_state *const s, __m128i *xmm_crc0, __m128i *xmm_crc1, __m128i *xmm_crc2, __m128i *xmm_crc3) {
     const __m128i xmm_fold4 = _mm_set_epi32(
             0x00000001, 0x54442bd4,
             0x00000001, 0xc6e41596);
@@ -190,7 +190,7 @@ local void fold_4(deflate_state *const s, __m128i *xmm_crc0, __m128i *xmm_crc1,
     *xmm_crc3 = _mm_castps_si128(ps_res3);
 }
 
-local const unsigned ALIGNED_(32) pshufb_shf_table[60] = {
+static const unsigned ALIGNED_(32) pshufb_shf_table[60] = {
     0x84838281, 0x88878685, 0x8c8b8a89, 0x008f8e8d, /* shl 15 (16 - 1)/shr1 */
     0x85848382, 0x89888786, 0x8d8c8b8a, 0x01008f8e, /* shl 14 (16 - 3)/shr2 */
     0x86858483, 0x8a898887, 0x8e8d8c8b, 0x0201008f, /* shl 13 (16 - 4)/shr3 */
@@ -208,7 +208,7 @@ local const unsigned ALIGNED_(32) pshufb_shf_table[60] = {
     0x0201008f, 0x06050403, 0x0a090807, 0x0e0d0c0b  /* shl  1 (16 -15)/shr15*/
 };
 
-local void partial_fold(deflate_state *const s, const size_t len, __m128i *xmm_crc0, __m128i *xmm_crc1,
+static void partial_fold(deflate_state *const s, const size_t len, __m128i *xmm_crc0, __m128i *xmm_crc1,
         __m128i *xmm_crc2, __m128i *xmm_crc3, __m128i *xmm_crc_part) {
 
     const __m128i xmm_fold4 = _mm_set_epi32(
@@ -378,7 +378,7 @@ done:
     CRC_SAVE(s)
 }
 
-local const unsigned ALIGNED_(16) crc_k[] = {
+static const unsigned ALIGNED_(16) crc_k[] = {
     0xccaa009e, 0x00000000, /* rk1 */
     0x751997d0, 0x00000001, /* rk2 */
     0xccaa009e, 0x00000000, /* rk5 */
@@ -387,11 +387,11 @@ local const unsigned ALIGNED_(16) crc_k[] = {
     0xdb710640, 0x00000001  /* rk8 */
 };
 
-local const unsigned ALIGNED_(16) crc_mask[4] = {
+static const unsigned ALIGNED_(16) crc_mask[4] = {
     0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000
 };
 
-local const unsigned ALIGNED_(16) crc_mask2[4] = {
+static const unsigned ALIGNED_(16) crc_mask2[4] = {
     0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF
 };
 
index b5190d59898411a83d1af594c899ad01e11419cb..68b5ddfa18a021d506fc1e0c76e15c72722c6312 100644 (file)
@@ -22,7 +22,7 @@
 extern void fill_window_sse(deflate_state *s);
 extern void flush_pending(z_stream *strm);
 
-local inline long compare258(const unsigned char *const src0, const unsigned char *const src1) {
+static inline long compare258(const unsigned char *const src0, const unsigned char *const src1) {
 #ifdef _MSC_VER
     long cnt;
 
@@ -111,10 +111,10 @@ local inline long compare258(const unsigned char *const src0, const unsigned cha
 #endif
 }
 
-local const unsigned quick_len_codes[MAX_MATCH-MIN_MATCH+1];
-local const unsigned quick_dist_codes[8192];
+static const unsigned quick_len_codes[MAX_MATCH-MIN_MATCH+1];
+static const unsigned quick_dist_codes[8192];
 
-local inline void quick_send_bits(deflate_state *const s, const int value, const int length) {
+static inline void quick_send_bits(deflate_state *const s, const int value, const int length) {
     unsigned code, out, w, b;
 
     out = s->bi_buf;
@@ -135,7 +135,7 @@ local inline void quick_send_bits(deflate_state *const s, const int value, const
     s->bi_valid = w - (b << 3);
 }
 
-local inline void static_emit_ptr(deflate_state *const s, const int lc, const unsigned dist) {
+static inline void static_emit_ptr(deflate_state *const s, const int lc, const unsigned dist) {
     unsigned code, len;
 
     code = quick_len_codes[lc] >> 8;
@@ -149,12 +149,12 @@ local inline void static_emit_ptr(deflate_state *const s, const int lc, const un
 
 const ct_data static_ltree[L_CODES+2];
 
-local inline void static_emit_lit(deflate_state *const s, const int lit) {
+static inline void static_emit_lit(deflate_state *const s, const int lit) {
     quick_send_bits(s, static_ltree[lit].Code, static_ltree[lit].Len);
     Tracecv(isgraph(lit), (stderr, " '%c' ", lit));
 }
 
-local void static_emit_tree(deflate_state *const s, const int flush) {
+static void static_emit_tree(deflate_state *const s, const int flush) {
     unsigned last;
 
     last = flush == Z_FINISH ? 1 : 0;
@@ -162,7 +162,7 @@ local void static_emit_tree(deflate_state *const s, const int flush) {
 }
 
 
-local void static_emit_end_block(deflate_state *const s, int last) {
+static void static_emit_end_block(deflate_state *const s, int last) {
     send_code(s, END_BLOCK, static_ltree);
 
     if (last)
@@ -172,7 +172,7 @@ local void static_emit_end_block(deflate_state *const s, int last) {
     flush_pending(s->strm);
 }
 
-local inline Pos quick_insert_string(deflate_state *const s, const Pos str) {
+static inline Pos quick_insert_string(deflate_state *const s, const Pos str) {
     Pos ret;
     unsigned h = 0;
 
@@ -252,7 +252,7 @@ ZLIB_INTERNAL block_state deflate_quick(deflate_state *s, int flush) {
     return block_done;
 }
 
-local const unsigned quick_len_codes[MAX_MATCH-MIN_MATCH+1] = {
+static const unsigned quick_len_codes[MAX_MATCH-MIN_MATCH+1] = {
     0x00004007, 0x00002007, 0x00006007, 0x00001007,
     0x00005007, 0x00003007, 0x00007007, 0x00000807,
     0x00004808, 0x0000c808, 0x00002808, 0x0000a808,
@@ -319,7 +319,7 @@ local const unsigned quick_len_codes[MAX_MATCH-MIN_MATCH+1] = {
     0x001c230d, 0x001d230d, 0x001e230d, 0x0000a308,
 };
 
-local const unsigned quick_dist_codes[8192] = {
+static const unsigned quick_dist_codes[8192] = {
     0x00000005, 0x00001005, 0x00000805, 0x00001805,
     0x00000406, 0x00002406, 0x00001406, 0x00003406,
     0x00000c07, 0x00002c07, 0x00004c07, 0x00006c07,
index fb2756717774a390c49f5d95ef27a47e0b4ceb1c..20a09707475fd4548bb1ba3fcaf2f06c87b5bbfc 100644 (file)
--- a/deflate.c
+++ b/deflate.c
@@ -69,17 +69,17 @@ typedef block_state (*compress_func) (deflate_state *s, int flush);
 /* Compression function. Returns the block state after the call. */
 
 void fill_window                 (deflate_state *s);
-local block_state deflate_stored (deflate_state *s, int flush);
+static block_state deflate_stored (deflate_state *s, int flush);
 block_state deflate_fast         (deflate_state *s, int flush);
 block_state deflate_quick        (deflate_state *s, int flush);
 #ifdef MEDIUM_STRATEGY
 block_state deflate_medium       (deflate_state *s, int flush);
 #endif
 block_state deflate_slow         (deflate_state *s, int flush);
-local block_state deflate_rle    (deflate_state *s, int flush);
-local block_state deflate_huff   (deflate_state *s, int flush);
-local void lm_init               (deflate_state *s);
-local void putShortMSB           (deflate_state *s, uint16_t b);
+static block_state deflate_rle   (deflate_state *s, int flush);
+static block_state deflate_huff  (deflate_state *s, int flush);
+static void lm_init              (deflate_state *s);
+static void putShortMSB          (deflate_state *s, uint16_t b);
 ZLIB_INTERNAL void flush_pending (z_stream *strm);
 ZLIB_INTERNAL int read_buf       (z_stream *strm, unsigned char *buf, unsigned size);
 
@@ -107,7 +107,7 @@ typedef struct config_s {
     compress_func func;
 } config;
 
-local const config configuration_table[10] = {
+static const config configuration_table[10] = {
 /*      good lazy nice chain */
 /* 0 */ {0,    0,  0,    0, deflate_stored},  /* store only */
 
@@ -541,7 +541,7 @@ unsigned long ZEXPORT deflateBound(z_stream *strm, unsigned long sourceLen) {
  * IN assertion: the stream state is correct and there is enough room in
  * pending_buf.
  */
-local void putShortMSB(deflate_state *s, uint16_t b) {
+static void putShortMSB(deflate_state *s, uint16_t b) {
     put_byte(s, (unsigned char)(b >> 8));
     put_byte(s, (unsigned char)(b & 0xff));
 }
@@ -997,7 +997,7 @@ ZLIB_INTERNAL int read_buf(z_stream *strm, unsigned char *buf, unsigned size) {
 /* ===========================================================================
  * Initialize the "longest match" routines for a new zlib stream
  */
-local void lm_init(deflate_state *s) {
+static void lm_init(deflate_state *s) {
     s->window_size = (unsigned long)2L*s->w_size;
 
     CLEAR_HASH(s);
@@ -1241,7 +1241,7 @@ void fill_window_c(deflate_state *s) {
  * NOTE: this function should be optimized to avoid extra copying from
  * window to pending_buf.
  */
-local block_state deflate_stored(deflate_state *s, int flush) {
+static block_state deflate_stored(deflate_state *s, int flush) {
     /* Stored blocks are limited to 0xffff bytes, pending_buf is limited
      * to pending_buf_size, and each stored block has a 5 byte header:
      */
@@ -1301,7 +1301,7 @@ local block_state deflate_stored(deflate_state *s, int flush) {
  * one.  Do not maintain a hash table.  (It will be regenerated if this run of
  * deflate switches away from Z_RLE.)
  */
-local block_state deflate_rle(deflate_state *s, int flush) {
+static block_state deflate_rle(deflate_state *s, int flush) {
     int bflush;                     /* set if current block must be flushed */
     unsigned int prev;              /* byte at distance one to match */
     unsigned char *scan, *strend;   /* scan goes up to strend for length of run */
@@ -1373,7 +1373,7 @@ local block_state deflate_rle(deflate_state *s, int flush) {
  * For Z_HUFFMAN_ONLY, do not look for matches.  Do not maintain a hash table.
  * (It will be regenerated if this run of deflate switches away from Huffman.)
  */
-local block_state deflate_huff(deflate_state *s, int flush) {
+static block_state deflate_huff(deflate_state *s, int flush) {
     int bflush;             /* set if current block must be flushed */
 
     for (;;) {
index 2d3202641d8d97056487f8936826e0e277989eb0..475bb3104fc5a40dbc3c8fe7032952fd17661a01 100644 (file)
--- a/deflate.h
+++ b/deflate.h
@@ -87,8 +87,8 @@ typedef struct ct_data_s {
 typedef struct static_tree_desc_s  static_tree_desc;
 
 typedef struct tree_desc_s {
-    ct_data *dyn_tree;           /* the dynamic tree */
-    int     max_code;            /* largest code with non zero frequency */
+    ct_data                *dyn_tree;  /* the dynamic tree */
+    int                    max_code;   /* largest code with non zero frequency */
     const static_tree_desc *stat_desc; /* the corresponding static tree */
 } tree_desc;
 
index 4b8282d46bcb35a71256ea81d1507dee8f7dc072..d5e315cbd130608692ea5d693493f21bc59422b1 100644 (file)
@@ -36,7 +36,7 @@ void flush_pending(z_stream *strm);
 extern Pos insert_string_sse(deflate_state *const s, const Pos str, uInt count);
 #endif
 
-local inline Pos insert_string_c(deflate_state *const s, const Pos str, uInt count) {
+static inline Pos insert_string_c(deflate_state *const s, const Pos str, uInt count) {
     Pos ret = 0;
     uInt idx;
 
@@ -51,7 +51,7 @@ local inline Pos insert_string_c(deflate_state *const s, const Pos str, uInt cou
     return ret;
 }
 
-local inline Pos insert_string(deflate_state *const s, const Pos str) {
+static inline Pos insert_string(deflate_state *const s, const Pos str) {
 #ifdef X86_SSE4_2_CRC_HASH
     if (x86_cpu_has_sse42)
         return insert_string_sse(s, str, 1);
@@ -60,7 +60,7 @@ local inline Pos insert_string(deflate_state *const s, const Pos str) {
 }
 
 #ifndef NOT_TWEAK_COMPILER
-local inline void bulk_insert_str(deflate_state *const s, Pos startpos, uInt count) {
+static inline void bulk_insert_str(deflate_state *const s, Pos startpos, uInt count) {
 # ifdef X86_SSE4_2_CRC_HASH
     if (x86_cpu_has_sse42) {
         insert_string_sse(s, startpos, count);
index 0921f176abfeef40d549b5f8d06ce24e5e376394..e075bfac94c792d16810e416ea15f66ed8a06b25 100644 (file)
--- a/gzguts.h
+++ b/gzguts.h
 #  define snprintf _snprintf
 #endif
 
-#ifndef local
-#  define local static
-#endif
-/* compile with -Dlocal if your debugger can't find static symbols */
-
 /* get errno and strerror definition */
 #ifndef NO_STRERROR
 #  include <errno.h>
diff --git a/gzlib.c b/gzlib.c
index e5ebe5fa7fa0beac3218f8f8a7f66f5a5e69e61f..c0f05d58565177ef15c65116df12185cdb62e839 100644 (file)
--- a/gzlib.c
+++ b/gzlib.c
 #endif
 
 /* Local functions */
-local void gz_reset(gz_statep);
-local gzFile gz_open(const void *, int, const char *);
+static void gz_reset(gz_statep);
+static gzFile gz_open(const void *, int, const char *);
 
 /* Reset gzip file state */
-local void gz_reset(gz_statep state) {
+static void gz_reset(gz_statep state) {
     state->x.have = 0;              /* no output data available */
     if (state->mode == GZ_READ) {   /* for reading ... */
         state->eof = 0;             /* not at end of file */
@@ -34,7 +34,7 @@ local void gz_reset(gz_statep state) {
 }
 
 /* Open a gzip file either by name or file descriptor. */
-local gzFile gz_open(const void *path, int fd, const char *mode) {
+static gzFile gz_open(const void *path, int fd, const char *mode) {
     gz_statep state;
     size_t len;
     int oflag;
index 5db2c5045baf6950ff58402dbe68fb516e106cc2..140553336f0441de98e97015ea72c468e4102c62 100644 (file)
--- a/gzread.c
+++ b/gzread.c
@@ -6,18 +6,18 @@
 #include "gzguts.h"
 
 /* Local functions */
-local int gz_load(gz_statep, unsigned char *, unsigned, unsigned *);
-local int gz_avail(gz_statep);
-local int gz_look(gz_statep);
-local int gz_decomp(gz_statep);
-local int gz_fetch(gz_statep);
-local int gz_skip(gz_statep, z_off64_t);
+static int gz_load(gz_statep, unsigned char *, unsigned, unsigned *);
+static int gz_avail(gz_statep);
+static int gz_look(gz_statep);
+static int gz_decomp(gz_statep);
+static int gz_fetch(gz_statep);
+static int gz_skip(gz_statep, z_off64_t);
 
 /* Use read() to load a buffer -- return -1 on error, otherwise 0.  Read from
    state->fd, and update state->eof, state->err, and state->msg as appropriate.
    This function needs to loop on read(), since read() is not guaranteed to
    read the number of bytes requested, depending on the type of descriptor. */
-local int gz_load(gz_statep state, unsigned char *buf, unsigned len, unsigned *have) {
+static int gz_load(gz_statep state, unsigned char *buf, unsigned len, unsigned *have) {
     int ret;
 
     *have = 0;
@@ -43,7 +43,7 @@ local int gz_load(gz_statep state, unsigned char *buf, unsigned len, unsigned *h
    If strm->avail_in != 0, then the current data is moved to the beginning of
    the input buffer, and then the remainder of the buffer is loaded with the
    available data from the input file. */
-local int gz_avail(gz_statep state) {
+static int gz_avail(gz_statep state) {
     unsigned got;
     z_stream *strm = &(state->strm);
 
@@ -75,7 +75,7 @@ local int gz_avail(gz_statep state) {
    case, all further file reads will be directly to either the output buffer or
    a user buffer.  If decompressing, the inflate state will be initialized.
    gz_look() will return 0 on success or -1 on failure. */
-local int gz_look(gz_statep state) {
+static int gz_look(gz_statep state) {
     z_stream *strm = &(state->strm);
 
     /* allocate read buffers and inflate memory */
@@ -159,7 +159,7 @@ local int gz_look(gz_statep state) {
    data.  If the gzip stream completes, state->how is reset to LOOK to look for
    the next gzip stream or raw data, once state->x.have is depleted.  Returns 0
    on success, -1 on failure. */
-local int gz_decomp(gz_statep state) {
+static int gz_decomp(gz_statep state) {
     int ret = Z_OK;
     unsigned had;
     z_stream *strm = &(state->strm);
@@ -209,7 +209,7 @@ local int gz_decomp(gz_statep state) {
    looked for to determine whether to copy or decompress.  Returns -1 on error,
    otherwise 0.  gz_fetch() will leave state->how as COPY or GZIP unless the
    end of the input file has been reached and all data has been processed.  */
-local int gz_fetch(gz_statep state) {
+static int gz_fetch(gz_statep state) {
     z_stream *strm = &(state->strm);
 
     do {
@@ -237,7 +237,7 @@ local int gz_fetch(gz_statep state) {
 }
 
 /* Skip len uncompressed bytes of output.  Return -1 on error, 0 on success. */
-local int gz_skip(gz_statep state, z_off64_t len) {
+static int gz_skip(gz_statep state, z_off64_t len) {
     unsigned n;
 
     /* skip over len bytes or reach end-of-file, whichever comes first */
index dedaee0cd45e94e53c76cf6b2a945884b8702b32..6ef2242aad2b70589806c94130c9640407121c98 100644 (file)
--- a/gzwrite.c
+++ b/gzwrite.c
@@ -7,13 +7,13 @@
 #include "gzguts.h"
 
 /* Local functions */
-local int gz_init(gz_statep);
-local int gz_comp(gz_statep, int);
-local int gz_zero(gz_statep, z_off64_t);
+static int gz_init(gz_statep);
+static int gz_comp(gz_statep, int);
+static int gz_zero(gz_statep, z_off64_t);
 
 /* Initialize state for writing a gzip file.  Mark initialization by setting
    state->size to non-zero.  Return -1 on failure or 0 on success. */
-local int gz_init(gz_statep state) {
+static int gz_init(gz_statep state) {
     int ret;
     z_stream *strm = &(state->strm);
 
@@ -66,7 +66,7 @@ local int gz_init(gz_statep state) {
    then the deflate() state is reset to start a new gzip stream.  If gz->direct
    is true, then simply write to the output file without compressing, and
    ignore flush. */
-local int gz_comp(gz_statep state, int flush) {
+static int gz_comp(gz_statep state, int flush) {
     int ret, got;
     unsigned have;
     z_stream *strm = &(state->strm);
@@ -126,7 +126,7 @@ local int gz_comp(gz_statep state, int flush) {
 }
 
 /* Compress len zeros to output.  Return -1 on error, 0 on success. */
-local int gz_zero(gz_statep state, z_off64_t len) {
+static int gz_zero(gz_statep state, z_off64_t len) {
     int first;
     unsigned n;
     z_stream *strm = &(state->strm);
index 9f3dc4645e8052f09643c38c288d1b9760565a3f..01b782f568c2c11ec6b509033f83a3a1d4271577 100644 (file)
--- a/infback.c
+++ b/infback.c
@@ -16,7 +16,7 @@
 #include "inffast.h"
 
 /* function prototypes */
-local void fixedtables(struct inflate_state *state);
+static void fixedtables(struct inflate_state *state);
 
 /*
    strm provides memory allocation functions in zalloc and zfree, or
@@ -64,7 +64,7 @@ int ZEXPORT inflateBackInit_(z_stream *strm, int windowBits, unsigned char *wind
    used for threaded applications, since the rewriting of the tables and virgin
    may not be thread-safe.
  */
-local void fixedtables(struct inflate_state *state) {
+static void fixedtables(struct inflate_state *state) {
 #ifdef BUILDFIXED
     static int virgin = 1;
     static code *lenfix, *distfix;
index 8d4a992f957690b8a6f109f3c87c1ed7e69c96a5..3ea438702b19b9f1490828c28440bb10b8e2bd1c 100644 (file)
--- a/inflate.c
+++ b/inflate.c
 #endif
 
 /* function prototypes */
-local void fixedtables(struct inflate_state *state);
-local int updatewindow(z_stream *strm, const unsigned char *end, uint32_t copy);
+static void fixedtables(struct inflate_state *state);
+static int updatewindow(z_stream *strm, const unsigned char *end, uint32_t copy);
 #ifdef BUILDFIXED
     void makefixed(void);
 #endif
-local uint32_t syncsearch(uint32_t *have, const unsigned char *buf, uint32_t len);
+static uint32_t syncsearch(uint32_t *have, const unsigned char *buf, uint32_t len);
 
 int ZEXPORT inflateResetKeep(z_stream *strm) {
     struct inflate_state *state;
@@ -232,7 +232,7 @@ int ZEXPORT inflatePrime(z_stream *strm, int bits, int value) {
    used for threaded applications, since the rewriting of the tables and virgin
    may not be thread-safe.
  */
-local void fixedtables(struct inflate_state *state) {
+static void fixedtables(struct inflate_state *state) {
 #ifdef BUILDFIXED
     static int virgin = 1;
     static code *lenfix, *distfix;
@@ -350,7 +350,7 @@ void makefixed(void) {
    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(z_stream *strm, const unsigned char *end, uint32_t copy) {
+static int updatewindow(z_stream *strm, const unsigned char *end, uint32_t copy) {
     struct inflate_state *state;
     uint32_t dist;
 
@@ -1316,7 +1316,7 @@ int ZEXPORT inflateGetHeader(z_stream *strm, gz_headerp head) {
    called again with more data and the *have state.  *have is initialized to
    zero for the first call.
  */
-local unsigned syncsearch(uint32_t *have, const unsigned char *buf, uint32_t len) {
+static unsigned syncsearch(uint32_t *have, const unsigned char *buf, uint32_t len) {
     uint32_t got;
     uint32_t next;
 
diff --git a/trees.c b/trees.c
index ee756fc5a25c83c9648631ae554a51a216b9f270..b55ccdf6833c9f583be2081059b9bb15979b49e2 100644 (file)
--- a/trees.c
+++ b/trees.c
 #define REPZ_11_138  18
 /* repeat a zero length 11-138 times  (7 bits of repeat count) */
 
-local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
+static const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
     = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0};
 
-local const int extra_dbits[D_CODES] /* extra bits for each distance code */
+static const int extra_dbits[D_CODES] /* extra bits for each distance code */
     = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};
 
-local const int extra_blbits[BL_CODES] /* extra bits for each bit length code */
+static const int extra_blbits[BL_CODES] /* extra bits for each bit length code */
     = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
 
-local const unsigned char bl_order[BL_CODES]
+static const unsigned char bl_order[BL_CODES]
     = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
 /* The lengths of the bit length codes are sent in order of decreasing
  * probability, to avoid transmitting the lengths for unused bit length codes.
@@ -87,24 +87,24 @@ ZLIB_INTERNAL ct_data static_ltree[L_CODES+2];
  * below).
  */
 
-local ct_data static_dtree[D_CODES];
+static ct_data static_dtree[D_CODES];
 /* The static distance tree. (Actually a trivial tree since all codes use
  * 5 bits.)
  */
 
-uch _dist_code[DIST_CODE_LEN];
+unsigned char _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.
  */
 
-uch _length_code[MAX_MATCH-MIN_MATCH+1];
+unsigned char _length_code[MAX_MATCH-MIN_MATCH+1];
 /* length code for each normalized match length (0 == MIN_MATCH) */
 
-local int base_length[LENGTH_CODES];
+static int base_length[LENGTH_CODES];
 /* First normalized length for each code (0 = MIN_MATCH) */
 
-local int base_dist[D_CODES];
+static int base_dist[D_CODES];
 /* First normalized distance for each code (0 = distance of 1) */
 
 #else
@@ -119,43 +119,43 @@ struct static_tree_desc_s {
     unsigned int   max_length;  /* max bit length for the codes */
 };
 
-local const static_tree_desc  static_l_desc =
+static const static_tree_desc  static_l_desc =
 {static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
 
-local const static_tree_desc  static_d_desc =
+static const static_tree_desc  static_d_desc =
 {static_dtree, extra_dbits, 0,          D_CODES, MAX_BITS};
 
-local const static_tree_desc  static_bl_desc =
+static const static_tree_desc  static_bl_desc =
 {(const ct_data *)0, extra_blbits, 0,   BL_CODES, MAX_BL_BITS};
 
 /* ===========================================================================
  * Local (static) routines in this file.
  */
 
-local void tr_static_init (void);
-local void init_block     (deflate_state *s);
-local void pqdownheap     (deflate_state *s, ct_data *tree, int k);
-local void gen_bitlen     (deflate_state *s, tree_desc *desc);
-local void gen_codes      (ct_data *tree, int max_code, uint16_t *bl_count);
-local void build_tree     (deflate_state *s, tree_desc *desc);
-local void scan_tree      (deflate_state *s, ct_data *tree, int max_code);
-local void send_tree      (deflate_state *s, ct_data *tree, int max_code);
-local int  build_bl_tree  (deflate_state *s);
-local void send_all_trees (deflate_state *s, int lcodes, int dcodes, int blcodes);
-local void compress_block (deflate_state *s, const ct_data *ltree, const ct_data *dtree);
-local int  detect_data_type (deflate_state *s);
-local unsigned bi_reverse (unsigned value, int length);
-local void bi_flush       (deflate_state *s);
-local void copy_block     (deflate_state *s, char *buf, unsigned len, int header);
+static void tr_static_init   (void);
+static void init_block       (deflate_state *s);
+static void pqdownheap       (deflate_state *s, ct_data *tree, int k);
+static void gen_bitlen       (deflate_state *s, tree_desc *desc);
+static void gen_codes        (ct_data *tree, int max_code, uint16_t *bl_count);
+static void build_tree       (deflate_state *s, tree_desc *desc);
+static void scan_tree        (deflate_state *s, ct_data *tree, int max_code);
+static void send_tree        (deflate_state *s, ct_data *tree, int max_code);
+static int  build_bl_tree    (deflate_state *s);
+static void send_all_trees   (deflate_state *s, int lcodes, int dcodes, int blcodes);
+static void compress_block   (deflate_state *s, const ct_data *ltree, const ct_data *dtree);
+static int  detect_data_type (deflate_state *s);
+static unsigned bi_reverse   (unsigned value, int length);
+static void bi_flush         (deflate_state *s);
+static void copy_block       (deflate_state *s, char *buf, unsigned len, int header);
 
 #ifdef GEN_TREES_H
-local void gen_trees_header(void);
+static void gen_trees_header (void);
 #endif
 
 /* ===========================================================================
  * Initialize the various 'constant' tables.
  */
-local void tr_static_init(void) {
+static void tr_static_init(void) {
 #if defined(GEN_TREES_H)
     static int static_init_done = 0;
     int n;        /* iterates over tree elements */
@@ -262,7 +262,7 @@ void gen_trees_header() {
         fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code, static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5));
     }
 
-    fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n");
+    fprintf(header, "static const ct_data static_dtree[D_CODES] = {\n");
     for (i = 0; i < D_CODES; i++) {
         fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code, static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5));
     }
@@ -277,12 +277,12 @@ void gen_trees_header() {
         fprintf(header, "%2u%s", _length_code[i], SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20));
     }
 
-    fprintf(header, "local const int base_length[LENGTH_CODES] = {\n");
+    fprintf(header, "static const int base_length[LENGTH_CODES] = {\n");
     for (i = 0; i < LENGTH_CODES; i++) {
         fprintf(header, "%d%s", base_length[i], SEPARATOR(i, LENGTH_CODES-1, 20));
     }
 
-    fprintf(header, "local const int base_dist[D_CODES] = {\n");
+    fprintf(header, "static const int base_dist[D_CODES] = {\n");
     for (i = 0; i < D_CODES; i++) {
         fprintf(header, "%5d%s", base_dist[i], SEPARATOR(i, D_CODES-1, 10));
     }
@@ -320,7 +320,7 @@ void ZLIB_INTERNAL _tr_init(deflate_state *s) {
 /* ===========================================================================
  * Initialize a new block.
  */
-local void init_block(deflate_state *s) {
+static void init_block(deflate_state *s) {
     int n; /* iterates over tree elements */
 
     /* Initialize the trees. */
@@ -365,7 +365,7 @@ local void init_block(deflate_state *s) {
  * when the heap property is re-established (each father smaller than its
  * two sons).
  */
-local void pqdownheap(deflate_state *s, ct_data *tree, int k) {
+static void pqdownheap(deflate_state *s, ct_data *tree, int k) {
     /* tree: the tree to restore */
     /* k: node to move down */
     int v = s->heap[k];
@@ -399,7 +399,7 @@ local void pqdownheap(deflate_state *s, ct_data *tree, int k) {
  *     The length opt_len is updated; static_len is also updated if stree is
  *     not null.
  */
-local void gen_bitlen(deflate_state *s, tree_desc *desc) {
+static void gen_bitlen(deflate_state *s, tree_desc *desc) {
     /* desc: the tree descriptor */
     ct_data *tree           = desc->dyn_tree;
     int max_code            = desc->max_code;
@@ -491,7 +491,7 @@ local void gen_bitlen(deflate_state *s, tree_desc *desc) {
  * OUT assertion: the field code is set for all tree elements of non
  *     zero code length.
  */
-local void gen_codes(ct_data *tree, int max_code, uint16_t *bl_count) {
+static void gen_codes(ct_data *tree, int max_code, uint16_t *bl_count) {
     /* tree: the tree to decorate */
     /* max_code: largest code with non zero frequency */
     /* bl_count: number of codes at each bit length */
@@ -532,7 +532,7 @@ local void gen_codes(ct_data *tree, int max_code, uint16_t *bl_count) {
  *     and corresponding code. The length opt_len is updated; static_len is
  *     also updated if stree is not null. The field max_code is set.
  */
-local void build_tree(deflate_state *s, tree_desc *desc) {
+static void build_tree(deflate_state *s, tree_desc *desc) {
     /* desc: the tree descriptor */
     ct_data *tree         = desc->dyn_tree;
     const ct_data *stree  = desc->stat_desc->static_tree;
@@ -620,7 +620,7 @@ local void build_tree(deflate_state *s, tree_desc *desc) {
  * Scan a literal or distance tree to determine the frequencies of the codes
  * in the bit length tree.
  */
-local void scan_tree(deflate_state *s, ct_data *tree, int max_code) {
+static void scan_tree(deflate_state *s, ct_data *tree, int max_code) {
     /* tree: the tree to be scanned */
     /* max_code: and its largest code of non zero frequency */
     int n;                     /* iterates over all tree elements */
@@ -668,7 +668,7 @@ local void scan_tree(deflate_state *s, ct_data *tree, int max_code) {
  * Send a literal or distance tree in compressed form, using the codes in
  * bl_tree.
  */
-local void send_tree(deflate_state *s, ct_data *tree, int max_code) {
+static void send_tree(deflate_state *s, ct_data *tree, int max_code) {
     /* tree: the tree to be scanned */
     /* max_code and its largest code of non zero frequency */
     int n;                     /* iterates over all tree elements */
@@ -726,7 +726,7 @@ local void send_tree(deflate_state *s, ct_data *tree, int max_code) {
  * Construct the Huffman tree for the bit lengths and return the index in
  * bl_order of the last bit length code to send.
  */
-local int build_bl_tree(deflate_state *s) {
+static int build_bl_tree(deflate_state *s) {
     int max_blindex;  /* index of last bit length code of non zero freq */
 
     /* Determine the bit length frequencies for literal and distance trees */
@@ -759,7 +759,7 @@ local int build_bl_tree(deflate_state *s) {
  * lengths of the bit length codes, the literal tree and the distance tree.
  * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
  */
-local void send_all_trees(deflate_state *s, int lcodes, int dcodes, int blcodes) {
+static void send_all_trees(deflate_state *s, int lcodes, int dcodes, int blcodes) {
     int rank;                    /* index in bl_order */
 
     Assert(lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
@@ -961,7 +961,7 @@ int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc) {
 /* ===========================================================================
  * Send the block data compressed using the given Huffman trees
  */
-local void compress_block(deflate_state *s, const ct_data *ltree, const ct_data *dtree) {
+static void compress_block(deflate_state *s, const ct_data *ltree, const ct_data *dtree) {
     /* ltree: literal tree */
     /* dtree: distance tree */
     unsigned dist;      /* distance of matched string */
@@ -1019,7 +1019,7 @@ local void compress_block(deflate_state *s, const ct_data *ltree, const ct_data
  *   (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).
  * IN assertion: the fields Freq of dyn_ltree are set.
  */
-local int detect_data_type(deflate_state *s) {
+static int detect_data_type(deflate_state *s) {
     /* black_mask is the bit mask of black-listed bytes
      * set bits 0..6, 14..25, and 28..31
      * 0xf3ffc07f = binary 11110011111111111100000001111111
@@ -1050,7 +1050,7 @@ local int detect_data_type(deflate_state *s) {
  * method would use a table)
  * IN assertion: 1 <= len <= 15
  */
-local unsigned bi_reverse(unsigned code, int len) {
+static unsigned bi_reverse(unsigned code, int len) {
     /* code: the value to invert */
     /* len: its bit length */
     register unsigned res = 0;
@@ -1064,7 +1064,7 @@ local unsigned bi_reverse(unsigned code, int len) {
 /* ===========================================================================
  * Flush the bit buffer, keeping at most 7 bits in it.
  */
-local void bi_flush(deflate_state *s) {
+static void bi_flush(deflate_state *s) {
     if (s->bi_valid == 16) {
         put_short(s, s->bi_buf);
         s->bi_buf = 0;
@@ -1096,7 +1096,7 @@ ZLIB_INTERNAL void bi_windup(deflate_state *s) {
  * Copy a stored block, storing first the length and its
  * one's complement if requested.
  */
-local void copy_block(deflate_state *s, char *buf, unsigned len, int header) {
+static void copy_block(deflate_state *s, char *buf, unsigned len, int header) {
     /* buf: the input data */
     /* len: its length */
     /* header: true if block header must be written */
diff --git a/trees.h b/trees.h
index debfbdd85840eacbeb91fcb43c9ac19a12ae43b4..6fc1c8485421d1da9cd88123f3287676c92d1610 100644 (file)
--- a/trees.h
+++ b/trees.h
@@ -64,7 +64,7 @@ ZLIB_INTERNAL const ct_data static_ltree[L_CODES+2] = {
 {{163},{  8}}, {{ 99},{  8}}, {{227},{  8}}
 };
 
-local const ct_data static_dtree[D_CODES] = {
+static 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}},
 {{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}},
@@ -118,12 +118,12 @@ const unsigned char ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {
 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
 };
 
-local const int base_length[LENGTH_CODES] = {
+static 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
 };
 
-local const int base_dist[D_CODES] = {
+static 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,
  1024,  1536,  2048,  3072,  4096,  6144,  8192, 12288, 16384, 24576
diff --git a/zlib.h b/zlib.h
index 3a1cbb2f05b001791f8ae8a5900c40be75ed4b27..774726242641968ab584aeba67f3d084e1a23306 100644 (file)
--- a/zlib.h
+++ b/zlib.h
@@ -953,7 +953,7 @@ ZEXTERN long ZEXPORT inflateMark(z_stream *strm);
    location in the input stream can be determined from avail_in and data_type
    as noted in the description for the Z_BLOCK flush parameter for inflate.
 
-     inflateMark returns the value noted above or -65536 if the provided
+     inflateMark returns the value noted above or -1 << 16 if the provided
    source stream state was inconsistent.
 */
 
diff --git a/zutil.h b/zutil.h
index b6e858c9cd29b70a6813060cb11e7caf5abcb615..0353210ede5a002679f709335b58d5dd910b7135 100644 (file)
--- a/zutil.h
+++ b/zutil.h
 #include <stdint.h>
 #include "zlib.h"
 
-#ifndef local
-#  define local static
-#endif
-/* compile with -Dlocal if your debugger can't find static symbols */
-
 typedef unsigned char uch; /* Included for compatibility with external code only */
 typedef uint16_t ush;      /* Included for compatibility with external code only */
 typedef unsigned long  ulg;