"Luís Oliveira" <luis...@gmail.com> writes: > On Fri, Jan 9, 2009 at 1:06 AM, John Fremlin <j...@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?
I'm not sure. I asked them and Duane said that wrapping with without-interrupts might be okay (defmacro with-errno (&body body) `( ,(progn 'progn #+allegro 'excl:without-interrupts) (locally ,@body) (get-errno))) I asked about whether this might not work in the event of GC and got no answer. >> 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. It'd be great to be able to use the def-foreign-call Allegro functionality. ClozureCL has something slightly similar called int-errno-call (defmacro int-errno-call (form) (let* ((value (gensym))) `(let* ((,value ,form)) (if (< ,value 0) (%get-errno) ,value)))) >> 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. _______________________________________________ cffi-devel mailing list cffi-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel