From 31e4bef13587877f5acb88c4ec10a8efdfb13ae8 Mon Sep 17 00:00:00 2001 From: Dave Rigby Date: Mon, 28 Feb 2022 16:05:36 +0000 Subject: [PATCH 1/2] 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 From 2073ffb684dc20ed1fe93455081e81481b14ec2a Mon Sep 17 00:00:00 2001 From: Dave Rigby Date: Mon, 28 Feb 2022 16:08:27 +0000 Subject: [PATCH 2/2] program_invocation_short_name is Linux-specific 'program_invocation_short_name' is Linux-specific; other OSs such as macOS do not support it. Fixes build break on macOS 12.2 with _GNU_SOURCE defined. --- client/TracyProfiler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 71032484..a9f674bd 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -391,7 +391,7 @@ static const char* GetProcessName() auto buf = getprogname(); if( buf ) processName = buf; # endif -#elif defined _GNU_SOURCE +#elif defined __linux__ && defined _GNU_SOURCE if( program_invocation_short_name ) processName = program_invocation_short_name; #elif defined __APPLE__ || defined BSD auto buf = getprogname(); @@ -408,7 +408,7 @@ static const char* GetProcessExecutablePath() return buf; #elif defined __ANDROID__ return nullptr; -#elif defined _GNU_SOURCE +#elif defined __linux__ && defined _GNU_SOURCE return program_invocation_name; #elif defined __APPLE__ static char buf[1024];