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
|
|
|
|
|
2015-07-06 12:01:55 +01:00
|
|
|
#ifndef FOREIGN_H
|
|
|
|
#define FOREIGN_H
|
|
|
|
|
2017-04-07 23:10:59 +01:00
|
|
|
/**
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2017-04-07 23:10:59 +01:00
|
|
|
@:
|
|
|
|
@file Foreign.h
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2017-04-07 23:10:59 +01:00
|
|
|
load_foreign_files/3 has works for the following configurations:
|
|
|
|
|
|
|
|
- linux: should work both for a.out (untested by me) and ELF;
|
|
|
|
|
|
|
|
- WIN32: works (notice that symbols are not exported by default)
|
|
|
|
|
|
|
|
- OSX: works using Mach dynamic libs.
|
|
|
|
|
|
|
|
- osf: should work, but isn't working yet.
|
|
|
|
|
|
|
|
- sunos4: should work, using A.OUT format;
|
|
|
|
|
|
|
|
- svr4, eg solaris: should work, using ELF format;
|
|
|
|
|
|
|
|
- AIX: should work for 3.2 and 4.1 at least, using ECOFF;
|
|
|
|
|
|
|
|
YAP should be able to load on most BSD Unixes, but you will need to
|
2001-04-09 20:54:03 +01:00
|
|
|
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 */
|
|
|
|
|
2016-01-31 10:23:27 +00:00
|
|
|
#ifdef 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
|
|
|
|
2013-04-25 23:15:04 +01:00
|
|
|
void *Yap_LoadForeignFile(char *, int);
|
|
|
|
int Yap_CallForeignFile(void *, char *);
|
|
|
|
int Yap_CloseForeignFile(void *);
|
|
|
|
Int Yap_LoadForeign(StringList, StringList, char *, YapInitProc *);
|
|
|
|
Int Yap_ReLoadForeign(StringList, StringList, char *, YapInitProc *);
|
|
|
|
void Yap_ReOpenLoadForeign(void);
|
|
|
|
void 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
|
2015-07-06 12:01:55 +01:00
|
|
|
|
|
|
|
#endif
|