diff options
author | 2018-09-11 18:18:58 +0000 | |
---|---|---|
committer | 2018-09-11 18:18:58 +0000 | |
commit | 820e1f31efc1d6ed04795ba2e79f3044e1907492 (patch) | |
tree | 815cebb3734784074b661935c33f00bd5eb4d862 /lib/libcxx/src/include/atomic_support.h | |
parent | Nuke unused LIST() ieee80211com_head. (diff) | |
download | wireguard-openbsd-820e1f31efc1d6ed04795ba2e79f3044e1907492.tar.xz wireguard-openbsd-820e1f31efc1d6ed04795ba2e79f3044e1907492.zip |
import of libc++ 6.0.0
Diffstat (limited to 'lib/libcxx/src/include/atomic_support.h')
-rw-r--r-- | lib/libcxx/src/include/atomic_support.h | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/lib/libcxx/src/include/atomic_support.h b/lib/libcxx/src/include/atomic_support.h index 8b719c5f221..ccd8d78d3d7 100644 --- a/lib/libcxx/src/include/atomic_support.h +++ b/lib/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) \ @@ -29,7 +30,7 @@ #endif #if !defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && !defined(_LIBCPP_HAS_NO_THREADS) -# if defined(_MSC_VER) && !defined(__clang__) +# if defined(_LIBCPP_WARNING) _LIBCPP_WARNING("Building libc++ without __atomic builtins is unsupported") # else # warning Building libc++ without __atomic builtins is unsupported @@ -45,7 +46,7 @@ namespace { enum __libcpp_atomic_order { _AO_Relaxed = __ATOMIC_RELAXED, _AO_Consume = __ATOMIC_CONSUME, - _AO_Aquire = __ATOMIC_ACQUIRE, + _AO_Acquire = __ATOMIC_ACQUIRE, _AO_Release = __ATOMIC_RELEASE, _AO_Acq_Rel = __ATOMIC_ACQ_REL, _AO_Seq = __ATOMIC_SEQ_CST @@ -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) |