On Wednesday, 9 January 2013 at 10:38:33 UTC, Walter Bright wrote:
Watcha do is something like this:

__thread int x;
int foo() { return x; }

Compile, disassemble, and look at the code generated and the fixup records. Then there's no need to guess :-)

I also think this is the best way of approaching such problems. If you can, also try to find the source code for the involved code. In case of trying to understand the OS X TLS mechanism, I found the following files from dyld to be helpful:

http://opensource.apple.com/source/dyld/dyld-210.2.3/src/threadLocalHelpers.s
http://opensource.apple.com/source/dyld/dyld-210.2.3/src/threadLocalVariables.c

David

Reply via email to