Module: wine Branch: master Commit: aabdaed10211fd5d6e7399c95b25a1a2bde3c7e6 URL: https://source.winehq.org/git/wine.git/?a=commit;h=aabdaed10211fd5d6e7399c95...
Author: Zebediah Figura z.figura12@gmail.com Date: Mon Jan 18 21:55:01 2021 -0600
include: Use __atomic_exchange_n() for InterlockedExchange*() if possible.
Signed-off-by: Zebediah Figura z.figura12@gmail.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
include/winnt.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/include/winnt.h b/include/winnt.h index e48c884cd4c..8abc11a7dd5 100644 --- a/include/winnt.h +++ b/include/winnt.h @@ -7015,7 +7015,9 @@ static FORCEINLINE unsigned char InterlockedCompareExchange128( volatile __int64 static FORCEINLINE LONG WINAPI InterlockedExchange( LONG volatile *dest, LONG val ) { LONG ret; -#if defined(__i386__) || defined(__x86_64__) +#if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) + ret = __atomic_exchange_n( dest, val, __ATOMIC_SEQ_CST ); +#elif defined(__i386__) || defined(__x86_64__) __asm__ __volatile__( "lock; xchgl %0,(%1)" : "=r" (ret) :"r" (dest), "0" (val) : "memory" ); #else @@ -7042,7 +7044,9 @@ static FORCEINLINE LONG WINAPI InterlockedDecrement( LONG volatile *dest ) static FORCEINLINE void * WINAPI InterlockedExchangePointer( void *volatile *dest, void *val ) { void *ret; -#ifdef __x86_64__ +#if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) + ret = __atomic_exchange_n( dest, val, __ATOMIC_SEQ_CST ); +#elif defined(__x86_64__) __asm__ __volatile__( "lock; xchgq %0,(%1)" : "=r" (ret) :"r" (dest), "0" (val) : "memory" ); #elif defined(__i386__) __asm__ __volatile__( "lock; xchgl %0,(%1)" : "=r" (ret) :"r" (dest), "0" (val) : "memory" );