From cd1551d2611028540a4d68363fb3e791e3bf8561 Mon Sep 17 00:00:00 2001 From: Nick Terrell Date: Mon, 15 Mar 2021 14:46:26 -0700 Subject: [PATCH] [lib][tracing] Add ZSTD_NO_TRACE macro When defined, it disables tracing, and avoids including the header. --- contrib/freestanding_lib/freestanding.py | 4 +++- contrib/linux-kernel/Makefile | 3 ++- lib/common/zstd_internal.h | 7 ++++++- lib/compress/zstd_compress.c | 1 - lib/compress/zstd_compress_internal.h | 1 - lib/decompress/zstd_decompress.c | 1 - lib/decompress/zstd_decompress_internal.h | 1 - 7 files changed, 11 insertions(+), 7 deletions(-) diff --git a/contrib/freestanding_lib/freestanding.py b/contrib/freestanding_lib/freestanding.py index ca3f0ac8b..a5bcf100f 100755 --- a/contrib/freestanding_lib/freestanding.py +++ b/contrib/freestanding_lib/freestanding.py @@ -28,6 +28,7 @@ SKIPPED_FILES = [ "common/threading.c", "common/threading.h", "common/zstd_trace.c", + "common/zstd_trace.h", "compress/zstdmt_compress.h", "compress/zstdmt_compress.c", ] @@ -658,7 +659,8 @@ def main(name, args): raise RuntimeError(f"{name} is both defined and undefined!") # Always set tracing to 0 - if "ZSTD_TRACE" not in (arg[0] for arg in args.defs): + if "ZSTD_NO_TRACE" not in (arg[0] for arg in args.defs): + args.defs.append(("ZSTD_NO_TRACE", None)) args.defs.append(("ZSTD_TRACE", "0")) args.replaces = parse_pair(args.replaces) diff --git a/contrib/linux-kernel/Makefile b/contrib/linux-kernel/Makefile index 1cbe3435f..0fefc2bf2 100644 --- a/contrib/linux-kernel/Makefile +++ b/contrib/linux-kernel/Makefile @@ -49,7 +49,8 @@ libzstd: -RZSTDLIB_VISIBILITY= \ -RZSTDERRORLIB_VISIBILITY= \ -DZSTD_HAVE_WEAK_SYMBOLS=0 \ - -DZSTD_TRACE=0 + -DZSTD_TRACE=0 \ + -DZSTD_NO_TRACE mv linux/lib/zstd/zstd.h linux/include/linux/zstd_lib.h mv linux/lib/zstd/common/zstd_errors.h linux/include/linux/ cp linux_zstd.h linux/include/linux/zstd.h diff --git a/lib/common/zstd_internal.h b/lib/common/zstd_internal.h index 53a982c73..1d1c91ffd 100644 --- a/lib/common/zstd_internal.h +++ b/lib/common/zstd_internal.h @@ -36,6 +36,11 @@ # define XXH_STATIC_LINKING_ONLY /* XXH64_state_t */ #endif #include "xxhash.h" /* XXH_reset, update, digest */ +#ifndef ZSTD_NO_TRACE +# include "zstd_trace.h" +#else +# define ZSTD_TRACE 0 +#endif #if defined (__cplusplus) extern "C" { @@ -365,7 +370,7 @@ typedef struct { /* longLengthPos and longLengthID to allow us to represent either a single litLength or matchLength * in the seqStore that has a value larger than U16 (if it exists). To do so, we increment - * the existing value of the litLength or matchLength by 0x10000. + * the existing value of the litLength or matchLength by 0x10000. */ U32 longLengthID; /* 0 == no longLength; 1 == Represent the long literal; 2 == Represent the long match; */ U32 longLengthPos; /* Index of the sequence to apply long length modification to */ diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c index 93c4075c5..597349712 100644 --- a/lib/compress/zstd_compress.c +++ b/lib/compress/zstd_compress.c @@ -14,7 +14,6 @@ #include "../common/zstd_deps.h" /* INT_MAX, ZSTD_memset, ZSTD_memcpy */ #include "../common/cpu.h" #include "../common/mem.h" -#include "../common/zstd_trace.h" #include "hist.h" /* HIST_countFast_wksp */ #define FSE_STATIC_LINKING_ONLY /* FSE_encodeSymbol */ #include "../common/fse.h" diff --git a/lib/compress/zstd_compress_internal.h b/lib/compress/zstd_compress_internal.h index 6083ed664..bfe83e214 100644 --- a/lib/compress/zstd_compress_internal.h +++ b/lib/compress/zstd_compress_internal.h @@ -19,7 +19,6 @@ * Dependencies ***************************************/ #include "../common/zstd_internal.h" -#include "../common/zstd_trace.h" /* ZSTD_TraceCtx */ #include "zstd_cwksp.h" #ifdef ZSTD_MULTITHREAD # include "zstdmt_compress.h" diff --git a/lib/decompress/zstd_decompress.c b/lib/decompress/zstd_decompress.c index 15139501b..10b6a88e1 100644 --- a/lib/decompress/zstd_decompress.c +++ b/lib/decompress/zstd_decompress.c @@ -58,7 +58,6 @@ #include "../common/zstd_deps.h" /* ZSTD_memcpy, ZSTD_memmove, ZSTD_memset */ #include "../common/cpu.h" /* bmi2 */ #include "../common/mem.h" /* low level memory routines */ -#include "../common/zstd_trace.h" #define FSE_STATIC_LINKING_ONLY #include "../common/fse.h" #define HUF_STATIC_LINKING_ONLY diff --git a/lib/decompress/zstd_decompress_internal.h b/lib/decompress/zstd_decompress_internal.h index 3fcec6c56..40d820231 100644 --- a/lib/decompress/zstd_decompress_internal.h +++ b/lib/decompress/zstd_decompress_internal.h @@ -21,7 +21,6 @@ *********************************************************/ #include "../common/mem.h" /* BYTE, U16, U32 */ #include "../common/zstd_internal.h" /* ZSTD_seqSymbol */ -#include "../common/zstd_trace.h" /* ZSTD_TraceCtx */