2001-04-09 20:54:03 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* *
|
|
|
|
* YAP Prolog *
|
|
|
|
* *
|
|
|
|
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
|
|
|
* *
|
|
|
|
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-97 *
|
|
|
|
* *
|
|
|
|
**************************************************************************
|
|
|
|
* *
|
|
|
|
* File: Foreign.h *
|
|
|
|
* comments: header file for dynamic loading routines *
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#define NO_DYN 1
|
|
|
|
|
|
|
|
/* Currently load_foreign_files works for the following machines:
|
|
|
|
|
|
|
|
AIX: should work for 3.2 and 4.1 at least, using ECOFF;
|
|
|
|
linux: should work both for a.out (untested by me) and ELF;
|
|
|
|
osf: should work, but isn't working yet.
|
|
|
|
sunos4: should work, using A.OUT format;
|
|
|
|
svr4, eg solaris: should work, using ELF format;
|
|
|
|
|
|
|
|
YAP should be able to load on most BSD Unixes, but you will need to
|
|
|
|
say that here.
|
|
|
|
|
|
|
|
YAP also supports COFF loading (pretty much the same technique as
|
|
|
|
used for A.OUT loading) but that is untested so far.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef _AIX
|
|
|
|
#undef NO_DYN
|
|
|
|
#endif /* __AIX */
|
|
|
|
|
2002-08-19 00:18:18 +01:00
|
|
|
#if HAVE_DLOPEN
|
2001-04-09 20:54:03 +01:00
|
|
|
#define LOAD_DL 1
|
2002-09-24 16:38:17 +01:00
|
|
|
#ifdef NO_DYN
|
|
|
|
#undef NO_DYN
|
|
|
|
#endif
|
2002-08-19 00:18:18 +01:00
|
|
|
#endif /* LOAD_DL */
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2001-09-24 19:07:16 +01:00
|
|
|
#if defined(sparc) || defined(__sparc)
|
2001-04-09 20:54:03 +01:00
|
|
|
#undef NO_DYN
|
2001-09-24 19:07:16 +01:00
|
|
|
#if (!defined(__svr4__) && !defined(__SVR4))
|
2001-04-09 20:54:03 +01:00
|
|
|
#define A_OUT 1
|
|
|
|
#else
|
|
|
|
#ifdef SIMICS
|
|
|
|
#define NO_DYN 1
|
|
|
|
#else
|
|
|
|
#define LOAD_DL 1
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2002-10-17 02:37:46 +01:00
|
|
|
#if defined(_WIN32)
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifdef NO_DYN
|
|
|
|
#undef NO_DYN
|
|
|
|
#define LOAD_DLL 1
|
|
|
|
#endif
|
2002-08-28 15:02:35 +01:00
|
|
|
#if LOAD_DL
|
|
|
|
#undef LOAD_DL
|
|
|
|
#endif
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __hpux
|
|
|
|
#ifdef NO_DYN
|
|
|
|
#undef NO_DYN
|
|
|
|
#endif
|
|
|
|
#define LOAD_SHL 1
|
|
|
|
#endif
|
|
|
|
|
2008-03-25 22:03:14 +00:00
|
|
|
#ifdef HAVE_NSLINKMODULE
|
2002-04-23 15:37:56 +01:00
|
|
|
#ifdef NO_DYN
|
|
|
|
#undef NO_DYN
|
|
|
|
#endif
|
2002-10-20 19:43:11 +01:00
|
|
|
#if !HAVE_DLOPEN
|
2002-09-24 16:38:17 +01:00
|
|
|
#define LOAD_DYLD 1
|
2002-10-20 19:43:11 +01:00
|
|
|
#endif
|
2002-09-24 16:38:17 +01:00
|
|
|
#endif /* LOAD_DYLD */
|
2002-04-23 15:37:56 +01:00
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
#define LOAD_SUCCEEDED 0
|
|
|
|
#define LOAD_FAILLED -1
|
|
|
|
|
|
|
|
typedef struct StringListItem {
|
2010-12-12 18:28:55 +00:00
|
|
|
Atom name;
|
2001-04-09 20:54:03 +01:00
|
|
|
void *handle;
|
|
|
|
struct StringListItem *next;
|
|
|
|
} StringListItem, *StringList;
|
|
|
|
|
|
|
|
typedef struct ForeignLoadItem {
|
|
|
|
StringList objs;
|
|
|
|
StringList libs;
|
2012-06-11 22:11:30 +01:00
|
|
|
Atom f;
|
2009-10-30 23:59:00 +00:00
|
|
|
Term module;
|
2001-04-09 20:54:03 +01:00
|
|
|
struct ForeignLoadItem *next;
|
|
|
|
} ForeignObj;
|
|
|
|
|
|
|
|
typedef void (*YapInitProc)(void);
|
|
|
|
|
2010-06-17 00:31:42 +01:00
|
|
|
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifndef STD_PROTO
|
|
|
|
#define STD_PROTO(F,A) F A
|
|
|
|
#endif
|
|
|
|
|
2013-01-13 17:55:13 +00:00
|
|
|
char *STD_PROTO(Yap_FindExecutable,(void));
|
2010-06-17 00:31:42 +01:00
|
|
|
void *STD_PROTO(Yap_LoadForeignFile,(char *, int));
|
|
|
|
int STD_PROTO(Yap_CallForeignFile,(void *, char *));
|
|
|
|
int STD_PROTO(Yap_CloseForeignFile,(void *));
|
|
|
|
Int STD_PROTO(Yap_LoadForeign,(StringList, StringList, char *, YapInitProc *));
|
|
|
|
Int STD_PROTO(Yap_ReLoadForeign,(StringList, StringList, char *, YapInitProc *));
|
2002-11-18 18:18:05 +00:00
|
|
|
void STD_PROTO(Yap_ReOpenLoadForeign,(void));
|
|
|
|
void STD_PROTO(Yap_ShutdownLoadForeign,(void));
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2010-06-17 00:31:42 +01:00
|
|
|
#define EAGER_LOADING 1
|
|
|
|
#define GLOBAL_LOADING 2
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|