Add multithreading functions and shutdown to the C API. Patch by Moritz

Maxeiner.

llvm-svn: 175398
This commit is contained in:
Duncan Sands 2013-02-17 16:35:51 +00:00
parent 76e65e4542
commit 1cba0a8e0a
2 changed files with 53 additions and 0 deletions

View File

@ -358,6 +358,11 @@ typedef enum {
void LLVMInitializeCore(LLVMPassRegistryRef R);
/** Deallocate and destroy all ManagedStatic variables.
@see llvm::llvm_shutdown
@see ManagedStatic */
void LLVMShutdown();
/*===-- Error handling ----------------------------------------------------===*/
@ -2622,6 +2627,34 @@ LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
@see llvm::PassManagerBase::~PassManagerBase. */
void LLVMDisposePassManager(LLVMPassManagerRef PM);
/**
* @}
*/
/**
* @defgroup LLVMCCoreThreading Threading
*
* Handle the structures needed to make LLVM safe for multithreading.
*
* @{
*/
/** Allocate and initialize structures needed to make LLVM safe for
multithreading. The return value indicates whether multithreaded
initialization succeeded. Must be executed in isolation from all
other LLVM api calls.
@see llvm::llvm_start_multithreaded */
LLVMBool LLVMStartMultithreaded();
/** Deallocate structures necessary to make LLVM safe for multithreading.
Must be executed in isolation from all other LLVM api calls.
@see llvm::llvm_stop_multithreaded */
void LLVMStopMultithreaded();
/** Check whether LLVM is executing in thread-safe mode or not.
@see llvm::llvm_is_multithreaded */
LLVMBool LLVMIsMultithreaded();
/**
* @}
*/

View File

@ -26,9 +26,11 @@
#include "llvm/Support/CallSite.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/system_error.h"
#include "llvm/Support/Threading.h"
#include <cassert>
#include <cstdlib>
#include <cstring>
@ -48,6 +50,10 @@ void LLVMInitializeCore(LLVMPassRegistryRef R) {
initializeCore(*unwrap(R));
}
void LLVMShutdown() {
llvm_shutdown();
}
/*===-- Error handling ----------------------------------------------------===*/
void LLVMDisposeMessage(char *Message) {
@ -2436,3 +2442,17 @@ LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM) {
void LLVMDisposePassManager(LLVMPassManagerRef PM) {
delete unwrap(PM);
}
/*===-- Threading ------------------------------------------------------===*/
LLVMBool LLVMStartMultithreaded() {
return llvm_start_multithreaded();
}
void LLVMStopMultithreaded() {
llvm_stop_multithreaded();
}
LLVMBool LLVMIsMultithreaded() {
return llvm_is_multithreaded();
}