diff options
Diffstat (limited to 'llvm/lib/Support/ManagedStatic.cpp')
-rw-r--r-- | llvm/lib/Support/ManagedStatic.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/llvm/lib/Support/ManagedStatic.cpp b/llvm/lib/Support/ManagedStatic.cpp index c51ef96..053493f 100644 --- a/llvm/lib/Support/ManagedStatic.cpp +++ b/llvm/lib/Support/ManagedStatic.cpp @@ -12,21 +12,20 @@ #include "llvm/Support/ManagedStatic.h" #include "llvm/Config/config.h" -#include "llvm/Support/Mutex.h" #include "llvm/Support/Threading.h" #include <cassert> #include <mutex> using namespace llvm; static const ManagedStaticBase *StaticList = nullptr; -static sys::Mutex *ManagedStaticMutex = nullptr; +static std::recursive_mutex *ManagedStaticMutex = nullptr; static llvm::once_flag mutex_init_flag; static void initializeMutex() { - ManagedStaticMutex = new sys::Mutex(); + ManagedStaticMutex = new std::recursive_mutex(); } -static sys::Mutex* getManagedStaticMutex() { +static std::recursive_mutex *getManagedStaticMutex() { llvm::call_once(mutex_init_flag, initializeMutex); return ManagedStaticMutex; } @@ -35,7 +34,7 @@ void ManagedStaticBase::RegisterManagedStatic(void *(*Creator)(), void (*Deleter)(void*)) const { assert(Creator); if (llvm_is_multithreaded()) { - std::lock_guard<sys::Mutex> Lock(*getManagedStaticMutex()); + std::lock_guard<std::recursive_mutex> Lock(*getManagedStaticMutex()); if (!Ptr.load(std::memory_order_relaxed)) { void *Tmp = Creator(); @@ -77,7 +76,7 @@ void ManagedStaticBase::destroy() const { /// llvm_shutdown - Deallocate and destroy all ManagedStatic variables. void llvm::llvm_shutdown() { - std::lock_guard<sys::Mutex> Lock(*getManagedStaticMutex()); + std::lock_guard<std::recursive_mutex> Lock(*getManagedStaticMutex()); while (StaticList) StaticList->destroy(); |