__sync_sub_and_fetch

Purpose

This function atomically subtracts the value of __v from 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_sub_and_fetch (T* __p, U __v, ...);

Parameters

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

Return value

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