[llvm-commits] [llvm] r72087 - /llvm/trunk/include/llvm/System/Atomic.h

Owen Anderson resistor at mac.com
Mon May 18 18:07:40 PDT 2009


Author: resistor
Date: Mon May 18 20:07:40 2009
New Revision: 72087

URL: http://llvm.org/viewvc/llvm-project?rev=72087&view=rev
Log:
Fix up the Windows portion of Atomic.h.  This is untested, but it is my best understanding of what should work.
I'd be much obliged if someone on MSVC++ could try this out and let me know if it works.

Modified:
    llvm/trunk/include/llvm/System/Atomic.h

Modified: llvm/trunk/include/llvm/System/Atomic.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Atomic.h?rev=72087&r1=72086&r2=72087&view=diff

==============================================================================
--- llvm/trunk/include/llvm/System/Atomic.h (original)
+++ llvm/trunk/include/llvm/System/Atomic.h Mon May 18 20:07:40 2009
@@ -62,11 +62,24 @@
     }
 #elif defined(_MSC_VER)
     typedef LONG cas_flag;
+    template<typename T>
     inline T CompareAndSwap(volatile T* ptr,
 			    T new_value,
 			    T old_value) {
-      return InterlockedCompareExchange(addr, new_value, old_value);
+      if (sizeof(T) == 4)
+	return InterlockedCompareExchange(ptr, new_value, old_value);
+      else
+	return InterlockedCompareExchange64(ptr, new_value, old_value);
     }
+    
+    template<typename T>
+    inline T* CompareAndSwap<T*>(volatile T** ptr,
+				 T* new_value,
+				 T* old_value) {
+      return InterlockedCompareExchangePtr(ptr, new_value, old_value);
+    }
+
+
 #else
 #  error No compare-and-swap implementation for your platform!
 #endif





More information about the llvm-commits mailing list