Returning errno as a second value
Luís Oliveira
luismbo at gmail.com
Thu Aug 8 21:37:13 UTC 2013
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
More information about the cffi-devel
mailing list