From ecb1684d518633630636453c82503e352224d9f4 Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Tue, 19 May 2009 01:07:40 +0000 Subject: [PATCH] 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 --- include/llvm/System/Atomic.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/include/llvm/System/Atomic.h b/include/llvm/System/Atomic.h index 5162f5d3c63..5bdbaffe023 100644 --- a/include/llvm/System/Atomic.h +++ b/include/llvm/System/Atomic.h @@ -62,11 +62,24 @@ namespace llvm { } #elif defined(_MSC_VER) typedef LONG cas_flag; + template 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 + inline T* CompareAndSwap(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