Andy Ayers
2014-Dec-12 01:49 UTC
[LLVMdev] why 'const' void * return for ThreadLocalImpl::getInstance()?
I'm probably missing something obvious here, but naively, this makes it kind of awkward to have mutable thread local state... -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141212/53b577ae/attachment.html>
David Majnemer
2014-Dec-12 02:39 UTC
[LLVMdev] why 'const' void * return for ThreadLocalImpl::getInstance()?
I think you are supposed to use ThreadLocal::get in cases where you want a pointer to mutable data: http://llvm.org/docs/doxygen/html/classllvm_1_1sys_1_1ThreadLocal.html#a66c83dcd38d9048a4f95255e44f13a0c On Thu, Dec 11, 2014 at 5:49 PM, Andy Ayers <andya at microsoft.com> wrote:> I’m probably missing something obvious here, but naively, this makes it > kind of awkward to have mutable thread local state… > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141211/3f188e47/attachment.html>
Andy Ayers
2014-Dec-12 02:48 UTC
[LLVMdev] why 'const' void * return for ThreadLocalImpl::getInstance()?
Yeah, I was using that -- I have, more or less, struct S {...}; llvm::sys::ThreadLocal<S> TLS; S * s = TLS.get(); The static_cast in ThreadLocal::get is where the compiler gripes…. Unable to convert from ‘const void *’ to ‘S *’. From: David Majnemer [mailto:david.majnemer at gmail.com] Sent: Thursday, December 11, 2014 6:39 PM To: Andy Ayers Cc: llvmdev at cs.uiuc.edu Subject: Re: [LLVMdev] why 'const' void * return for ThreadLocalImpl::getInstance()? I think you are supposed to use ThreadLocal::get in cases where you want a pointer to mutable data: http://llvm.org/docs/doxygen/html/classllvm_1_1sys_1_1ThreadLocal.html#a66c83dcd38d9048a4f95255e44f13a0c On Thu, Dec 11, 2014 at 5:49 PM, Andy Ayers <andya at microsoft.com<mailto:andya at microsoft.com>> wrote: I’m probably missing something obvious here, but naively, this makes it kind of awkward to have mutable thread local state… _______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu<mailto:LLVMdev at cs.uiuc.edu> http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141212/f22f0bec/attachment.html>