[llvm] r190923 - Revert r190921. It broke Windows.
Filip Pizlo
fpizlo at apple.com
Tue Sep 17 23:37:56 PDT 2013
Author: fpizlo
Date: Wed Sep 18 01:37:55 2013
New Revision: 190923
URL: http://llvm.org/viewvc/llvm-project?rev=190923&view=rev
Log:
Revert r190921. It broke Windows.
I'll roll it back in when I have a chance to look at it in detail.
Modified:
llvm/trunk/lib/Support/DynamicLibrary.cpp
Modified: llvm/trunk/lib/Support/DynamicLibrary.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/DynamicLibrary.cpp?rev=190923&r1=190922&r2=190923&view=diff
==============================================================================
--- llvm/trunk/lib/Support/DynamicLibrary.cpp (original)
+++ llvm/trunk/lib/Support/DynamicLibrary.cpp Wed Sep 18 01:37:55 2013
@@ -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 =
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(co
}
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())
More information about the llvm-commits
mailing list