[libcxx-commits] [libcxx] [libcxx] atomic min/max (PR #186694)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Mar 17 05:41:36 PDT 2026


================
@@ -258,6 +258,50 @@ __cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_o
   return __atomic_fetch_xor(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order));
 }
 
+template <typename _Tp>
+_LIBCPP_HIDE_FROM_ABI _Tp
+__cxx_atomic_fetch_min(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __val, memory_order __order) _NOEXCEPT {
+  _Tp __old = __cxx_atomic_load(__a, memory_order_relaxed);
+  _Tp __new;
+  do {
+    __new = __old < __val ? __old : __val;
+  } while (!__cxx_atomic_compare_exchange_weak(__a, &__old, __new, __order, memory_order_relaxed));
----------------
gonzalobg wrote:

There were many more of these missing, so have addressed these in https://github.com/llvm/llvm-project/pull/186694/commits/0adc9b3e864f4cba65342b184fcff203c46bb637

https://github.com/llvm/llvm-project/pull/186694


More information about the libcxx-commits mailing list