Have llvm_start_multithreaded return a bool indicating whether multithreaded
authorOwen Anderson <resistor@mac.com>
Wed, 20 May 2009 21:03:06 +0000 (21:03 +0000)
committerOwen Anderson <resistor@mac.com>
Wed, 20 May 2009 21:03:06 +0000 (21:03 +0000)
initialization succeeded or not, rather than just asserting.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72182 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/ManagedStatic.h
lib/Support/ManagedStatic.cpp

index 7eecce3241d60becb82d93167333ad3e3d75b9f7..619cc2055250a9b46f95ecdb0b177e1a5c1343ae 100644 (file)
@@ -96,8 +96,10 @@ public:
 
 
 /// llvm_start_multithreaded - Allocate and initialize structures needed to
-/// make LLVM safe for multithreading.
-void llvm_start_multithreaded();
+/// make LLVM safe for multithreading.  The return value indicates whether
+/// multithreaded initialization succeeded.  LLVM will still be operational
+/// on "failed" return, but will not be safe to run multithreaded.
+bool llvm_start_multithreaded();
 
 /// llvm_shutdown - Deallocate and destroy all ManagedStatic variables.
 void llvm_shutdown();
index 056b6c06c1ee141b031462a3aa2759c1420bd688..a3b2bcc66a9c6dc390c7239b34ede162499386b7 100644 (file)
@@ -68,12 +68,13 @@ void ManagedStaticBase::destroy() const {
   DeleterFn = 0;
 }
 
-void llvm::llvm_start_multithreaded() {
+bool llvm::llvm_start_multithreaded() {
 #if LLVM_MULTITHREADED
   assert(ManagedStaticMutex == 0 && "Multithreaded LLVM already initialized!");
   ManagedStaticMutex = new sys::Mutex(true);
+  return true;
 #else
-  assert(0 && "LLVM built without multithreading support!");
+  return false;
 #endif
 }