1
0
mirror of https://github.com/wolfpld/tracy synced 2025-05-02 21:53:52 +00:00

Merge pull request #334 from daverigby/master

Fix macOS build breaks when _GNU_SOURCE defined
This commit is contained in:
Bartosz Taudul 2022-02-28 17:44:59 +01:00 committed by GitHub
commit ee4f4f491f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -391,7 +391,7 @@ static const char* GetProcessName()
auto buf = getprogname(); auto buf = getprogname();
if( buf ) processName = buf; if( buf ) processName = buf;
# endif # endif
#elif defined _GNU_SOURCE #elif defined __linux__ && defined _GNU_SOURCE
if( program_invocation_short_name ) processName = program_invocation_short_name; if( program_invocation_short_name ) processName = program_invocation_short_name;
#elif defined __APPLE__ || defined BSD #elif defined __APPLE__ || defined BSD
auto buf = getprogname(); auto buf = getprogname();
@ -408,7 +408,7 @@ static const char* GetProcessExecutablePath()
return buf; return buf;
#elif defined __ANDROID__ #elif defined __ANDROID__
return nullptr; return nullptr;
#elif defined _GNU_SOURCE #elif defined __linux__ && defined _GNU_SOURCE
return program_invocation_name; return program_invocation_name;
#elif defined __APPLE__ #elif defined __APPLE__
static char buf[1024]; static char buf[1024];

View File

@ -155,14 +155,22 @@ TRACY_API void SetThreadName( const char* name )
const auto sz = strlen( name ); const auto sz = strlen( name );
if( sz <= 15 ) if( sz <= 15 )
{ {
#if defined __APPLE__
pthread_setname_np( name );
#else
pthread_setname_np( pthread_self(), name ); pthread_setname_np( pthread_self(), name );
#endif
} }
else else
{ {
char buf[16]; char buf[16];
memcpy( buf, name, 15 ); memcpy( buf, name, 15 );
buf[15] = '\0'; buf[15] = '\0';
#if defined __APPLE__
pthread_setname_np( buf );
#else
pthread_setname_np( pthread_self(), buf ); pthread_setname_np( pthread_self(), buf );
#endif
} }
} }
#endif #endif