<div dir="ltr">Having had a closer look at the code, I noticed that the with-foreign-pointer macro allocates in a static area if #<span style="font-family:arial,sans-serif">+</span><span style="font-family:arial,sans-serif">(version>= 8 1).</span><div>
<div><br></div><div style>Perhaps it<span style="font-family:arial,sans-serif;font-size:13px">'s better to add additional calls to </span><font face="arial, sans-serif">#+(version>= 8 1) in the %foreign-funcall macro, and the defcfun-helper-forms function, so that if </font><span style="font-family:arial,sans-serif">#+(version>= 8 1) the appropriate options are set to allow for GC to run during foreign function execution.</span></div>
</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jul 30, 2013 at 5:33 PM, Felix Filozov <span dir="ltr"><<a href="mailto:ffilozov@gmail.com" target="_blank">ffilozov@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi all,<div><br></div><div>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.</div>
<div><br></div><div>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.</div><div><br></div><div>Moreover, once GC blocks, other processes can't make progress. In my case, I need GC to run during foreign function execution.</div>
<div><br></div><div>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:</div>
<div><br></div><div>(defcfun ("strlen" :native-args (:allow-gc :always)) :int</div><div> (str :string))</div><div><br></div><div>Another option is to create a global variable that holds native arguments, and def-foreign-call would read this directly.</div>
<div><br></div><div>Thanks,</div><div>Felix</div></div>
</blockquote></div><br></div>