Fixes the Atomic implementation if compiled by MSVC compiler.
authorOscar Fuentes <ofv@wanadoo.es>
Mon, 7 Dec 2009 05:29:59 +0000 (05:29 +0000)
committerOscar Fuentes <ofv@wanadoo.es>
Mon, 7 Dec 2009 05:29:59 +0000 (05:29 +0000)
sys::cas_flag should be long on this platform, InterlockedAdd() is
defined only for the Itanium architecture (according to MSDN).

Patch by Michael Beck!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90748 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/System/Atomic.h
lib/System/Atomic.cpp

index 0c05d696e39294f7dbc164f6cc847615d16ebcd6..fc19369d11bdeb387f34ef02c741cea160736fad 100644 (file)
@@ -20,7 +20,11 @@ namespace llvm {
   namespace sys {
     void MemoryFence();
 
+#ifdef _MSC_VER
+    typedef long cas_flag;
+#else
     typedef uint32_t cas_flag;
+#endif
     cas_flag CompareAndSwap(volatile cas_flag* ptr,
                             cas_flag new_value,
                             cas_flag old_value);
index f9b55a186d1829fa0e6498d1e0e70aba46bed995..7ba8b774d5e0a0b3e590806e468f599d3b138100 100644 (file)
@@ -85,7 +85,7 @@ sys::cas_flag sys::AtomicAdd(volatile sys::cas_flag* ptr, sys::cas_flag val) {
 #elif defined(__GNUC__)
   return __sync_add_and_fetch(ptr, val);
 #elif defined(_MSC_VER)
-  return InterlockedAdd(ptr, val);
+  return InterlockedExchangeAdd(ptr, val) + val;
 #else
 #  error No atomic add implementation for your platform!
 #endif