This commit is contained in:
Nekotekina 2015-05-27 13:55:15 +03:00
parent 7037da80cb
commit 26e5a07905
2 changed files with 11 additions and 8 deletions

View File

@ -93,27 +93,27 @@ template<typename T> static inline typename std::enable_if<std::is_arithmetic<T>
return __sync_lock_test_and_set(dest, value);
}
template<typename T> static inline typename std::enable_if<std::is_arithmetic<T>::value, T>::type sync_lock_fetch_and_add(volatile T* dest, T value)
template<typename T> static inline typename std::enable_if<std::is_arithmetic<T>::value, T>::type sync_fetch_and_add(volatile T* dest, T value)
{
return __sync_lock_fetch_and_add(dest, value);
}
template<typename T> static inline typename std::enable_if<std::is_arithmetic<T>::value, T>::type sync_lock_fetch_and_sub(volatile T* dest, T value)
template<typename T> static inline typename std::enable_if<std::is_arithmetic<T>::value, T>::type sync_fetch_and_sub(volatile T* dest, T value)
{
return __sync_lock_fetch_and_sub(dest, value);
}
template<typename T> static inline typename std::enable_if<std::is_arithmetic<T>::value, T>::type sync_lock_fetch_and_or(volatile T* dest, T value)
template<typename T> static inline typename std::enable_if<std::is_arithmetic<T>::value, T>::type sync_fetch_and_or(volatile T* dest, T value)
{
return __sync_lock_fetch_and_or(dest, value);
}
template<typename T> static inline typename std::enable_if<std::is_arithmetic<T>::value, T>::type sync_lock_fetch_and_and(volatile T* dest, T value)
template<typename T> static inline typename std::enable_if<std::is_arithmetic<T>::value, T>::type sync_fetch_and_and(volatile T* dest, T value)
{
return __sync_lock_fetch_and_and(dest, value);
}
template<typename T> static inline typename std::enable_if<std::is_arithmetic<T>::value, T>::type sync_lock_fetch_and_xor(volatile T* dest, T value)
template<typename T> static inline typename std::enable_if<std::is_arithmetic<T>::value, T>::type sync_fetch_and_xor(volatile T* dest, T value)
{
return __sync_lock_fetch_and_xor(dest, value);
}

View File

@ -76,7 +76,8 @@ public:
// read data with memory barrier
__forceinline const type read_sync() const volatile
{
return from_subtype(sync_val_compare_and_swap(const_cast<subtype*>(&sub_data), 0, 0));
const subtype zero = {};
return from_subtype(sync_val_compare_and_swap(const_cast<subtype*>(&sub_data), zero, zero));
}
// atomically replace data with exch, return previous data value
@ -126,7 +127,8 @@ public:
// perform atomic operation on data with additional memory barrier
template<typename FT> __forceinline void atomic_op_sync(const FT atomic_proc) volatile
{
subtype old = sync_val_compare_and_swap(&sub_data, 0, 0);
const subtype zero = {};
subtype old = sync_val_compare_and_swap(&sub_data, zero, zero);
while (true)
{
subtype _new = old;
@ -140,7 +142,8 @@ public:
// perform atomic operation on data with additional memory barrier and special exit condition (if intermediate result != proceed_value)
template<typename RT, typename FT> __forceinline RT atomic_op_sync(const RT proceed_value, const FT atomic_proc) volatile
{
subtype old = sync_val_compare_and_swap(&sub_data, 0, 0);
const subtype zero = {};
subtype old = sync_val_compare_and_swap(&sub_data, zero, zero);
while (true)
{
subtype _new = old;