first attempt at error handling
This commit is contained in:
parent
b74e38378f
commit
5b047b516b
17
C/load_dl.c
17
C/load_dl.c
|
@ -38,6 +38,7 @@ void *
|
||||||
Yap_LoadForeignFile(char *file, int flags)
|
Yap_LoadForeignFile(char *file, int flags)
|
||||||
{
|
{
|
||||||
int dlflag;
|
int dlflag;
|
||||||
|
void *out;
|
||||||
|
|
||||||
if (flags & EAGER_LOADING)
|
if (flags & EAGER_LOADING)
|
||||||
dlflag = RTLD_NOW;
|
dlflag = RTLD_NOW;
|
||||||
|
@ -48,15 +49,21 @@ Yap_LoadForeignFile(char *file, int flags)
|
||||||
else
|
else
|
||||||
dlflag |= RTLD_LOCAL;
|
dlflag |= RTLD_LOCAL;
|
||||||
|
|
||||||
return (void *)dlopen(file,dlflag);
|
out = (void *)dlopen(file,dlflag);
|
||||||
|
if (!out) {
|
||||||
|
Yap_Error(SYSTEM_ERROR, ARG1, "dlopen error %s\n", dlerror());
|
||||||
|
}
|
||||||
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Yap_CallForeignFile(void *handle, char *f)
|
Yap_CallForeignFile(void *handle, char *f)
|
||||||
{
|
{
|
||||||
YapInitProc proc = (YapInitProc) dlsym(handle, f);
|
YapInitProc proc = (YapInitProc) dlsym(handle, f);
|
||||||
if (!proc)
|
if (!proc) {
|
||||||
|
Yap_Error(SYSTEM_ERROR, ARG1, "dlsym error %s\n", dlerror());
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
(*proc) ();
|
(*proc) ();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -64,7 +71,11 @@ Yap_CallForeignFile(void *handle, char *f)
|
||||||
int
|
int
|
||||||
Yap_CloseForeignFile(void *handle)
|
Yap_CloseForeignFile(void *handle)
|
||||||
{
|
{
|
||||||
return dlclose(handle);
|
if ( dlclose(handle) < 0) {
|
||||||
|
Yap_Error(SYSTEM_ERROR, ARG1, "dlclose error %s\n", dlerror());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in New Issue