From: Sam S. <sd...@gn...> - 2003-04-04 16:27:28
|
> * In message <9F8582E37B2EE5498E76392AEDDCD3FE036C4ED4@G8PQD.blf01.telekom.de> > * On the subject of "[clisp-list] linux FFI: What/where is _IO_stdin/out/err_? -- errno" > * Sent on Fri, 4 Apr 2003 15:54:30 +0200 > * Honorable "Hoehle, Joerg-Cyril" <Joe...@t-...> writes: > > is it legal to assign to errno? > E.g. errno = 0; in C application code? yes, absolutely. > Shall CLISP Linux FFI support assignment to errno? yes, absolutely. > On a (Suse)Linux box, I found > /usr/include/errno.h > /* Declare the `errno' variable, unless it's defined as a macro by > bits/errno.h. This is the case in GNU, where it is a per-thread > variable. This redeclaration using the macro still works, but it > > And in /usr/include/bits/errno.h > /* Function to get address of global `errno' variable. */ > extern int *__errno_location (void) __THROW __attribute__ ((__const__)); > > # if !defined _LIBC || defined _LIBC_REENTRANT > /* When using threads, errno is a per-thread value. */ > # define errno (*__errno_location ()) > > Thus, printf("%d",errno); works. > But such a #define does not work with errno=x; why not?! (*foo()) = 10; will write 10 into the memory area pointed to by the return value of foo(). > BTW, in order not to have to revisit this area the day CLISP would > have threads, linux:errno has to become a symbol-macro which expands > to a FFI call. > (def-call-out __errno_location (:arguments) (:return-type (c-ptr int))) > (define-symbol-macro errno (linux:__errno_location)) > But that does not support (setf linux:errno x). se we should add a (setf linux:errno) macro or function. -- Sam Steingold (http://www.podval.org/~sds) running RedHat8 GNU/Linux <http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/> <http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html> I want Tamagochi! -- What for? Your pet hamster is still alive! |