YAP 7.1.0
load_aix.c
1/*************************************************************************
2* *
3* YAP Prolog *
4* *
5* Yap Prolog was developed at NCCUP - Universidade do Porto *
6* *
7* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
8* *
9**************************************************************************
10* *
11* File: load_dl.c *
12* comments: dl based dynamic loaderr of external routines *
13* tested on i486-linuxelf *
14*************************************************************************/
15
16#ifdef _AIX
17
18#include "Yap.h"
19#include "Yatom.h"
20#include "yapio.h"
21#include "Foreign.h"
22#include <stdio.h>
23#include <errno.h>
24
25/*
26 * FindExecutable(argv[0]) should be called on yap initialization to
27 * locate the executable of Yap
28*/
29char *
30Yap_FindExecutable(void)
31{
32 return NULL;
33}
34
35
36void *
37Yap_LoadForeignFile(char *file, int flags)
38{
39 /* not implemented */
40 return NULL;
41}
42
43int
44Yap_CallForeignFile(void *handle, char *f)
45{
46 return FALSE;
47}
48
49int
50Yap_CloseForeignFile(void *handle)
51{
52 return -1;
53}
54
55
56/*
57 * LoadForeign(ofiles,libs,proc_name,init_proc) dynamically loads foreign
58 * code files and libraries and locates an initialization routine
59*/
60static Int
61LoadForeign(StringList ofiles, StringList libs,
62 char *proc_name, YapInitProc *init_proc)
63{
64
65 extern char *sys_errlist[ ];
66
67 /* load wants to follow the LIBRARY_PATH */
68 if (ofiles->next != NULL || libs != NULL) {
69 strcpy(LOCAL_ErrorSay," Load Failed: in AIX you must load a single object file");
70 return LOAD_FAILLED;
71 }
72 if (!Yap_AbsoluteFileInBuffer(AtomName(ofiles->name), LOCAL_FileNameBuf, MAX_PATH, true)) {
73 strcpy(LOCAL_ErrorSay, " Trying to open unexisting file in LoadForeign ");
74 return LOAD_FAILLED;
75 }
76 /* In AIX, just call load and everything will go in */
77 if ((*init_proc=((YapInitProc *)load(LOCAL_FileNameBuf,0,NULL))) == NULL) {
78 strcpy(LOCAL_ErrorSay,sys_errlist[errno]);
79 return LOAD_FAILLED;
80 }
81 return LOAD_SUCCEEDED;
82}
83
84Int
85Yap_LoadForeign(StringList ofiles, StringList libs,
86 char *proc_name, YapInitProc *init_proc)
87{
88 return LoadForeign(ofiles, libs, proc_name, init_proc);
89}
90
91void
92Yap_ShutdownLoadForeign(void)
93{
94}
95
96Int
97Yap_ReLoadForeign(StringList ofiles, StringList libs,
98 char *proc_name, YapInitProc *init_proc)
99{
100 return(LoadForeign(ofiles,libs, proc_name, init_proc));
101}
102
103#endif /* _AIX */
104
105
106
107
load_foreign_files/3 has works for the following configurations:
Main definitions.