From: Hans Kristian Rosbach Date: Fri, 5 Jun 2015 16:34:42 +0000 (+0200) Subject: Revert "Replace 'unsigned long' with most suitable fixed-size type." X-Git-Tag: 1.9.9-b1~801^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=814535421783abb5d5f95073f528bbf434f192bc;p=thirdparty%2Fzlib-ng.git Revert "Replace 'unsigned long' with most suitable fixed-size type." This commit was cherry-picked and was not done, resulting in a few problems with gcc on 64bit windows. This reverts commit edd7a72e056b994458ff040d4740b16b35336b60. Conflicts: arch/x86/crc_folding.c arch/x86/fill_window_sse.c deflate.c deflate.h match.c trees.c --- diff --git a/arch/x86/crc_folding.c b/arch/x86/crc_folding.c index 0e77223d0..32a37c38f 100644 --- a/arch/x86/crc_folding.c +++ b/arch/x86/crc_folding.c @@ -256,7 +256,7 @@ local void partial_fold(deflate_state *const s, const size_t len, __m128i *xmm_c } ZLIB_INTERNAL void crc_fold_copy(deflate_state *const s, unsigned char *dst, const unsigned char *src, long len) { - uintptr_t algn_diff; + unsigned long algn_diff; __m128i xmm_t0, xmm_t1, xmm_t2, xmm_t3; CRC_LOAD(s) diff --git a/arch/x86/fill_window_sse.c b/arch/x86/fill_window_sse.c index dabe5afb4..b9c79ff50 100644 --- a/arch/x86/fill_window_sse.c +++ b/arch/x86/fill_window_sse.c @@ -18,15 +18,15 @@ extern int read_buf(z_stream *strm, unsigned char *buf, unsigned size); ZLIB_INTERNAL void fill_window_sse(deflate_state *s) { const __m128i xmm_wsize = _mm_set1_epi16(s->w_size); - register uint32_t n; + register unsigned n; register Pos *p; - uint32_t more; /* Amount of free space at the end of the window. */ + unsigned more; /* Amount of free space at the end of the window. */ uInt wsize = s->w_size; Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); do { - more = (uint32_t)(s->window_size -(uint32_t)s->lookahead -(uint32_t)s->strstart); + more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); /* Deal with !@#$% 64K limit: */ if (sizeof(int) <= 2) { @@ -135,8 +135,8 @@ ZLIB_INTERNAL void fill_window_sse(deflate_state *s) { * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. */ if (s->high_water < s->window_size) { - uint32_t curr = s->strstart + (uint32_t)(s->lookahead); - uint32_t init; + ulg curr = s->strstart + (ulg)(s->lookahead); + ulg init; if (s->high_water < curr) { /* Previous high water mark below current data -- zero WIN_INIT @@ -147,12 +147,12 @@ ZLIB_INTERNAL void fill_window_sse(deflate_state *s) { init = WIN_INIT; memset(s->window + curr, 0, (unsigned)init); s->high_water = curr + init; - } else if (s->high_water < curr + WIN_INIT) { + } else if (s->high_water < (ulg)curr + WIN_INIT) { /* High water mark at or above current data, but below current data * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up * to end of window, whichever is less. */ - init = curr + WIN_INIT - s->high_water; + init = (ulg)curr + WIN_INIT - s->high_water; if (init > s->window_size - s->high_water) init = s->window_size - s->high_water; memset(s->window + s->high_water, 0, (unsigned)init); @@ -160,6 +160,6 @@ ZLIB_INTERNAL void fill_window_sse(deflate_state *s) { } } - Assert(s->strstart <= s->window_size - MIN_LOOKAHEAD, "not enough room for search"); + Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, "not enough room for search"); } #endif diff --git a/deflate.c b/deflate.c index 95b92cb51..65ea7537f 100644 --- a/deflate.c +++ b/deflate.c @@ -326,7 +326,7 @@ int ZEXPORT deflateInit2_(z_stream *strm, int level, int method, int windowBits, overlay = (uint16_t *) ZALLOC(strm, s->lit_bufsize, sizeof(uint16_t)+2); s->pending_buf = (unsigned char *) overlay; - s->pending_buf_size = (uint32_t)s->lit_bufsize * (sizeof(uint16_t)+2L); + s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(uint16_t)+2L); if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || s->pending_buf == Z_NULL) { @@ -1076,7 +1076,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) { - s->window_size = (uint32_t)2L*s->w_size; + s->window_size = (ulg)2L*s->w_size; CLEAR_HASH(s); @@ -1155,13 +1155,13 @@ local void fill_window(deflate_state *s) { local void fill_window_c(deflate_state *s) { register unsigned n; register Pos *p; - uint32_t more; /* Amount of free space at the end of the window. */ + unsigned more; /* Amount of free space at the end of the window. */ uInt wsize = s->w_size; Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); do { - more = (uint32_t)(s->window_size -(uint32_t)s->lookahead -(uint32_t)s->strstart); + more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); /* If the window is almost full and there is insufficient lookahead, * move the upper half to the lower one to make room in the upper half. @@ -1281,8 +1281,8 @@ local void fill_window_c(deflate_state *s) { * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. */ if (s->high_water < s->window_size) { - uint32_t curr = s->strstart + (uint32_t)(s->lookahead); - uint32_t init; + ulg curr = s->strstart + (ulg)(s->lookahead); + ulg init; if (s->high_water < curr) { /* Previous high water mark below current data -- zero WIN_INIT @@ -1293,12 +1293,12 @@ local void fill_window_c(deflate_state *s) { init = WIN_INIT; memset(s->window + curr, 0, (unsigned)init); s->high_water = curr + init; - } else if (s->high_water < curr + WIN_INIT) { + } else if (s->high_water < (ulg)curr + WIN_INIT) { /* High water mark at or above current data, but below current data * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up * to end of window, whichever is less. */ - init = curr + WIN_INIT - s->high_water; + init = (ulg)curr + WIN_INIT - s->high_water; if (init > s->window_size - s->high_water) init = s->window_size - s->high_water; memset(s->window + s->high_water, 0, (unsigned)init); @@ -1306,7 +1306,7 @@ local void fill_window_c(deflate_state *s) { } } - Assert(s->strstart <= s->window_size - MIN_LOOKAHEAD, + Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, "not enough room for search"); } @@ -1318,7 +1318,7 @@ local void fill_window_c(deflate_state *s) { _tr_flush_block(s, (s->block_start >= 0L ? \ (char *)&s->window[(unsigned)s->block_start] : \ (char *)Z_NULL), \ - (uint16_t)((int32_t)s->strstart - s->block_start), \ + (ulg)((long)s->strstart - s->block_start), \ (last)); \ s->block_start = s->strstart; \ flush_pending(s->strm); \ @@ -1344,8 +1344,8 @@ local 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: */ - uint32_t max_block_size = 0xffff; - uint32_t max_start; + ulg max_block_size = 0xffff; + ulg max_start; if (max_block_size > s->pending_buf_size - 5) { max_block_size = s->pending_buf_size - 5; @@ -1371,7 +1371,7 @@ local block_state deflate_stored(deflate_state *s, int flush) { /* Emit a stored block if pending_buf will be full: */ max_start = s->block_start + max_block_size; - if (s->strstart == 0 || s->strstart >= max_start) { + if (s->strstart == 0 || (ulg)s->strstart >= max_start) { /* strstart == 0 is possible when wraparound on 16-bit machine */ s->lookahead = (uInt)(s->strstart - max_start); s->strstart = (uInt)max_start; diff --git a/deflate.h b/deflate.h index 7cb315df1..32e65ab61 100644 --- a/deflate.h +++ b/deflate.h @@ -100,17 +100,17 @@ typedef unsigned IPos; */ typedef struct internal_state { - z_stream *strm; /* pointer back to this zlib stream */ - int status; /* as the name implies */ - unsigned char *pending_buf; /* output still pending */ - uint16_t pending_buf_size; /* size of pending_buf */ - unsigned char *pending_out; /* next pending byte to output to the stream */ - uInt pending; /* nb of bytes in the pending buffer */ - int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ - gz_headerp gzhead; /* gzip header information to write */ - uInt gzindex; /* where in extra, name, or comment */ - unsigned char method; /* can only be DEFLATED */ - int last_flush; /* value of flush param for previous deflate call */ + z_stream *strm; /* pointer back to this zlib stream */ + int status; /* as the name implies */ + unsigned char *pending_buf; /* output still pending */ + ulg pending_buf_size; /* size of pending_buf */ + unsigned char *pending_out; /* next pending byte to output to the stream */ + uInt pending; /* nb of bytes in the pending buffer */ + int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ + gz_headerp gzhead; /* gzip header information to write */ + uInt gzindex; /* where in extra, name, or comment */ + unsigned char method; /* can only be DEFLATED */ + int last_flush; /* value of flush param for previous deflate call */ #ifdef X86_PCLMULQDQ_CRC unsigned __attribute__((aligned(16))) crc0[4 * 5]; @@ -132,7 +132,7 @@ typedef struct internal_state { * To do: use the user input buffer as sliding window. */ - uint32_t window_size; + ulg window_size; /* Actual size of window: 2*wSize, except when the user input buffer * is directly used as sliding window. */ @@ -253,14 +253,14 @@ typedef struct internal_state { * array would be necessary. */ - uint32_t opt_len; /* bit length of current block with optimal trees */ - uint32_t static_len; /* bit length of current block with static trees */ - uInt matches; /* number of string matches in current block */ - uInt insert; /* bytes at end of window left to insert */ + ulg opt_len; /* bit length of current block with optimal trees */ + ulg static_len; /* bit length of current block with static trees */ + uInt matches; /* number of string matches in current block */ + uInt insert; /* bytes at end of window left to insert */ #ifdef DEBUG - uint32_t compressed_len; /* total bit length of compressed file mod 2^32 */ - uint32_t bits_sent; /* bit length of compressed data sent mod 2^32 */ + ulg compressed_len; /* total bit length of compressed file mod 2^32 */ + ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ #endif uint16_t bi_buf; @@ -272,7 +272,7 @@ typedef struct internal_state { * are always zero. */ - uint32_t high_water; + ulg high_water; /* High water mark offset in window for initialized bytes -- bytes above * this are set to zero in order to avoid memory check warnings when * longest match routines access bytes past the input. This is then @@ -334,10 +334,10 @@ typedef enum { /* in trees.c */ void ZLIB_INTERNAL _tr_init(deflate_state *s); int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc); -void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, char *buf, uint16_t stored_len, int last); +void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, char *buf, ulg stored_len, int last); void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s); void ZLIB_INTERNAL _tr_align(deflate_state *s); -void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, char *buf, uint16_t stored_len, int last); +void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, char *buf, ulg stored_len, int last); void ZLIB_INTERNAL bi_windup(deflate_state *s); #define d_code(dist) ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) @@ -424,7 +424,7 @@ void ZLIB_INTERNAL bi_windup(deflate_state *s); local void send_bits(deflate_state *s, int value, int length) { Tracevv((stderr, " l %2d v %4x ", length, value)); Assert(length > 0 && length <= 15, "invalid length"); - s->bits_sent += (uint32_t)length; + s->bits_sent += (ulg)length; /* If not enough room in bi_buf, use (valid) bits from bi_buf and * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid)) diff --git a/infback.c b/infback.c index ce5431ae7..e32e63aaf 100644 --- a/infback.c +++ b/infback.c @@ -156,7 +156,7 @@ local void fixedtables(struct inflate_state *state) { do { \ PULL(); \ have--; \ - hold += (uint32_t)(*next++) << bits; \ + hold += (unsigned long)(*next++) << bits; \ bits += 8; \ } while (0) @@ -232,13 +232,13 @@ local void fixedtables(struct inflate_state *state) { */ int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc, out_func out, void *out_desc) { struct inflate_state *state; - const unsigned char *next; /* next input */ - unsigned char *put; /* next output */ + const unsigned char *next; /* next input */ + unsigned char *put; /* next output */ unsigned have, left; /* available input and output */ - uint32_t hold; /* bit buffer */ + unsigned long hold; /* bit buffer */ unsigned bits; /* bits in bit buffer */ unsigned copy; /* number of stored or match bytes to copy */ - unsigned char *from; /* where to copy match bytes from */ + unsigned char *from; /* where to copy match bytes from */ code here; /* current decoding table entry */ code last; /* parent table entry */ unsigned len; /* length to copy for repeats, bits to drop */ diff --git a/inffast.c b/inffast.c index 7c5040eab..b7e72d427 100644 --- a/inffast.c +++ b/inffast.c @@ -76,22 +76,22 @@ void ZLIB_INTERNAL inflate_fast(z_stream *strm, unsigned start) { /* start: inflate()'s starting value for strm->avail_out */ struct inflate_state *state; - const unsigned char *in; /* local strm->next_in */ - const unsigned char *last; /* have enough input while in < last */ - unsigned char *out; /* local strm->next_out */ - unsigned char *beg; /* inflate()'s initial strm->next_out */ - unsigned char *end; /* while out < end, enough space available */ + const unsigned char *in; /* local strm->next_in */ + const unsigned char *last; /* have enough input while in < last */ + unsigned char *out; /* local strm->next_out */ + unsigned char *beg; /* inflate()'s initial strm->next_out */ + unsigned char *end; /* while out < end, enough space available */ #ifdef INFLATE_STRICT unsigned dmax; /* maximum distance from zlib header */ #endif unsigned wsize; /* window size or zero if not using window */ unsigned whave; /* valid bytes in the window */ unsigned wnext; /* window write index */ - unsigned char *window; /* allocated sliding window, if wsize != 0 */ - uint32_t hold; /* local strm->hold */ + unsigned char *window; /* allocated sliding window, if wsize != 0 */ + unsigned long hold; /* local strm->hold */ unsigned bits; /* local strm->bits */ - code const *lcode; /* local strm->lencode */ - code const *dcode; /* local strm->distcode */ + code const *lcode; /* local strm->lencode */ + code const *dcode; /* local strm->distcode */ unsigned lmask; /* mask for first level of length codes */ unsigned dmask; /* mask for first level of distance codes */ code here; /* retrieved table entry */ @@ -126,9 +126,9 @@ void ZLIB_INTERNAL inflate_fast(z_stream *strm, unsigned start) { input data or output space */ do { if (bits < 15) { - hold += (uint32_t)(PUP(in)) << bits; + hold += (unsigned long)(PUP(in)) << bits; bits += 8; - hold += (uint32_t)(PUP(in)) << bits; + hold += (unsigned long)(PUP(in)) << bits; bits += 8; } here = lcode[hold & lmask]; @@ -145,7 +145,7 @@ void ZLIB_INTERNAL inflate_fast(z_stream *strm, unsigned start) { op &= 15; /* number of extra bits */ if (op) { if (bits < op) { - hold += (uint32_t)(PUP(in)) << bits; + hold += (unsigned long)(PUP(in)) << bits; bits += 8; } len += BITS(op); @@ -153,9 +153,9 @@ void ZLIB_INTERNAL inflate_fast(z_stream *strm, unsigned start) { } Tracevv((stderr, "inflate: length %u\n", len)); if (bits < 15) { - hold += (uint32_t)(PUP(in)) << bits; + hold += (unsigned long)(PUP(in)) << bits; bits += 8; - hold += (uint32_t)(PUP(in)) << bits; + hold += (unsigned long)(PUP(in)) << bits; bits += 8; } here = dcode[hold & dmask]; @@ -166,10 +166,10 @@ void ZLIB_INTERNAL inflate_fast(z_stream *strm, unsigned start) { dist = (unsigned)(here.val); op &= 15; /* number of extra bits */ if (bits < op) { - hold += (uint32_t)(PUP(in)) << bits; + hold += (unsigned long)(PUP(in)) << bits; bits += 8; if (bits < op) { - hold += (uint32_t)(PUP(in)) << bits; + hold += (unsigned long)(PUP(in)) << bits; bits += 8; } } diff --git a/inflate.c b/inflate.c index 73958d168..0eef2f1f5 100644 --- a/inflate.c +++ b/inflate.c @@ -460,7 +460,7 @@ local int updatewindow(z_stream *strm, const unsigned char *end, unsigned copy) do { \ if (have == 0) goto inf_leave; \ have--; \ - hold += (uint32_t)(*next++) << bits; \ + hold += (unsigned long)(*next++) << bits; \ bits += 8; \ } while (0) @@ -575,13 +575,13 @@ local int updatewindow(z_stream *strm, const unsigned char *end, unsigned copy) int ZEXPORT inflate(z_stream *strm, int flush) { struct inflate_state *state; const unsigned char *next; /* next input */ - unsigned char *put; /* next output */ + unsigned char *put; /* next output */ unsigned have, left; /* available input and output */ - uint32_t hold; /* bit buffer */ + unsigned long hold; /* bit buffer */ unsigned bits; /* bits in bit buffer */ unsigned in, out; /* save starting available input and output */ unsigned copy; /* number of stored or match bytes to copy */ - unsigned char *from; /* where to copy match bytes from */ + unsigned char *from; /* where to copy match bytes from */ code here; /* current decoding table entry */ code last; /* parent table entry */ unsigned len; /* length to copy for repeats, bits to drop */ @@ -1257,7 +1257,7 @@ int ZEXPORT inflateGetDictionary(z_stream *strm, unsigned char *dictionary, uInt int ZEXPORT inflateSetDictionary(z_stream *strm, const unsigned char *dictionary, uInt dictLength) { struct inflate_state *state; - uint32_t dictid; + unsigned long dictid; int ret; /* check state */ @@ -1335,7 +1335,7 @@ local unsigned syncsearch(unsigned *have, const unsigned char *buf, unsigned len int ZEXPORT inflateSync(z_stream *strm) { unsigned len; /* number of bytes to look at or looked at */ - size_t in, out; /* temporary to save total_in and total_out */ + unsigned long in, out; /* temporary to save total_in and total_out */ unsigned char buf[4]; /* to restore bit buffer to byte string */ struct inflate_state *state; diff --git a/inflate.h b/inflate.h index df58e56e2..9cb7f06fa 100644 --- a/inflate.h +++ b/inflate.h @@ -88,8 +88,8 @@ struct inflate_state { int havedict; /* true if dictionary provided */ int flags; /* gzip header method and flags (0 if zlib) */ unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ - size_t check; /* protected copy of check value */ - size_t total; /* protected copy of output count */ + unsigned long check; /* protected copy of check value */ + unsigned long total; /* protected copy of output count */ gz_headerp head; /* where to save gzip header information */ /* sliding window */ unsigned wbits; /* log base 2 of requested window size */ @@ -98,7 +98,7 @@ struct inflate_state { unsigned wnext; /* window write index */ unsigned char *window; /* allocated sliding window, if needed */ /* bit accumulator */ - uint32_t hold; /* input bit accumulator */ + unsigned long hold; /* input bit accumulator */ unsigned bits; /* number of bits in "in" */ /* for string and stored block copying */ unsigned length; /* literal or length of data to copy */ diff --git a/match.c b/match.c index f8afa16ba..626727301 100644 --- a/match.c +++ b/match.c @@ -72,7 +72,7 @@ ZLIB_INTERNAL unsigned longest_match(deflate_state *const s, IPos cur_match) { scan_end1 = scan[best_len-1]; scan_end = scan[best_len]; - Assert((size_t)s->strstart <= s->window_size - MIN_LOOKAHEAD, "need lookahead"); + Assert((unsigned long)s->strstart <= s->window_size - MIN_LOOKAHEAD, "need lookahead"); do { Assert(cur_match < s->strstart, "no future"); match = s->window + cur_match; @@ -190,7 +190,7 @@ ZLIB_INTERNAL unsigned longest_match(deflate_state *const s, IPos cur_match) { scan_start = *(uint16_t *)scan; scan_end = *(uint16_t *)(scan + best_len-1); - Assert((size_t)s->strstart <= s->window_size - MIN_LOOKAHEAD, "need lookahead"); + Assert((unsigned long)s->strstart <= s->window_size - MIN_LOOKAHEAD, "need lookahead"); do { unsigned char *match; Assert(cur_match < s->strstart, "no future"); @@ -363,7 +363,7 @@ ZLIB_INTERNAL unsigned longest_match(deflate_state *const s, IPos cur_match) { */ if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; - Assert((size_t)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); + Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); do { Assert(cur_match < s->strstart, "no future"); @@ -409,17 +409,17 @@ ZLIB_INTERNAL unsigned longest_match(deflate_state *const s, IPos cur_match) { scan += 2, match+=2; Assert(*scan == *match, "match[2]?"); do { - uintptr_t sv = *(uintptr_t*)(void*)scan; - uintptr_t mv = *(uintptr_t*)(void*)match; - uintptr_t xor = sv ^ mv; + unsigned long sv = *(unsigned long*)(void*)scan; + unsigned long mv = *(unsigned long*)(void*)match; + unsigned long xor = sv ^ mv; if (xor) { int match_byte = __builtin_ctzl(xor) / 8; scan += match_byte; match += match_byte; break; } else { - scan += sizeof(uintptr_t); - match += sizeof(uintptr_t); + scan += sizeof(unsigned long); + match += sizeof(unsigned long); } } while (scan < strend); diff --git a/trees.c b/trees.c index c688ed5ec..e7b45bb0e 100644 --- a/trees.c +++ b/trees.c @@ -146,7 +146,7 @@ local void compress_block (deflate_state *s, const ct_data *ltree, const ct_data 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, uint16_t len, int header); +local void copy_block (deflate_state *s, char *buf, unsigned len, int header); #ifdef GEN_TREES_H local void gen_trees_header(void); @@ -438,9 +438,9 @@ local void gen_bitlen(deflate_state *s, tree_desc *desc) { if (n >= base) xbits = extra[n-base]; f = tree[n].Freq; - s->opt_len += (size_t)f * (bits + xbits); + s->opt_len += (ulg)f * (bits + xbits); if (stree) - s->static_len += (size_t)f * (stree[n].Len + xbits); + s->static_len += (ulg)f * (stree[n].Len + xbits); } if (overflow == 0) return; @@ -784,16 +784,16 @@ local void send_all_trees(deflate_state *s, int lcodes, int dcodes, int blcodes) /* =========================================================================== * Send a stored block */ -void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, char *buf, uint16_t stored_len, int last) { +void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, char *buf, ulg stored_len, int last) { /* buf: input block */ /* stored_len: length of input block */ /* last: one if this is the last block for a file */ send_bits(s, (STORED_BLOCK << 1)+last, 3); /* send block type */ #ifdef DEBUG - s->compressed_len = (s->compressed_len + 3 + 7) & (uint32_t)~7L; + s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; s->compressed_len += (stored_len + 4) << 3; #endif - copy_block(s, buf, stored_len, 1); /* with header */ + copy_block(s, buf, (unsigned)stored_len, 1); /* with header */ } /* =========================================================================== @@ -820,11 +820,11 @@ void ZLIB_INTERNAL _tr_align(deflate_state *s) { * Determine the best encoding for the current block: dynamic trees, static * trees or store, and output the encoded block to the zip file. */ -void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, char *buf, uint16_t stored_len, int last) { +void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, char *buf, ulg stored_len, int last) { /* buf: input block, or NULL if too old */ /* stored_len: length of input block */ /* last: one if this is the last block for a file */ - uint16_t opt_lenb, static_lenb; /* opt_len and static_len in bytes */ + ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ int max_blindex = 0; /* index of last bit length code of non zero freq */ /* Build the Huffman trees unless a stored block is forced */ @@ -938,11 +938,11 @@ int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc) { /* Try to guess if it is profitable to stop the current block here */ if ((s->last_lit & 0x1fff) == 0 && s->level > 2) { /* Compute an upper bound for the compressed length */ - size_t out_length = (size_t)s->last_lit*8L; - size_t in_length = (size_t)((long)s->strstart - s->block_start); + ulg out_length = (ulg)s->last_lit*8L; + ulg in_length = (ulg)((long)s->strstart - s->block_start); int dcode; for (dcode = 0; dcode < D_CODES; dcode++) { - out_length += (size_t)s->dyn_dtree[dcode].Freq * (5L+extra_dbits[dcode]); + out_length += (ulg)s->dyn_dtree[dcode].Freq * (5L+extra_dbits[dcode]); } out_length >>= 3; Tracev((stderr, "\nlast_lit %u, in %ld, out ~%ld(%ld%%) ", @@ -1024,7 +1024,7 @@ local int detect_data_type(deflate_state *s) { * set bits 0..6, 14..25, and 28..31 * 0xf3ffc07f = binary 11110011111111111100000001111111 */ - uint32_t black_mask = 0xf3ffc07fUL; + unsigned long black_mask = 0xf3ffc07fUL; int n; /* Check for non-textual ("black-listed") bytes. */ @@ -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, uint16_t len, int header) { +local 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 */ @@ -1110,7 +1110,7 @@ local void copy_block(deflate_state *s, char *buf, uint16_t len, int header) { #endif } #ifdef DEBUG - s->bits_sent += (uint32_t)len << 3; + s->bits_sent += (ulg)len << 3; #endif while (len--) { put_byte(s, *buf++);