# 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")
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);
*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);
*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);
*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);
*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 */
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(
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 */
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
};
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;
#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;
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;
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;
}
-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)
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;
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,
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,
/* 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);
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 */
* 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));
}
/* ===========================================================================
* 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);
* 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:
*/
* 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 */
* 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 (;;) {
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;
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;
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);
}
#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);
# 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>
#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 */
}
/* 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;
#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;
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);
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 */
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);
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 {
}
/* 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 */
#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);
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);
}
/* 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);
#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
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;
#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;
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;
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;
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;
#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.
* 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
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 */
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));
}
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));
}
/* ===========================================================================
* 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. */
* 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];
* 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;
* 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 */
* 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;
* 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 */
* 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 */
* 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 */
* 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");
/* ===========================================================================
* 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 */
* (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
* 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;
/* ===========================================================================
* 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;
* 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 */
{{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}},
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
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.
*/
#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;