Fix thread ids on osx, iphone.

This commit is contained in:
Bartosz Taudul 2017-11-03 10:49:49 +01:00
parent 3659afac2a
commit 1d9542ea25
2 changed files with 6 additions and 0 deletions

View File

@ -91,6 +91,8 @@ void SetThreadName( std::thread::native_handle_type handle, const char* name )
auto data = (ThreadNameData*)tracy_malloc( sizeof( ThreadNameData ) ); auto data = (ThreadNameData*)tracy_malloc( sizeof( ThreadNameData ) );
# ifdef _WIN32 # ifdef _WIN32
data->id = GetThreadId( static_cast<HANDLE>( handle ) ); data->id = GetThreadId( static_cast<HANDLE>( handle ) );
# elif defined __MACOSX__ || defined __IPHONE__
pthread_thread_id( handle, data->id );
# else # else
data->id = (uint64_t)handle; data->id = (uint64_t)handle;
# endif # endif

View File

@ -24,6 +24,10 @@ static inline uint64_t GetThreadHandle()
#ifdef _WIN32 #ifdef _WIN32
static_assert( sizeof( decltype( GetCurrentThreadId() ) ) <= sizeof( uint64_t ), "Thread handle too big to fit in protocol" ); static_assert( sizeof( decltype( GetCurrentThreadId() ) ) <= sizeof( uint64_t ), "Thread handle too big to fit in protocol" );
return uint64_t( GetCurrentThreadId() ); return uint64_t( GetCurrentThreadId() );
#elif defined __MACOSX__ || defined __IPHONE__
uint64_t id;
pthread_threadid_np( pthread_self(), id );
return id;
#else #else
static_assert( sizeof( decltype( pthread_self() ) ) <= sizeof( uint64_t ), "Thread handle too big to fit in protocol" ); static_assert( sizeof( decltype( pthread_self() ) ) <= sizeof( uint64_t ), "Thread handle too big to fit in protocol" );
return uint64_t( pthread_self() ); return uint64_t( pthread_self() );