[llvm] 8bcf799 - Fix have pthread_getname for some system (#110854)

via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 3 06:13:56 PDT 2024


Author: William Moses
Date: 2024-10-03T08:13:53-05:00
New Revision: 8bcf79914b9395048d2ef11b6dc5f95fddb9747a

URL: https://github.com/llvm/llvm-project/commit/8bcf79914b9395048d2ef11b6dc5f95fddb9747a
DIFF: https://github.com/llvm/llvm-project/commit/8bcf79914b9395048d2ef11b6dc5f95fddb9747a.diff

LOG: Fix have pthread_getname for some system (#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

Added: 
    

Modified: 
    llvm/lib/Support/Unix/Threading.inc

Removed: 
    


################################################################################
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