tracy/common/TracySystem.hpp

34 lines
856 B
C++
Raw Normal View History

2017-09-10 15:46:20 +00:00
#ifndef __TRACYSYSTEM_HPP__
#define __TRACYSYSTEM_HPP__
#ifdef _WIN32
extern "C" __declspec(dllimport) unsigned long __stdcall GetCurrentThreadId(void);
#else
# include <pthread.h>
#endif
#include <stdint.h>
2017-09-10 15:46:20 +00:00
#include <thread>
namespace tracy
{
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() );
#else
static_assert( sizeof( decltype( pthread_self() ) ) <= sizeof( uint64_t ), "Thread handle too big to fit in protocol" );
return uint64_t( pthread_self() );
#endif
}
2017-09-10 15:46:20 +00:00
void SetThreadName( std::thread& thread, const char* name );
void SetThreadName( std::thread::native_handle_type handle, const char* name );
const char* GetThreadName( uint64_t id );
2017-09-10 15:46:20 +00:00
}
#endif