[cfe-dev] status of 'thread_local'

James Gregurich bayoubengal at me.com
Tue Oct 16 14:08:00 PDT 2012


BTW:

What is the lifetime on a __thread variable?  It gets destructed at the time the thread exits?



On Oct 16, 2012, at 2:06 PM, James Gregurich <bayoubengal at me.com> wrote:

> 
> thanks all for the info. 
> 
> On Oct 16, 2012, at 1:59 PM, James Gregurich <bayoubengal at me.com> wrote:
> 
>> hmmm.   I just ran the test against the 10.7 SDK again and it worked. I'm not sure what I had wrong the first time. 
>> 
>> ok.  "__thread" works for me. I have to encapsulate the implementation anyway as my code currently uses boost::thread_specific_ptr and it must continue to work on 10.6. 
>> 
>> 
>> 
>> 
>> On Oct 16, 2012, at 1:45 PM, Jean-Daniel Dupas <devlists at shadowlab.org> wrote:
>> 
>>> Can you define "does not work" ? 
>>> 
>>> I just compiled the following code in C++ mode, and it generate the expected llvm assembly:
>>> 
>>> __thread int foo;
>>> 
>>> int main(int arcg, char **argv) { return 0; }
>>> 
>>> ====== output:
>>> 
>>> @foo = thread_local global i32 0, align 4
>>> 
>>> define i32 @main(i32 %arcg, i8** %argv) nounwind uwtable ssp {
>>> entry:
>>>   %retval = alloca i32, align 4
>>>>>> 
>>> 
>>> 
>>> Le 16 oct. 2012 à 22:40, James Gregurich <bayoubengal at me.com> a écrit :
>>> 
>>>> Is it C-only? I ran a test with C++ and it didn't work. Does it work with C++ and I need to supply some flag to compiler to enable it? I'll poke around with google and see what info I can dig up.
>>>> 
>>>> 
>>>> 
>>>> 
>>>> On Oct 16, 2012, at 1:34 PM, Jean-Daniel Dupas <devlists at shadowlab.org> wrote:
>>>> 
>>>>> 
>>>>> Le 16 oct. 2012 à 21:04, James Gregurich <bayoubengal at me.com> a écrit :
>>>>> 
>>>>>> howdy!
>>>>>> 
>>>>>> What is the status of 'thread_local' support in clang? is that something that will be delivered in the next few months? later? never will be delivered? has been delivered, but the website not updated?
>>>>>> 
>>>>> 
>>>>> AFAIK, thread locals are supported in C using the __thread keyword on platform that support it for some times (OS X 10.7 for Mach-O, ELF platforms, …).
>>>>> 
>>>>> 
>>>>> -- Jean-Daniel
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> _______________________________________________
>>>>> cfe-dev mailing list
>>>>> cfe-dev at cs.uiuc.edu
>>>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>>> 
>>> 
>>> -- Jean-Daniel
>>> 
>>> 
>>> 
>>> 
>> 
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121016/df8c34e7/attachment.html>


More information about the cfe-dev mailing list