mirror of
https://github.com/corda/corda.git
synced 2025-01-07 13:38:47 +00:00
support atomicCompareAndSwap on powerpc for GCC versions prior to 4.1
This commit is contained in:
parent
f75868b394
commit
2276eece0e
@ -91,16 +91,33 @@ syncInstructionCache(const void* start, unsigned size)
|
||||
}
|
||||
|
||||
#ifdef USE_ATOMIC_OPERATIONS
|
||||
# if (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 1)
|
||||
inline bool
|
||||
atomicCompareAndSwap(uintptr_t* p, uintptr_t old, uintptr_t new_)
|
||||
{
|
||||
#if (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 1)
|
||||
return __sync_bool_compare_and_swap(p, old, new_);
|
||||
#else // not GCC >= 4.1
|
||||
bool result;
|
||||
|
||||
__asm__ __volatile__(" sync\n"
|
||||
"1:\n"
|
||||
" lwarx %0,0,%2\n"
|
||||
" cmpw %0,%3\n"
|
||||
" bne- 2f\n"
|
||||
" stwcx. %4,0,%2\n"
|
||||
" bne- 1b\n"
|
||||
" isync \n"
|
||||
"2:\n"
|
||||
" xor %0,%0,%3\n"
|
||||
" cntlzw %0,%0\n"
|
||||
" srwi %0,%0,5\n"
|
||||
: "=&r"(result), "+m"(*p)
|
||||
: "r"(p), "r"(old), "r"(new_)
|
||||
: "cc", "memory");
|
||||
|
||||
return result;
|
||||
#endif // not GCC >= 4.1
|
||||
}
|
||||
# else // not GCC >= 4.1
|
||||
// todo: implement using inline assembly
|
||||
# undef USE_ATOMIC_OPERATIONS
|
||||
# endif // not GCC >= 4.1
|
||||
#endif // USE_ATOMIC_OPERATIONS
|
||||
|
||||
inline uint64_t
|
||||
|
Loading…
Reference in New Issue
Block a user