delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/06/04/23:26:36

From: james AT bellhow DOT com (James Schettine)
Subject: Thread Local Storage
4 Jun 1997 23:26:36 -0700 :
Sender: mail AT cygnus DOT com
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <3395BA54.446B9B3D.cygnus.gnu-win32@bellhow.com>
References: <199706032105 DOT OAA27240 AT cirdan DOT cygnus DOT com>
X-Mailer: Mozilla 3.01 (X11; I; SunOS 4.1.4 sun4m)
MIME-Version: 1.0
Original-To: gnu-win32 AT cygnus DOT com
Original-Sender: owner-gnu-win32 AT cygnus DOT com

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!		James AT bellhow DOT com
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019