zlib patch for DEBUG pre-processor

Patch as described on zlib:
https://github.com/madler/zlib/pull/80
This commit is contained in:
Daniel Rosser 2014-10-06 14:37:39 +11:00
parent fb2eba8eac
commit 7d413184e6
11 changed files with 41 additions and 41 deletions

View File

@ -92,7 +92,7 @@ local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
local uInt longest_match OF((deflate_state *s, IPos cur_match)); local uInt longest_match OF((deflate_state *s, IPos cur_match));
#endif #endif
#ifdef DEBUG #ifdef ZLIB_DEBUG
local void check_match OF((deflate_state *s, IPos start, IPos match, local void check_match OF((deflate_state *s, IPos start, IPos match,
int length)); int length));
#endif #endif
@ -1349,7 +1349,7 @@ local uInt longest_match(s, cur_match)
#endif /* FASTEST */ #endif /* FASTEST */
#ifdef DEBUG #ifdef ZLIB_DEBUG
/* =========================================================================== /* ===========================================================================
* Check that the match at match_start is indeed a match. * Check that the match at match_start is indeed a match.
*/ */

View File

@ -249,7 +249,7 @@ typedef struct internal_state {
uInt matches; /* number of string matches in current block */ uInt matches; /* number of string matches in current block */
uInt insert; /* bytes at end of window left to insert */ uInt insert; /* bytes at end of window left to insert */
#ifdef DEBUG #ifdef ZLIB_DEBUG
ulg compressed_len; /* total bit length of compressed file 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 */ ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
#endif #endif
@ -309,7 +309,7 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
* used. * used.
*/ */
#ifndef DEBUG #ifndef ZLIB_DEBUG
/* Inline versions of _tr_tally for speed: */ /* Inline versions of _tr_tally for speed: */
#if defined(GEN_TREES_H) || !defined(STDC) #if defined(GEN_TREES_H) || !defined(STDC)

View File

@ -36,7 +36,7 @@
#include "deflate.h" #include "deflate.h"
#ifdef DEBUG #ifdef ZLIB_DEBUG
# include <ctype.h> # include <ctype.h>
#endif #endif
@ -159,7 +159,7 @@ local void copy_block OF((deflate_state *s, charf *buf, unsigned len,
local void gen_trees_header OF((void)); local void gen_trees_header OF((void));
#endif #endif
#ifndef DEBUG #ifndef ZLIB_DEBUG
# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) # define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
/* Send a code of the given tree. c and tree must not have side effects */ /* Send a code of the given tree. c and tree must not have side effects */
@ -182,7 +182,7 @@ local void gen_trees_header OF((void));
* Send a value on a given number of bits. * Send a value on a given number of bits.
* IN assertion: length <= 16 and value fits in length bits. * IN assertion: length <= 16 and value fits in length bits.
*/ */
#ifdef DEBUG #ifdef ZLIB_DEBUG
local void send_bits OF((deflate_state *s, int value, int length)); local void send_bits OF((deflate_state *s, int value, int length));
local void send_bits(s, value, length) local void send_bits(s, value, length)
@ -394,7 +394,7 @@ void ZLIB_INTERNAL _tr_init(s)
s->bi_buf = 0; s->bi_buf = 0;
s->bi_valid = 0; s->bi_valid = 0;
#ifdef DEBUG #ifdef ZLIB_DEBUG
s->compressed_len = 0L; s->compressed_len = 0L;
s->bits_sent = 0L; s->bits_sent = 0L;
#endif #endif
@ -869,7 +869,7 @@ void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last)
int last; /* one if this is the last block for a file */ int last; /* one if this is the last block for a file */
{ {
send_bits(s, (STORED_BLOCK<<1)+last, 3); /* send block type */ send_bits(s, (STORED_BLOCK<<1)+last, 3); /* send block type */
#ifdef DEBUG #ifdef ZLIB_DEBUG
s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
s->compressed_len += (stored_len + 4) << 3; s->compressed_len += (stored_len + 4) << 3;
#endif #endif
@ -894,7 +894,7 @@ void ZLIB_INTERNAL _tr_align(s)
{ {
send_bits(s, STATIC_TREES<<1, 3); send_bits(s, STATIC_TREES<<1, 3);
send_code(s, END_BLOCK, static_ltree); send_code(s, END_BLOCK, static_ltree);
#ifdef DEBUG #ifdef ZLIB_DEBUG
s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
#endif #endif
bi_flush(s); bi_flush(s);
@ -974,7 +974,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
send_bits(s, (STATIC_TREES<<1)+last, 3); send_bits(s, (STATIC_TREES<<1)+last, 3);
compress_block(s, (const ct_data *)static_ltree, compress_block(s, (const ct_data *)static_ltree,
(const ct_data *)static_dtree); (const ct_data *)static_dtree);
#ifdef DEBUG #ifdef ZLIB_DEBUG
s->compressed_len += 3 + s->static_len; s->compressed_len += 3 + s->static_len;
#endif #endif
} else { } else {
@ -983,7 +983,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
max_blindex+1); max_blindex+1);
compress_block(s, (const ct_data *)s->dyn_ltree, compress_block(s, (const ct_data *)s->dyn_ltree,
(const ct_data *)s->dyn_dtree); (const ct_data *)s->dyn_dtree);
#ifdef DEBUG #ifdef ZLIB_DEBUG
s->compressed_len += 3 + s->opt_len; s->compressed_len += 3 + s->opt_len;
#endif #endif
} }
@ -995,7 +995,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
if (last) { if (last) {
bi_windup(s); bi_windup(s);
#ifdef DEBUG #ifdef ZLIB_DEBUG
s->compressed_len += 7; /* align on byte boundary */ s->compressed_len += 7; /* align on byte boundary */
#endif #endif
} }
@ -1193,7 +1193,7 @@ local void bi_windup(s)
} }
s->bi_buf = 0; s->bi_buf = 0;
s->bi_valid = 0; s->bi_valid = 0;
#ifdef DEBUG #ifdef ZLIB_DEBUG
s->bits_sent = (s->bits_sent+7) & ~7; s->bits_sent = (s->bits_sent+7) & ~7;
#endif #endif
} }
@ -1213,11 +1213,11 @@ local void copy_block(s, buf, len, header)
if (header) { if (header) {
put_short(s, (ush)len); put_short(s, (ush)len);
put_short(s, (ush)~len); put_short(s, (ush)~len);
#ifdef DEBUG #ifdef ZLIB_DEBUG
s->bits_sent += 2*16; s->bits_sent += 2*16;
#endif #endif
} }
#ifdef DEBUG #ifdef ZLIB_DEBUG
s->bits_sent += (ulg)len<<3; s->bits_sent += (ulg)len<<3;
#endif #endif
while (len--) { while (len--) {

View File

@ -61,7 +61,7 @@ uLong ZEXPORT zlibCompileFlags()
case 8: flags += 2 << 6; break; case 8: flags += 2 << 6; break;
default: flags += 3 << 6; default: flags += 3 << 6;
} }
#ifdef DEBUG #ifdef ZLIB_DEBUG
flags += 1 << 8; flags += 1 << 8;
#endif #endif
#if defined(ASMV) || defined(ASMINF) #if defined(ASMV) || defined(ASMINF)
@ -115,7 +115,7 @@ uLong ZEXPORT zlibCompileFlags()
return flags; return flags;
} }
#ifdef DEBUG #ifdef ZLIB_DEBUG
# ifndef verbose # ifndef verbose
# define verbose 0 # define verbose 0

