1 //===-- llvm/Support/Threading.h - Control multithreading mode --*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // TThis file defines llvm_start_multithreaded() and friends. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_SYSTEM_THREADING_H 15 #define LLVM_SYSTEM_THREADING_H 16 17 namespace llvm { 18 /// llvm_start_multithreaded - Allocate and initialize structures needed to 19 /// make LLVM safe for multithreading. The return value indicates whether 20 /// multithreaded initialization succeeded. LLVM will still be operational 21 /// on "failed" return, and will still be safe for hosting threading 22 /// applications in the JIT, but will not be safe for concurrent calls to the 23 /// LLVM APIs. 24 /// THIS MUST EXECUTE IN ISOLATION FROM ALL OTHER LLVM API CALLS. 25 bool llvm_start_multithreaded(); 26 27 /// llvm_stop_multithreaded - Deallocate structures necessary to make LLVM 28 /// safe for multithreading. 29 /// THIS MUST EXECUTE IN ISOLATION FROM ALL OTHER LLVM API CALLS. 30 void llvm_stop_multithreaded(); 31 32 /// llvm_is_multithreaded - Check whether LLVM is executing in thread-safe 33 /// mode or not. 34 bool llvm_is_multithreaded(); 35 36 /// acquire_global_lock - Acquire the global lock. This is a no-op if called 37 /// before llvm_start_multithreaded(). 38 void llvm_acquire_global_lock(); 39 40 /// release_global_lock - Release the global lock. This is a no-op if called 41 /// before llvm_start_multithreaded(). 42 void llvm_release_global_lock(); 43 44 /// llvm_execute_on_thread - Execute the given \arg UserFn on a separate 45 /// thread, passing it the provided \arg UserData. 46 /// 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. 50 /// 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 54 /// the thread stack. 55 void llvm_execute_on_thread(void (*UserFn)(void*), void *UserData, 56 unsigned RequestedStackSize = 0); 57 } 58 59 #endif 60