diff --git a/common/TracySystem.cpp b/common/TracySystem.cpp index 3a65c78b..2c475cd3 100644 --- a/common/TracySystem.cpp +++ b/common/TracySystem.cpp @@ -91,6 +91,8 @@ void SetThreadName( std::thread::native_handle_type handle, const char* name ) auto data = (ThreadNameData*)tracy_malloc( sizeof( ThreadNameData ) ); # ifdef _WIN32 data->id = GetThreadId( static_cast( handle ) ); +# elif defined __MACOSX__ || defined __IPHONE__ + pthread_thread_id( handle, data->id ); # else data->id = (uint64_t)handle; # endif diff --git a/common/TracySystem.hpp b/common/TracySystem.hpp index 5c01ba7d..c5a466c4 100644 --- a/common/TracySystem.hpp +++ b/common/TracySystem.hpp @@ -24,6 +24,10 @@ static inline uint64_t GetThreadHandle() #ifdef _WIN32 static_assert( sizeof( decltype( GetCurrentThreadId() ) ) <= sizeof( uint64_t ), "Thread handle too big to fit in protocol" ); return uint64_t( GetCurrentThreadId() ); +#elif defined __MACOSX__ || defined __IPHONE__ + uint64_t id; + pthread_threadid_np( pthread_self(), id ); + return id; #else static_assert( sizeof( decltype( pthread_self() ) ) <= sizeof( uint64_t ), "Thread handle too big to fit in protocol" ); return uint64_t( pthread_self() );