OSCompareAndSwapAtomicEx64

Syntax

#include <cafe/os.h>

BOOL OSCompareAndSwapAtomicEx64(volatile OSAtomicVar64* ptr, u64 cmp_val,
			        u64 new_val, u64 *orig_val);

Parameters

ptr Pointer to data to compare and swap atomically.
cmp_val Value to compare against memory.
new_val Value to swap into memory.
orig_val Returned original atomic value.

Return Values

TRUE if cmp_val and value contained at address ptr are equal. FALSE if cmp_val and value contained at address ptr are not equal.

Description

OSCompareAndSwapAtomicEx64 performs an atomic swap with a 64-bit value in memory. If cmp_val and the value contained at the address ptr are equal, the value contained at address ptr is changed to new_val. This is useful if the value needs to be atomically manipulated by multiple processors. This version always returns the original atomic value on function entry to variable orig_val.

It does not act as a memory barrier.

CAUTION:
This 64-bit API implementation is much slower than its equivalent 32-bit atomic API version. If 64-bit values are not needed, use the 32-bit atomic API version instead. The 32-bit version is listed in the See Also section of this topic. For more information, see Synchronization and Atomics in the Espresso CPU Performance Guide.

Do Not Call From

None.

See Also

OSAddAtomic64
OSAndAtomic64
OSCompareAndSwapAtomic64
OSCompareAndSwapAtomicEx (32-bit)
OSDecAtomic64
OSGetAtomic64
OSIncAtomic64
OSOrAtomic64
OSSetAtomic64
OSSwapAtomic64
OSTestAndClearAtomic64
OSTestAndSetAtomic64
OSXorAtomic64

Revision History

2014/07/08 Added 64-bit caution.
2013/05/08 Automated cleanup pass.
2010/08/30 Initial version.


CONFIDENTIAL