OSCompareAndSwapAtomic

Syntax

#include <cafe/os.h>

BOOL OSCompareAndSwapAtomic(volatile OSAtomicVar* ptr, u32 cmp_val, u32 new_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.

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

OSCompareAndSwapAtomic performs an atomic swap with a 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.

It does not act as a memory barrier.

Do Not Call From

None.

See Also

OSAddAtomic
OSAndAtomic
OSCompareAndSwapAtomicEx
OSDecAtomic
OSIncAtomic
OSOrAtomic
OSSwapAtomic
OSTestAndClearAtomic
OSTestAndSetAtomic
OSXorAtomic

Revision History

2013/05/08 Automated cleanup pass.
2012/07/25 Cleanup Pass
2010/08/30 Initial version.


CONFIDENTIAL