DragonFly BSD
DragonFly kernel List (threaded) for 2005-03
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: What is __thread tls?


From: Zera William Holladay <zholla1@xxxxxxx>
Date: Mon, 14 Mar 2005 20:15:02 -0600 (CST)

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@xxxxxxxxxxxxx>
>



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]