[libcxx-commits] [libcxx] [libc++] Implement P0493R5: Atomic minimum/maximum (PR #180333)
Connector Switch via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jul 13 06:12:30 PDT 2026
================
@@ -259,6 +261,77 @@ __cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_o
std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order));
}
+// Clang's __c11_atomic_fetch_max/min builtins do not accept pointer
+// arguments, so dispatch to a CAS loop for pointer types.
+// TODO: Use the builtin for pointer types once Clang accepts them.
+template <class _Tp, __enable_if_t<!is_pointer<_Tp>::value, int> = 0>
----------------
c8ef wrote:
> if one day clang adds the support for pointer fetch min/max, we don't need to change any code here as the concept will detect it
On second thought, this also means we currently lack test coverage for the built-in branch guarded by `if constexpr`. Because of this, I’d prefer to hold off on adding it for now. We can add it manually once our CI includes compilers that actually support it.
https://github.com/llvm/llvm-project/pull/180333
More information about the libcxx-commits
mailing list