[compiler-rt] Fix libFuzzer not building with pthreads on Windows (PR #109525)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 21 02:22:30 PDT 2024
https://github.com/Zentrik updated https://github.com/llvm/llvm-project/pull/109525
>From 0c1067433727a18d37aa49620e564ab68e646d62 Mon Sep 17 00:00:00 2001
From: Zentrik <llvm.zentrik at gmail.com>
Date: Sat, 21 Sep 2024 10:10:29 +0100
Subject: [PATCH 1/2] Fix libFuzzer not building with pthreads on Windows
Fixes https://github.com/llvm/llvm-project/issues/106871
---
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..ca0a2a9f958caa 100644
--- a/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
@@ -239,6 +239,9 @@ size_t PageSize() {
}
void SetThreadName(std::thread &thread, const std::string &name) {
+#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 +256,7 @@ void SetThreadName(std::thread &thread, const std::string &name) {
}
}
}
+#endif
}
} // namespace fuzzer
>From 907a0b2c502870351ab512c98c284bd39bc2b291 Mon Sep 17 00:00:00 2001
From: Zentrik <llvm.zentrik at gmail.com>
Date: Sat, 21 Sep 2024 10:22:12 +0100
Subject: [PATCH 2/2] Format
---
compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp b/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
index ca0a2a9f958caa..37aecae7237ae9 100644
--- a/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
@@ -239,7 +239,8 @@ size_t PageSize() {
}
void SetThreadName(std::thread &thread, const std::string &name) {
-#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || defined(_GLIBCXX_GCC_GTHR_POSIX_H)
+#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);
More information about the llvm-commits
mailing list