[llvm] Fix have pthread_getname for some system (PR #110854)
William Moses via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 2 07:48:14 PDT 2024
https://github.com/wsmoses created https://github.com/llvm/llvm-project/pull/110854
I'm on a system that has have_pthread_getname_np defined but set to 0. The correct behavior here is not to use the function, but presently the macros will attempt to use a non-existing function.
This previously worked before https://github.com/llvm/llvm-project/pull/106486/files
>From f1946e32e9ae73bc87e0e89124222aa865879b0a Mon Sep 17 00:00:00 2001
From: William Moses <gh at wsmoses.com>
Date: Wed, 2 Oct 2024 09:47:51 -0500
Subject: [PATCH] Fix have pthread_getname for some system
I'm on a system that has have_pthread_getname_np defined but set to 0. The correct behavior here is not to use the function, but presently the macros will attempt to use a non-existing function.
This previously worked before https://github.com/llvm/llvm-project/pull/106486/files
---
llvm/lib/Support/Unix/Threading.inc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Support/Unix/Threading.inc b/llvm/lib/Support/Unix/Threading.inc
index 0afd1d817f88e6..a354984cabb1ef 100644
--- a/llvm/lib/Support/Unix/Threading.inc
+++ b/llvm/lib/Support/Unix/Threading.inc
@@ -237,14 +237,14 @@ void llvm::get_thread_name(SmallVectorImpl<char> &Name) {
char Buffer[len] = {'\0'}; // FIXME: working around MSan false positive.
if (0 == ::pthread_getname_np(::pthread_self(), Buffer, len))
Name.append(Buffer, Buffer + strlen(Buffer));
-#elif defined(HAVE_PTHREAD_GET_NAME_NP)
+#elif defined(HAVE_PTHREAD_GET_NAME_NP) && HAVE_PTHREAD_GET_NAME_NP
constexpr uint32_t len = get_max_thread_name_length_impl();
char buf[len];
::pthread_get_name_np(::pthread_self(), buf, len);
Name.append(buf, buf + strlen(buf));
-#elif defined(HAVE_PTHREAD_GETNAME_NP)
+#elif defined(HAVE_PTHREAD_GETNAME_NP) && HAVE_PTHREAD_GETNAME_NP
constexpr uint32_t len = get_max_thread_name_length_impl();
char buf[len];
::pthread_getname_np(::pthread_self(), buf, len);
More information about the llvm-commits
mailing list