Skip to content

Commit edb7a55

Browse files
Zentrikgiordano
authored andcommitted
Fix libFuzzer not building with pthreads on Windows (llvm#109525)
Fixes llvm#106871 (cherry picked from commit b4130be)
1 parent 4e01dcc commit edb7a55

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 =
@@ -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)