View File

@ -216,7 +216,7 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#endif #endif
/* Diagnostic functions */ /* Diagnostic functions */
#ifdef DEBUG #ifdef ZLIB_DEBUG
# include <stdio.h> # include <stdio.h>
extern int ZLIB_INTERNAL z_verbose; extern int ZLIB_INTERNAL z_verbose;
extern void ZLIB_INTERNAL z_error OF((char *m)); extern void ZLIB_INTERNAL z_error OF((char *m));

View File

@ -93,7 +93,7 @@ local uInt longest_match OF((deflate_state *s, IPos cur_match));
#endif #endif
local uInt longest_match_fast OF((deflate_state *s, IPos cur_match)); local uInt longest_match_fast OF((deflate_state *s, IPos cur_match));
#ifdef DEBUG #ifdef ZLIB_DEBUG
local void check_match OF((deflate_state *s, IPos start, IPos match, local void check_match OF((deflate_state *s, IPos start, IPos match,
int length)); int length));
#endif #endif
@ -1225,7 +1225,7 @@ local uInt longest_match_fast(s, cur_match)
return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead; return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead;
} }
#ifdef DEBUG #ifdef ZLIB_DEBUG
/* =========================================================================== /* ===========================================================================
* Check that the match at match_start is indeed a match. * Check that the match at match_start is indeed a match.
*/ */

