From 721c201bd55ffb73cb2ba8d39e0570fa38c44e15 Mon Sep 17 00:00:00 2001 From: dim Date: Wed, 15 Aug 2012 19:34:23 +0000 Subject: Vendor import of llvm trunk r161861: http://llvm.org/svn/llvm-project/llvm/trunk@161861 --- lib/Support/Windows/ThreadLocal.inc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'lib/Support/Windows/ThreadLocal.inc') diff --git a/lib/Support/Windows/ThreadLocal.inc b/lib/Support/Windows/ThreadLocal.inc index 512462d..057deb3 100644 --- a/lib/Support/Windows/ThreadLocal.inc +++ b/lib/Support/Windows/ThreadLocal.inc @@ -22,26 +22,25 @@ namespace llvm { using namespace sys; -ThreadLocalImpl::ThreadLocalImpl() { - DWORD* tls = new DWORD; +ThreadLocalImpl::ThreadLocalImpl() : data() { + typedef int SIZE_TOO_BIG[sizeof(DWORD) <= sizeof(data) ? 1 : -1]; + DWORD* tls = reinterpret_cast(&data); *tls = TlsAlloc(); assert(*tls != TLS_OUT_OF_INDEXES); - data = tls; } ThreadLocalImpl::~ThreadLocalImpl() { - DWORD* tls = static_cast(data); + DWORD* tls = reinterpret_cast(&data); TlsFree(*tls); - delete tls; } const void* ThreadLocalImpl::getInstance() { - DWORD* tls = static_cast(data); + DWORD* tls = reinterpret_cast(&data); return TlsGetValue(*tls); } void ThreadLocalImpl::setInstance(const void* d){ - DWORD* tls = static_cast(data); + DWORD* tls = reinterpret_cast(&data); int errorcode = TlsSetValue(*tls, const_cast(d)); assert(errorcode != 0); (void)errorcode; -- cgit v1.1