Important: The information in this document is obsolete and should not be used for new development.
OTCompareAndSwap8
Atomically compares two 8-bit values and changes one of these values if they are the same.C INTERFACE
Boolean OTCompareAndSwap8( UInt32 oldVal, UInt32 newVal, UInt8* where)C++ INTERFACE
None. C++ applications use the C interface to this function.PARAMETERS
oldVal
- The 8-bit value being compared to the value referenced by the
where
parameter.newVal
- The value to be assigned to the 8-bit value referenced by the
where
parameter.where
- A reference to the 8-bit value being compared to that specified by the
oldVal
parameter.- function result
- Returns
true
if the swap is done.DISCUSSION
This function compares the least significant 8 bits ofoldVal
with the value referenced by thewhere
parameter. If the two values are the same, the function replaces the 8-bit value referenced by thewhere
parameter with the value specified by thenewVal
parameter and it returnstrue
. If the two values are not the same, no swap occurs and the function returnsfalse
.The entire compare and swap operation is atomic.
Use the
OTCompareAndSwap32
function to compare two 32-bit values and set one if they are the same.Use the
OTCompareAndSwap16
function to compare two 16-bit values and set one if they are the same.