git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158346
91177308-0d34-0410-b5e6-
96231b3b80d8
///
/// 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();
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);
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();