From e5dba91c387bed8b2a6c9e352f48b27864411b66 Mon Sep 17 00:00:00 2001 From: Evgenii Kliuchnikov Date: Tue, 28 Mar 2023 16:17:13 +0000 Subject: Add BROTLI_ENABLE_DUMP build option PiperOrigin-RevId: 520047051 --- c/common/platform.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/c/common/platform.h b/c/common/platform.h index 4186a8e..f1c1dc7 100644 --- a/c/common/platform.h +++ b/c/common/platform.h @@ -14,10 +14,11 @@ * BROTLI_BUILD_LITTLE_ENDIAN forces to use little-endian optimizations * BROTLI_BUILD_NO_RBIT disables "rbit" optimization for ARM CPUs * BROTLI_BUILD_NO_UNALIGNED_READ_FAST forces off the fast-unaligned-read - optimizations (mainly for testing purposes). + optimizations (mainly for testing purposes) * BROTLI_DEBUG dumps file name and line number when decoder detects stream or memory error * BROTLI_ENABLE_LOG enables asserts and dumps various state information + * BROTLI_ENABLE_DUMP overrides default "dump" behaviour */ #ifndef BROTLI_COMMON_PLATFORM_H_ @@ -402,14 +403,24 @@ static BROTLI_INLINE void BROTLI_UNALIGNED_STORE_PTR(void* p, const void* v) { #endif #if defined(BROTLI_DEBUG) || defined(BROTLI_ENABLE_LOG) +#define BROTLI_ENABLE_DUMP_DEFAULT 1 #define BROTLI_DCHECK(x) assert(x) +#else +#define BROTLI_ENABLE_DUMP_DEFAULT 0 +#define BROTLI_DCHECK(x) +#endif + +#if !defined(BROTLI_ENABLE_DUMP) +#define BROTLI_ENABLE_DUMP BROTLI_ENABLE_DUMP_DEFAULT +#endif + +#if BROTLI_ENABLE_DUMP static BROTLI_INLINE void BrotliDump(const char* f, int l, const char* fn) { fprintf(stderr, "%s:%d (%s)\n", f, l, fn); fflush(stderr); } #define BROTLI_DUMP() BrotliDump(__FILE__, __LINE__, __FUNCTION__) #else -#define BROTLI_DCHECK(x) #define BROTLI_DUMP() (void)(0) #endif @@ -517,7 +528,7 @@ BROTLI_UNUSED_FUNCTION void BrotliSuppressUnusedFunctions(void) { BROTLI_UNUSED(&brotli_max_uint8_t); BROTLI_UNUSED(&BrotliDefaultAllocFunc); BROTLI_UNUSED(&BrotliDefaultFreeFunc); -#if defined(BROTLI_DEBUG) || defined(BROTLI_ENABLE_LOG) +#if BROTLI_ENABLE_DUMP BROTLI_UNUSED(&BrotliDump); #endif } -- cgit v1.1