Store Doubleword Conditional Indexed, Store Word Conditional Indexed
Stores the value specified by val into the memory location specified by addr.
int __stdcx(volatile long* addr, long val);
int __stwcx(volatile int* addr, int val);
Returns 1 if the update of addr is successful and 0 if it is unsuccessful.
This function can be used with a preceding __ldarx (or __lwarx) built-in function to implement a read-modify-write on a specified memory location. The two built-in functions work together to ensure that if the store is successfully performed, no other processor or mechanism can modify the target doubleword between the time the __ldarx function is executed and the time the __stdcx function completes. This has the same effect as inserting __fence built-in functions before and after the __stdcx built-in function and can inhibit compiler optimization of surrounding code.
__stdcx is valid only in 64-bit mode.