[cffi-devel] Safe errno collection
John Fremlin
jf at msi.co.jp
Tue Jan 13 01:24:10 UTC 2009
"Luís Oliveira" <luismbo at gmail.com> writes:
> On Fri, Jan 9, 2009 at 5:17 AM, John Fremlin <jf at msi.co.jp> wrote:
>> 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))))
>
> This doesn't address your concern that something might happen between
> FORM and %GET-ERRNO does it? But, again, it seems like the only
> problem here is tied to user-space threads. You might want to use
> WITHOUT-SCHEDULING instead, not sure.
Yes. On ClozureCL it is quite easy to get errno safely.
My main point is that as errno is not mentioned in the CL standard, the
implementation may do anything it wishes with it, and it would be nice
if there was a library with a helpful way that allowed one to get errno
safely on supported Lisps.
If one were actually using some kinds of rubbishy threading the last
thing one wants is to put without-scheduling or without-interrupts
around foreign function calls, as I understand it.
> BTW, have a look at Osicat:
> <http://common-lisp.net/project/osicat/git/osicat.git/>. I believe it
> has the functionality you're looking for in the ERRNO-WRAPPER type and
> the DEFSYSCALL macro (both in osicat/posix/early.lisp). It's just
> missing a WITHOUT-SCHEDULING (or WITHOUT-INTERRUPTS?) for Allegro with
> user-space threads, IIUC.
I have my own defsyscall I am very happy with, and am very happy with
getting the value of errno (and printing out an error message with the
symbolic name of the error, e.g. EPERM: Permission denied, if anybody
wants this code I may be allowed to share it).
It is just the without-scheduling bit that I need . . .
More information about the cffi-devel
mailing list