[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:14:09 PDT 2024
https://github.com/Zentrik created https://github.com/llvm/llvm-project/pull/109525
Fixes https://github.com/llvm/llvm-project/issues/106871
>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] 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
More information about the llvm-commits
mailing list