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!

llvm-svn: 90748
This commit is contained in:
Oscar Fuentes 2009-12-07 05:29:59 +00:00
parent c0dacee1e0
commit 8b6d88d2f8
2 changed files with 5 additions and 1 deletions

View 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);

View 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