Don't need to truncate thread names to 15 chars on Apple platforms.
The 15 character limit is an archaic limitation of Linux/Android, and not macOS/iOS. So the name here doesn't need truncated in TaskSystem.cpp
#elif (defined _GNU_SOURCE || defined __clang__) && !defined __EMSCRIPTEN__
{
#if defined __APPLE__
pthread_setname_np( name );
#else
// only linux/android have a 15 char name limit
const auto sz = strlen( name );
if( sz <= 15 )
{
pthread_setname_np( pthread_self(), name );
}
else
{
char buf[16];
memcpy( buf, name, 15 );
buf[15] = '\0';
pthread_setname_np( pthread_self(), buf );
}
#endif
}
Please provide a reference to documentation that supports this claim.
Not sure what docs you expect. This stuff is rarely documented. macOS is 64 chars at least. Also the tracy thread names are > 15 and get truncated always. Seeing "Tracy Compress Wo" is not ideal. These should be shortened.
https://sourceware.org/bugzilla/show_bug.cgi?id=16578
Also the macOS build GetThreadName doesn't return anything but an id. Code would look something like the following. The call needs a pthread ptr, and int (32-bit) won't hold that. I'm hoping that the thread name table returns valid names and so this code isn't needed.
TRACY_API const char* GetThreadName( uint32_t id )
{
#elif defined __APPLE__
static char nameBuf[63 + 1] = {0};
if (pthread_getname_np(static_cast<pthread_t*>(id), nameBuf, 63) == 0) {
return nameBuf;
};
}
Macos has longer thread names, this is confirmed by the libpthread implementation: https://github.com/apple-oss-distributions/libpthread/blob/1ebf56b3a702df53213c2996e5e128a535d2577e/src/pthread.c#L1190
Pthread limits the name to 64bytes internally (but provides the full length to the system)
https://github.com/apple-oss-distributions/libpthread/blob/1ebf56b3a702df53213c2996e5e128a535d2577e/src/types_internal.h#L141