diff --git a/include/mimalloc-internal.h b/include/mimalloc-internal.h index 6b38348c..90b5a56f 100644 --- a/include/mimalloc-internal.h +++ b/include/mimalloc-internal.h @@ -753,11 +753,7 @@ static inline uintptr_t _mi_thread_id(void) mi_attr_noexcept { // The big preprocessor macros that follow emit the 5 declarations with default // implementations for the first 4 versions so only the 5th needs to be implemented. // ------------------------------------------------------------------------------------------------------------- -#ifdef NDEBUG -#define MI_DEBUG_ONLY(x) -#else -#define MI_DEBUG_ONLY(x) x -#endif +#define MI_DEBUG_ONLY(x) x // we still allow dbg entry points in release mode to enable linking with a release build #define MI_ALLOC_API1(tp,name,tp0,arg0,tp1,arg1) \ static tp mi_base_##name(tp0 arg0, tp1 arg1 MI_SOURCE_XPARAM) mi_attr_noexcept; \ diff --git a/include/mimalloc.h b/include/mimalloc.h index 2d83bc18..18e2665f 100644 --- a/include/mimalloc.h +++ b/include/mimalloc.h @@ -95,24 +95,24 @@ extern "C" { // ----------------------------------------------------------------------------------- // Debugging -// The debug build declares two entry points for each allocation function: +// We declare two entry points for each allocation function: // the normal one (`mi_malloc`) and one that takes a source argument (`dbg_mi_malloc`) // The following macros make it easier to specify this. +// Note: these are even defined in release mode (where the source argument is ignored) +// so one can still build a debug program that links with the release build of mimalloc. // ----------------------------------------------------------------------------------- -#if defined(NDEBUG) -#define mi_export_alloc(decls,tp,name,attrs,...) decls mi_decl_export tp name(__VA_ARGS__) attrs // release mode has just one entry point -#else typedef struct mi_source_s { long long src; // packed encoding of the source location. } mi_source_t; + mi_decl_export mi_source_t mi_source_ret(void* return_address); mi_decl_export mi_source_t mi_source_loc(const char* fname, int lineno); mi_decl_export void* mi_source_unpack(mi_source_t source, const char** fname, int* lineno); + #define mi_export_alloc(decls,tp,name,attrs,...) \ decls mi_decl_export tp dbg_##name( __VA_ARGS__, mi_source_t dbg_source) attrs; \ decls mi_decl_export tp name(__VA_ARGS__) attrs -#endif #define mi_export_malloc(tp,name,...) mi_export_alloc(mi_decl_nodiscard, mi_decl_restrict tp, name, mi_attr_noexcept mi_attr_malloc, __VA_ARGS__) #define mi_export_realloc(tp,name,...) mi_export_alloc(mi_decl_nodiscard, tp, name, mi_attr_noexcept, __VA_ARGS__) diff --git a/src/static.c b/src/static.c index 1a99d243..b7377114 100644 --- a/src/static.c +++ b/src/static.c @@ -6,7 +6,7 @@ terms of the MIT license. A copy of the license can be found in the file -----------------------------------------------------------------------------*/ #define _DEFAULT_SOURCE -#define MI_NO_SOURCE_DEBUG +#define MI_DEBUG_NO_SOURCE_LOC #include "mimalloc.h" #include "mimalloc-internal.h" diff --git a/test/main-override.cpp b/test/main-override.cpp index 51eaefd2..fafc4750 100644 --- a/test/main-override.cpp +++ b/test/main-override.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #ifdef _WIN32 #include