make sure that atom garbage collector knows about foreign function names.
This commit is contained in:
parent
b0e44bc276
commit
2e319c50ba
@ -68,7 +68,7 @@ LoadForeign(StringList ofiles, StringList libs,
|
||||
strcpy(Yap_ErrorSay," Load Failed: in AIX you must load a single object file");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
if (!Yap_TrueFileName(ofiles->s, Yap_FileNameBuf, TRUE)) {
|
||||
if (!Yap_TrueFileName(AtomName(ofiles->name), Yap_FileNameBuf, TRUE)) {
|
||||
strcpy(Yap_ErrorSay, " Trying to open unexisting file in LoadForeign ");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ LoadForeign(StringList ofiles,
|
||||
|
||||
while(tmp != NULL) {
|
||||
strcat(o_files," ");
|
||||
strcat(o_files,tmp->s);
|
||||
strcat(o_files,AtomName(tmp->name));
|
||||
tmp = tmp->next;
|
||||
}
|
||||
}
|
||||
@ -165,7 +165,7 @@ LoadForeign(StringList ofiles,
|
||||
|
||||
while(tmp != NULL) {
|
||||
strcat(l_files," ");
|
||||
strcat(l_files,tmp->s);
|
||||
strcat(l_files,AtomName(tmp->name));
|
||||
tmp = tmp->next;
|
||||
}
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ LoadForeign(StringList ofiles,
|
||||
|
||||
while(tmp != NULL) {
|
||||
strcat(o_files," ");
|
||||
strcat(o_files,tmp->s);
|
||||
strcat(o_files,AtomName(tmp->name));
|
||||
tmp = tmp->next;
|
||||
}
|
||||
}
|
||||
@ -166,7 +166,7 @@ LoadForeign(StringList ofiles,
|
||||
|
||||
while(tmp != NULL) {
|
||||
strcat(l_files," ");
|
||||
strcat(l_files,tmp->s);
|
||||
strcat(l_files,AtomName(tmp->name));
|
||||
tmp = tmp->next;
|
||||
}
|
||||
}
|
||||
|
@ -92,9 +92,9 @@ LoadForeign(StringList ofiles, StringList libs,
|
||||
|
||||
while (libs) {
|
||||
|
||||
if (!Yap_TrueFileName(libs->s, Yap_FileNameBuf, TRUE)) {
|
||||
if (!Yap_TrueFileName(AtomName(libs->name), Yap_FileNameBuf, TRUE)) {
|
||||
/* use LD_LIBRARY_PATH */
|
||||
strncpy(Yap_FileNameBuf, libs->s, YAP_FILENAME_MAX);
|
||||
strncpy(Yap_FileNameBuf, AtomName(libs->name), YAP_FILENAME_MAX);
|
||||
}
|
||||
|
||||
#ifdef __osf__
|
||||
@ -116,7 +116,7 @@ LoadForeign(StringList ofiles, StringList libs,
|
||||
other routines */
|
||||
|
||||
/* dlopen wants to follow the LD_CONFIG_PATH */
|
||||
if (!Yap_TrueFileName(ofiles->s, Yap_FileNameBuf, TRUE)) {
|
||||
if (!Yap_TrueFileName(AtomName(ofiles->name), Yap_FileNameBuf, TRUE)) {
|
||||
strcpy(Yap_ErrorSay, "%% Trying to open unexisting file in LoadForeign");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ LoadForeign(StringList ofiles, StringList libs,
|
||||
}
|
||||
|
||||
while (ofiles) {
|
||||
if((error=dld_link(ofiles->s)) !=0) {
|
||||
if((error=dld_link(AtomName(ofiles->name))) !=0) {
|
||||
strcpy(Yap_ErrorSay,dld_strerror(error));
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ LoadForeign(StringList ofiles, StringList libs,
|
||||
while (ofiles) {
|
||||
HINSTANCE handle;
|
||||
|
||||
if (Yap_TrueFileName(ofiles->s, Yap_FileNameBuf, TRUE) &&
|
||||
if (Yap_TrueFileName(AtomName(ofiles->name), Yap_FileNameBuf, TRUE) &&
|
||||
(handle=LoadLibrary(Yap_FileNameBuf)) != 0)
|
||||
{
|
||||
Yap_ErrorSay[0]=~'\0';
|
||||
@ -84,12 +84,13 @@ LoadForeign(StringList ofiles, StringList libs,
|
||||
other routines */
|
||||
while (libs) {
|
||||
HINSTANCE handle;
|
||||
char * s = AtomName(libs->name);
|
||||
|
||||
if (libs->s[0] == '-') {
|
||||
strcat(Yap_FileNameBuf,libs->s+2);
|
||||
if (s[0] == '-') {
|
||||
strcat(Yap_FileNameBuf,s+2);
|
||||
strcat(Yap_FileNameBuf,".dll");
|
||||
} else {
|
||||
strcpy(Yap_FileNameBuf,libs->s);
|
||||
strcpy(Yap_FileNameBuf,s);
|
||||
}
|
||||
|
||||
if((handle=LoadLibrary(Yap_FileNameBuf)) == 0)
|
||||
|
@ -145,7 +145,7 @@ LoadForeign(StringList ofiles, StringList libs,
|
||||
void *handle;
|
||||
|
||||
/* mydlopen wants to follow the LD_CONFIG_PATH */
|
||||
if (!Yap_TrueFileName(ofiles->s, Yap_FileNameBuf, TRUE)) {
|
||||
if (!Yap_TrueFileName(AtomName(ofiles->name), Yap_FileNameBuf, TRUE)) {
|
||||
strcpy(Yap_ErrorSay, "%% Trying to open unexisting file in LoadForeign");
|
||||
return LOAD_FAILLED;
|
||||
}
|
||||
@ -163,13 +163,14 @@ LoadForeign(StringList ofiles, StringList libs,
|
||||
/* load libraries first so that their symbols are available to
|
||||
other routines */
|
||||
while (libs) {
|
||||
|
||||
if (libs->s[0] == '-') {
|
||||
char *s = AtomName(lib->name);
|
||||
|
||||
if (ls[0] == '-') {
|
||||
strcpy(Yap_FileNameBuf,"lib");
|
||||
strcat(Yap_FileNameBuf,libs->s+2);
|
||||
strcat(Yap_FileNameBuf,s+2);
|
||||
strcat(Yap_FileNameBuf,".so");
|
||||
} else {
|
||||
strcpy(Yap_FileNameBuf,libs->s);
|
||||
strcpy(Yap_FileNameBuf,s);
|
||||
}
|
||||
|
||||
if((libs->handle=mydlopen(Yap_FileNameBuf)) == NULL)
|
||||
|
@ -57,7 +57,7 @@ p_load_foreign(void)
|
||||
t = TailOfTerm(t);
|
||||
new = (StringList) Yap_AllocCodeSpace(sizeof(StringListItem));
|
||||
new->next = ofiles;
|
||||
new->s = RepAtom(AtomOfTerm(t1))->StrOfAE;
|
||||
new->name = AtomOfTerm(t1);
|
||||
ofiles = new;
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ p_load_foreign(void)
|
||||
t = TailOfTerm(t);
|
||||
new = (StringList) Yap_AllocCodeSpace(sizeof(StringListItem));
|
||||
new->next = libs;
|
||||
new->s = RepAtom(AtomOfTerm(t1))->StrOfAE;
|
||||
new->name = AtomOfTerm(t1);
|
||||
libs = new;
|
||||
}
|
||||
|
||||
|
11
C/load_shl.c
11
C/load_shl.c
@ -61,7 +61,7 @@ LoadForeign( StringList ofiles, StringList libs,
|
||||
int valid_fname;
|
||||
|
||||
/* shl_load wants to follow the LD_CONFIG_PATH */
|
||||
valid_fname = Yap_TrueFileName( ofiles->s, Yap_FileNameBuf, TRUE );
|
||||
valid_fname = Yap_TrueFileName( AtomName(ofiles->name), Yap_FileNameBuf, TRUE );
|
||||
|
||||
if( !valid_fname ) {
|
||||
strcpy( Yap_ErrorSay, "%% Trying to open non-existing file in LoadForeign" );
|
||||
@ -89,14 +89,15 @@ LoadForeign( StringList ofiles, StringList libs,
|
||||
}
|
||||
|
||||
while( libs ) {
|
||||
|
||||
if( libs->s[0] == '-' ) {
|
||||
char *s = AtomName(lib->s);
|
||||
|
||||
if( s[0] == '-' ) {
|
||||
strcpy( Yap_FileNameBuf, "lib" );
|
||||
strcat( Yap_FileNameBuf, libs->s+2 );
|
||||
strcat( Yap_FileNameBuf, s+2 );
|
||||
strcat( Yap_FileNameBuf, ".sl" );
|
||||
}
|
||||
else {
|
||||
strcpy( Yap_FileNameBuf, libs->s );
|
||||
strcpy( Yap_FileNameBuf, s );
|
||||
}
|
||||
|
||||
*(shl_t *)libs->handle = shl_load( Yap_FileNameBuf, BIND_DEFERRED, 0 );
|
||||
|
@ -84,7 +84,7 @@
|
||||
#define LOAD_FAILLED -1
|
||||
|
||||
typedef struct StringListItem {
|
||||
char *s;
|
||||
Atom name;
|
||||
void *handle;
|
||||
struct StringListItem *next;
|
||||
} StringListItem, *StringList;
|
||||
|
@ -960,8 +960,7 @@ RestoreForeignCode(void)
|
||||
while (objs != NULL) {
|
||||
if (objs->next != NULL)
|
||||
objs->next = (StringList)AddrAdjust((ADDR)objs->next);
|
||||
if (objs->s != NULL)
|
||||
objs->s = (char *)AddrAdjust((ADDR)objs->s);
|
||||
objs->name = AtomAdjust(objs->name);
|
||||
objs = objs->next;
|
||||
}
|
||||
if (f_code->libs != NULL)
|
||||
@ -970,8 +969,7 @@ RestoreForeignCode(void)
|
||||
while (libs != NULL) {
|
||||
if (libs->next != NULL)
|
||||
libs->next = (StringList)AddrAdjust((ADDR)libs->next);
|
||||
if (libs->s != NULL)
|
||||
libs->s = (char *)AddrAdjust((ADDR)libs->s);
|
||||
libs->name = AtomAdjust(libs->name);
|
||||
libs = libs->next;
|
||||
}
|
||||
if (f_code->f != NULL)
|
||||
|
Reference in New Issue
Block a user