summaryrefslogtreecommitdiff
path: root/boost/atomic/detail/ops_extending_cas_based.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/atomic/detail/ops_extending_cas_based.hpp')
-rw-r--r--boost/atomic/detail/ops_extending_cas_based.hpp15
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;
}
};