Returning errno as a second value
Felix Filozov
ffilozov at gmail.com
Fri Aug 9 10:01:30 UTC 2013
The test case is calling a foreign function that creates a ZMQ socket, and
calling it twice with the same arguments sets errno.
But (with-delayed-interrupts (foreign call) (get errno foreign calL))
always returns 0. As Franz said, this should not be expected to work.
On Thu, Aug 8, 2013 at 11:37 PM, Luís Oliveira <luismbo at gmail.com> wrote:
> Felix Filozov <ffilozov at gmail.com> writes:
>
> > Looking into Allegro CL SMP's manual, there's a macro called
> > with-delayed-interrupts, which should prevent interrupts and GC from
> > running. However, the wrong errno was still returned when I used this
> > macro. I will ask Franz if such a macro exists.
>
> What's your test case like?
>
>
> > I started exploring your second suggestion. I created an errno
> > defstruct (this is what the user passes), in the CFFI package, and I
> > tried passing that structure to the CFFI-SYS layer to be modified, but
> > then I realized that CFFI-SYS doesn't know anything about the CFFI
> > package so it can't modify the structure. So I'm passing a function to
> > CFFI-SYS, which gets called with the returned errno value as an
> > argument. I don't know if I like this callback mechanism.
>
> Seems a bit heavy handed, yeah. We can split cffi-sys in two files: a
> shared file (with the package define and perhaps that structure
> definition) and an implementation-specific file.
>
>
> > Also, while reading through the code I noticed that there's some edge
> > cases that would need to be handled. For example %defcfun may make a
> > call to foreign-funcall if the argument types and the returns types
> > are considered call-by-value. What does that mean?
>
> We've recently added support for passing structures by value. When that
> functionality is needed, we use libffi for invoking the foreign
> function. I have no idea how we can reliably get errno in that case.
>
>
> > I also don't quite understand what entry-vec is, if that's something
> > that can be ignored for now.
>
> I don't remember the details, but doc/allegro-internals.txt has some
> info about it.
>
> Cheers,
>
> --
> Luís Oliveira
> http://kerno.org/~luis
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20130809/f8179973/attachment.html>
More information about the cffi-devel
mailing list