[tree-ssa mudflap] per-thread items

Timothy J. Wood tjw@omnigroup.com
Sat May 17 19:40:00 GMT 2003


On Saturday, May 17, 2003, at 10:19  AM, Eyal Lebedinsky wrote:
> Nevertheless, and as I should hit the bed now, is it possible
> that 'errno' is allocated for each thread and as such it cannot
> be registered once only at the start of the run? If so, does
> the current code handle this?


   Absolutely.  Mac OS X/Darwin has the following in <sys/errno.h>

extern int * __error __P((void));
#define errno (*__error())

   From the Darwin source:

#undef errno
extern int errno;
int *__error(void) {
     pthread_t self = pthread_self();
     /* If we're not a detached pthread, just return the global errno */
     if ((self == (pthread_t)0) || (self->sig != _PTHREAD_SIG) || 
(self->detached & _PTHREAD_CREATE_PARENT)) {
         return &errno;
     }
     return &self->err_no;
}


-tim



More information about the Gcc mailing list