pthread_setname_np takes 1 arg on macOS

pthread_setname_np() can only set the name of the current thread on
macOS, so only pass a single name argument.

Fixes build break on macOS 12.2 with _GNU_SOURCE defined.
This commit is contained in:
Dave Rigby 2022-02-28 16:05:36 +00:00 committed by Dave Rigby
parent 6c33a23390
commit 31e4bef135

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