mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-09 08:49:31 +03:00
keep dbg entries in release build to allow linking with both
This commit is contained in:
parent
ae6491f201
commit
e9c5b31b1c
4 changed files with 7 additions and 12 deletions
|
@ -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
|
// 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.
|
// implementations for the first 4 versions so only the 5th needs to be implemented.
|
||||||
// -------------------------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------------------------
|
||||||
#ifdef NDEBUG
|
#define MI_DEBUG_ONLY(x) x // we still allow dbg entry points in release mode to enable linking with a release build
|
||||||
#define MI_DEBUG_ONLY(x)
|
|
||||||
#else
|
|
||||||
#define MI_DEBUG_ONLY(x) x
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MI_ALLOC_API1(tp,name,tp0,arg0,tp1,arg1) \
|
#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; \
|
static tp mi_base_##name(tp0 arg0, tp1 arg1 MI_SOURCE_XPARAM) mi_attr_noexcept; \
|
||||||
|
|
|
@ -95,24 +95,24 @@ extern "C" {
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------
|
||||||
// Debugging
|
// 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 normal one (`mi_malloc`) and one that takes a source argument (`dbg_mi_malloc`)
|
||||||
// The following macros make it easier to specify this.
|
// 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 {
|
typedef struct mi_source_s {
|
||||||
long long src; // packed encoding of the source location.
|
long long src; // packed encoding of the source location.
|
||||||
} mi_source_t;
|
} mi_source_t;
|
||||||
|
|
||||||
mi_decl_export mi_source_t mi_source_ret(void* return_address);
|
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 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);
|
mi_decl_export void* mi_source_unpack(mi_source_t source, const char** fname, int* lineno);
|
||||||
|
|
||||||
#define mi_export_alloc(decls,tp,name,attrs,...) \
|
#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 dbg_##name( __VA_ARGS__, mi_source_t dbg_source) attrs; \
|
||||||
decls mi_decl_export tp name(__VA_ARGS__) 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_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__)
|
#define mi_export_realloc(tp,name,...) mi_export_alloc(mi_decl_nodiscard, tp, name, mi_attr_noexcept, __VA_ARGS__)
|
||||||
|
|
|
@ -6,7 +6,7 @@ terms of the MIT license. A copy of the license can be found in the file
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
|
|
||||||
#define MI_NO_SOURCE_DEBUG
|
#define MI_DEBUG_NO_SOURCE_LOC
|
||||||
#include "mimalloc.h"
|
#include "mimalloc.h"
|
||||||
#include "mimalloc-internal.h"
|
#include "mimalloc-internal.h"
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
#include <mimalloc.h>
|
#include <mimalloc.h>
|
||||||
#include <mimalloc-new-delete.h>
|
#include <mimalloc-new-delete.h>
|
||||||
#include <mimalloc-override.h>
|
#include <mimalloc-override.h>
|
||||||
#include <crtdbg.h>
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
Loading…
Add table
Reference in a new issue