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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72087 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Owen Anderson 2009-05-19 01:07:40 +00:00
parent 03462230c7
commit ecb1684d51

View File

@ -62,11 +62,24 @@ namespace llvm {
}
#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