[libcxx-commits] [libcxx] [libcxx] atomic min/max (PR #186694)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Mar 21 07:15:11 PDT 2026
================
@@ -259,6 +261,48 @@ __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));
}
+template <class _Tp>
+_LIBCPP_HIDE_FROM_ABI _Tp
+__cxx_atomic_fetch_min(__cxx_atomic_base_impl<_Tp> volatile* __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, std::addressof(__old), __new, __order, memory_order_relaxed));
----------------
huixie90 wrote:
sorry reply to the wrong PR
https://github.com/llvm/llvm-project/pull/186694
More information about the libcxx-commits
mailing list