From 31e4bef13587877f5acb88c4ec10a8efdfb13ae8 Mon Sep 17 00:00:00 2001 From: Dave Rigby Date: Mon, 28 Feb 2022 16:05:36 +0000 Subject: [PATCH] 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. --- common/TracySystem.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/TracySystem.cpp b/common/TracySystem.cpp index b9754d33..1248fdee 100644 --- a/common/TracySystem.cpp +++ b/common/TracySystem.cpp @@ -155,14 +155,22 @@ TRACY_API void SetThreadName( const char* name ) const auto sz = strlen( name ); if( sz <= 15 ) { +#if defined __APPLE__ + pthread_setname_np( name ); +#else pthread_setname_np( pthread_self(), name ); +#endif } else { char buf[16]; memcpy( buf, name, 15 ); buf[15] = '\0'; +#if defined __APPLE__ + pthread_setname_np( buf ); +#else pthread_setname_np( pthread_self(), buf ); +#endif } } #endif