Feature request: dlopen(NULL, ...
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.
Hey, see may comment under the issue. This addition looks like a plausible feature to implement and it seems that it can work also on Windows. I like the second proposal, to make it a separate function ffi:load-main-program, because this is different from loading libraries. If someone steps in and implements it, it is important to add regression test to src/tests/normal-tests/embedding.lsp (so we can check if it works on other platforms / architectures by simply issueing make check) and adding information about this interface to the new documentation to src/doc/new-doc/extensions/ffi_dffi.txi . Also implementation should cover also Windows. Otherwise I'm putting it in my backlog, but I probably won't tackle it very soon. Best regards, Daniel -- Daniel Kochmański ;; aka jackdaniel | Przemyśl, Poland TurtleWare - Daniel Kochmański | www.turtleware.eu "Be the change that you wish to see in the world." - Mahatma Gandhi
participants (2)
-
Daniel Kochmański
-
Michael Fox