-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
8 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |