[llvm-commits] [llvm] r90748 - in /llvm/trunk: include/llvm/System/Atomic.h lib/System/Atomic.cpp
Oscar Fuentes
ofv at wanadoo.es
Sun Dec 6 21:29:59 PST 2009
Author: ofv
Date: Sun Dec 6 23:29:59 2009
New Revision: 90748
URL: http://llvm.org/viewvc/llvm-project?rev=90748&view=rev
Log:
Fixes the Atomic implementation if compiled by MSVC compiler.
sys::cas_flag should be long on this platform, InterlockedAdd() is
defined only for the Itanium architecture (according to MSDN).
Patch by Michael Beck!
Modified:
llvm/trunk/include/llvm/System/Atomic.h
llvm/trunk/lib/System/Atomic.cpp
Modified: llvm/trunk/include/llvm/System/Atomic.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Atomic.h?rev=90748&r1=90747&r2=90748&view=diff
==============================================================================
--- llvm/trunk/include/llvm/System/Atomic.h (original)
+++ llvm/trunk/include/llvm/System/Atomic.h Sun Dec 6 23:29:59 2009
@@ -20,7 +20,11 @@
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);
Modified: llvm/trunk/lib/System/Atomic.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Atomic.cpp?rev=90748&r1=90747&r2=90748&view=diff
==============================================================================
--- llvm/trunk/lib/System/Atomic.cpp (original)
+++ llvm/trunk/lib/System/Atomic.cpp Sun Dec 6 23:29:59 2009
@@ -85,7 +85,7 @@
#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
More information about the llvm-commits
mailing list