DragonFly kernel List (threaded) for 2005-03
Re: What is __thread tls?
On Mon, 14 Mar 2005, Matthew Dillon wrote:
> :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.
> 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! :)
> Matthew Dillon