From 6abdc5f5a3e8bbc3949218b7ded8ea0334e72080 Mon Sep 17 00:00:00 2001 From: daan Date: Thu, 4 Jul 2019 09:28:22 -0700 Subject: [PATCH] do not enable verbose by default in the debug build; add trace messages for verbose level 2 --- include/mimalloc-internal.h | 12 ++++++++++++ src/options.c | 10 +++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/include/mimalloc-internal.h b/include/mimalloc-internal.h index 172be180..3754d9fd 100644 --- a/include/mimalloc-internal.h +++ b/include/mimalloc-internal.h @@ -14,12 +14,19 @@ terms of the MIT license. A copy of the license can be found in the file #define MI_TLS_RECURSE_GUARD #endif +#if (MI_DEBUG>0) +#define mi_trace_message(...) _mi_trace_message(__VA_ARGS__) +#else +#define mi_trace_message(...) +#endif + // "options.c" void _mi_fprintf(FILE* out, const char* fmt, ...); void _mi_error_message(const char* fmt, ...); void _mi_warning_message(const char* fmt, ...); void _mi_verbose_message(const char* fmt, ...); +void _mi_trace_message(const char* fmt, ...); // "init.c" extern mi_stats_t _mi_stats_main; @@ -116,6 +123,11 @@ bool _mi_page_is_valid(mi_page_t* page); Inlined definitions ----------------------------------------------------------- */ #define UNUSED(x) (void)(x) +#if (MI_DEBUG>0) +#define UNUSED_RELEASE(x) +#else +#define UNUSED_RELEASE(x) UNUSED(x) +#endif #define MI_INIT4(x) x(),x(),x(),x() #define MI_INIT8(x) MI_INIT4(x),MI_INIT4(x) diff --git a/src/options.c b/src/options.c index 9de7aa8b..52fda953 100644 --- a/src/options.c +++ b/src/options.c @@ -39,7 +39,7 @@ static mi_option_desc_t options[_mi_option_last] = { #endif { 0, UNINIT, "show_stats" }, { MI_DEBUG, UNINIT, "show_errors" }, - { MI_DEBUG, UNINIT, "verbose" } + { 0, UNINIT, "verbose" } }; static void mi_option_init(mi_option_desc_t* desc); @@ -105,6 +105,14 @@ void _mi_fprintf( FILE* out, const char* fmt, ... ) { va_end(args); } +void _mi_trace_message(const char* fmt, ...) { + if (mi_option_get(mi_option_verbose) <= 1) return; // only with verbose level 2 or higher + va_list args; + va_start(args, fmt); + mi_vfprintf(stderr, "mimalloc: ", fmt, args); + va_end(args); +} + void _mi_verbose_message(const char* fmt, ...) { if (!mi_option_is_enabled(mi_option_verbose)) return; va_list args;