This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Thread Local Storage


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]