[plt-scheme] FFI + errno

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Dec 9 13:55:59 EST 2009

At Wed, 9 Dec 2009 10:30:33 -0800, Steve Huffman wrote:
> > I almost suggested wrapping the call to the function that sets `errno'
> > and the access of `errno' with `scheme_start_atomic()' and
> > `scheme_end_atomic()' (which you can access them with the FFI). But
> > that's not good enough, because the runtime system occasionally uses
> > `errno'-setting function internally, even when not switching Scheme
> > threads.
> 
> The PLT runtime can preempt a FFI function call?

No. I mean

    (scheme_start_atomic)
    (open path O_RDONLY)
    (let ([v (ptr-ref (__error) _int)])
      (scheme_end_atomic)

where the runtime might do some administrative work between the `open'
return and the `__error' call.


Posted on the users mailing list.