From 3c4a7463b88cec69e65e2364b03c1140aac59f7d Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Thu, 21 Nov 2019 02:29:17 +0100 Subject: [PATCH] Retrieve proper thread ids on BSD. --- common/TracySystem.hpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/common/TracySystem.hpp b/common/TracySystem.hpp index 7f6424ef..85b107fd 100644 --- a/common/TracySystem.hpp +++ b/common/TracySystem.hpp @@ -16,6 +16,12 @@ extern "C" __declspec(dllimport) unsigned long __stdcall GetCurrentThreadId(void # else # include # endif +#elif defined __FreeBSD__ +# include +#elif defined __NetBSD__ || defined __DragonFly__ +# include +#elif defined __OpenBSD__ +# include #endif #include @@ -40,6 +46,16 @@ static inline uint64_t GetThreadHandleImpl() return (uint64_t)gettid(); #elif defined __linux__ return (uint64_t)syscall( SYS_gettid ); +#elif defined __FreeBSD__ + long id; + thr_self( &id ); + return id; +#elif defined __NetBSD__ + return _lwp_self(); +#elif defined __DragonFly__ + return lwp_gettid(); +#elif defined __OpenBSD__ + return getthrid(); #else static_assert( sizeof( decltype( pthread_self() ) ) <= sizeof( uint64_t ), "Thread handle too big to fit in protocol" ); return uint64_t( pthread_self() );