Fix Mac build.

Change-Id: I2d83c018399422af0f8aa1cdaba7ade014053992
diff --git a/src/thread.cc b/src/thread.cc
index d43d2ef..f879ee2 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -468,11 +468,11 @@
 }
 
 void Thread::AtomicSetFlag(ThreadFlag flag) {
-  android_atomic_or(flag, reinterpret_cast<int32_t*>(&state_and_flags_));
+  android_atomic_or(flag, &state_and_flags_.as_int);
 }
 
 void Thread::AtomicClearFlag(ThreadFlag flag) {
-  android_atomic_and(-1 ^ flag, reinterpret_cast<int32_t*>(&state_and_flags_));
+  android_atomic_and(-1 ^ flag, &state_and_flags_.as_int);
 }
 
 ThreadState Thread::SetState(ThreadState new_state) {
@@ -480,9 +480,9 @@
   // old_state_and_flags.suspend_request is true.
   DCHECK_NE(new_state, kRunnable);
   DCHECK_EQ(this, Thread::Current());
-  struct StateAndFlags old_state_and_flags = state_and_flags_;
-  state_and_flags_.state = new_state;
-  return static_cast<ThreadState>(old_state_and_flags.state);
+  union StateAndFlags old_state_and_flags = state_and_flags_;
+  state_and_flags_.as_struct.state = new_state;
+  return static_cast<ThreadState>(old_state_and_flags.as_struct.state);
 }
 
 void Thread::ModifySuspendCount(int delta, bool for_debugger) {
@@ -524,7 +524,7 @@
   DCHECK_EQ(this, Thread::Current());
   // Change to non-runnable state, thereby appearing suspended to the system.
   DCHECK_EQ(GetState(), kRunnable);
-  state_and_flags_.state = new_state;
+  state_and_flags_.as_struct.state = new_state;
   // Release share on mutator_lock_.
   Locks::mutator_lock_->SharedUnlock();
 }
@@ -550,7 +550,7 @@
     // Re-acquire shared mutator_lock_ access.
     Locks::mutator_lock_->SharedLock();
     // Atomically change from suspended to runnable if no suspend request pending.
-    int16_t old_flags = state_and_flags_.flags;
+    int16_t old_flags = state_and_flags_.as_struct.flags;
     if ((old_flags & kSuspendRequest) == 0) {
       int32_t old_state_and_flags = old_flags | (old_state << 16);
       int32_t new_state_and_flags = old_flags | (kRunnable << 16);
@@ -884,8 +884,8 @@
       last_no_thread_suspension_cause_(NULL),
       thread_exit_check_count_(0) {
   CHECK_EQ((sizeof(Thread) % 4), 0U) << sizeof(Thread);
-  state_and_flags_.flags = 0;
-  state_and_flags_.state = kNative;
+  state_and_flags_.as_struct.flags = 0;
+  state_and_flags_.as_struct.state = kNative;
   memset(&held_mutexes_[0], 0, sizeof(held_mutexes_));
 }
 
diff --git a/src/thread.h b/src/thread.h
index a58fb65..1b9bb74 100644
--- a/src/thread.h
+++ b/src/thread.h
@@ -153,7 +153,7 @@
       LOCKS_EXCLUDED(Locks::thread_suspend_count_lock_);
 
   ThreadState GetState() const {
-    return static_cast<ThreadState>(state_and_flags_.state);
+    return static_cast<ThreadState>(state_and_flags_.as_struct.state);
   }
 
   ThreadState SetState(ThreadState new_state);
@@ -604,7 +604,7 @@
   // Avoid use, callers should use SetState. Used only by SignalCatcher::HandleSigQuit and ~Thread.
   ThreadState SetStateUnsafe(ThreadState new_state) {
     ThreadState old_state = GetState();
-    state_and_flags_.state = new_state;
+    state_and_flags_.as_struct.state = new_state;
     return old_state;
   }
   friend class SignalCatcher;  // For SetStateUnsafe.
@@ -641,7 +641,7 @@
   }
 
   bool ReadFlag(ThreadFlag flag) const {
-    return (state_and_flags_.flags & flag) != 0;
+    return (state_and_flags_.as_struct.flags & flag) != 0;
   }
 
   void AtomicSetFlag(ThreadFlag flag);
@@ -662,18 +662,21 @@
 
   // 32 bits of atomically changed state and flags. Keeping as 32 bits allows and atomic CAS to
   // change from being Suspended to Runnable without a suspend request occurring.
-  struct PACKED StateAndFlags {
-    // Bitfield of flag values. Must be changed atomically so that flag values aren't lost. See
-    // ThreadFlags for bit field meanings.
-    volatile uint16_t flags;
-    // Holds the ThreadState. May be changed non-atomically between Suspended (ie not Runnable)
-    // transitions. Changing to Runnable requires that the suspend_request be part of the atomic
-    // operation. If a thread is suspended and a suspend_request is present, a thread may not
-    // change to Runnable as a GC or other operation is in progress.
-    uint16_t state;
+  union StateAndFlags {
+    struct PACKED {
+      // Bitfield of flag values. Must be changed atomically so that flag values aren't lost. See
+      // ThreadFlags for bit field meanings.
+      volatile uint16_t flags;
+      // Holds the ThreadState. May be changed non-atomically between Suspended (ie not Runnable)
+      // transitions. Changing to Runnable requires that the suspend_request be part of the atomic
+      // operation. If a thread is suspended and a suspend_request is present, a thread may not
+      // change to Runnable as a GC or other operation is in progress.
+      uint16_t state;
+    } as_struct;
+    int32_t as_int;
   };
-  struct StateAndFlags state_and_flags_;
-  COMPILE_ASSERT(sizeof(struct StateAndFlags) == sizeof(int32_t),
+  union StateAndFlags state_and_flags_;
+  COMPILE_ASSERT(sizeof(union StateAndFlags) == sizeof(int32_t),
                  sizeof_state_and_flags_and_int32_are_different);
 
   // A non-zero value is used to tell the current thread to enter a safe point