Created attachment 879
git format-patch
In src/core/thread.d:
_tlsstart/_tlsend should be handled same as for linux elf.
- extern void* _tlsstart;
- extern void* _tlsend;
+ extern __thread int _tlsstart;
+ extern __thread int _tlsend;
Comment #1 by bugzilla — 2011-01-25T17:09:58Z
__thread is the default for D2, so this patch doesn't do anything.
Comment #2 by braddr — 2011-01-25T18:59:51Z
So, the obvious follow up here is that the existing __thread parts from the other _tlsstart and _tlsend declarations should be yanked as pointless:
diff --git a/src/core/thread.d b/src/core/thread.d
index a317306..911efb3 100644
--- a/src/core/thread.d
+++ b/src/core/thread.d
@@ -130,8 +130,8 @@ version( Windows )
// these are defined in dm\src\win32\tlsseg.asm by DMC.
extern (C)
{
- extern __thread int _tlsstart;
- extern __thread int _tlsend;
+ extern int _tlsstart;
+ extern int _tlsend;
}
}
else
@@ -251,8 +251,8 @@ else version( Posix )
{
extern (C)
{
- extern __thread int _tlsstart;
- extern __thread int _tlsend;
+ extern int _tlsstart;
+ extern int _tlsend;
}
}
else version( OSX )
Also, how about the int vs void* difference? From the look of the usage pattern, it probably doesn't matter, but it does stand out as a difference.
Comment #3 by code — 2011-01-26T06:43:37Z
Sorry, shouldn't have cited only part of the patch.
The important difference is in "void[] thread_getTLSBlock()".
_tlsstart/_tlsend are used directly as pointers to the TLS section.
But instead the address of the symbols should be taken.
Please have a look at the attachment and things should be clear.
Comment #4 by schveiguy — 2011-01-26T07:08:53Z
Sorry, that thread_getTLSBlock function was mine (used to prune the LRU cache for array appending during a collection cycle). I misinterpreted the difference between _tlsstart/_tlsend in FreeBSD being a pointer meaning that it points to where tls starts/ends. I never tested it, since I don't have a FreeBSD system.
I think the patch should be applied. It won't affect anything other than the thread_getTLSBlock function, as the code that assigns the Thread.m_tls member already correctly uses the address of the _tlsstart and _tlsend to determine the block, not the values as I have done.
I'd apply the patch, but I have yet to take the time to learn git.