From 2c252226fc22b981d1368ac39aa385cdbc32f41f Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Mon, 9 Oct 2017 00:39:12 +0200 Subject: [PATCH] Force proper initialization order on gcc. --- client/TracyProfiler.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 2f377067..5909192a 100755 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -26,6 +26,12 @@ # define DISABLE_LZ4 #endif +#ifdef __GNUC__ +#define init_order( val ) __attribute__ ((init_priority(val))) +#else +#define init_order(x) +#endif + namespace tracy { @@ -48,13 +54,13 @@ static const char* GetProcessName() enum { QueuePrealloc = 256 * 1024 }; -moodycamel::ConcurrentQueue s_queue( QueueItemSize * QueuePrealloc ); -thread_local moodycamel::ProducerToken s_token( s_queue ); +moodycamel::ConcurrentQueue init_order(101) s_queue( QueueItemSize * QueuePrealloc ); +thread_local moodycamel::ProducerToken init_order(102) s_token( s_queue ); std::atomic s_id( 0 ); #ifndef TRACY_DISABLE -static Profiler s_profiler; +static Profiler init_order(103) s_profiler; #endif static Profiler* s_instance = nullptr;