View File

@ -246,7 +246,7 @@ typedef struct internal_state {
uInt matches; /* number of string matches in current block */ uInt matches; /* number of string matches in current block */
int last_eob_len; /* bit length of EOB code for last block */ int last_eob_len; /* bit length of EOB code for last block */
#ifdef DEBUG #ifdef ZLIB_DEBUG
ulg compressed_len; /* total bit length of compressed file 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 */ ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
#endif #endif
@ -294,7 +294,7 @@ void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
* used. * used.
*/ */
#ifndef DEBUG #ifndef ZLIB_DEBUG
/* Inline versions of _tr_tally for speed: */ /* Inline versions of _tr_tally for speed: */
#if defined(GEN_TREES_H) || !defined(STDC) #if defined(GEN_TREES_H) || !defined(STDC)

View File

@ -238,7 +238,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#endif #endif
/* Diagnostic functions */ /* Diagnostic functions */
#ifdef DEBUG #ifdef ZLIB_DEBUG
# include <stdio.h> # include <stdio.h>
extern int z_verbose; extern int z_verbose;
extern void z_error OF((char *m)); extern void z_error OF((char *m));

View File

@ -93,7 +93,7 @@ local uInt longest_match OF((deflate_state *s, IPos cur_match));
#endif #endif
local uInt longest_match_fast OF((deflate_state *s, IPos cur_match)); local uInt longest_match_fast OF((deflate_state *s, IPos cur_match));
#ifdef DEBUG #ifdef ZLIB_DEBUG
local void check_match OF((deflate_state *s, IPos start, IPos match, local void check_match OF((deflate_state *s, IPos start, IPos match,
int length)); int length));
#endif #endif
@ -1225,7 +1225,7 @@ local uInt longest_match_fast(s, cur_match)
return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead; return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead;
} }
#ifdef DEBUG #ifdef ZLIB_DEBUG
/* =========================================================================== /* ===========================================================================
* Check that the match at match_start is indeed a match. * Check that the match at match_start is indeed a match.
*/ */

View File

