forked from OSchip/llvm-project
parent
04bf64d43c
commit
e4807c5767
|
@ -12,7 +12,6 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "Win32.h"
|
||||
#include "llvm/System/RWMutex.h"
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#include <imagehlp.h>
|
||||
|
@ -68,7 +67,6 @@ extern "C" {
|
|||
PVOID UserContext)
|
||||
#endif
|
||||
{
|
||||
llvm::sys::SmartScopedWriter<true> Writer(&SymbolsLock);
|
||||
// Ignore VC++ runtimes prior to 7.1. Somehow some of them get loaded
|
||||
// into the process.
|
||||
if (stricmp(ModuleName, "msvci70") != 0 &&
|
||||
|
@ -91,13 +89,11 @@ extern "C" {
|
|||
}
|
||||
|
||||
DynamicLibrary::DynamicLibrary() : handle(0) {
|
||||
SmartScopedWriter<true> Writer(&SymbolsLock);
|
||||
handle = GetModuleHandle(NULL);
|
||||
OpenedHandles.push_back((HMODULE)handle);
|
||||
}
|
||||
|
||||
DynamicLibrary::~DynamicLibrary() {
|
||||
llvm::sys::SmartScopedWriter<true> Writer(&SymbolsLock);
|
||||
if (handle == 0)
|
||||
return;
|
||||
|
||||
|
@ -119,7 +115,6 @@ DynamicLibrary::~DynamicLibrary() {
|
|||
bool DynamicLibrary::LoadLibraryPermanently(const char *filename,
|
||||
std::string *ErrMsg) {
|
||||
if (filename) {
|
||||
llvm::sys::SmartScopedWriter<true> Writer(&SymbolsLock);
|
||||
HMODULE a_handle = LoadLibrary(filename);
|
||||
|
||||
if (a_handle == 0)
|
||||
|
@ -171,24 +166,22 @@ bool DynamicLibrary::LoadLibraryPermanently(const char *filename,
|
|||
|
||||
void* DynamicLibrary::SearchForAddressOfSymbol(const char* symbolName) {
|
||||
// First check symbols added via AddSymbol().
|
||||
SymbolsLock.reader_acquire();
|
||||
std::map<std::string, void *>::iterator I = symbols.find(symbolName);
|
||||
std::map<std::string, void *>::iterator E = symbols.end();
|
||||
SymbolsLock.reader_release();
|
||||
if (I != E)
|
||||
return I->second;
|
||||
if (ExplicitSymbols) {
|
||||
std::map<std::string, void *>::iterator I =
|
||||
ExplicitSymbols->find(symbolName);
|
||||
std::map<std::string, void *>::iterator E = ExplicitSymbols->end();
|
||||
if (I != E)
|
||||
return I->second;
|
||||
}
|
||||
|
||||
// Now search the libraries.
|
||||
SymbolsLock.writer_acquire();
|
||||
for (std::vector<HMODULE>::iterator I = OpenedHandles.begin(),
|
||||
E = OpenedHandles.end(); I != E; ++I) {
|
||||
FARPROC ptr = GetProcAddress((HMODULE)*I, symbolName);
|
||||
if (ptr) {
|
||||
SymbolsLock.writer_release();
|
||||
return (void *) ptr;
|
||||
}
|
||||
}
|
||||
SymbolsLock.writer_release();
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue