support dyld interface on Next and OSX machines.

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@605 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2002-09-24 15:38:17 +00:00
parent ad67affbbd
commit d1c4016480
4 changed files with 1981 additions and 4617 deletions

View File

@ -8,9 +8,9 @@
* * * *
************************************************************************** **************************************************************************
* * * *
* File: load_dl.c * * File: load_dyld.c *
* comments: dl based dynamic loaderr of external routines * * comments: dyld based dynamic loaderr of external routines *
* tested on i486-linuxelf * * tested on MacOS *
*************************************************************************/ *************************************************************************/
#include "Yap.h" #include "Yap.h"
@ -19,22 +19,19 @@
#include "yapio.h" #include "yapio.h"
#include "Foreign.h" #include "Foreign.h"
#if LOAD_DYDL #if LOAD_DYLD
#include <string.h> #include <string.h>
/* This code is originally from Rex A. Dieter posting in comp.sys.next.programmer */ /* Code originally from Rex A. Dieter's posting in comp.sys.next.programmer
and from dynload_next.c in the Python sources
*/
#import <mach-o/dyld.h> #import <mach-o/dyld.h>
enum dyldErrorSource static int dl_errno;
{
OFImage,
};
#define NUM_OFI_ERRORS (sizeof(OFIErrorStrings) / sizeof(OFIErrorStrings[0]))
static char * static char *
mydlerror(int dl_errno) mydlerror(void)
{ {
char *errString; char *errString;
switch(dl_errno) { switch(dl_errno) {
@ -61,6 +58,16 @@ mydlerror(int dl_errno)
} }
/*
* YAP_FindExecutable(argv[0]) should be called on yap initialization to
* locate the executable of Yap
*/
void
YAP_FindExecutable(char *name)
{
}
static void * static void *
mydlopen(char *path) mydlopen(char *path)
{ {
@ -81,17 +88,25 @@ static void *
mydlsym(char *symbol) mydlsym(char *symbol)
{ {
void *addr; void *addr;
if (NSIsSymbolNameDefined(symbol)) char funcname[256];
addr = NSAddressOfSymbol(NSLookupAndBindSymbol(symbol));
#if HAVE_SNPRINTF
snprintf(funcname, sizeof(funcname), "_init%.200s", symbol);
#else
sprintf(funcname, "_%.200s", symbol);
#endif
if (NSIsSymbolNameDefined(funcname))
addr = NSAddressOfSymbol(NSLookupAndBindSymbol(funcname));
else else
addr = NULL; addr = NULL;
return addr; return addr;
} }
static void static int
mydlclose(void *handle) mydlclose(void *handle)
{ {
NSUnLinkModule(handle, NSUNLINKMODULE_OPTION_NONE); NSUnLinkModule(handle, NSUNLINKMODULE_OPTION_NONE);
return TRUE;
} }
/* /*

View File

@ -36,12 +36,11 @@
#if HAVE_DLOPEN #if HAVE_DLOPEN
#define LOAD_DL 1 #define LOAD_DL 1
#ifdef NO_DYN
#undef NO_DYN
#endif
#endif /* LOAD_DL */ #endif /* LOAD_DL */
#if HAVE_NSLINKMODULE
#define LOAD_DYLD 1
#endif /* LOAD_DYLD */
#if defined(sparc) || defined(__sparc) #if defined(sparc) || defined(__sparc)
#undef NO_DYN #undef NO_DYN
#if (!defined(__svr4__) && !defined(__SVR4)) #if (!defined(__svr4__) && !defined(__SVR4))
@ -72,16 +71,12 @@
#define LOAD_SHL 1 #define LOAD_SHL 1
#endif #endif
/* #if HAVE_NSLINKMODULE
#if defined(__MACH__) && defined(__APPLE__)
#ifdef NO_DYN #ifdef NO_DYN
#undef NO_DYN #undef NO_DYN
#endif #endif
#ifndef LOAD_DL #define LOAD_DYLD 1
#define LOAD_DL 1 #endif /* LOAD_DYLD */
#endif
#endif
*/
extern char LoadMsg[]; extern char LoadMsg[];

6534
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -845,7 +845,7 @@ AC_CHECK_FUNCS(time times tmpnam usleep vsnprintf)
AC_CHECK_FUNC(regexec, [NO_BUILTIN_REGEXP="#"], [NO_BUILTIN_REGEXP=""]) AC_CHECK_FUNC(regexec, [NO_BUILTIN_REGEXP="#"], [NO_BUILTIN_REGEXP=""])
AC_CHECK_FUNC(NSLinkModule) AC_CHECK_FUNCS(NSLinkModule)
if test "$use_condor" = "no" if test "$use_condor" = "no"
then then