aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2024-02-26 13:17:32 +0000
committerJonathan Wakely <jwakely@redhat.com>2024-03-07 20:55:25 +0000
commite162b2ff52c5e20f6624ff6b66845fe573cef183 (patch)
tree5634fc016e8cec642b8ff7b64ce372af6c63235e /libstdc++-v3/include
parentddd347fca0685804bf68d6c768282573f3ea6442 (diff)
downloadgcc-e162b2ff52c5e20f6624ff6b66845fe573cef183.zip
gcc-e162b2ff52c5e20f6624ff6b66845fe573cef183.tar.gz
gcc-e162b2ff52c5e20f6624ff6b66845fe573cef183.tar.bz2
libstdc++: Do not define lock-free atomic aliases if not fully lock-free [PR114103]
The whole point of these typedefs is to guarantee lock-freedom, so if the target has no such types, we shouldn't defined the typedefs at all. libstdc++-v3/ChangeLog: PR libstdc++/114103 * include/bits/version.def (atomic_lock_free_type_aliases): Add extra_cond to check for at least one always-lock-free type. * include/bits/version.h: Regenerate. * include/std/atomic (atomic_signed_lock_free) (atomic_unsigned_lock_free): Only use always-lock-free types. * src/c++20/tzdb.cc (time_zone::_Impl::RulesCounter): Don't use atomic counter if lock-free aliases aren't available. * testsuite/29_atomics/atomic/lock_free_aliases.cc: XFAIL for targets without lock-free word-size compare_exchange.
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r--libstdc++-v3/include/bits/version.def1
-rw-r--r--libstdc++-v3/include/bits/version.h2
-rw-r--r--libstdc++-v3/include/std/atomic6
3 files changed, 5 insertions, 4 deletions
diff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def
index 502961e..d298420 100644
--- a/libstdc++-v3/include/bits/version.def
+++ b/libstdc++-v3/include/bits/version.def
@@ -739,6 +739,7 @@ ftms = {
values = {
v = 201907;
cxxmin = 20;
+ extra_cond = "(__GCC_ATOMIC_INT_LOCK_FREE | __GCC_ATOMIC_LONG_LOCK_FREE | __GCC_ATOMIC_CHAR_LOCK_FREE) & 2";
};
};
diff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h
index 7a6fbd3..9107b45 100644
--- a/libstdc++-v3/include/bits/version.h
+++ b/libstdc++-v3/include/bits/version.h
@@ -819,7 +819,7 @@
#undef __glibcxx_want_atomic_float
#if !defined(__cpp_lib_atomic_lock_free_type_aliases)
-# if (__cplusplus >= 202002L)
+# if (__cplusplus >= 202002L) && ((__GCC_ATOMIC_INT_LOCK_FREE | __GCC_ATOMIC_LONG_LOCK_FREE | __GCC_ATOMIC_CHAR_LOCK_FREE) & 2)
# define __glibcxx_atomic_lock_free_type_aliases 201907L
# if defined(__glibcxx_want_all) || defined(__glibcxx_want_atomic_lock_free_type_aliases)
# define __cpp_lib_atomic_lock_free_type_aliases 201907L
diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic
index 559f837..1462cf5 100644
--- a/libstdc++-v3/include/std/atomic
+++ b/libstdc++-v3/include/std/atomic
@@ -1774,13 +1774,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
= atomic<make_signed_t<__detail::__platform_wait_t>>;
using atomic_unsigned_lock_free
= atomic<make_unsigned_t<__detail::__platform_wait_t>>;
-# elif ATOMIC_INT_LOCK_FREE || !(ATOMIC_LONG_LOCK_FREE || ATOMIC_CHAR_LOCK_FREE)
+# elif ATOMIC_INT_LOCK_FREE == 2
using atomic_signed_lock_free = atomic<signed int>;
using atomic_unsigned_lock_free = atomic<unsigned int>;
-# elif ATOMIC_LONG_LOCK_FREE
+# elif ATOMIC_LONG_LOCK_FREE == 2
using atomic_signed_lock_free = atomic<signed long>;
using atomic_unsigned_lock_free = atomic<unsigned long>;
-# elif ATOMIC_CHAR_LOCK_FREE
+# elif ATOMIC_CHAR_LOCK_FREE == 2
using atomic_signed_lock_free = atomic<signed char>;
using atomic_unsigned_lock_free = atomic<unsigned char>;
# else