Feature request: dlopen(NULL, ...
Michael Fox
415fox at gmail.com
Tue Jan 3 00:21:05 UTC 2017
I was wondering if I could get some feeback on an ECL feature request that I posted here: https://gitlab.com/embeddable-common-lisp/ecl/issues/336 <https://gitlab.com/embeddable-common-lisp/ecl/issues/336>
Here is the text:
I would like to be able to call functions using dynamic FFI in the program into which ECL has been embedded.
In Linux, you can do this by calling `dlopen` with `NULL` for the filename.
> If filename is NULL, then the returned handle is for the main
program.
http://man7.org/linux/man-pages/man3/dlopen.3.html
Looking at ECL source code, it does not seem to be supported. `dlopen` is called in `c/ffi/libraries.d` like this:
char *filename_string = (char*)filename->base_string.self;
#ifdef HAVE_DLFCN_H
block->cblock.handle = dlopen(filename_string, RTLD_NOW|RTLD_GLOBAL);
So, I guess there's no way to set `filename_string = NULL`.
One way to do it would be to say if you call
(ffi:load-foreign-library "")
Then it will skip the checks to see if the file exists and just call `dlopen(NULL, ...`
Another way would be to make a new function `ffi:load-main-program`. I don't have any suggestions as to which would be better as I am very new to Lisp.
Thank you for your attention.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20170102/a51d93cf/attachment.html>
More information about the ecl-devel
mailing list