summaryrefslogtreecommitdiff
path: root/lib/Support/ThreadLocal.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-06-13 16:30:06 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-06-13 16:30:06 +0000
commit1a18e9a2c4495052b903481c83616265074c4e91 (patch)
tree96ec37d506b3e1e6aba1737429b9234db79261d4 /lib/Support/ThreadLocal.cpp
parent575e90e955064f60ac66230dce6c27653973c149 (diff)
downloadllvm-1a18e9a2c4495052b903481c83616265074c4e91.tar.gz
llvm-1a18e9a2c4495052b903481c83616265074c4e91.tar.bz2
llvm-1a18e9a2c4495052b903481c83616265074c4e91.tar.xz
Fix building ThreadLocal.cpp with --disable-threads.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158405 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/ThreadLocal.cpp')
-rw-r--r--lib/Support/ThreadLocal.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/Support/ThreadLocal.cpp b/lib/Support/ThreadLocal.cpp
index 17e0fe15b0..109580478d 100644
--- a/lib/Support/ThreadLocal.cpp
+++ b/lib/Support/ThreadLocal.cpp
@@ -25,9 +25,16 @@ namespace llvm {
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