projects
/
oota-llvm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Scalar: Remove some implicit ilist iterator conversions, NFC
[oota-llvm.git]
/
lib
/
Support
/
Windows
/
ThreadLocal.inc
diff --git
a/lib/Support/Windows/ThreadLocal.inc
b/lib/Support/Windows/ThreadLocal.inc
index 53070ead5471709a01ac5f75a192bc5c6c9b8b28..b9cb8ff9836ecf4c87b1bed5745328bfa5d3ac7d 100644
(file)
--- a/
lib/Support/Windows/ThreadLocal.inc
+++ b/
lib/Support/Windows/ThreadLocal.inc
@@
-1,4
+1,4
@@
-//= llvm/S
ystem
/Win32/ThreadLocal.inc - Win32 Thread Local Data -*- C++ -*-===//
+//= llvm/S
upport
/Win32/ThreadLocal.inc - Win32 Thread Local Data -*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
//
// The LLVM Compiler Infrastructure
//
@@
-16,32
+16,31
@@
//=== is guaranteed to work on *all* Win32 variants.
//===----------------------------------------------------------------------===//
//=== is guaranteed to work on *all* Win32 variants.
//===----------------------------------------------------------------------===//
-#include "Windows.h"
+#include "Windows
Support
.h"
#include "llvm/Support/ThreadLocal.h"
namespace llvm {
using namespace sys;
#include "llvm/Support/ThreadLocal.h"
namespace llvm {
using namespace sys;
-ThreadLocalImpl::ThreadLocalImpl() {
- DWORD* tls = new DWORD;
+ThreadLocalImpl::ThreadLocalImpl() : data() {
+ static_assert(sizeof(DWORD) <= sizeof(data), "size too big");
+ DWORD* tls = reinterpret_cast<DWORD*>(&data);
*tls = TlsAlloc();
assert(*tls != TLS_OUT_OF_INDEXES);
*tls = TlsAlloc();
assert(*tls != TLS_OUT_OF_INDEXES);
- data = tls;
}
ThreadLocalImpl::~ThreadLocalImpl() {
}
ThreadLocalImpl::~ThreadLocalImpl() {
- DWORD* tls =
static_cast<DWORD*>(
data);
+ DWORD* tls =
reinterpret_cast<DWORD*>(&
data);
TlsFree(*tls);
TlsFree(*tls);
- delete tls;
}
}
-
const void*
ThreadLocalImpl::getInstance() {
- DWORD* tls =
static_cast<DWORD*>(
data);
+
void *
ThreadLocalImpl::getInstance() {
+ DWORD* tls =
reinterpret_cast<DWORD*>(&
data);
return TlsGetValue(*tls);
}
void ThreadLocalImpl::setInstance(const void* d){
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;
int errorcode = TlsSetValue(*tls, const_cast<void*>(d));
assert(errorcode != 0);
(void)errorcode;