]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Use hardware_destructive_interference_size in atomic.cc
authorJonathan Wakely <jwakely@redhat.com>
Thu, 30 Apr 2026 15:06:11 +0000 (16:06 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 6 May 2026 09:52:44 +0000 (10:52 +0100)
This code was moved from a header into the library, so is no longer
affected by compiler options used when including the headers. We can
just use std::hardware_destructive_interference_size now, and remove the
comment.

libstdc++-v3/ChangeLog:

* src/c++20/atomic.cc (__waitable_state::_S_align): Remove.
(__waitable_state::_M_waiters, __waitable_state::_M_ver): Use
std::hardware_destructive_interference_size for alignment.

Reviewed-by: Tomasz KamiƄski <tkaminsk@redhat.com>
libstdc++-v3/src/c++20/atomic.cc

index 3e02f437db3c5a02b87829d88f4fa905f17e3fb9..3fbc05c2e68200d1481e23238123818214049015 100644 (file)
@@ -289,12 +289,9 @@ namespace
   // The state used by atomic waiting and notifying functions.
   struct __waitable_state
   {
-    // Don't use std::hardware_destructive_interference_size here because we
-    // don't want the layout of library types to depend on compiler options.
-    static constexpr auto _S_align = 64;
-
     // Count of threads blocked waiting on this state.
-    alignas(_S_align) __platform_wait_t _M_waiters = 0;
+    alignas(std::hardware_destructive_interference_size)
+      __platform_wait_t _M_waiters = 0;
 
 #ifndef _GLIBCXX_HAVE_PLATFORM_WAIT
     mutex _M_mtx;
@@ -310,7 +307,8 @@ namespace
     // If we can't do a platform wait on the atomic variable itself,
     // we use this member as a proxy for the atomic variable and we
     // use this for waiting and notifying functions instead.
-    alignas(_S_align) __platform_wait_t _M_ver = 0;
+    alignas(std::hardware_destructive_interference_size)
+      __platform_wait_t _M_ver = 0;
 
 #ifndef _GLIBCXX_HAVE_PLATFORM_WAIT
     __condvar _M_cv;