From: andy Date: Fri, 15 Oct 1999 19:11:55 +0000 (+0000) Subject: [project @ 1999-10-15 19:11:54 by andy] X-Git-Tag: Approximately_9120_patches~5697 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=07a8980dbced907eb0a6f3c873dfc6be270ffbae;p=ghc-hetmet.git [project @ 1999-10-15 19:11:54 by andy] Changing order of check for use of DLL for dynamic linking. (Under cygwin, we still want to use DLL's). --- diff --git a/ghc/interpreter/dynamic.c b/ghc/interpreter/dynamic.c index 3fb2a61..be6fa5b 100644 --- a/ghc/interpreter/dynamic.c +++ b/ghc/interpreter/dynamic.c @@ -7,8 +7,8 @@ * Hugs version 1.4, December 1997 * * $RCSfile: dynamic.c,v $ - * $Revision: 1.5 $ - * $Date: 1999/06/07 17:22:31 $ + * $Revision: 1.6 $ + * $Date: 1999/10/15 19:11:54 $ * ------------------------------------------------------------------------*/ #include "prelude.h" @@ -16,7 +16,41 @@ #include "errors.h" #include "dynamic.h" -#if HAVE_DLFCN_H /* eg LINUX, SOLARIS, ULTRIX */ +#if HAVE_WINDOWS_H && !defined(__MSDOS__) + +#include + +ObjectFile loadLibrary(fn) +String fn; { + return LoadLibrary(fn); +} + +void* lookupSymbol(file,symbol) +ObjectFile file; +String symbol; { + return GetProcAddress(file,symbol); +} + +const char *dlerror(void) +{ + return ""; +} + +void* getDLLSymbol(dll,symbol) /* load dll and lookup symbol */ +String dll; +String symbol; { + ObjectFile instance = LoadLibrary(dll); + if (NULL == instance) { + /* GetLastError allegedly provides more detail - in practice, + * it tells you nothing more. + */ + ERRMSG(0) "Error while importing DLL \"%s\"", dll + EEND; + } + return GetProcAddress(instance,symbol); +} + +#elif HAVE_DLFCN_H /* eg LINUX, SOLARIS, ULTRIX */ #include #include @@ -65,40 +99,6 @@ String symbol; { return (0 == shl_findsym(&instance,symbol,TYPE_PROCEDURE,&r)) ? r : 0; } -#elif HAVE_WINDOWS_H && !defined(__MSDOS__) - -#include - -ObjectFile loadLibrary(fn) -String fn; { - return LoadLibrary(fn); -} - -void* lookupSymbol(file,symbol) -ObjectFile file; -String symbol; { - return GetProcAddress(file,symbol); -} - -const char *dlerror(void) -{ - return ""; -} - -void* getDLLSymbol(dll,symbol) /* load dll and lookup symbol */ -String dll; -String symbol; { - ObjectFile instance = LoadLibrary(dll); - if (NULL == instance) { - /* GetLastError allegedly provides more detail - in practice, - * it tells you nothing more. - */ - ERRMSG(0) "Error while importing DLL \"%s\"", dll - EEND; - } - return GetProcAddress(instance,symbol); -} - #else /* Dynamic loading not available */ void* getDLLSymbol(dll,symbol) /* load dll and lookup symbol */ diff --git a/ghc/interpreter/prelude.h b/ghc/interpreter/prelude.h index 8886a3a..3d41bb1 100644 --- a/ghc/interpreter/prelude.h +++ b/ghc/interpreter/prelude.h @@ -8,8 +8,8 @@ * Hugs version 1.4, December 1997 * * $RCSfile: prelude.h,v $ - * $Revision: 1.3 $ - * $Date: 1999/02/03 17:08:36 $ + * $Revision: 1.4 $ + * $Date: 1999/10/15 19:11:55 $ * ------------------------------------------------------------------------*/ #include "config.h" @@ -246,12 +246,12 @@ typedef void* HpPtr; /* ToDo: this should probably go in dynamic.h - but then * storage.h has to include dynamic.h! */ -#if HAVE_DLFCN_H /* eg LINUX, SOLARIS, ULTRIX */ +#if HAVE_WINDOWS_H && !defined(__MSDOS__) +typedef HINSTANCE ObjectFile; +#elif HAVE_DLFCN_H /* eg LINUX, SOLARIS, ULTRIX */ typedef void* ObjectFile; #elif HAVE_DL_H /* eg HPUX */ typedef shl_t ObjectFile; -#elif HAVE_WINDOWS_H && !defined(__MSDOS__) -typedef HINSTANCE ObjectFile; #else #warning GHC file loading not available on this machine #endif