What is __thread tls?
Zera William Holladay
zholla1 at uic.edu
Mon Mar 14 18:16:39 PST 2005
On Mon, 14 Mar 2005, Matthew Dillon wrote:
[cut]
> :I was under the impression that each pthread has its own errno??? Perhaps
> :I am not understanding the context. I'm writing my first threaded
> :application so I had best get this straight sooner rather than later.
> :
> :-Zera
>
> yup, you are right... see if you can figure out how errno is defined
> for a threaded program in the current environment. Hint: it isn't a
> simple global declaration.
#define errno (* __error()) /* errno.h */
For threaded applications (per the comment):
The function __error() returns a pointer to a field "error" in the pthread
structure (on line 712 of pthread_private.h).
Otherwise and for the main thread:
__error() is a pointer to a global variable.
If I'm right, then that's pretty cool! :)
-Zera
> -Matt
> Matthew Dillon
> <dillon at xxxxxxxxxxxxx>
>
More information about the Kernel
mailing list