Allowing GC in Allegro CL SMP during foreign function calls

Felix Filozov ffilozov at gmail.com
Tue Jul 30 21:23:08 UTC 2013


Having had a closer look at the code, I noticed that the
with-foreign-pointer macro allocates in a static area if #+(version>= 8 1).

Perhaps it's better to add additional calls to #+(version>= 8 1) in the
%foreign-funcall macro, and the defcfun-helper-forms function, so that
if #+(version>=
8 1) the appropriate options are set to allow for GC to run during foreign
function execution.


On Tue, Jul 30, 2013 at 5:33 PM, Felix Filozov <ffilozov at gmail.com> wrote:

> Hi all,
>
> When defining a foreign function using def-foreign-call, there's an option
> one could set called :allow-gc. Setting it to :always, allows the garbage
> collector to run while the foreign function is executing.
>
> At the moment CFFI uses the default value for :allow-gc, which is :never.
> This prevents GC from running when a foreign function is executing.
>
> Moreover, once GC blocks, other processes can't make progress. In my case,
> I need GC to run during foreign function execution.
>
> What do you think about extending the defcfun and foreign-call interfaces
> to allow for native options to be passed? name-and-options could be
> extended to accept a new argument, :native-args, for example. Then you'd be
> able to use defcfun as follows:
>
> (defcfun ("strlen" :native-args (:allow-gc :always)) :int
>   (str :string))
>
> Another option is to create a global variable that holds native arguments,
> and def-foreign-call would read this directly.
>
> Thanks,
> Felix
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20130730/2749a679/attachment.html>


More information about the cffi-devel mailing list