Allowing GC in Allegro CL SMP during foreign function calls

Felix Filozov ffilozov at gmail.com
Tue Jul 30 15:33:33 UTC 2013


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/98ab53a4/attachment.html>


More information about the cffi-devel mailing list