Subject: Thread Local Storage
From: [email-masked] (James Schettine)

4 Jun 1997 23:26:36 -0700
Sender: [email-masked]
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
References: <[email-masked]>
X-Mailer: Mozilla 3.01 (X11; I; SunOS 4.1.4 sun4m)
MIME-Version: 1.0
Original-To: [email-masked]
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Original-Sender: [email-masked]

I saw somewhere in this lists archives:

#define THREADLOCAL __attribute__((section(".tls")))
int foo THREADLOCAL = 42;

which looks like it will place the variable in the .tls section,
and NT will create a .tls data area for each thread.

It looks like my "old" compiler generates something close to
the following pseudo-reference:

	(*(tls ***)(fs:0x2c))[tls_index]->foo

where _tls_index looks like a global variable, 0x2c is a "well known"
offset into the fs selector(?), tls is a pseudo-structure which is
dependent on link order, and foo is an offset into tls.

this expression is put in automatically for __declspec(thread) vars,
and can be used as an lval or rval.

I would love to have a macro to put around all uses of a tls
var to generate something like this.  It doesn't need to be
hidden for now.

Is there a better way to solve the broken process model problem
(other than reorganizing gobs of old code?)

Thanks for looking at it!		[email-masked]
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".