aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgenii Kliuchnikov <eustas@google.com>2023-03-28 16:17:13 +0000
committerEvgenii Kliuchnikov <eustas.ru@gmail.com>2023-07-04 07:54:07 +0000
commite5dba91c387bed8b2a6c9e352f48b27864411b66 (patch)
treec136b5f0927d5e4866eed786c5a3c9dec98e98d9
parent745fd08ef29ba7c86def64a21905fa7a9a7b89a6 (diff)
downloadbrotli-e5dba91c387bed8b2a6c9e352f48b27864411b66.zip
brotli-e5dba91c387bed8b2a6c9e352f48b27864411b66.tar.gz
brotli-e5dba91c387bed8b2a6c9e352f48b27864411b66.tar.bz2
Add BROTLI_ENABLE_DUMP build option
PiperOrigin-RevId: 520047051
-rw-r--r--c/common/platform.h17
1 files 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
}