mirror of
https://github.com/reactos/reactos.git
synced 2024-08-04 10:30:59 +00:00
- Patch by hackbunny:
"64-bit __sync_val_compare_and_swap is, apparently, not inlined on x86. Go figure." "Add "lock" prefix to cmpxchg8b, just in case" svn path=/trunk/; revision=36126
This commit is contained in:
parent
4c462c3876
commit
b08929de56
|
@ -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__
|
||||
|
|
Loading…
Reference in a new issue