On Wed, Aug 10, 2011 at 8:11 PM, Jean-Sebastien Delfino
<jsdelf...@apache.org> wrote:
> On Wed, Aug 10, 2011 at 6:45 AM, dsh <daniel.hais...@googlemail.com> wrote:
>> Hi Jean-Sebastien,
>>
>> On Wed, Aug 10, 2011 at 6:45 AM, Jean-Sebastien Delfino
>> <jsdelf...@apache.org> wrote:
>>>
>>> That's what I meant when I mentioned 'convert usages of __thread to
>>> Posix thread TLS calls' in my previous post [1].
>>>
>>> __thread works for me with GCC on Mac OS X (using the GCC build from
>>> the HPC project [2]), but causes a compile error with Clang/LLVM. It's
>>> listed as a limitation of Clang on Mac OS X in the Clang user manual
>>> (look for __thread on this page [3]).
>>>
>>
>> Does "Works for me" mean it compiles for you just fine AND during
>> runtime you are getting the expected behavior or does it just mean the
>> code compiles just fine if using GCC?
>>
>> I am asking cause I googled a bit last night and from what I found I
>> had the feeling thread local isn't really supported on OS X during
>> runtime.
>>
>
> Hi Daniel!
>
> __thread compiles and behaves as expected for me on OS X with GCC 4.6
> (the version referenced in the macos/macos-install script).
>
> I've added some test logic to kernel/parallel-test.cpp to help verify
> that (see SVN r1156460).
>
> Parallel-test built with GCC works, showing that __thread is correctly
> implemented by GCC on OS X.
>
> After commenting __thread on parallel-test.cpp:line 134, parallel-test
> breaks with an assertion error, showing that the test is actually
> effective at testing thread local storage.
>
> I'm hoping that this additional test code will help you when you
> implement thread local storage over the pthread API. In the meantime
> you don't have to worry about it if you --disable-threads :)
>

Hi Daniel,

In SVN revision 1162472 I've replaced the references to __thread by a
new portable implementation of thread local storage using the POSIX
pthread key_create, key_delete, setspecific and getspecific functions.
See the perthread_ptr class in kernel/parallel.hpp, the tests in
kernel/parallel-test.cpp and other usages throughout the code base.
Compared to __thread, it also works on class and struct fields and can
take an initialization function responsible for creating the thread
specific value.

Hope that helps... We shouldn't need to use --disable-threads anymore
with CLang/LLVM.
--
Jean-Sebastien

Reply via email to