Module: wine Branch: master Commit: 934c02c794d2bf8084c01dd9646b9b4884cdc716 URL: https://source.winehq.org/git/wine.git/?a=commit;h=934c02c794d2bf8084c01dd96...
Author: Stefan Dösinger stefan@codeweavers.com Date: Sun Nov 17 13:43:15 2019 +0100
libs/port: Use MSVC intrinsics for interlocked functions.
Signed-off-by: Stefan Dösinger stefan@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
libs/port/interlocked.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
diff --git a/libs/port/interlocked.c b/libs/port/interlocked.c index 59b852f7e9..040ab756eb 100644 --- a/libs/port/interlocked.c +++ b/libs/port/interlocked.c @@ -138,6 +138,47 @@ __ASM_GLOBAL_FUNC(interlocked_xchg_add,
#elif defined(__x86_64__)
+#if defined(_MSC_VER) + +#include <intrin.h> + +int interlocked_cmpxchg(int *dest, int xchg, int compare) +{ + return _InterlockedCompareExchange(dest, xchg, compare); +} + +void *interlocked_cmpxchg_ptr(void **dest, void *xchg, void *compare) +{ + return _InterlockedCompareExchangePointer(dest, xchg, compare); +} + +__int64 interlocked_cmpxchg64(__int64 *dest, __int64 xchg, __int64 compare) +{ + return _InterlockedCompareExchange64(dest, xchg, compare); +} + +int interlocked_xchg(int *dest, int val) +{ + return _InterlockedExchange(dest, val); +} + +void *interlocked_xchg_ptr(void **dest, void *val) +{ + return _InterlockedExchangePointer(dest, val); +} + +int interlocked_xchg_add(int *dest, int incr) +{ + return _InterlockedExchangeAdd(dest, incr); +} + +int interlocked_cmpxchg128(__int64 *dest, __int64 xchg_high, __int64 xchg_low, __int64 *compare) +{ + return _InterlockedCompareExchange128(dest, xchg_high, xchg_low, compare); +} + +#else + __ASM_GLOBAL_FUNC(interlocked_cmpxchg, "mov %edx, %eax\n\t" "lock cmpxchgl %esi,(%rdi)\n\t" @@ -179,6 +220,7 @@ __ASM_GLOBAL_FUNC(interlocked_cmpxchg128, __ASM_CFI(".cfi_adjust_cfa_offset -8\n\t") __ASM_CFI(".cfi_same_value %rbx\n\t") "ret") +#endif
#elif defined(__powerpc__)