git: 0e426a4a3468 - stable/12 - [libcxx] Guard C++20 atomic type aliases
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 22 Dec 2021 10:06:41 UTC
The branch stable/12 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=0e426a4a346876e61adc0b3981a91fe1e039c1ee commit 0e426a4a346876e61adc0b3981a91fe1e039c1ee Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2021-12-17 22:10:49 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2021-12-22 10:01:33 +0000 [libcxx] Guard C++20 atomic type aliases Apply abandoned llvm review https://reviews.llvm.org/D75183 anyway: The std::atomic_signed_lock_free and std::atomic_unsigned_lock_free typedefs are a C++20 feature and should be guarded with an #if, so that they don't get defined in C++17 and prior versions. Also with the current implementation inclusion of the <atomic> header will fail the compilation for targets that don't have lock-free atomic integers (e.g. Armv6-M) because __libcpp_signed_lock_free and __libcpp_unsigned_lock_free will not get defined. We should not try to define std::atomic_signed_lock_free and std::atomic_unsigned_lock_free in this case as well (according to [atomics.alias]/2 these typedefs are optional in freestanding implementations). --- contrib/llvm-project/libcxx/include/atomic | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/contrib/llvm-project/libcxx/include/atomic b/contrib/llvm-project/libcxx/include/atomic index 5ab48f55ddd3..264023405516 100644 --- a/contrib/llvm-project/libcxx/include/atomic +++ b/contrib/llvm-project/libcxx/include/atomic @@ -2761,6 +2761,8 @@ typedef atomic<uintmax_t> atomic_uintmax_t; # define _LIBCPP_CONTENTION_LOCK_FREE false #endif +#if _LIBCPP_STD_VER > 17 + #if ATOMIC_LLONG_LOCK_FREE == 2 typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, long long>::type __libcpp_signed_lock_free; typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned long long>::type __libcpp_unsigned_lock_free; @@ -2775,10 +2777,15 @@ typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, char>::typ typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned char>::type __libcpp_unsigned_lock_free; #else // No signed/unsigned lock-free types +# define _LIBCPP_CANNOT_DEFINE_ATOMIC_LOCK_FREE_TYPE_ALIASES #endif +#ifndef _LIBCPP_CANNOT_DEFINE_ATOMIC_LOCK_FREE_TYPE_ALIASES typedef atomic<__libcpp_signed_lock_free> atomic_signed_lock_free; typedef atomic<__libcpp_unsigned_lock_free> atomic_unsigned_lock_free; +#endif + +#endif // _LIBCPP_STD_VER > 17 #define ATOMIC_FLAG_INIT {false} #define ATOMIC_VAR_INIT(__v) {__v}