X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FSupport%2FDynamicLibrary.cpp;h=f14cb45d9dc066b9f7bf45f6f1b304e20508d318;hb=627190ed78c9c2752dfe7be6ea426690863d54e4;hp=63298b99a0c987c1fb6f1bad31cb8aadbb7a03fb;hpb=0bce85fbfacec97255337d12fc0ab193f03f21c3;p=oota-llvm.git diff --git a/lib/Support/DynamicLibrary.cpp b/lib/Support/DynamicLibrary.cpp index 63298b99a0c..f14cb45d9dc 100644 --- a/lib/Support/DynamicLibrary.cpp +++ b/lib/Support/DynamicLibrary.cpp @@ -13,11 +13,11 @@ // //===----------------------------------------------------------------------===// -#include "llvm/ADT/StringMap.h" -#include "llvm/ADT/DenseSet.h" #include "llvm/Support/DynamicLibrary.h" -#include "llvm/Support/Mutex.h" +#include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/StringMap.h" #include "llvm/Config/config.h" +#include "llvm/Support/Mutex.h" #include #include @@ -46,10 +46,12 @@ void llvm::sys::DynamicLibrary::AddSymbol(StringRef symbolName, void *symbolValue) { SmartScopedLock lock(getMutex()); if (ExplicitSymbols == 0) - ExplicitSymbols = new llvm::StringMap(); + ExplicitSymbols = new StringMap(); (*ExplicitSymbols)[symbolName] = symbolValue; } +char llvm::sys::DynamicLibrary::Invalid = 0; + #ifdef LLVM_ON_WIN32 #include "Windows/DynamicLibrary.inc" @@ -70,6 +72,8 @@ static DenseSet *OpenedHandles = 0; DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename, std::string *errMsg) { + SmartScopedLock lock(getMutex()); + void *handle = dlopen(filename, RTLD_LAZY|RTLD_GLOBAL); if (handle == 0) { if (errMsg) *errMsg = dlerror(); @@ -83,7 +87,6 @@ DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename, handle = RTLD_DEFAULT; #endif - SmartScopedLock lock(getMutex()); if (OpenedHandles == 0) OpenedHandles = new DenseSet(); @@ -157,7 +160,7 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char *symbolName) { // On linux we have a weird situation. The stderr/out/in symbols are both // macros and global variables because of standards requirements. So, we // boldly use the EXPLICIT_SYMBOL macro without checking for a #define first. -#if defined(__linux__) +#if defined(__linux__) and !defined(__ANDROID__) { EXPLICIT_SYMBOL(stderr); EXPLICIT_SYMBOL(stdout);