__sync_fetch_and_add

Purpose

This function atomically adds the value of __v to the variable that __p points to. The result is stored in the address that is specified by __p.

A full memory barrier is created when this function is invoked.

Prototype

T __sync_fetch_and_add (T* __p, U __v, ...);

Parameters

__p
The pointer of a variable to which __v is to be added. The value of this variable is to be changed to the result of the add operation.
__v
The variable whose value is to be added to the variable that __p points to.

Return value

The function returns the initial value of the variable that __p points to.



Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us