Skip to content

Commit b4130be

Browse files
authored
Fix libFuzzer not building with pthreads on Windows (llvm#109525)
Fixes llvm#106871
1 parent cf9fc5e commit b4130be

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@ size_t PageSize() {
239239
}
240240

241241
void SetThreadName(std::thread &thread, const std::string &name) {
242+
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
243+
defined(_GLIBCXX_GCC_GTHR_POSIX_H)
244+
(void)pthread_setname_np(thread.native_handle(), name.c_str());
245+
#else
242246
typedef HRESULT(WINAPI * proc)(HANDLE, PCWSTR);
243247
HMODULE kbase = GetModuleHandleA("KernelBase.dll");
244248
proc ThreadNameProc = reinterpret_cast<proc>(
@@ -253,6 +257,7 @@ void SetThreadName(std::thread &thread, const std::string &name) {
253257
}
254258
}
255259
}
260+
#endif
256261
}
257262

258263
} // namespace fuzzer

0 commit comments

Comments
 (0)