Bug 1025900 - #include intrin.h directly in Atomics.h instead of declaring functions manually from it; r=froydnj
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 16 Jun 2014 18:19:49 -0400
changeset 188954 51144145675ea873036130a6b3a5fb0bfdbda541
parent 188953 412e31d5a16947768ec3a8e645fe5b739ce2464b
child 188955 04a017df20aa7a594c77a0a0bc923bad717773cc
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersfroydnj
bugs1025900, 1022049
milestone33.0a1
Bug 1025900 - #include intrin.h directly in Atomics.h instead of declaring functions manually from it; r=froydnj This is basically more of bug 1022049.
mfbt/Atomics.h
--- a/mfbt/Atomics.h
+++ b/mfbt/Atomics.h
@@ -509,29 +509,19 @@ struct AtomicIntrinsics<T*, Order> : pub
 
 /*
  * Windows comes with a full complement of atomic operations.
  * Unfortunately, most of those aren't available for Windows XP (even if
  * the compiler supports intrinsics for them), which is the oldest
  * version of Windows we support.  Therefore, we only provide operations
  * on 32-bit datatypes for 32-bit Windows versions; for 64-bit Windows
  * versions, we support 64-bit datatypes as well.
- *
- * To avoid namespace pollution issues, we declare whatever functions we
- * need ourselves.
  */
 
-extern "C" {
-long __cdecl _InterlockedExchangeAdd(long volatile* aDst, long aVal);
-long __cdecl _InterlockedOr(long volatile* aDst, long aVal);
-long __cdecl _InterlockedXor(long volatile* aDst, long aVal);
-long __cdecl _InterlockedAnd(long volatile* aDst, long aVal);
-long __cdecl _InterlockedExchange(long volatile *aDst, long aVal);
-long __cdecl _InterlockedCompareExchange(long volatile *aDst, long aNewVal, long aOldVal);
-}
+#  include <intrin.h>
 
 #  pragma intrinsic(_InterlockedExchangeAdd)
 #  pragma intrinsic(_InterlockedOr)
 #  pragma intrinsic(_InterlockedXor)
 #  pragma intrinsic(_InterlockedAnd)
 #  pragma intrinsic(_InterlockedExchange)
 #  pragma intrinsic(_InterlockedCompareExchange)
 
@@ -634,32 +624,16 @@ struct PrimitiveIntrinsics<4>
   static bool compareExchange(Type* aPtr, Type aOldVal, Type aNewVal)
   {
     return _InterlockedCompareExchange(aPtr, aNewVal, aOldVal) == aOldVal;
   }
 };
 
 #  if defined(_M_X64)
 
-extern "C" {
-long long __cdecl _InterlockedExchangeAdd64(long long volatile* aDst,
-                                            long long aVal);
-long long __cdecl _InterlockedOr64(long long volatile* aDst,
-                                   long long aVal);
-long long __cdecl _InterlockedXor64(long long volatile* aDst,
-                                    long long aVal);
-long long __cdecl _InterlockedAnd64(long long volatile* aDst,
-                                    long long aVal);
-long long __cdecl _InterlockedExchange64(long long volatile* aDst,
-                                         long long aVal);
-long long __cdecl _InterlockedCompareExchange64(long long volatile* aDst,
-                                                long long aNewVal,
-                                                long long aOldVal);
-}
-
 #    pragma intrinsic(_InterlockedExchangeAdd64)
 #    pragma intrinsic(_InterlockedOr64)
 #    pragma intrinsic(_InterlockedXor64)
 #    pragma intrinsic(_InterlockedAnd64)
 #    pragma intrinsic(_InterlockedExchange64)
 #    pragma intrinsic(_InterlockedCompareExchange64)
 
 template <>
@@ -708,18 +682,16 @@ struct PrimitiveIntrinsics<8>
   static bool compareExchange(Type* aPtr, Type aOldVal, Type aNewVal)
   {
     return _InterlockedCompareExchange64(aPtr, aNewVal, aOldVal) == aOldVal;
   }
 };
 
 #  endif
 
-extern "C" { void _ReadWriteBarrier(); }
-
 #  pragma intrinsic(_ReadWriteBarrier)
 
 template<MemoryOrdering Order> struct Barrier;
 
 /*
  * We do not provide an afterStore method in Barrier, as Relaxed and
  * ReleaseAcquire orderings do not require one, and the required barrier
  * for SequentiallyConsistent is handled by PrimitiveIntrinsics.