summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Windows
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-06-12 00:21:31 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-06-12 00:21:31 +0000
commit8d19c86c9a2fb83d606aef7e6e0b43c886ec6bc5 (patch)
tree27023e3a392b7e534729678f59db918a248cc3cc /llvm/lib/Support/Windows
parent2fdc07ee8972b41032a98ed7699fed132557a78e (diff)
downloadbcm5719-llvm-8d19c86c9a2fb83d606aef7e6e0b43c886ec6bc5.tar.gz
bcm5719-llvm-8d19c86c9a2fb83d606aef7e6e0b43c886ec6bc5.zip
For llvm::sys::ThreadLocalImpl instead of malloc'ing the platform-specific
thread local data, embed them in the class using a uint64_t and make sure we get compiler errors if there's a platform where this is not big enough. This makes ThreadLocal more safe for using it in conjunction with CrashRecoveryContext. Related to crash in rdar://11434201. llvm-svn: 158342
Diffstat (limited to 'llvm/lib/Support/Windows')
-rw-r--r--llvm/lib/Support/Windows/ThreadLocal.inc13
1 files changed, 6 insertions, 7 deletions
diff --git a/llvm/lib/Support/Windows/ThreadLocal.inc b/llvm/lib/Support/Windows/ThreadLocal.inc
index 512462d8900..99c6f4f63b3 100644
--- a/llvm/lib/Support/Windows/ThreadLocal.inc
+++ b/llvm/lib/Support/Windows/ThreadLocal.inc
@@ -22,26 +22,25 @@
namespace llvm {
using namespace sys;
-ThreadLocalImpl::ThreadLocalImpl() {
- DWORD* tls = new DWORD;
+ThreadLocalImpl::ThreadLocalImpl() : data(0) {
+ typedef int SIZE_TOO_BIG[sizeof(DWORD) <= sizeof(data) ? 1 : -1];
+ DWORD* tls = reinterpret_cast<DWORD*>(&data);
*tls = TlsAlloc();
assert(*tls != TLS_OUT_OF_INDEXES);
- data = tls;
}
ThreadLocalImpl::~ThreadLocalImpl() {
- DWORD* tls = static_cast<DWORD*>(data);
+ DWORD* tls = reinterpret_cast<DWORD*>(&data);
TlsFree(*tls);
- delete tls;
}
const void* ThreadLocalImpl::getInstance() {
- DWORD* tls = static_cast<DWORD*>(data);
+ DWORD* tls = reinterpret_cast<DWORD*>(&data);
return TlsGetValue(*tls);
}
void ThreadLocalImpl::setInstance(const void* d){
- DWORD* tls = static_cast<DWORD*>(data);
+ DWORD* tls = reinterpret_cast<DWORD*>(&data);
int errorcode = TlsSetValue(*tls, const_cast<void*>(d));
assert(errorcode != 0);
(void)errorcode;
OpenPOWER on IntegriCloud