Fix rpmalloc init for shared libraries.

This commit is contained in:
Bartosz Taudul 2021-06-13 12:15:36 +02:00
parent f4d80a4f5f
commit d07db80b44
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
2 changed files with 9 additions and 8 deletions

View File

@ -3,15 +3,17 @@
#include <atomic>
#include "../common/TracyAlloc.hpp"
#include "../common/TracyForceInline.hpp"
#include "../common/TracyYield.hpp"
namespace tracy
{
extern thread_local bool RpThreadInitDone;
extern std::atomic<int> RpInitDone;
extern std::atomic<int> RpInitLock;
TRACY_API void InitRpmallocPlumbing()
tracy_no_inline static void InitRpmallocPlumbing()
{
const auto done = RpInitDone.load( std::memory_order_acquire );
if( !done )
@ -30,6 +32,11 @@ TRACY_API void InitRpmallocPlumbing()
RpThreadInitDone = true;
}
TRACY_API void InitRpmalloc()
{
if( !RpThreadInitDone ) InitRpmallocPlumbing();
}
}
#endif

View File

@ -13,13 +13,7 @@ namespace tracy
{
#ifdef TRACY_ENABLE
extern thread_local bool RpThreadInitDone;
TRACY_API void InitRpmallocPlumbing();
static tracy_force_inline void InitRpmalloc()
{
if( !RpThreadInitDone ) InitRpmallocPlumbing();
}
TRACY_API void InitRpmalloc();
#endif
static inline void* tracy_malloc( size_t size )