[llvm] Fix have pthread_getname for some system (PR #110854)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 2 07:48:49 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-support
Author: William Moses (wsmoses)
<details>
<summary>Changes</summary>
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
---
Full diff: https://github.com/llvm/llvm-project/pull/110854.diff
1 Files Affected:
- (modified) llvm/lib/Support/Unix/Threading.inc (+2-2)
``````````diff
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);
``````````
</details>
https://github.com/llvm/llvm-project/pull/110854
More information about the llvm-commits
mailing list