From 339b7fd2a6f1044cb7fa1ad56a2576866c7dd1af Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 14 Aug 2019 01:57:10 +0200 Subject: [PATCH] Use kernel thread ids on linux. --- common/TracySystem.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/common/TracySystem.hpp b/common/TracySystem.hpp index 6cdc7fe2..1d48d9ca 100644 --- a/common/TracySystem.hpp +++ b/common/TracySystem.hpp @@ -15,6 +15,13 @@ extern "C" __declspec(dllimport) unsigned long __stdcall GetCurrentThreadId(void # include #endif +#ifdef __ANDROID__ +# include +#elif defined __linux__ +# include +# include +#endif + #include #include @@ -34,6 +41,10 @@ static inline uint64_t GetThreadHandleImpl() uint64_t id; pthread_threadid_np( pthread_self(), &id ); return id; +#elif defined __ANDROID__ + return (uint64_t)gettid(); +#elif defined __linux__ + return (uint64_t)syscall( SYS_gettid ); #else static_assert( sizeof( decltype( pthread_self() ) ) <= sizeof( uint64_t ), "Thread handle too big to fit in protocol" ); return uint64_t( pthread_self() );