From d4bd3c6308bddabc0b92f476d491599a6d52e4a0 Mon Sep 17 00:00:00 2001 From: Xinliang David Li Date: Sun, 20 Dec 2015 19:11:44 +0000 Subject: [PGO] Implement BOOL_CMPXCHG for Windows git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@256128 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/profile/InstrProfilingPort.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib') diff --git a/lib/profile/InstrProfilingPort.h b/lib/profile/InstrProfilingPort.h index d42e85376..06727091a 100644 --- a/lib/profile/InstrProfilingPort.h +++ b/lib/profile/InstrProfilingPort.h @@ -23,8 +23,21 @@ #define COMPILER_RT_SECTION(Sect) __attribute__((section(Sect))) #if COMPILER_RT_HAS_ATOMICS == 1 +#ifdef _MSC_VER +#include +#if defined(_WIN32) +#define COMPILER_RT_BOOL_CMPXCHG(Ptr, OldV, NewV) \ + (InterlockedCompareExchange((LONG volatile *)Ptr, (LONG)NewV, (LONG)OldV) == \ + (LONG)OldV) +#else +#define COMPILER_RT_BOOL_CMPXCHG(Ptr, OldV, NewV) \ + (InterlockedCompareExchange64((LONGLONG volatile *)Ptr, (LONGLONG)NewV, \ + (LONGLONG)OldV) == (LONGLONG)OldV) +#endif +#else #define COMPILER_RT_BOOL_CMPXCHG(Ptr, OldV, NewV) \ __sync_bool_compare_and_swap(Ptr, OldV, NewV) +#endif #else #define COMPILER_RT_BOOL_CMPXCHG(Ptr, OldV, NewV) \ BoolCmpXchg((void **)Ptr, OldV, NewV) -- cgit v1.2.1