summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/Support/ThreadLocal.h7
-rw-r--r--llvm/lib/Support/ThreadLocal.cpp2
-rw-r--r--llvm/lib/Support/Windows/ThreadLocal.inc2
3 files changed, 8 insertions, 3 deletions
diff --git a/llvm/include/llvm/Support/ThreadLocal.h b/llvm/include/llvm/Support/ThreadLocal.h
index 1a0a00fd515..2957034ec74 100644
--- a/llvm/include/llvm/Support/ThreadLocal.h
+++ b/llvm/include/llvm/Support/ThreadLocal.h
@@ -28,7 +28,12 @@ namespace llvm {
///
/// This is embedded in the class and we avoid malloc'ing/free'ing it,
/// to make this class more safe for use along with CrashRecoveryContext.
- ThreadLocalDataTy data;
+ union {
+ char data[sizeof(ThreadLocalDataTy)];
+ struct {
+ ThreadLocalDataTy align_data;
+ };
+ };
public:
ThreadLocalImpl();
virtual ~ThreadLocalImpl();
diff --git a/llvm/lib/Support/ThreadLocal.cpp b/llvm/lib/Support/ThreadLocal.cpp
index 1030a2b97db..17e0fe15b02 100644
--- a/llvm/lib/Support/ThreadLocal.cpp
+++ b/llvm/lib/Support/ThreadLocal.cpp
@@ -40,7 +40,7 @@ void ThreadLocalImpl::removeInstance() { data = 0; }
namespace llvm {
using namespace sys;
-ThreadLocalImpl::ThreadLocalImpl() : data(0) {
+ThreadLocalImpl::ThreadLocalImpl() : data() {
typedef int SIZE_TOO_BIG[sizeof(pthread_key_t) <= sizeof(data) ? 1 : -1];
pthread_key_t* key = reinterpret_cast<pthread_key_t*>(&data);
int errorcode = pthread_key_create(key, NULL);
diff --git a/llvm/lib/Support/Windows/ThreadLocal.inc b/llvm/lib/Support/Windows/ThreadLocal.inc
index 99c6f4f63b3..057deb325d6 100644
--- a/llvm/lib/Support/Windows/ThreadLocal.inc
+++ b/llvm/lib/Support/Windows/ThreadLocal.inc
@@ -22,7 +22,7 @@
namespace llvm {
using namespace sys;
-ThreadLocalImpl::ThreadLocalImpl() : data(0) {
+ThreadLocalImpl::ThreadLocalImpl() : data() {
typedef int SIZE_TOO_BIG[sizeof(DWORD) <= sizeof(data) ? 1 : -1];
DWORD* tls = reinterpret_cast<DWORD*>(&data);
*tls = TlsAlloc();
OpenPOWER on IntegriCloud