diff options
author | Mehdi Amini <mehdi.amini@apple.com> | 2016-05-14 23:44:21 +0000 |
---|---|---|
committer | Mehdi Amini <mehdi.amini@apple.com> | 2016-05-14 23:44:21 +0000 |
commit | 0fb24887026f9314a49f1ebd6ff6ed5352279913 (patch) | |
tree | e80df19c6a511d8e00d1f669b332a6ac2e8227b5 /llvm/lib/Support/ManagedStatic.cpp | |
parent | 0b89ade3411e74c30de7a7cab92d417415ff6db6 (diff) | |
download | bcm5719-llvm-0fb24887026f9314a49f1ebd6ff6ed5352279913.tar.gz bcm5719-llvm-0fb24887026f9314a49f1ebd6ff6ed5352279913.zip |
Revert "Revert "Revert 220932.": "Removing the static initializer in ManagedStatic.cpp by using llvm_call_once to initialize the ManagedStatic mutex""
This reverts commit r269577.
Broke NetBSD, waiting for Kamil to investigate
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 269584
Diffstat (limited to 'llvm/lib/Support/ManagedStatic.cpp')
-rw-r--r-- | llvm/lib/Support/ManagedStatic.cpp | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/llvm/lib/Support/ManagedStatic.cpp b/llvm/lib/Support/ManagedStatic.cpp index b1feddc09ec..b8fb2841e52 100644 --- a/llvm/lib/Support/ManagedStatic.cpp +++ b/llvm/lib/Support/ManagedStatic.cpp @@ -16,23 +16,16 @@ #include "llvm/Support/Atomic.h" #include "llvm/Support/Mutex.h" #include "llvm/Support/MutexGuard.h" -#include "llvm/Support/Threading.h" #include <cassert> using namespace llvm; static const ManagedStaticBase *StaticList = nullptr; -static sys::Mutex *ManagedStaticMutex = nullptr; -LLVM_DEFINE_ONCE_FLAG(mutex_init_flag); -static void initializeMutex() { - ManagedStaticMutex = new sys::Mutex(); -} - -static sys::Mutex* getManagedStaticMutex() { +static sys::Mutex& getManagedStaticMutex() { // We need to use a function local static here, since this can get called // during a static constructor and we need to guarantee that it's initialized // correctly. - call_once(mutex_init_flag, initializeMutex); + static sys::Mutex ManagedStaticMutex; return ManagedStaticMutex; } @@ -40,7 +33,7 @@ void ManagedStaticBase::RegisterManagedStatic(void *(*Creator)(), void (*Deleter)(void*)) const { assert(Creator); if (llvm_is_multithreaded()) { - MutexGuard Lock(*getManagedStaticMutex()); + MutexGuard Lock(getManagedStaticMutex()); if (!Ptr) { void* tmp = Creator(); @@ -90,7 +83,7 @@ void ManagedStaticBase::destroy() const { /// llvm_shutdown - Deallocate and destroy all ManagedStatic variables. void llvm::llvm_shutdown() { - MutexGuard Lock(*getManagedStaticMutex()); + MutexGuard Lock(getManagedStaticMutex()); while (StaticList) StaticList->destroy(); |