[Openmcl-devel] Executing CCL from within C/C++
Pascal J. Bourguignon
pjb at informatimago.com
Mon Jul 25 16:34:45 PDT 2016
Josh Hamell <jhamell at sift.net> writes:
> Hi,
>
> We have had great experiences using CCL on a number of different
> projects in different capacities, and are now looking at a very niche
> use case.
>
> Within Linux, is it possible to compile a C/C++ program against
> lisp-kernel headers, link against the binary (lx86cl64), and execute
> arbitrary Lisp code as input char* s-expressions? Naively, I can peruse
> the exposed functions using objdump, and would like to believe in a
> simple way to start the interpreter, load an existing heap image, and
> run, all through simple C. This is sort of a "reverse CFFI" - our issue
> is that the C code needs to be the application entry point, without
> resorting to separate processes.
>
> We have looked at another Common Lisp implementation which supports this
> kind of interaction, but have come away with some serious issues which
> we do not have the resources to address on this project.
Have a look at: http://www.xach.com/lisp/lispvan-2008-02-28.pdf
While it would be trivial to rename main into ccl_main, and to link it
as a library instead of an executable, it wouldn't be too useful given
that this "libccl" would still:
1- expect ccl_main to be called from the main thread,
2- preempt unix signals,
3- manage the threads (and possibly the memory, I don't know),
in such a way that the rest of your C program would have a hard time
doing almost anything.
The problem is not the "entry point", but rather those questions of
threads and signals. Some of the related resources are unique in a unix
process, so all the code must manage their shared access. (Just to take
a single example, alarm(2) uses SIGALRM, and therefore only one single
alarm can be set up at a given time; so two "libraries" used in a
program cannot use it at the same time).
Finally, you may consider ecl (libecl.so) which is already designed to
be used as a library in a C program.
--
__Pascal Bourguignon__ http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk
More information about the Openmcl-devel
mailing list