| 56 | { |
| 57 | |
| 58 | TRACY_API uint64_t GetThreadHandleImpl() |
| 59 | { |
| 60 | #if defined _WIN32 || defined __CYGWIN__ |
| 61 | static_assert( sizeof( decltype( GetCurrentThreadId() ) ) <= sizeof( uint64_t ), "Thread handle too big to fit in protocol" ); |
| 62 | return uint64_t( GetCurrentThreadId() ); |
| 63 | #elif defined __APPLE__ |
| 64 | uint64_t id; |
| 65 | pthread_threadid_np( pthread_self(), &id ); |
| 66 | return id; |
| 67 | #elif defined __ANDROID__ |
| 68 | return (uint64_t)gettid(); |
| 69 | #elif defined __linux__ |
| 70 | return (uint64_t)syscall( SYS_gettid ); |
| 71 | #elif defined __FreeBSD__ |
| 72 | long id; |
| 73 | thr_self( &id ); |
| 74 | return id; |
| 75 | #elif defined __NetBSD__ |
| 76 | return _lwp_self(); |
| 77 | #elif defined __DragonFly__ |
| 78 | return lwp_gettid(); |
| 79 | #elif defined __OpenBSD__ |
| 80 | return getthrid(); |
| 81 | #else |
| 82 | static_assert( sizeof( decltype( pthread_self() ) ) <= sizeof( uint64_t ), "Thread handle too big to fit in protocol" ); |
| 83 | return uint64_t( pthread_self() ); |
| 84 | #endif |
| 85 | |
| 86 | } |
| 87 | |
| 88 | } |
| 89 |
no test coverage detected