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