"Luís Oliveira" luismbo@gmail.com writes:
On Fri, Jan 9, 2009 at 12:51 AM, John Fremlin jf@msi.co.jp wrote:
The page http://www.franz.com/support/documentation/8.1/doc/foreign-functions.htm documents the :FOREIGN-ADDRESS type.
I kept trying to point out that this was being used by cffi as a *Lisp* type not a *foreign-type*. It is not a Lisp type.
Oh, yes, that part was clearly broken. But it was being used a foreign type as well, but even then it doesn't seem to work in all contexts.
Yes, I don't think it is even a "proper" foreign type, it is a bit like :void.
The other change from my patch was about allocating the stack objects in a space that will not be moved by the GC.
I've applied that already, thanks! IIUC, :FOREIGN-STATIC-GC is only relevant when WITH-STACK-FOBJECT fails to stack allocate, in which case it actually allocates on the heap.
http://www.franz.com/support/documentation/8.1/doc/operators/ff/with-stack-f...
The allocation argument defaults to :foreign, and can be one of :c, :aligned, :lisp, :lisp-short, :foreign, or :foreign-static-gc. Note that if allocation is :c or :aligned, it is not stack-allocated, but instead is allocated and deallocated at the appropriate places within the form.
This is actually a little misleading, as it goes on to say
Otherwise, the object is allocated as specified. In this case, if the allocation requires explicit de-allocation, it is the responsibility of the application to de-allocate the object.
http://www.franz.com/support/documentation/8.1/doc/operators/ff/with-static-...
with-static-fobject on the other hand behaves in a much more sensible way. It will try to allocate on the stack but if it can't it will unwind-protect a deallocation.
Hmm, now that I read the documentation more carefully, it seems that if WITH-STACK-FOBJECT allocates on the heap then it won't deallocate the object and we should be using WITH-STATIC-FOBJECT instead. Does that sound right? If it does, I'll apply the attached patch during the weekend or so.
Why do you still need the
(cond ((and (constantp size) (<= (eval size) ff:*max-stack-fobject-bytes*))
This was just to check whether the with-stack-fobject would actually allocate the thing on the stack (if it did not then we would have to free it by ourselves, and so we would not use with-stack-fobject at all).
You can just use with-static-fobject for everything now and let Allegro decide whether it can allocate on the stack?