Skip to content

Commit

Permalink
Avoid use of DEBUG macro -- change to ZLIB_DEBUG.
Browse files Browse the repository at this point in the history
# Conflicts:
#	win32/Makefile.gcc
  • Loading branch information
madler authored and kornelski committed Oct 12, 2023
1 parent 232f80a commit b2e793a
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 45 deletions.
2 changes: 1 addition & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ CC=cc

CFLAGS=-O
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
#CFLAGS=-g -DDEBUG
#CFLAGS=-g -DZLIB_DEBUG
#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
# -Wstrict-prototypes -Wmissing-prototypes

Expand Down
2 changes: 1 addition & 1 deletion amiga/Makefile.sas
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
CC=sc
CFLAGS=OPT
#CFLAGS=OPT CPU=68030
#CFLAGS=DEBUG=LINE
#CFLAGS=ZLIB_DEBUG=LINE
LDFLAGS=LIB z.lib

SCOPTIONS=OPTSCHED OPTINLINE OPTALIAS OPTTIME OPTINLOCAL STRMERGE \
Expand Down
6 changes: 3 additions & 3 deletions deflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static void putShortMSB(deflate_state *s, uint32_t b);
static void flush_pending(z_streamp strm);
static int read_buf(z_streamp strm, uint8_t *buf, uint32_t size);

