[compiler-rt] [compiler-rt][fuzzer] SetThreadName build fix for Cygwin attempt (PR #106902)

David CARLIER via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 1 04:33:19 PDT 2024


https://github.com/devnexen created https://github.com/llvm/llvm-project/pull/106902

None

>From e09879bb7a2f3cb2f4f28c1b9d1fff1cf7b769f9 Mon Sep 17 00:00:00 2001
From: David Carlier <devnexen at gmail.com>
Date: Sun, 1 Sep 2024 12:32:43 +0100
Subject: [PATCH] [compiler-rt][fuzzer] SetThreadName build fix for Cygwin
 attempt

---
 compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp b/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
index e0210aa0ac3651..09db33a4a3c5b7 100644
--- a/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
@@ -239,6 +239,7 @@ size_t PageSize() {
 }
 
 void SetThreadName(std::thread &thread, const std::string &name) {
+#if !defined(__CYGWIN__)
   typedef HRESULT(WINAPI * proc)(HANDLE, PCWSTR);
   HMODULE kbase = GetModuleHandleA("KernelBase.dll");
   proc ThreadNameProc = reinterpret_cast<proc>(
@@ -253,6 +254,9 @@ void SetThreadName(std::thread &thread, const std::string &name) {
       }
     }
   }
+#else
+  (void)pthread_setname_np(thread.native_handle(), name.c_str());
+#endif
 }
 
 } // namespace fuzzer



More information about the llvm-commits mailing list