summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2015-12-20 19:11:44 +0000
committerXinliang David Li <davidxl@google.com>2015-12-20 19:11:44 +0000
commitd4bd3c6308bddabc0b92f476d491599a6d52e4a0 (patch)
treefa3df39eefeb57fdae7fcea2346b0c29f1c4ccd8 /lib
parent23f8795107c4c6fd4e1e417020769d9dde1cbc6b (diff)
downloadcompiler-rt-d4bd3c6308bddabc0b92f476d491599a6d52e4a0.tar.gz
[PGO] Implement BOOL_CMPXCHG for Windows
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@256128 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/profile/InstrProfilingPort.h13
1 files changed, 13 insertions, 0 deletions
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 <windows.h>
+#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)