2005-04-09 18:30:46 -04:00
|
|
|
#include "factor.h"
|
|
|
|
|
|
|
|
void primitive_dlopen(void)
|
|
|
|
{
|
|
|
|
DLL* dll;
|
|
|
|
F_STRING* path;
|
|
|
|
|
2005-06-16 18:50:49 -04:00
|
|
|
maybe_gc(sizeof(DLL));
|
2005-04-09 18:30:46 -04:00
|
|
|
|
|
|
|
path = untag_string(dpop());
|
|
|
|
dll = allot_object(DLL_TYPE,sizeof(DLL));
|
|
|
|
dll->path = tag_object(path);
|
2005-08-15 15:34:00 -04:00
|
|
|
ffi_dlopen(dll,true);
|
2005-04-09 18:30:46 -04:00
|
|
|
|
|
|
|
dpush(tag_object(dll));
|
|
|
|
}
|
|
|
|
|
|
|
|
void primitive_dlsym(void)
|
|
|
|
{
|
|
|
|
CELL dll;
|
2005-08-15 15:34:00 -04:00
|
|
|
F_STRING *sym;
|
|
|
|
void *handle;
|
2005-04-09 18:30:46 -04:00
|
|
|
|
2005-06-16 18:50:49 -04:00
|
|
|
maybe_gc(0);
|
2005-04-09 18:30:46 -04:00
|
|
|
|
|
|
|
dll = dpop();
|
|
|
|
sym = untag_string(dpop());
|
2005-08-15 15:34:00 -04:00
|
|
|
|
|
|
|
if(dll == F)
|
|
|
|
handle = NULL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DLL *d = untag_dll(dll);
|
|
|
|
if(d->dll == NULL)
|
|
|
|
general_error(ERROR_EXPIRED,dll);
|
|
|
|
handle = d->dll;
|
|
|
|
}
|
|
|
|
|
|
|
|
dpush(tag_cell((CELL)ffi_dlsym(handle,sym,true)));
|
2005-04-09 18:30:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void primitive_dlclose(void)
|
|
|
|
{
|
|
|
|
ffi_dlclose(untag_dll(dpop()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void fixup_dll(DLL* dll)
|
|
|
|
{
|
|
|
|
data_fixup(&dll->path);
|
2005-08-15 15:34:00 -04:00
|
|
|
ffi_dlopen(dll,false);
|
2005-04-09 18:30:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void collect_dll(DLL* dll)
|
|
|
|
{
|
2005-05-12 01:02:39 -04:00
|
|
|
copy_handle(&dll->path);
|
2005-04-09 18:30:46 -04:00
|
|
|
}
|