@ -39,7 +39,7 @@
#include "deflate.h" #include "deflate.h"
#ifdef DEBUG #ifdef ZLIB_DEBUG
# include <ctype.h> # include <ctype.h>
#endif #endif
@ -167,7 +167,7 @@ local void copy_block OF((deflate_state *s, charf *buf, unsigned len,
local void gen_trees_header OF((void)); local void gen_trees_header OF((void));
#endif #endif
#ifndef DEBUG #ifndef ZLIB_DEBUG
# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) # define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
/* Send a code of the given tree. c and tree must not have side effects */ /* Send a code of the given tree. c and tree must not have side effects */
@ -190,7 +190,7 @@ local void gen_trees_header OF((void));
* Send a value on a given number of bits. * Send a value on a given number of bits.
* IN assertion: length <= 16 and value fits in length bits. * IN assertion: length <= 16 and value fits in length bits.
*/ */
#ifdef DEBUG #ifdef ZLIB_DEBUG
local void send_bits OF((deflate_state *s, int value, int length)); local void send_bits OF((deflate_state *s, int value, int length));
local void send_bits(s, value, length) local void send_bits(s, value, length)
@ -400,7 +400,7 @@ void _tr_init(s)
s->bi_buf = 0; s->bi_buf = 0;
s->bi_valid = 0; s->bi_valid = 0;
s->last_eob_len = 8; /* enough lookahead for inflate */ s->last_eob_len = 8; /* enough lookahead for inflate */
#ifdef DEBUG #ifdef ZLIB_DEBUG
s->compressed_len = 0L; s->compressed_len = 0L;
s->bits_sent = 0L; s->bits_sent = 0L;
#endif #endif
@ -875,7 +875,7 @@ void _tr_stored_block(s, buf, stored_len, eof)
int eof; /* true if this is the last block for a file */ int eof; /* true if this is the last block for a file */
{ {
send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */ send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */
#ifdef DEBUG #ifdef ZLIB_DEBUG
s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
s->compressed_len += (stored_len + 4) << 3; s->compressed_len += (stored_len + 4) << 3;
#endif #endif
@ -898,7 +898,7 @@ void _tr_align(s)
{ {
send_bits(s, STATIC_TREES<<1, 3); send_bits(s, STATIC_TREES<<1, 3);
send_code(s, END_BLOCK, static_ltree); send_code(s, END_BLOCK, static_ltree);
#ifdef DEBUG #ifdef ZLIB_DEBUG
s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
#endif #endif
bi_flush(s); bi_flush(s);
@ -910,7 +910,7 @@ void _tr_align(s)
if (1 + s->last_eob_len + 10 - s->bi_valid < 9) { if (1 + s->last_eob_len + 10 - s->bi_valid < 9) {
send_bits(s, STATIC_TREES<<1, 3); send_bits(s, STATIC_TREES<<1, 3);
send_code(s, END_BLOCK, static_ltree); send_code(s, END_BLOCK, static_ltree);
#ifdef DEBUG #ifdef ZLIB_DEBUG
s->compressed_len += 10L; s->compressed_len += 10L;
#endif #endif
bi_flush(s); bi_flush(s);
@ -991,7 +991,7 @@ void _tr_flush_block(s, buf, stored_len, eof)
#endif #endif
send_bits(s, (STATIC_TREES<<1)+eof, 3); send_bits(s, (STATIC_TREES<<1)+eof, 3);
compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree); compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree);
#ifdef DEBUG #ifdef ZLIB_DEBUG
s->compressed_len += 3 + s->static_len; s->compressed_len += 3 + s->static_len;
#endif #endif
} else { } else {
@ -999,7 +999,7 @@ void _tr_flush_block(s, buf, stored_len, eof)
send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,
max_blindex+1); max_blindex+1);
compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree); compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree);
#ifdef DEBUG #ifdef ZLIB_DEBUG
s->compressed_len += 3 + s->opt_len; s->compressed_len += 3 + s->opt_len;
#endif #endif
} }
@ -1011,7 +1011,7 @@ void _tr_flush_block(s, buf, stored_len, eof)
if (eof) { if (eof) {
bi_windup(s); bi_windup(s);
#ifdef DEBUG #ifdef ZLIB_DEBUG
s->compressed_len += 7; /* align on byte boundary */ s->compressed_len += 7; /* align on byte boundary */
#endif #endif
} }
@ -1189,7 +1189,7 @@ local void bi_windup(s)
} }
s->bi_buf = 0; s->bi_buf = 0;
s->bi_valid = 0; s->bi_valid = 0;
#ifdef DEBUG #ifdef ZLIB_DEBUG
s->bits_sent = (s->bits_sent+7) & ~7; s->bits_sent = (s->bits_sent+7) & ~7;
#endif #endif
} }
@ -1210,11 +1210,11 @@ local void copy_block(s, buf, len, header)
if (header) { if (header) {
put_short(s, (ush)len); put_short(s, (ush)len);
put_short(s, (ush)~len); put_short(s, (ush)~len);
#ifdef DEBUG #ifdef ZLIB_DEBUG
s->bits_sent += 2*16; s->bits_sent += 2*16;
#endif #endif
} }
#ifdef DEBUG #ifdef ZLIB_DEBUG
s->bits_sent += (ulg)len<<3; s->bits_sent += (ulg)len<<3;
#endif #endif
while (len--) { while (len--) {

View File

@ -58,7 +58,7 @@ uLong ZEXPORT zlibCompileFlags()
case 8: flags += 2 << 6; break; case 8: flags += 2 << 6; break;
default: flags += 3 << 6; default: flags += 3 << 6;
} }
#ifdef DEBUG #ifdef ZLIB_DEBUG
flags += 1 << 8; flags += 1 << 8;
#endif #endif
#if defined(ASMV) || defined(ASMINF) #if defined(ASMV) || defined(ASMINF)
@ -112,7 +112,7 @@ uLong ZEXPORT zlibCompileFlags()
return flags; return flags;
} }
#ifdef DEBUG #ifdef ZLIB_DEBUG
# ifndef verbose # ifndef verbose
# define verbose 0 # define verbose 0