all global symbols should now start with _YAP
global functions should not be called from within file (bug in binutils/WIN32). git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@675 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
@@ -28,14 +28,12 @@ static char SccsId[] = "%W% %G%.2";
|
||||
|
||||
#include "Foreign.h"
|
||||
|
||||
#if _WIN32
|
||||
#if _WIN32 || defined(__CYGWIN__)
|
||||
#ifndef SHLIB_SUFFIX
|
||||
#define SHLIB_SUFFIX "dll"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
char LoadMsg[512];
|
||||
|
||||
STD_PROTO(Int p_load_foreign, (void));
|
||||
|
||||
Int
|
||||
@@ -49,7 +47,7 @@ p_load_foreign(void)
|
||||
StringList new;
|
||||
Int returncode = FALSE;
|
||||
|
||||
strcpy(LoadMsg,"Invalid arguments");
|
||||
strcpy(_YAP_ErrorSay,"Invalid arguments");
|
||||
|
||||
/* collect the list of object files */
|
||||
t = Deref(ARG1);
|
||||
@@ -57,7 +55,7 @@ p_load_foreign(void)
|
||||
if (t == TermNil) break;
|
||||
t1 = HeadOfTerm(t);
|
||||
t = TailOfTerm(t);
|
||||
new = (StringList) AllocCodeSpace(sizeof(StringListItem));
|
||||
new = (StringList) _YAP_AllocCodeSpace(sizeof(StringListItem));
|
||||
new->next = ofiles;
|
||||
new->s = RepAtom(AtomOfTerm(t1))->StrOfAE;
|
||||
ofiles = new;
|
||||
@@ -69,7 +67,7 @@ p_load_foreign(void)
|
||||
if (t == TermNil) break;
|
||||
t1 = HeadOfTerm(t);
|
||||
t = TailOfTerm(t);
|
||||
new = (StringList) AllocCodeSpace(sizeof(StringListItem));
|
||||
new = (StringList) _YAP_AllocCodeSpace(sizeof(StringListItem));
|
||||
new->next = libs;
|
||||
new->s = RepAtom(AtomOfTerm(t1))->StrOfAE;
|
||||
libs = new;
|
||||
@@ -82,14 +80,14 @@ p_load_foreign(void)
|
||||
|
||||
|
||||
/* call the OS specific function for dynamic loading */
|
||||
if(LoadForeign(ofiles,libs,InitProcName,&InitProc)==LOAD_SUCCEEDED) {
|
||||
if(_YAP_LoadForeign(ofiles,libs,InitProcName,&InitProc)==LOAD_SUCCEEDED) {
|
||||
(*InitProc)();
|
||||
returncode = TRUE;
|
||||
}
|
||||
|
||||
/* I should recover space if load foreign fails */
|
||||
if (returncode == TRUE) {
|
||||
ForeignObj *f_code = (ForeignObj *)AllocCodeSpace(sizeof(ForeignObj));
|
||||
ForeignObj *f_code = (ForeignObj *)_YAP_AllocCodeSpace(sizeof(ForeignObj));
|
||||
f_code->objs = ofiles;
|
||||
f_code->libs = libs;
|
||||
f_code->f = InitProcName;
|
||||
@@ -102,22 +100,22 @@ p_load_foreign(void)
|
||||
|
||||
static Int
|
||||
p_obj_suffix(void) {
|
||||
return(unify(StringToList(SHLIB_SUFFIX),ARG1));
|
||||
return(_YAP_unify(_YAP_StringToList(SHLIB_SUFFIX),ARG1));
|
||||
}
|
||||
|
||||
void
|
||||
InitLoadForeign(void)
|
||||
_YAP_InitLoadForeign(void)
|
||||
{
|
||||
if (yap_args == NULL)
|
||||
YAP_FindExecutable("yap");
|
||||
if (_YAP_argv == NULL)
|
||||
_YAP_FindExecutable("yap");
|
||||
else
|
||||
YAP_FindExecutable(yap_args[0]);
|
||||
InitCPred("$load_foreign_files", 3, p_load_foreign, SafePredFlag|SyncPredFlag);
|
||||
InitCPred("$obj_suffix", 1, p_obj_suffix, SafePredFlag);
|
||||
_YAP_FindExecutable(_YAP_argv[0]);
|
||||
_YAP_InitCPred("$load_foreign_files", 3, p_load_foreign, SafePredFlag|SyncPredFlag);
|
||||
_YAP_InitCPred("$obj_suffix", 1, p_obj_suffix, SafePredFlag);
|
||||
}
|
||||
|
||||
void
|
||||
ReOpenLoadForeign(void)
|
||||
_YAP_ReOpenLoadForeign(void)
|
||||
{
|
||||
ForeignObj *f_code = ForeignCodeLoaded;
|
||||
SMALLUNSGN OldModule = CurrentModule;
|
||||
@@ -125,7 +123,7 @@ ReOpenLoadForeign(void)
|
||||
|
||||
while (f_code != NULL) {
|
||||
CurrentModule = f_code->module;
|
||||
if(ReLoadForeign(f_code->objs,f_code->libs,f_code->f,&InitProc)==LOAD_SUCCEEDED) {
|
||||
if(_YAP_ReLoadForeign(f_code->objs,f_code->libs,f_code->f,&InitProc)==LOAD_SUCCEEDED) {
|
||||
(*InitProc)();
|
||||
}
|
||||
f_code = f_code->next;
|
||||
|
Reference in New Issue
Block a user