diff options
author | Filip Pizlo <fpizlo@apple.com> | 2013-09-18 06:37:55 +0000 |
---|---|---|
committer | Filip Pizlo <fpizlo@apple.com> | 2013-09-18 06:37:55 +0000 |
commit | 163df38bdf365ac743fa0e1067441dc7f0800bed (patch) | |
tree | 32cf64151eb6ce3ea93725561d9528a1de452f1e /lib/Support | |
parent | e77ea6b07e23c38706476fb41d210e4102ffa7eb (diff) | |
download | external_llvm-163df38bdf365ac743fa0e1067441dc7f0800bed.zip external_llvm-163df38bdf365ac743fa0e1067441dc7f0800bed.tar.gz external_llvm-163df38bdf365ac743fa0e1067441dc7f0800bed.tar.bz2 |
Revert r190921. It broke Windows.
I'll roll it back in when I have a chance to look at it in detail.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190923 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r-- | lib/Support/DynamicLibrary.cpp | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/lib/Support/DynamicLibrary.cpp b/lib/Support/DynamicLibrary.cpp index c063f53..f14cb45 100644 --- a/lib/Support/DynamicLibrary.cpp +++ b/lib/Support/DynamicLibrary.cpp @@ -14,7 +14,6 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/DynamicLibrary.h" -#include "llvm/Support/ManagedStatic.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/StringMap.h" #include "llvm/Config/config.h" @@ -23,12 +22,31 @@ #include <cstring> // Collection of symbol name/value pairs to be searched prior to any libraries. -static llvm::ManagedStatic<llvm::StringMap<void *> > ExplicitSymbols; -static llvm::ManagedStatic<llvm::sys::SmartMutex<true> > SymbolsMutex; +static llvm::StringMap<void *> *ExplicitSymbols = 0; + +namespace { + +struct ExplicitSymbolsDeleter { + ~ExplicitSymbolsDeleter() { + delete ExplicitSymbols; + } +}; + +} + +static ExplicitSymbolsDeleter Dummy; + + +static llvm::sys::SmartMutex<true>& getMutex() { + static llvm::sys::SmartMutex<true> HandlesMutex; + return HandlesMutex; +} void llvm::sys::DynamicLibrary::AddSymbol(StringRef symbolName, void *symbolValue) { - SmartScopedLock<true> lock(*SymbolsMutex); + SmartScopedLock<true> lock(getMutex()); + if (ExplicitSymbols == 0) + ExplicitSymbols = new StringMap<void*>(); (*ExplicitSymbols)[symbolName] = symbolValue; } @@ -54,7 +72,7 @@ static DenseSet<void *> *OpenedHandles = 0; DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename, std::string *errMsg) { - SmartScopedLock<true> lock(*SymbolsMutex); + SmartScopedLock<true> lock(getMutex()); void *handle = dlopen(filename, RTLD_LAZY|RTLD_GLOBAL); if (handle == 0) { @@ -108,10 +126,10 @@ void *SearchForAddressOfSpecialSymbol(const char* symbolName); } void* DynamicLibrary::SearchForAddressOfSymbol(const char *symbolName) { - SmartScopedLock<true> Lock(*SymbolsMutex); + SmartScopedLock<true> Lock(getMutex()); // First check symbols added via AddSymbol(). - if (ExplicitSymbols.isConstructed()) { + if (ExplicitSymbols) { StringMap<void *>::iterator i = ExplicitSymbols->find(symbolName); if (i != ExplicitSymbols->end()) |