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:
parent
ad67affbbd
commit
d1c4016480
@ -8,9 +8,9 @@
|
||||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: load_dl.c *
|
||||
* comments: dl based dynamic loaderr of external routines *
|
||||
* tested on i486-linuxelf *
|
||||
* File: load_dyld.c *
|
||||
* comments: dyld based dynamic loaderr of external routines *
|
||||
* tested on MacOS *
|
||||
*************************************************************************/
|
||||
|
||||
#include "Yap.h"
|
||||
@ -19,22 +19,19 @@
|
||||
#include "yapio.h"
|
||||
#include "Foreign.h"
|
||||
|
||||
#if LOAD_DYDL
|
||||
#if LOAD_DYLD
|
||||
|
||||
#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>
|
||||
|
||||
enum dyldErrorSource
|
||||
{
|
||||
OFImage,
|
||||
};
|
||||
|
||||
#define NUM_OFI_ERRORS (sizeof(OFIErrorStrings) / sizeof(OFIErrorStrings[0]))
|
||||
static int dl_errno;
|
||||
|
||||
static char *
|
||||
mydlerror(int dl_errno)
|
||||
mydlerror(void)
|
||||
{
|
||||
char *errString;
|
||||
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 *
|
||||
mydlopen(char *path)
|
||||
{
|
||||
@ -81,17 +88,25 @@ static void *
|
||||
mydlsym(char *symbol)
|
||||
{
|
||||
void *addr;
|
||||
if (NSIsSymbolNameDefined(symbol))
|
||||
addr = NSAddressOfSymbol(NSLookupAndBindSymbol(symbol));
|
||||
char funcname[256];
|
||||
|
||||
#if HAVE_SNPRINTF
|
||||
snprintf(funcname, sizeof(funcname), "_init%.200s", symbol);
|
||||
#else
|
||||
sprintf(funcname, "_%.200s", symbol);
|
||||
#endif
|
||||
if (NSIsSymbolNameDefined(funcname))
|
||||
addr = NSAddressOfSymbol(NSLookupAndBindSymbol(funcname));
|
||||
else
|
||||
addr = NULL;
|
||||
return addr;
|
||||
}
|
||||
|
||||
static void
|
||||
static int
|
||||
mydlclose(void *handle)
|
||||
{
|
||||
NSUnLinkModule(handle, NSUNLINKMODULE_OPTION_NONE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
|
17
H/Foreign.h
17
H/Foreign.h
@ -36,12 +36,11 @@
|
||||
|
||||
#if HAVE_DLOPEN
|
||||
#define LOAD_DL 1
|
||||
#ifdef NO_DYN
|
||||
#undef NO_DYN
|
||||
#endif
|
||||
#endif /* LOAD_DL */
|
||||
|
||||
#if HAVE_NSLINKMODULE
|
||||
#define LOAD_DYLD 1
|
||||
#endif /* LOAD_DYLD */
|
||||
|
||||
#if defined(sparc) || defined(__sparc)
|
||||
#undef NO_DYN
|
||||
#if (!defined(__svr4__) && !defined(__SVR4))
|
||||
@ -72,16 +71,12 @@
|
||||
#define LOAD_SHL 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
#if defined(__MACH__) && defined(__APPLE__)
|
||||
#if HAVE_NSLINKMODULE
|
||||
#ifdef NO_DYN
|
||||
#undef NO_DYN
|
||||
#endif
|
||||
#ifndef LOAD_DL
|
||||
#define LOAD_DL 1
|
||||
#endif
|
||||
#endif
|
||||
*/
|
||||
#define LOAD_DYLD 1
|
||||
#endif /* LOAD_DYLD */
|
||||
|
||||
extern char LoadMsg[];
|
||||
|
||||
|
@ -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(NSLinkModule)
|
||||
AC_CHECK_FUNCS(NSLinkModule)
|
||||
|
||||
if test "$use_condor" = "no"
|
||||
then
|
||||
|
Reference in New Issue
Block a user