Skip to content

Commit

Permalink
Test alternate patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Zentrik committed Sep 20, 2024
1 parent 27501dc commit baef840
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions llvm-patches/fix_setthreadname.patch
Original file line number Diff line number Diff line change
@@ -1,32 +1,22 @@
From 7c4cffd9d8be424e9e9542be9aec3b5a6f69073e Mon Sep 17 00:00:00 2001
From: David CARLIER <[email protected]>
Date: Sun, 1 Sep 2024 13:35:10 +0100
Subject: [PATCH] [compiler-rt][fuzzer] SetThreadName build fix for Mingwin
attempt (#106902)

---
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..7252d99dd375df 100644
index e0210aa0ac36..ca0a2a9f958c 100644
--- a/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
@@ -239,6 +239,7 @@ size_t PageSize() {
@@ -239,6 +239,9 @@ size_t PageSize() {
}

void SetThreadName(std::thread &thread, const std::string &name) {
+#if !defined(__MINGW32__)
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || defined(_GLIBCXX_GCC_GTHR_POSIX_H)
+ (void)pthread_setname_np(thread.native_handle(), name.c_str());
+#else
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) {
@@ -253,6 +256,7 @@ void SetThreadName(std::thread &thread, const std::string &name) {
}
}
}
+#else
+ (void)pthread_setname_np(thread.native_handle(), name.c_str());
+#endif
}

} // namespace fuzzer

0 comments on commit baef840

Please sign in to comment.