diff --git a/reactos/include/psdk/intrin_x86.h b/reactos/include/psdk/intrin_x86.h index b528735cb75..3873ad4ed2f 100644 --- a/reactos/include/psdk/intrin_x86.h +++ b/reactos/include/psdk/intrin_x86.h @@ -104,11 +104,6 @@ static __inline__ __attribute__((always_inline)) long _InterlockedCompareExchang return __sync_val_compare_and_swap(Destination, Comperand, Exchange); } -static __inline__ __attribute__((always_inline)) long long _InterlockedCompareExchange64(volatile long long * const Destination, const long long Exchange, const long long Comperand) -{ - return __sync_val_compare_and_swap(Destination, Comperand, Exchange); -} - static __inline__ __attribute__((always_inline)) void * _InterlockedCompareExchangePointer(void * volatile * const Destination, void * const Exchange, void * const Comperand) { return __sync_val_compare_and_swap(Destination, Comperand, Exchange); @@ -236,23 +231,6 @@ static __inline__ __attribute__((always_inline)) long _InterlockedCompareExchang return retval; } -static __inline__ __attribute__((always_inline)) long long _InterlockedCompareExchange64(volatile long long * const Destination, const long long Exchange, const long long Comperand) -{ - long long retval = Comperand; - - __asm__ - ( - "cmpxchg8b %[Destination]" : - [retval] "+A" (retval) : - [Destination] "m" (*Destination), - "b" ((unsigned long)((Exchange >> 0) & 0xFFFFFFFF)), - "c" ((unsigned long)((Exchange >> 32) & 0xFFFFFFFF)) : - "memory" - ); - - return retval; -} - static __inline__ __attribute__((always_inline)) void * _InterlockedCompareExchangePointer(void * volatile * const Destination, void * const Exchange, void * const Comperand) { void * retval = (void *)Comperand; @@ -443,6 +421,34 @@ static __inline__ __attribute__((always_inline)) long _InterlockedXor(volatile l #endif +#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100 && defined(__x86_64__) + +static __inline__ __attribute__((always_inline)) long long _InterlockedCompareExchange64(volatile long long * const Destination, const long long Exchange, const long long Comperand) +{ + return __sync_val_compare_and_swap(Destination, Comperand, Exchange); +} + +#else + +static __inline__ __attribute__((always_inline)) long long _InterlockedCompareExchange64(volatile long long * const Destination, const long long Exchange, const long long Comperand) +{ + long long retval = Comperand; + + __asm__ + ( + "lock; cmpxchg8b %[Destination]" : + [retval] "+A" (retval) : + [Destination] "m" (*Destination), + "b" ((unsigned long)((Exchange >> 0) & 0xFFFFFFFF)), + "c" ((unsigned long)((Exchange >> 32) & 0xFFFFFFFF)) : + "memory" + ); + + return retval; +} + +#endif + static __inline__ __attribute__((always_inline)) long _InterlockedAddLargeStatistic(volatile long long * const Addend, const long Value) { __asm__