[cffi-devel] Safe errno collection

Luís Oliveira luismbo at gmail.com
Fri Jan 9 02:58:07 UTC 2009


On Fri, Jan 9, 2009 at 1:06 AM, John Fremlin <jf at msi.co.jp> wrote:
> However, there is no guarantee that between calling your function and
> getting the errno, the Lisp environment will not call a C function that
> resets errno.

I guess this is more of a problem in Lisps with userspace threads. Are
there other situations? (Signal handlers shouldn't mess with errno...
Maybe GC hooks?) Any idea how Allegro implements this?


> In SBCL there is a native get-errno function to get the errno.
>
> Is there any plan to add a semi-portable wrapper to this functionality
> for CFFI?

Adding a CFFI-SYS:GET-ERRNO function sounds like a good idea. I don't
understand the other bit well enough yet to have an opinion.


> If not, would you accept a patch for it? I guess the obvious way is to
> modify (cffi:defcfun ...) to take a :after-collect-value argument, so
> that it could work not only for errno

Indeed, it'd be useful for GetLastError() as well, etc.

-- 
Luís Oliveira
http://student.dei.uc.pt/~lmoliv/




More information about the cffi-devel mailing list