1 //===-- llvm/Support/Threading.h - Control multithreading mode --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // TThis file defines llvm_start_multithreaded() and friends.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_SUPPORT_THREADING_H
15 #define LLVM_SUPPORT_THREADING_H
17 #include "llvm/Support/Mutex.h"
20 /// llvm_get_global_lock - returns the llvm global lock object.
21 sys::Mutex& llvm_get_global_lock();
23 /// llvm_start_multithreaded - Allocate and initialize structures needed to
24 /// make LLVM safe for multithreading. The return value indicates whether
25 /// multithreaded initialization succeeded. LLVM will still be operational
26 /// on "failed" return, and will still be safe for hosting threading
27 /// applications in the JIT, but will not be safe for concurrent calls to the
29 /// THIS MUST EXECUTE IN ISOLATION FROM ALL OTHER LLVM API CALLS.
30 bool llvm_start_multithreaded();
32 /// llvm_stop_multithreaded - Deallocate structures necessary to make LLVM
33 /// safe for multithreading.
34 /// THIS MUST EXECUTE IN ISOLATION FROM ALL OTHER LLVM API CALLS.
35 void llvm_stop_multithreaded();
37 /// llvm_is_multithreaded - Check whether LLVM is executing in thread-safe
39 bool llvm_is_multithreaded();
41 /// llvm_execute_on_thread - Execute the given \p UserFn on a separate
42 /// thread, passing it the provided \p UserData.
44 /// This function does not guarantee that the code will actually be executed
45 /// on a separate thread or honoring the requested stack size, but tries to do
46 /// so where system support is available.
48 /// \param UserFn - The callback to execute.
49 /// \param UserData - An argument to pass to the callback function.
50 /// \param RequestedStackSize - If non-zero, a requested size (in bytes) for
52 void llvm_execute_on_thread(void (*UserFn)(void*), void *UserData,
53 unsigned RequestedStackSize = 0);