Brent Fulgham <[EMAIL PROTECTED]> writes: > > /* errno is a per-thread variable. */ > > #include <hurd/threadvar.h> > > #define errno (*__hurd_errno_location ()) > > #define __set_errno(val) errno = (val)
> Ahh -- this makes a lot of sense now. So we should probably file > bugs upstream against software that makes use of errno without including > the errno header file in a particular module/source file. I think > there's a lot of stuff out there that relies on the belief that it's > an `extern int`, which is (as we now know) not always the case. The interesting thing about this errno hack (which is I think is used on all platforms that support both threads and ANSI-C, not just the Hurd), is that errno still *is* an extern int, in some sense. I.e., in #include <errno.h> extern int errno; the second line expands to extern int (*__hurd_errno_location ()); which is a perfectly valid declaration, although unfortunately not a prototype, of the function __hurd_errno_location(). You can also take the address of errno and all things should work just fine (until you try to use the resulting pointer from another thread). /Niels

