mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-23 06:44:35 +00:00
Fix thread ids on osx, iphone.
This commit is contained in:
parent
3659afac2a
commit
1d9542ea25
@ -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
|
||||||
|
@ -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() );
|
||||||
|
Loading…
Reference in New Issue
Block a user