Is D right for me?
Jacob Carlborg
doob at me.com
Thu Oct 14 12:11:00 PDT 2010
On 2010-10-14 17:51, Sean Kelly wrote:
> Jacob Carlborg<doob at me.com> wrote:
>> On 2010-10-13 20:18, Walter Bright wrote:
>>> Jacob Carlborg wrote:
>>>> I don't know how you have implemented TLS on Mac OS X but it does
>>>> support TLS via the Posix API pthreads. This is the only page from
>>>> Apple's documentation I could find for now (I'm certain I've seen a
>>>> better page)
>>>> http://developer.apple.com/macosx/multithreadedprogramming.html .
>>>
>>> Yeah, I know about pthreads TLS, but that's wholly inadequate.
>>>
>>>> According to these:
>>>> http://lifecs.likai.org/2010/05/mac-os-x-thread-local-storage.html
>>>> and
>>>> http://lists.apple.com/archives/darwin-dev/2005/Sep/msg00005.html
>>>> the
>>>> implementation of TLS in the Posix API on Mac OS X should be as fast
>>>> as the EFL implementation. As the blog post mentions, there is an
>>>> inline version of pthread_getspecific. I also have to add that I
>>>> have
>>>> no idea if the pthreads can be used to implement TLS in the
>>>> compiler.
>>>
>>> With gcc on OSX, try this:
>>>
>>> __thread int x;
>>>
>>> It will fail. Furthermore, OSX has no documented way to allocate TLS
>>> static data in the object file. I spent considerable effort figuring
>>> out
>>> a way to do this and get around the numerous bugs in the OSX linker
>>> that
>>> tried to stop me.
>>
>> I just read a bit about how TLS is implemented on linux, just of
>> curiosity what was the problem, the linker, runtime, loader or all? On
>> linux the static TLS data is put in the the object file like any other
>> data. The only difference is it has a different name of the
>> section/segment and an additional flag. Then of course the linker,
>> runtime and loader know about these sections and make any necessary
>> initializations when the application loads.
>>
>
> On OSX the object file format lacks a way to specify a TLS data section,
> and so the linker would need upgrading as well. And the compiler, since
> it needs to generate the object files.
As I said, the static TLS data is put in the object file like any other
data. I can see that the linker could/would be a problem. Of course the
compiler needs to be updated but there should be any problems updating
dmd. I guess you're referring to gcc. I also have to say that I haven't
fully understood what the linker does in this case, with the TLS data.
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list