summaryrefslogtreecommitdiffstats
path: root/libcxx/src/include/atomic_support.h
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/src/include/atomic_support.h')
-rw-r--r--libcxx/src/include/atomic_support.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/libcxx/src/include/atomic_support.h b/libcxx/src/include/atomic_support.h
index 08847e63070..ccd8d78d3d7 100644
--- a/libcxx/src/include/atomic_support.h
+++ b/libcxx/src/include/atomic_support.h
@@ -16,6 +16,7 @@
#if defined(__clang__) && __has_builtin(__atomic_load_n) \
&& __has_builtin(__atomic_store_n) \
&& __has_builtin(__atomic_add_fetch) \
+ && __has_builtin(__atomic_exchange_n) \
&& __has_builtin(__atomic_compare_exchange_n) \
&& defined(__ATOMIC_RELAXED) \
&& defined(__ATOMIC_CONSUME) \
@@ -84,6 +85,14 @@ _ValueType __libcpp_atomic_add(_ValueType* __val, _AddType __a,
template <class _ValueType>
inline _LIBCPP_INLINE_VISIBILITY
+_ValueType __libcpp_atomic_exchange(_ValueType* __target,
+ _ValueType __value, int __order = _AO_Seq)
+{
+ return __atomic_exchange_n(__target, __value, __order);
+}
+
+template <class _ValueType>
+inline _LIBCPP_INLINE_VISIBILITY
bool __libcpp_atomic_compare_exchange(_ValueType* __val,
_ValueType* __expected, _ValueType __after,
int __success_order = _AO_Seq,
@@ -137,6 +146,16 @@ _ValueType __libcpp_atomic_add(_ValueType* __val, _AddType __a,
template <class _ValueType>
inline _LIBCPP_INLINE_VISIBILITY
+_ValueType __libcpp_atomic_exchange(_ValueType* __target,
+ _ValueType __value, int __order = _AO_Seq)
+{
+ _ValueType old = *__target;
+ *__target = __value;
+ return old;
+}
+
+template <class _ValueType>
+inline _LIBCPP_INLINE_VISIBILITY
bool __libcpp_atomic_compare_exchange(_ValueType* __val,
_ValueType* __expected, _ValueType __after,
int = 0, int = 0)
OpenPOWER on IntegriCloud