mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-25 04:55:04 +02:00
Improve error reporting for dl functions
This commit is contained in:
parent
a019a29471
commit
6511490f21
1 changed files with 7 additions and 6 deletions
13
runtime.c
13
runtime.c
|
@ -5629,23 +5629,24 @@ double MRG32k3a (double seed)
|
||||||
/** Dynamic loading */
|
/** Dynamic loading */
|
||||||
void Cyc_import_shared_object(void *data, object cont, object filename, object entry_pt_fnc)
|
void Cyc_import_shared_object(void *data, object cont, object filename, object entry_pt_fnc)
|
||||||
{
|
{
|
||||||
|
char buffer[256];
|
||||||
void *handle;
|
void *handle;
|
||||||
function_type entry_pt;
|
function_type entry_pt;
|
||||||
Cyc_check_str(data, filename);
|
Cyc_check_str(data, filename);
|
||||||
Cyc_check_str(data, entry_pt_fnc);
|
Cyc_check_str(data, entry_pt_fnc);
|
||||||
handle = dlopen(string_str(filename), RTLD_GLOBAL | RTLD_LAZY);
|
handle = dlopen(string_str(filename), RTLD_GLOBAL | RTLD_LAZY);
|
||||||
if (handle == NULL) {
|
if (handle == NULL) {
|
||||||
//make_string(s, dlerror());
|
snprintf(buffer, 256, "%s", dlerror());
|
||||||
fprintf(stderr, "%s\n", dlerror());
|
make_string(s, buffer);
|
||||||
Cyc_rt_raise2(data, "Unable to import library", filename);
|
Cyc_rt_raise2(data, "Unable to import library", &s);
|
||||||
}
|
}
|
||||||
dlerror(); /* Clear any existing error */
|
dlerror(); /* Clear any existing error */
|
||||||
|
|
||||||
entry_pt = (function_type) dlsym(handle, string_str(entry_pt_fnc));
|
entry_pt = (function_type) dlsym(handle, string_str(entry_pt_fnc));
|
||||||
if (entry_pt == NULL) {
|
if (entry_pt == NULL) {
|
||||||
//make_string(s, dlerror());
|
snprintf(buffer, 256, "%s, %s, %s", string_str(filename), string_str(entry_pt_fnc), dlerror());
|
||||||
fprintf(stderr, "%s\n", dlerror());
|
make_string(s, buffer);
|
||||||
Cyc_rt_raise2(data, "Unable to load symbol", entry_pt_fnc);
|
Cyc_rt_raise2(data, "Unable to load symbol", &s);
|
||||||
}
|
}
|
||||||
mclosure1(clo, entry_pt, cont);
|
mclosure1(clo, entry_pt, cont);
|
||||||
entry_pt(data, 0, &clo, &clo);
|
entry_pt(data, 0, &clo, &clo);
|
||||||
|
|
Loading…
Add table
Reference in a new issue