__sync_bool_compare_and_swap
Purpose
This function compares the value of __compVal with the value of the variable that __p points to. If they are equal, the value of __exchVal is stored in the address that is specified by __p; otherwise, no operation is performed.
A full memory barrier is created when this function is invoked.
Prototype
bool __sync_bool_compare_and_swap (T* __p, U __compVal, V __exchVal, ...);
Parameters
- __p
- The pointer to a variable whose value is to be compared with.
- __compVal
- The value to be compared with the value of the variable that __p points to.
- __exchVal
- The value to be stored in the address that __p points to.
Return value
If the value of __compVal and the value of the variable that __p points to are equal, the function returns true; otherwise, it returns false.


