mirror of
https://github.com/wolfpld/tracy
synced 2025-04-29 12:23:53 +00:00
Retrieve proper thread ids on BSD.
This commit is contained in:
parent
c79449a6a1
commit
3c4a7463b8
@ -16,6 +16,12 @@ extern "C" __declspec(dllimport) unsigned long __stdcall GetCurrentThreadId(void
|
|||||||
# else
|
# else
|
||||||
# include <sys/syscall.h>
|
# include <sys/syscall.h>
|
||||||
# endif
|
# endif
|
||||||
|
#elif defined __FreeBSD__
|
||||||
|
# include <sys/thr.h>
|
||||||
|
#elif defined __NetBSD__ || defined __DragonFly__
|
||||||
|
# include <sys/lwp.h>
|
||||||
|
#elif defined __OpenBSD__
|
||||||
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@ -40,6 +46,16 @@ static inline uint64_t GetThreadHandleImpl()
|
|||||||
return (uint64_t)gettid();
|
return (uint64_t)gettid();
|
||||||
#elif defined __linux__
|
#elif defined __linux__
|
||||||
return (uint64_t)syscall( SYS_gettid );
|
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
|
#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…
x
Reference in New Issue
Block a user