The synchronization primitive intrinsics provide a variety of operations. Besides performing these operations, each intrinsic has two key properties:
the function performed is guaranteed to be atomic
associated with each intrinsic are certain memory barrier properties that restrict the movement of memory references to visible data across the intrinsic operation by either the compiler or the processor
For the following intrinsics, <type> is either a 32-bit or 64-bit integer.
<type> __sync_fetch_and_add(<type> *ptr,<type> val)
<type> __sync_fetch_and_and(<type> *ptr,<type> val)
<type> __sync_fetch_and_nand(<type> *ptr,<type> val)
<type> __sync_fetch_and_or(<type> *ptr,<type> val)
<type> __sync_fetch_and_sub(<type> *ptr,<type> val)
<type> __sync_fetch_and_xor(<type> *ptr,<type> val)
<type> __sync_add_and_fetch(<type> *ptr,<type> val)
<type> __sync_sub_and_fetch(<type> *ptr,<type> val)
<type> __sync_or_and_fetch(<type> *ptr,<type> val)
<type> __sync_and_and_fetch(<type> *ptr,<type> val)
<type> __sync_nand_and_fetch(<type> *ptr,<type> val)
<type> __sync_xor_and_fetch(<type> *ptr,<type> val)
<type> __sync_val_compare_and_swap(<type> *ptr, <type> old_val, <type> new_val)
int __sync_bool_compare_and_swap(<type> *ptr, <type> old_val, <type> new_val)
void __sync_synchronize (void);
<type> __sync_lock_test_and_set(<type> *ptr,<type> val)
void __sync_lock_release(<type> *ptr)