From a9ffa384e86bb23e6b71646570ced9a6b9718249 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Mon, 20 Jul 2020 15:06:36 -0400 Subject: [PATCH] Use alignas to effectively define padding and fix 32-bit build Change-Id: Ib318d2fe847625567de93c9268cf000ec35a921f --- rocclr/thread/semaphore.hpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/rocclr/thread/semaphore.hpp b/rocclr/thread/semaphore.hpp index c76ce36e2e..975b3238f0 100644 --- a/rocclr/thread/semaphore.hpp +++ b/rocclr/thread/semaphore.hpp @@ -42,25 +42,17 @@ namespace amd { class Thread; //! \brief Counting semaphore -class Semaphore : public HeapObject { +class alignas(64) Semaphore : public HeapObject { private: std::atomic_int state_; //!< This semaphore's value. - // The base class size is 1, so padding alignment is needed. - static constexpr size_t state_size = sizeof(std::atomic_int) + - alignof(std::atomic_int); - - union { #ifdef _WIN32 - void* handle_; //!< The semaphore object's handle. + void* handle_; //!< The semaphore object's handle. #else // !_WIN32 - sem_t sem_; //!< The semaphore object's identifier. + sem_t sem_; //!< The semaphore object's identifier. #endif /*!_WIN32*/ - char padding_[64 - state_size]; - }; - - public: +public: Semaphore(); ~Semaphore();