Title: [118603] trunk/Source/WTF
Revision
118603
Author
[email protected]
Date
2012-05-25 20:09:34 -0700 (Fri, 25 May 2012)

Log Message

weakCompareAndSwap should work on Windows
https://bugs.webkit.org/show_bug.cgi?id=87549

Reviewed by Jessie Berlin.

* wtf/Atomics.h:
(WTF):
(WTF::weakCompareAndSwap):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (118602 => 118603)


--- trunk/Source/WTF/ChangeLog	2012-05-26 02:24:53 UTC (rev 118602)
+++ trunk/Source/WTF/ChangeLog	2012-05-26 03:09:34 UTC (rev 118603)
@@ -1,3 +1,14 @@
+2012-05-25  Filip Pizlo  <[email protected]>
+
+        weakCompareAndSwap should work on Windows
+        https://bugs.webkit.org/show_bug.cgi?id=87549
+
+        Reviewed by Jessie Berlin.
+
+        * wtf/Atomics.h:
+        (WTF):
+        (WTF::weakCompareAndSwap):
+
 2012-05-24  Allan Sandfeld Jensen  <[email protected]>
 
         cti_vm_throw gets kicked out by gcc 4.6 -flto

Modified: trunk/Source/WTF/wtf/Atomics.h (118602 => 118603)


--- trunk/Source/WTF/wtf/Atomics.h	2012-05-26 02:24:53 UTC (rev 118602)
+++ trunk/Source/WTF/wtf/Atomics.h	2012-05-26 03:09:34 UTC (rev 118603)
@@ -118,6 +118,17 @@
 
 #endif
 
+#if OS(WINDOWS)
+inline bool weakCompareAndSwap(volatile unsigned* location, unsigned expected, unsigned newValue)
+{
+    return InterlockedCompareExchange(reinterpret_cast<LONG volatile*>(location), static_cast<LONG>(newValue), static_cast<LONG>(expected)) == static_cast<LONG>(expected);
+}
+
+inline bool weakCompareAndSwap(void*volatile* location, void* expected, void* newValue)
+{
+    return InterlockedCompareExchangePointer(location, newValue, expected) == expected;
+}
+#else // OS(WINDOWS) --> not windows
 #if COMPILER(GCC) && !COMPILER(CLANG) // Work around a gcc bug 
 inline bool weakCompareAndSwap(volatile unsigned* location, unsigned expected, unsigned newValue) 
 #else
@@ -184,6 +195,7 @@
     return 0;
 #endif // ENABLE(COMPARE_AND_SWAP)
 }
+#endif // OS(WINDOWS) (end of the not-windows case)
 
 inline bool weakCompareAndSwapUIntPtr(volatile uintptr_t* location, uintptr_t expected, uintptr_t newValue)
 {
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to