llvm.org GIT mirror llvm / 3e61374
Satisfy C++ aliasing rules, per suggestion by Chandler. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158346 91177308-0d34-0410-b5e6-96231b3b80d8 Argyrios Kyrtzidis 8 years ago
3 changed file(s) with 8 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
2727 ///
2828 /// This is embedded in the class and we avoid malloc'ing/free'ing it,
2929 /// to make this class more safe for use along with CrashRecoveryContext.
30 ThreadLocalDataTy data;
30 union {
31 char data[sizeof(ThreadLocalDataTy)];
32 struct {
33 ThreadLocalDataTy align_data;
34 };
35 };
3136 public:
3237 ThreadLocalImpl();
3338 virtual ~ThreadLocalImpl();
3939 namespace llvm {
4040 using namespace sys;
4141
42 ThreadLocalImpl::ThreadLocalImpl() : data(0) {
42 ThreadLocalImpl::ThreadLocalImpl() : data() {
4343 typedef int SIZE_TOO_BIG[sizeof(pthread_key_t) <= sizeof(data) ? 1 : -1];
4444 pthread_key_t* key = reinterpret_cast(&data);
4545 int errorcode = pthread_key_create(key, NULL);
2121 namespace llvm {
2222 using namespace sys;
2323
24 ThreadLocalImpl::ThreadLocalImpl() : data(0) {
24 ThreadLocalImpl::ThreadLocalImpl() : data() {
2525 typedef int SIZE_TOO_BIG[sizeof(DWORD) <= sizeof(data) ? 1 : -1];
2626 DWORD* tls = reinterpret_cast(&data);
2727 *tls = TlsAlloc();