mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-23 20:15:05 +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 */
|
||||
void Cyc_import_shared_object(void *data, object cont, object filename, object entry_pt_fnc)
|
||||
{
|
||||
char buffer[256];
|
||||
void *handle;
|
||||
function_type entry_pt;
|
||||
Cyc_check_str(data, filename);
|
||||
Cyc_check_str(data, entry_pt_fnc);
|
||||
handle = dlopen(string_str(filename), RTLD_GLOBAL | RTLD_LAZY);
|
||||
if (handle == NULL) {
|
||||
//make_string(s, dlerror());
|
||||
fprintf(stderr, "%s\n", dlerror());
|
||||
Cyc_rt_raise2(data, "Unable to import library", filename);
|
||||
snprintf(buffer, 256, "%s", dlerror());
|
||||
make_string(s, buffer);
|
||||
Cyc_rt_raise2(data, "Unable to import library", &s);
|
||||
}
|
||||
dlerror(); /* Clear any existing error */
|
||||
|
||||
entry_pt = (function_type) dlsym(handle, string_str(entry_pt_fnc));
|
||||
if (entry_pt == NULL) {
|
||||
//make_string(s, dlerror());
|
||||
fprintf(stderr, "%s\n", dlerror());
|
||||
Cyc_rt_raise2(data, "Unable to load symbol", entry_pt_fnc);
|
||||
snprintf(buffer, 256, "%s, %s, %s", string_str(filename), string_str(entry_pt_fnc), dlerror());
|
||||
make_string(s, buffer);
|
||||
Cyc_rt_raise2(data, "Unable to load symbol", &s);
|
||||
}
|
||||
mclosure1(clo, entry_pt, cont);
|
||||
entry_pt(data, 0, &clo, &clo);
|
||||
|
|
Loading…
Add table
Reference in a new issue