Skip to content

Commit

Permalink
Fix libFuzzer not building with pthreads on Windows (llvm#109525)
Browse files Browse the repository at this point in the history
Fixes llvm#106871

(cherry picked from commit b4130be)
  • Loading branch information
Zentrik authored and giordano committed Oct 8, 2024
1 parent 4e01dcc commit edb7a55
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -253,6 +257,7 @@ void SetThreadName(std::thread &thread, const std::string &name) {
}
}
}
#endif
}

} // namespace fuzzer
Expand Down

0 comments on commit edb7a55

Please sign in to comment.