[llvm-commits] [llvm] r158405 - /llvm/trunk/lib/Support/ThreadLocal.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Wed Jun 13 09:30:06 PDT 2012


Author: akirtzidis
Date: Wed Jun 13 11:30:06 2012
New Revision: 158405

URL: http://llvm.org/viewvc/llvm-project?rev=158405&view=rev
Log:
Fix building ThreadLocal.cpp with --disable-threads.

Modified:
    llvm/trunk/lib/Support/ThreadLocal.cpp

Modified: llvm/trunk/lib/Support/ThreadLocal.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ThreadLocal.cpp?rev=158405&r1=158404&r2=158405&view=diff
==============================================================================
--- llvm/trunk/lib/Support/ThreadLocal.cpp (original)
+++ llvm/trunk/lib/Support/ThreadLocal.cpp Wed Jun 13 11:30:06 2012
@@ -25,9 +25,16 @@
 using namespace sys;
 ThreadLocalImpl::ThreadLocalImpl() { }
 ThreadLocalImpl::~ThreadLocalImpl() { }
-void ThreadLocalImpl::setInstance(const void* d) { data = const_cast<void*>(d);}
+void ThreadLocalImpl::setInstance(const void* d) {
+  typedef int SIZE_TOO_BIG[sizeof(d) <= sizeof(data) ? 1 : -1];
+  void **pd = reinterpret_cast<void**>(&data);
+  *pd = const_cast<void*>(d);
+}
 const void* ThreadLocalImpl::getInstance() { return data; }
-void ThreadLocalImpl::removeInstance() { data = 0; }
+void ThreadLocalImpl::removeInstance() {
+  void **pd = reinterpret_cast<void**>(&data);
+  *pd = 0;
+}
 }
 #else
 





More information about the llvm-commits mailing list