For PR797:
[oota-llvm.git] / lib / System / Win32 / DynamicLibrary.inc
index 310d3dc83590a5345301efa204d7acc7cee128e5..287a4c009e688b6109458bcdaa593a8c16b57a96 100644 (file)
 #include "Win32.h"
 
 #ifdef __MINGW32__
-#include <imagehlp.h>
+ #include <imagehlp.h>
 #else
-#include <dbghelp.h>
+ #include <dbghelp.h>
 #endif
 
-#pragma comment(lib, "dbghelp.lib")
+#ifdef __MINGW32__
+ #if (HAVE_LIBIMAGEHLP != 1)
+  #error "libimagehlp.a should be present"
+ #endif
+#else
+ #pragma comment(lib, "dbghelp.lib")
+#endif
 
 namespace llvm {
 using namespace sys;
@@ -88,12 +94,13 @@ DynamicLibrary::~DynamicLibrary() {
   }
 }
 
-void DynamicLibrary::LoadLibraryPermanently(const char* filename) {
+bool DynamicLibrary::LoadLibraryPermanently(const char *filename,
+                                            std::string *ErrMsg) {
   if (filename) {
     HMODULE a_handle = LoadLibrary(filename);
 
     if (a_handle == 0)
-      ThrowError(std::string(filename) + ": Can't open : ");
+      return GetError(std::string(filename) + ": Can't open : ", ErrMsg);
 
     OpenedHandles.push_back(a_handle);
   } else {
@@ -104,6 +111,7 @@ void DynamicLibrary::LoadLibraryPermanently(const char* filename) {
 
   // Because we don't remember the handle, we will never free it; hence,
   // it is loaded permanently.
+  return false;
 }
 
 void* DynamicLibrary::SearchForAddressOfSymbol(const char* symbolName) {