Fix builds with MingW.

This commit is contained in:
Rokas Kupstys
2019-01-19 13:03:30 +02:00
parent 32f0a27d3b
commit 8157e3a0b3
11 changed files with 69 additions and 45 deletions

View File

@@ -21,6 +21,9 @@
# include <fcntl.h>
#endif
#ifdef __MINGW32__
# define __STDC_FORMAT_MACROS
#endif
#include <inttypes.h>
#include <stdio.h>
@@ -51,7 +54,7 @@ void SetThreadName( std::thread& thread, const char* name )
void SetThreadName( std::thread::native_handle_type handle, const char* name )
{
#ifdef _WIN32
#if defined _WIN32 && !defined PTW32_VERSION && !defined __WINPTHREADS_VERSION
# if defined NTDDI_WIN10_RS2 && NTDDI_VERSION >= NTDDI_WIN10_RS2
wchar_t buf[256];
mbstowcs( buf, name, 256 );
@@ -108,7 +111,13 @@ void SetThreadName( std::thread::native_handle_type handle, const char* name )
buf[sz+1] = '\0';
auto data = (ThreadNameData*)tracy_malloc( sizeof( ThreadNameData ) );
# ifdef _WIN32
# if defined PTW32_VERSION
data->id = pthread_getw32threadid_np( static_cast<pthread_t>( handle ) );
# elif defined __WINPTHREADS_VERSION
data->id = GetThreadId( pthread_gethandle( static_cast<pthread_t>( handle ) ) );
# else
data->id = GetThreadId( static_cast<HANDLE>( handle ) );
# endif
# elif defined __APPLE__
pthread_threadid_np( handle, &data->id );
# else