From 1a18e9a2c4495052b903481c83616265074c4e91 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Wed, 13 Jun 2012 16:30:06 +0000 Subject: [PATCH] Fix building ThreadLocal.cpp with --disable-threads. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158405 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/ThreadLocal.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/Support/ThreadLocal.cpp b/lib/Support/ThreadLocal.cpp index 17e0fe15b02..109580478de 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(d);} +void ThreadLocalImpl::setInstance(const void* d) { + typedef int SIZE_TOO_BIG[sizeof(d) <= sizeof(data) ? 1 : -1]; + void **pd = reinterpret_cast(&data); + *pd = const_cast(d); +} const void* ThreadLocalImpl::getInstance() { return data; } -void ThreadLocalImpl::removeInstance() { data = 0; } +void ThreadLocalImpl::removeInstance() { + void **pd = reinterpret_cast(&data); + *pd = 0; +} } #else