Fix mingw/cygwin thread name setter/getter.

This commit is contained in:
Bartosz Taudul 2019-11-07 18:58:08 +01:00
parent bb2d44ae08
commit 0f6101b19a

View File

@ -51,12 +51,12 @@ TRACY_API void InitRPMallocThread();
void SetThreadName( const char* name ) void SetThreadName( const char* name )
{ {
#if defined _WIN32 && !defined PTW32_VERSION && !defined __WINPTHREADS_VERSION #if defined _WIN32 || defined __CYGWIN__
# if defined NTDDI_WIN10_RS2 && NTDDI_VERSION >= NTDDI_WIN10_RS2 # if defined NTDDI_WIN10_RS2 && NTDDI_VERSION >= NTDDI_WIN10_RS2
wchar_t buf[256]; wchar_t buf[256];
mbstowcs( buf, name, 256 ); mbstowcs( buf, name, 256 );
SetThreadDescription( GetCurrentThread(), buf ); SetThreadDescription( GetCurrentThread(), buf );
# else # elif defined _MSC_VER
const DWORD MS_VC_EXCEPTION=0x406D1388; const DWORD MS_VC_EXCEPTION=0x406D1388;
# pragma pack( push, 8 ) # pragma pack( push, 8 )
struct THREADNAME_INFO struct THREADNAME_INFO
@ -129,7 +129,7 @@ const char* GetThreadName( uint64_t id )
ptr = ptr->next; ptr = ptr->next;
} }
#else #else
# ifdef _WIN32 # if defined _WIN32 || defined __CYGWIN__
# if defined NTDDI_WIN10_RS2 && NTDDI_VERSION >= NTDDI_WIN10_RS2 # if defined NTDDI_WIN10_RS2 && NTDDI_VERSION >= NTDDI_WIN10_RS2
auto hnd = OpenThread( THREAD_QUERY_LIMITED_INFORMATION, FALSE, (DWORD)id ); auto hnd = OpenThread( THREAD_QUERY_LIMITED_INFORMATION, FALSE, (DWORD)id );
if( hnd != 0 ) if( hnd != 0 )