mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
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:
parent
e482bc8561
commit
78b4b30d08
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user