aboutsummaryrefslogtreecommitdiff
path: root/compiler-rt/lib/fuzzer
diff options
context:
space:
mode:
authorZentrik <llvm.zentrik@gmail.com>2024-09-24 21:33:57 +0100
committerGitHub <noreply@github.com>2024-09-24 23:33:57 +0300
commitb4130bee6bfd34d8045f02fc9f951bcb5db9d85c (patch)
tree65d2d1ab5ef8b1e170d09f752e7164c6a8955831 /compiler-rt/lib/fuzzer
parentcf9fc5e22fa51e5b3a8182e7ef408cd77064a664 (diff)
downloadllvm-b4130bee6bfd34d8045f02fc9f951bcb5db9d85c.zip
llvm-b4130bee6bfd34d8045f02fc9f951bcb5db9d85c.tar.gz
llvm-b4130bee6bfd34d8045f02fc9f951bcb5db9d85c.tar.bz2
Fix libFuzzer not building with pthreads on Windows (#109525)
Fixes https://github.com/llvm/llvm-project/issues/106871
Diffstat (limited to 'compiler-rt/lib/fuzzer')
-rw-r--r--compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp b/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
index e0210aa..37aecae 100644
--- a/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
@@ -239,6 +239,10 @@ 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 +257,7 @@ void SetThreadName(std::thread &thread, const std::string &name) {
}
}
}
+#endif
}
} // namespace fuzzer