_ _CMP_STORE_LONG Intrinsic

The _ _CMP_STORE_LONG intrinsic has the following declaration:

int __CMP_STORE_LONG(void *, int, int, void *);

This intrinsic function uses the first argument (a longword-aligned pointer) to compare the memory location specified with the contents of the second argument under a memory interlock. If the values differ, the intrinsic returns 0. If the values are the same, an attempt is made to store the value of the third argument into the longword-aligned memory location specified by the fourth argument using a store-conditional instruction. If the store is successful, the intrinsic returns 1; otherwise, it returns 0.

This intrinsic can be used to implement efficient guarded access to a data item (specified by the fourth argument) under control of a state variable (specified by the first argument).

This intrinsic does not contain memory barrier instructions; you are responsible for adding them as required.