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/Config/llvm-config.h"
18 #include "llvm/Support/Compiler.h"
23 #if LLVM_ENABLE_THREADS != 0
24 typedef std::mutex mutex;
25 typedef std::recursive_mutex recursive_mutex;
31 bool try_lock() { return true; }
33 typedef null_mutex mutex;
34 typedef null_mutex recursive_mutex;
37 /// llvm_get_global_lock() - returns the llvm global lock object.
38 llvm::recursive_mutex &llvm_get_global_lock();
40 /// llvm_is_multithreaded() - returns true if LLVM is compiled with support
41 /// for multiple threads, and false otherwise.
42 bool llvm_is_multithreaded();
44 /// llvm_execute_on_thread - Execute the given \p UserFn on a separate
45 /// thread, passing it the provided \p UserData.
47 /// This function does not guarantee that the code will actually be executed
48 /// on a separate thread or honoring the requested stack size, but tries to do
49 /// so where system support is available.
51 /// \param UserFn - The callback to execute.
52 /// \param UserData - An argument to pass to the callback function.
53 /// \param RequestedStackSize - If non-zero, a requested size (in bytes) for
55 void llvm_execute_on_thread(void (*UserFn)(void*), void *UserData,
56 unsigned RequestedStackSize = 0);