[llvm] r175398 - Add multithreading functions and shutdown to the C API. Patch by Moritz
Duncan Sands
baldrick at free.fr
Sun Feb 17 08:35:51 PST 2013
Author: baldrick
Date: Sun Feb 17 10:35:51 2013
New Revision: 175398
URL: http://llvm.org/viewvc/llvm-project?rev=175398&view=rev
Log:
Add multithreading functions and shutdown to the C API. Patch by Moritz
Maxeiner.
Modified:
llvm/trunk/include/llvm-c/Core.h
llvm/trunk/lib/IR/Core.cpp
Modified: llvm/trunk/include/llvm-c/Core.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=175398&r1=175397&r2=175398&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/Core.h (original)
+++ llvm/trunk/include/llvm-c/Core.h Sun Feb 17 10:35:51 2013
@@ -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 ----------------------------------------------------===*/
@@ -2624,6 +2629,34 @@ void LLVMDisposePassManager(LLVMPassMana
/**
* @}
+ */
+
+/**
+ * @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();
+
+/**
+ * @}
*/
/**
Modified: llvm/trunk/lib/IR/Core.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Core.cpp?rev=175398&r1=175397&r2=175398&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Core.cpp (original)
+++ llvm/trunk/lib/IR/Core.cpp Sun Feb 17 10:35:51 2013
@@ -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(LLVMPassRegistry
initializeCore(*unwrap(R));
}
+void LLVMShutdown() {
+ llvm_shutdown();
+}
+
/*===-- Error handling ----------------------------------------------------===*/
void LLVMDisposeMessage(char *Message) {
@@ -2436,3 +2442,17 @@ LLVMBool LLVMFinalizeFunctionPassManager
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();
+}
More information about the llvm-commits
mailing list