Fix up erroneous alignas usage while making this portable to GCC 4.7
[oota-llvm.git] / include / llvm / Support / ThreadLocal.h
index 155a4db818b94b90fb09fcfb36252b6bf7c346ca..62ec90ad24f5595ebacc2468c509af97aa78870c 100644 (file)
@@ -1,4 +1,4 @@
-//===- llvm/System/ThreadLocal.h - Thread Local Data ------------*- C++ -*-===//
+//===- llvm/Support/ThreadLocal.h - Thread Local Data ------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -15,6 +15,7 @@
 #define LLVM_SYSTEM_THREAD_LOCAL_H
 
 #include "llvm/Support/Threading.h"
+#include "llvm/Support/DataTypes.h"
 #include <cassert>
 
 namespace llvm {
@@ -22,7 +23,15 @@ namespace llvm {
     // ThreadLocalImpl - Common base class of all ThreadLocal instantiations.
     // YOU SHOULD NEVER USE THIS DIRECTLY.
     class ThreadLocalImpl {
-      void* data;
+      typedef uint64_t ThreadLocalDataTy;
+      /// \brief Platform-specific thread local data.
+      ///
+      /// 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.
+      union {
+        char data[sizeof(ThreadLocalDataTy)];
+        ThreadLocalDataTy align_data;
+      };
     public:
       ThreadLocalImpl();
       virtual ~ThreadLocalImpl();