Atomics.h on Windows: remove seq_cst hack
authorjfbastien@apple.com <jfbastien@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Sep 2016 23:20:56 +0000 (23:20 +0000)
committerjfbastien@apple.com <jfbastien@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Sep 2016 23:20:56 +0000 (23:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=162022

Reviewed by Mark Lam.

No need to force access to seq_cst, always inlining fixes the MSVC warning.

* wtf/Atomics.h:
(WTF::Atomic::compareExchangeWeak): remove seq_cst hack
(WTF::Atomic::compareExchangeStrong): remove seq_cst hack
(WTF::Atomic::exchangeAndAdd): remove seq_cst hack
(WTF::Atomic::exchange): remove seq_cst hack

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206468 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WTF/ChangeLog
Source/WTF/wtf/Atomics.h

index 8e69f1e..dca468f 100644 (file)
@@ -1,3 +1,18 @@
+2016-09-27  JF Bastien  <jfbastien@apple.com>
+
+        Atomics.h on Windows: remove seq_cst hack
+        https://bugs.webkit.org/show_bug.cgi?id=162022
+
+        Reviewed by Mark Lam.
+
+        No need to force access to seq_cst, always inlining fixes the MSVC warning.
+
+        * wtf/Atomics.h:
+        (WTF::Atomic::compareExchangeWeak): remove seq_cst hack
+        (WTF::Atomic::compareExchangeStrong): remove seq_cst hack
+        (WTF::Atomic::exchangeAndAdd): remove seq_cst hack
+        (WTF::Atomic::exchange): remove seq_cst hack
+
 2016-09-27  Don Olmstead  <don.olmstead@am.sony.com>
 
         [CMake] Use CMake to determine HAVE_* defines
index e46a4ba..73fe937 100644 (file)
@@ -58,66 +58,32 @@ struct Atomic {
 
     ALWAYS_INLINE bool compareExchangeWeak(T expected, T desired, std::memory_order order = std::memory_order_seq_cst)
     {
-#if OS(WINDOWS)
-        // Windows makes strange assertions about the argument to compare_exchange_weak, and anyway,
-        // Windows is X86 so seq_cst is cheap.
-        order = std::memory_order_seq_cst;
-#endif
         T expectedOrActual = expected;
         return value.compare_exchange_weak(expectedOrActual, desired, order);
     }
 
     ALWAYS_INLINE bool compareExchangeWeak(T expected, T desired, std::memory_order order_success, std::memory_order order_failure)
     {
-#if OS(WINDOWS)
-        // Windows makes strange assertions about the argument to compare_exchange_weak, and anyway,
-        // Windows is X86 so seq_cst is cheap.
-        order_success = std::memory_order_seq_cst;
-        order_failure = std::memory_order_seq_cst;
-#endif
         T expectedOrActual = expected;
         return value.compare_exchange_weak(expectedOrActual, desired, order_success, order_failure);
     }
 
     ALWAYS_INLINE bool compareExchangeStrong(T expected, T desired, std::memory_order order = std::memory_order_seq_cst)
     {
-#if OS(WINDOWS)
-        // See above.
-        order = std::memory_order_seq_cst;
-#endif
         T expectedOrActual = expected;
         return value.compare_exchange_strong(expectedOrActual, desired, order);
     }
 
     ALWAYS_INLINE bool compareExchangeStrong(T expected, T desired, std::memory_order order_success, std::memory_order order_failure)
     {
-#if OS(WINDOWS)
-        // See above.
-        order_success = std::memory_order_seq_cst;
-        order_failure = std::memory_order_seq_cst;
-#endif
         T expectedOrActual = expected;
         return value.compare_exchange_strong(expectedOrActual, desired, order_success, order_failure);
     }
 
     template<typename U>
-    ALWAYS_INLINE T exchangeAndAdd(U addend, std::memory_order order = std::memory_order_seq_cst)
-    {
-#if OS(WINDOWS)
-        // See above.
-        order = std::memory_order_seq_cst;
-#endif
-        return value.fetch_add(addend, order);
-    }
+    ALWAYS_INLINE T exchangeAndAdd(U addend, std::memory_order order = std::memory_order_seq_cst) { return value.fetch_add(addend, order); }
     
-    ALWAYS_INLINE T exchange(T newValue, std::memory_order order = std::memory_order_seq_cst)
-    {
-#if OS(WINDOWS)
-        // See above.
-        order = std::memory_order_seq_cst;
-#endif
-        return value.exchange(newValue, order);
-    }
+    ALWAYS_INLINE T exchange(T newValue, std::memory_order order = std::memory_order_seq_cst) { return value.exchange(newValue, order); }
 
     std::atomic<T> value;
 };