Commit aabdaed1 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

include: Use __atomic_exchange_n() for InterlockedExchange*() if possible.

parent dc02bbee
...@@ -7015,7 +7015,9 @@ static FORCEINLINE unsigned char InterlockedCompareExchange128( volatile __int64 ...@@ -7015,7 +7015,9 @@ static FORCEINLINE unsigned char InterlockedCompareExchange128( volatile __int64
static FORCEINLINE LONG WINAPI InterlockedExchange( LONG volatile *dest, LONG val ) static FORCEINLINE LONG WINAPI InterlockedExchange( LONG volatile *dest, LONG val )
{ {
LONG ret; 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)" __asm__ __volatile__( "lock; xchgl %0,(%1)"
: "=r" (ret) :"r" (dest), "0" (val) : "memory" ); : "=r" (ret) :"r" (dest), "0" (val) : "memory" );
#else #else
...@@ -7042,7 +7044,9 @@ static FORCEINLINE LONG WINAPI InterlockedDecrement( LONG volatile *dest ) ...@@ -7042,7 +7044,9 @@ static FORCEINLINE LONG WINAPI InterlockedDecrement( LONG volatile *dest )
static FORCEINLINE void * WINAPI InterlockedExchangePointer( void *volatile *dest, void *val ) static FORCEINLINE void * WINAPI InterlockedExchangePointer( void *volatile *dest, void *val )
{ {
void *ret; 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" ); __asm__ __volatile__( "lock; xchgq %0,(%1)" : "=r" (ret) :"r" (dest), "0" (val) : "memory" );
#elif defined(__i386__) #elif defined(__i386__)
__asm__ __volatile__( "lock; xchgl %0,(%1)" : "=r" (ret) :"r" (dest), "0" (val) : "memory" ); __asm__ __volatile__( "lock; xchgl %0,(%1)" : "=r" (ret) :"r" (dest), "0" (val) : "memory" );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment