diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2019-12-05 15:12:59 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2019-12-05 15:12:59 +0900 |
commit | b8cf34c691623e4ec329053cbbf68522a855882d (patch) | |
tree | 34da08632a99677f6b79ecb65e5b655a5b69a67f /boost/atomic/detail/ops_extending_cas_based.hpp | |
parent | 3fdc3e5ee96dca5b11d1694975a65200787eab86 (diff) | |
download | boost-b8cf34c691623e4ec329053cbbf68522a855882d.tar.gz boost-b8cf34c691623e4ec329053cbbf68522a855882d.tar.bz2 boost-b8cf34c691623e4ec329053cbbf68522a855882d.zip |
Imported Upstream version 1.67.0upstream/1.67.0
Diffstat (limited to 'boost/atomic/detail/ops_extending_cas_based.hpp')
-rw-r--r-- | boost/atomic/detail/ops_extending_cas_based.hpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/boost/atomic/detail/ops_extending_cas_based.hpp b/boost/atomic/detail/ops_extending_cas_based.hpp index 3f21031f12..5f197cea48 100644 --- a/boost/atomic/detail/ops_extending_cas_based.hpp +++ b/boost/atomic/detail/ops_extending_cas_based.hpp @@ -18,6 +18,7 @@ #include <boost/memory_order.hpp> #include <boost/atomic/detail/config.hpp> #include <boost/atomic/detail/storage_type.hpp> +#include <boost/atomic/detail/integral_extend.hpp> #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once @@ -32,18 +33,18 @@ struct extending_cas_based_operations : public Base { typedef typename Base::storage_type storage_type; - typedef typename make_storage_type< Size, Signed >::type emulated_storage_type; + typedef typename make_storage_type< Size >::type emulated_storage_type; static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { storage_type old_val; atomics::detail::non_atomic_load(storage, old_val); - emulated_storage_type new_val; + storage_type new_val; do { - new_val = static_cast< emulated_storage_type >(old_val) + static_cast< emulated_storage_type >(v); + new_val = atomics::detail::integral_extend< Signed, storage_type >(static_cast< emulated_storage_type >(old_val + v)); } - while (!Base::compare_exchange_weak(storage, old_val, static_cast< storage_type >(new_val), order, memory_order_relaxed)); + while (!Base::compare_exchange_weak(storage, old_val, new_val, order, memory_order_relaxed)); return old_val; } @@ -51,12 +52,12 @@ struct extending_cas_based_operations : { storage_type old_val; atomics::detail::non_atomic_load(storage, old_val); - emulated_storage_type new_val; + storage_type new_val; do { - new_val = static_cast< emulated_storage_type >(old_val) - static_cast< emulated_storage_type >(v); + new_val = atomics::detail::integral_extend< Signed, storage_type >(static_cast< emulated_storage_type >(old_val - v)); } - while (!Base::compare_exchange_weak(storage, old_val, static_cast< storage_type >(new_val), order, memory_order_relaxed)); + while (!Base::compare_exchange_weak(storage, old_val, new_val, order, memory_order_relaxed)); return old_val; } }; |