Bug 1189894 - remove Atomics.h IntrinsicAddSub hack; r=erahm

This hack was only required for broken headers in GCC 4.6.  Since we
only support GCC 4.7+ now, this hack is no longer necessary.
This commit is contained in:
Nathan Froyd 2015-07-31 22:25:21 -04:00
parent e482bc8561
commit 78b4b30d08

View File

@ -267,28 +267,12 @@ struct IntrinsicAddSub<T*, Order> : public IntrinsicBase<T*, Order>
static T* add(typename Base::ValueType& aPtr, ptrdiff_t aVal)
{
return aPtr.fetch_add(fixupAddend(aVal), Base::OrderedOp::AtomicRMWOrder);
return aPtr.fetch_add(aVal, Base::OrderedOp::AtomicRMWOrder);
}
static T* sub(typename Base::ValueType& aPtr, ptrdiff_t aVal)
{
return aPtr.fetch_sub(fixupAddend(aVal), Base::OrderedOp::AtomicRMWOrder);
}
private:
/*
* GCC 4.6's <atomic> header has a bug where adding X to an
* atomic<T*> is not the same as adding X to a T*. Hence the need
* for this function to provide the correct addend.
*/
static ptrdiff_t fixupAddend(ptrdiff_t aVal)
{
#if defined(__clang__) || defined(_MSC_VER)
return aVal;
#elif defined(__GNUC__) && !MOZ_GCC_VERSION_AT_LEAST(4, 7, 0)
return aVal * sizeof(T);
#else
return aVal;
#endif
return aPtr.fetch_sub(aVal, Base::OrderedOp::AtomicRMWOrder);
}
};