16 #include "llvm/Config/config.h"
24 #if LLVM_ENABLE_THREADS != 0
31 #if LLVM_ENABLE_THREADS != 0 && defined(HAVE_PTHREAD_H)
35 void (*UserFn)(
void *);
45 unsigned RequestedStackSize) {
51 if (::pthread_attr_init(&Attr) != 0)
55 if (RequestedStackSize != 0) {
56 if (::pthread_attr_setstacksize(&Attr, RequestedStackSize) != 0)
65 ::pthread_join(Thread,
nullptr);
68 ::pthread_attr_destroy(&Attr);
70 #elif LLVM_ENABLE_THREADS!=0 && defined(LLVM_ON_WIN32)
79 static unsigned __stdcall ThreadCallback(
void *param) {
81 info->func(info->param);
87 unsigned RequestedStackSize) {
90 HANDLE hThread = (HANDLE)::_beginthreadex(NULL,
91 RequestedStackSize, ThreadCallback,
100 (void)::WaitForSingleObject(hThread, INFINITE);
101 ::CloseHandle(hThread);
107 unsigned RequestedStackSize) {
108 (void) RequestedStackSize;
static void * ExecuteOnThread_Dispatch(void *Arg)
static std::error_code error(DiagnosticHandlerFunction DiagnosticHandler, std::error_code EC, const Twine &Message)
bool llvm_is_multithreaded()
Returns true if LLVM is compiled with support for multi-threading, and false otherwise.
void llvm_execute_on_thread(void(*UserFn)(void *), void *UserData, unsigned RequestedStackSize=0)
llvm_execute_on_thread - Execute the given UserFn on a separate thread, passing it the provided UserD...