Bug 1189894 - remove Atomics.h IntrinsicAddSub hack; r=erahm
authorNathan Froyd <froydnj@mozilla.com>
Fri, 31 Jul 2015 22:25:21 -0400
changeset 288356 d50e76df21a5676629ff6daa71eaac946ace85a2
parent 288355 2a80d4a658c6cc1507874b683197fd947bff301d
child 288357 d55b72972b58499cdc0b4b6158e1bcea0e70d955
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm
bugs1189894
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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.
mfbt/Atomics.h
--- a/mfbt/Atomics.h
+++ b/mfbt/Atomics.h
@@ -262,38 +262,22 @@ struct IntrinsicAddSub : public Intrinsi
 
 template<typename T, MemoryOrdering Order>
 struct IntrinsicAddSub<T*, Order> : public IntrinsicBase<T*, Order>
 {
   typedef IntrinsicBase<T*, Order> Base;
 
   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);
   }
 };
 
 template<typename T, MemoryOrdering Order>
 struct IntrinsicIncDec : public IntrinsicAddSub<T, Order>
 {
   typedef IntrinsicBase<T, Order> Base;