#ifdef DEBUG
#ifdef ZLIB_DEBUG
static void check_match(deflate_state *s, IPos start, IPos match,
int length);
#endif
Expand Down Expand Up @@ -1235,7 +1235,7 @@ static uint32_t longest_match(deflate_state *s, IPos cur_match /* current match
return s->lookahead;
}

#ifdef DEBUG
#ifdef ZLIB_DEBUG
/* ===========================================================================
* Check that the match at match_start is indeed a match.
*/
Expand All @@ -1257,7 +1257,7 @@ static void check_match(deflate_state *s, IPos start, IPos match, int length) {
}
#else
# define check_match(s, start, match, length)
#endif /* DEBUG */
#endif /* ZLIB_DEBUG */

/* ===========================================================================
* Fill the window when the lookahead becomes insufficient.
Expand Down
2 changes: 1 addition & 1 deletion deflate.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ typedef struct internal_state {
uint32_t matches; /* number of string matches in current block */
uint32_t insert; /* bytes at end of window left to insert */

#ifdef DEBUG
#ifdef ZLIB_DEBUG
uint64_t compressed_len; /* total bit length of compressed file mod 2^32 */
uint64_t bits_sent; /* bit length of compressed data sent mod 2^32 */
#endif
Expand Down
2 changes: 1 addition & 1 deletion examples/gzlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ typedef unsigned int uint;
typedef unsigned long ulong;

/* Macro for debugging to deterministically force recovery operations */
#ifdef DEBUG
#ifdef GZLOG_DEBUG
#include <setjmp.h> /* longjmp */
jmp_buf gzlog_jump; /* where to go back to */
int gzlog_bail = 0; /* which point to bail at (1..8) */
Expand Down
4 changes: 2 additions & 2 deletions inflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1264,13 +1264,13 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
Note: a memory error from inflate() is non-recoverable.
*/
inf_leave:
#if defined(DEBUG) && (defined(INFLATE_CHUNK_SIMD_NEON) || defined(INFLATE_CHUNK_SIMD_SSE2))
#if defined(ZLIB_DEBUG) && (defined(INFLATE_CHUNK_SIMD_NEON) || defined(INFLATE_CHUNK_SIMD_SSE2))
/* XXX(cavalcantii): I put this in place back in 2017 to help debug faulty
* client code relying on undefined behavior when chunk_copy first landed.
*
* It is save to say after all these years that Chromium code is well
* behaved and works fine with the optimization, therefore we can enable
* this only for DEBUG builds.
* this only for ZLIB_DEBUG builds.
*
* We write a defined value in the unused space to help mark
* where the stream has ended. We don't use zeros as that can
Expand Down
2 changes: 1 addition & 1 deletion make_vms.com
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ $! Check if parameter actually contains something
$!
$ if f$edit(cparm,"trim") .nes. ""
$ then
$ if cparm .eqs. "DEBUG"
$ if cparm .eqs. "ZLIB_DEBUG"
$ then
$ ccopt = ccopt + "/noopt/deb"
$ lopts = lopts + "/deb"
Expand Down
2 changes: 1 addition & 1 deletion msdos/Makefile.dj2
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ CC=gcc

#CFLAGS=-MMD -O
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
#CFLAGS=-MMD -g -DDEBUG
#CFLAGS=-MMD -g -DZLIB_DEBUG
CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
-Wstrict-prototypes -Wmissing-prototypes

Expand Down
2 changes: 1 addition & 1 deletion msdos/Makefile.emx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ CC=gcc

#CFLAGS=-MMD -O
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
#CFLAGS=-MMD -g -DDEBUG
#CFLAGS=-MMD -g -DZLIB_DEBUG
CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
-Wstrict-prototypes -Wmissing-prototypes

Expand Down
2 changes: 1 addition & 1 deletion old/Makefile.emx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ CC=gcc -Zwin32

#CFLAGS=-MMD -O
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
#CFLAGS=-MMD -g -DDEBUG
#CFLAGS=-MMD -g -DZLIB_DEBUG
CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
-Wstrict-prototypes -Wmissing-prototypes

Expand Down
2 changes: 1 addition & 1 deletion old/os2/Makefile.os2
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ CC=gcc -Zomf -s

CFLAGS=-O6 -Wall
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
#CFLAGS=-g -DDEBUG
#CFLAGS=-g -DZLIB_DEBUG
#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
# -Wstrict-prototypes -Wmissing-prototypes

Expand Down
2 changes: 1 addition & 1 deletion treebuild.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
<!--
CFLAGS=-O
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
#CFLAGS=-g -DDEBUG
#CFLAGS=-g -DZLIB_DEBUG
#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
# -Wstrict-prototypes -Wmissing-prototypes
Expand Down
40 changes: 20 additions & 20 deletions trees.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

#include "deflate.h"

#ifdef DEBUG
#ifdef ZLIB_DEBUG
# include <ctype.h>
#endif

Expand Down Expand Up @@ -159,11 +159,11 @@ static void copy_block (deflate_state *s, uint8_t *buf, unsigned len,
static void gen_trees_header OF(void);
#endif

#ifndef DEBUG
#ifndef ZLIB_DEBUG
# 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 */

#else /* DEBUG */
#else /* !ZLIB_DEBUG */
# define send_code(s, c, tree) \
{ if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \
send_bits(s, tree[c].Code, tree[c].Len); }
Expand All @@ -177,7 +177,7 @@ static void gen_trees_header OF(void);

static void send_bits(deflate_state* s, uint64_t val, int len)
{
#ifdef DEBUG
#ifdef ZLIB_DEBUG
Tracevv((stderr," l %2d v %4llx ", len, val));
Assert(len > 0 && len <= 64, "invalid length");
s->bits_sent += len;
Expand Down Expand Up @@ -283,7 +283,7 @@ static void tr_static_init(void) {
* Genererate the file trees.h describing the static trees.
*/
#ifdef GEN_TREES_H
# ifndef DEBUG
# ifndef ZLIB_DEBUG
# include <stdio.h>
# endif

Expand Down Expand Up @@ -357,7 +357,7 @@ void ZLIB_INTERNAL _tr_init(deflate_state *s) {

s->bi_buf = 0;
s->bi_valid = 0;
#ifdef DEBUG
#ifdef ZLIB_DEBUG
s->compressed_len = 0L;
s->bits_sent = 0L;
#endif
Expand Down Expand Up @@ -802,7 +802,7 @@ static void send_all_trees(deflate_state *s, int lcodes, int dcodes,
void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, uint8_t *buf, /* input block */ uint64_t stored_len, /* length of input block */ int last) /* one if this is the last block for a file */
{
send_bits(s, (STORED_BLOCK<<1)+last, 3); /* send block type */
#ifdef DEBUG
#ifdef ZLIB_DEBUG
s->compressed_len = (s->compressed_len + 3 + 7) & (uint64_t)~7L;
s->compressed_len += (stored_len + 4) << 3;
#endif
Expand All @@ -824,7 +824,7 @@ void ZLIB_INTERNAL _tr_align(deflate_state *s)
{
send_bits(s, STATIC_TREES<<1, 3);
send_code(s, END_BLOCK, static_ltree);
#ifdef DEBUG
#ifdef ZLIB_DEBUG
s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
#endif
bi_flush(s);
Expand Down Expand Up @@ -900,7 +900,7 @@ void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, uint8_t *buf, /* input bloc
send_bits(s, (STATIC_TREES<<1)+last, 3);
compress_block(s, (const ct_data *)static_ltree,
(const ct_data *)static_dtree);
#ifdef DEBUG
#ifdef ZLIB_DEBUG
s->compressed_len += 3 + s->static_len;
#endif
} else {
Expand All @@ -909,7 +909,7 @@ void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, uint8_t *buf, /* input bloc
max_blindex+1);
compress_block(s, (const ct_data *)s->dyn_ltree,
(const ct_data *)s->dyn_dtree);
#ifdef DEBUG
#ifdef ZLIB_DEBUG
s->compressed_len += 3 + s->opt_len;
#endif
}
Expand All @@ -918,7 +918,7 @@ void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, uint8_t *buf, /* input bloc

if (last) {
bi_windup(s);
#ifdef DEBUG
#ifdef ZLIB_DEBUG
s->compressed_len += 7; /* align on byte boundary */
#endif
}
Expand Down Expand Up @@ -976,7 +976,7 @@ static void compress_block(deflate_state *s, const ct_data *ltree, /* literal tr
if (dist == 0) {
uint64_t val = ltree[lc].Code;
int len = ltree[lc].Len;
#ifdef DEBUG
#ifdef ZLIB_DEBUG
Tracevv((stderr," l %2d v %4llx ", len, val));
Assert(len > 0 && len <= 64, "invalid length");
s->bits_sent += len;
Expand All @@ -1000,7 +1000,7 @@ static void compress_block(deflate_state *s, const ct_data *ltree, /* literal tr

val = ltree[code+LITERALS+1].Code;
len = ltree[code+LITERALS+1].Len;
#ifdef DEBUG
#ifdef ZLIB_DEBUG
Tracevv((stderr," l %2d v %4llx ", len, val));
Assert(len > 0 && len <= 64, "invalid length");
s->bits_sent += len;
Expand All @@ -1019,7 +1019,7 @@ static void compress_block(deflate_state *s, const ct_data *ltree, /* literal tr
lc -= base_length[code];
val = lc;
len = extra;
#ifdef DEBUG
#ifdef ZLIB_DEBUG
Tracevv((stderr," l %2d v %4llx ", len, val));
Assert(len > 0 && len <= 64, "invalid length");
s->bits_sent += len;
Expand All @@ -1039,7 +1039,7 @@ static void compress_block(deflate_state *s, const ct_data *ltree, /* literal tr
Assert (code < D_CODES, "bad d_code");
val = dtree[code].Code;
len = dtree[code].Len;
#ifdef DEBUG
#ifdef ZLIB_DEBUG
Tracevv((stderr," l %2d v %4llx ", len, val));
Assert(len > 0 && len <= 64, "invalid length");
s->bits_sent += len;
Expand All @@ -1061,7 +1061,7 @@ static void compress_block(deflate_state *s, const ct_data *ltree, /* literal tr
len = extra;
bit_buf ^= (val << filled);
filled += len;
#ifdef DEBUG
#ifdef ZLIB_DEBUG
Tracevv((stderr," l %2d v %4llx ", len, val));
Assert(len > 0 && len <= 64, "invalid length");
s->bits_sent += len;
Expand All @@ -1083,7 +1083,7 @@ static void compress_block(deflate_state *s, const ct_data *ltree, /* literal tr
val = ltree[END_BLOCK].Code;
len = ltree[END_BLOCK].Len;

#ifdef DEBUG
#ifdef ZLIB_DEBUG
Tracevv((stderr," l %2d v %4llx ", len, val));
Assert(len > 0 && len <= 64, "invalid length");
s->bits_sent += len;
Expand Down Expand Up @@ -1194,7 +1194,7 @@ static void bi_windup(deflate_state *s)
}
s->bi_buf = 0;
s->bi_valid = 0;
#ifdef DEBUG
#ifdef ZLIB_DEBUG
s->bits_sent = (s->bits_sent+7) & ~7;
#endif
}
Expand All @@ -1210,11 +1210,11 @@ static void copy_block(deflate_state *s, uint8_t *buf, /* the input data */ u
if (header) {
put_short(s, (uint16_t)len);
put_short(s, (uint16_t)~len);
#ifdef DEBUG
#ifdef ZLIB_DEBUG
s->bits_sent += 2*16;
#endif
}
#ifdef DEBUG
#ifdef ZLIB_DEBUG
s->bits_sent += (ulg)len<<3;
#endif
while (len--) {
Expand Down
7 changes: 1 addition & 6 deletions win32/Makefile.gcc
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
#
# make -fwin32/Makefile.gcc; make test testdll -fwin32/Makefile.gcc
#
# To use the asm code, type:
# cp contrib/asm?86/match.S ./match.S
# make LOC=-DASMV OBJA=match.o -fwin32/Makefile.gcc
#
# To install libz.a, zconf.h and zlib.h in the system directories, type:
#
# make install -fwin32/Makefile.gcc
Expand All @@ -38,8 +34,7 @@ IMPLIB = libz.dll.a
#
SHARED_MODE=0

#LOC = -DASMV
#LOC = -DDEBUG -g
#LOC = -DZLIB_DEBUG -g

PREFIX =
CC = $(PREFIX)gcc
Expand Down
2 changes: 1 addition & 1 deletion zlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags(void);
7.6: size of z_off_t
Compiler, assembler, and debug options:
8: DEBUG
8: ZLIB_DEBUG
9: ASMV or ASMINF -- use ASM code
10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention
11: 0 (reserved)
Expand Down
4 changes: 2 additions & 2 deletions zutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ uLong ZEXPORT zlibCompileFlags(void) {
case 8: flags += 2 << 6; break;
default: flags += 3 << 6;
}
#ifdef DEBUG
#ifdef ZLIB_DEBUG
flags += 1 << 8;
#endif
#if defined(ASMV) || defined(ASMINF)
Expand Down Expand Up @@ -113,7 +113,7 @@ uLong ZEXPORT zlibCompileFlags(void) {
return flags;
}

#ifdef DEBUG
#ifdef ZLIB_DEBUG

# ifndef verbose
# define verbose 0
Expand Down
2 changes: 1 addition & 1 deletion zutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#endif

/* Diagnostic functions */
#ifdef DEBUG
#ifdef ZLIB_DEBUG
# include <stdio.h>
extern int ZLIB_INTERNAL z_verbose;
extern void ZLIB_INTERNAL z_error(char *m);
Expand Down

0 comments on commit b2e793a

Please sign in to comment.