__sync_bool_compare_and_swap
Note: When you invoke the Clang-based front end of IBM® XL C/C++ for AIX® 16.1 using the xlclang or xlclang++ invocation command, GCC
compare and swap built-in functions are not supported. Use the C++11 atomics features
instead.
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
.