_InterlockedExchangeAdd Intrinsic Functions
Microsoft Specific
Provide compiler intrinsic support for the Win32 Windows SDK_InterlockedExchangeAdd Intrinsic Functions function.
long _InterlockedExchangeAdd(
long volatile * Addend,
long Value
);
long _InterlockedExchangeAdd_acq(
long volatile * Addend,
long Value
);
long _InterlockedExchangeAdd_rel(
long volatile * Addend,
long Value
);
__int64 _InterlockedExchangeAdd64(
__int64 volatile * Addend,
__int64 Value
);
__int64 _InterlockedExchangeAdd64_acq(
__int64 volatile * Addend,
__int64 Value
);
__int64 _InterlockedExchangeAdd64_rel(
__int64 volatile * Addend,
__int64 Value
);
Parameters
[in, out] Addend
The value to be added to; replaced by the result of the addition.[in] Value
The value to add.
Return Value
The return value is the initial value of the variable pointed to by the Addend parameter.
Requirements
Intrinsic |
Architecture |
---|---|
_InterlockedExchangeAdd |
x86, IPF, x64 |
_InterlockedExchangeAdd_acq |
IPF |
_InterlockedExchangeAdd_rel |
IPF |
_InterlockedExchangeAdd64 |
IPF, x64 |
_InterlockedExchangeAdd64_acq |
IPF |
_InterlockedExchangeAdd64_rel |
IPF |
Header file <intrin.h>
Remarks
There are several variations on _InterlockedExchangeAdd that vary based on the data types they involve and whether processor-specific acquire or release semantics is used.
While the _InterlockedExchangeAdd function operates on 32-bit integer values, _InterlockedExchangeAdd64 operates on 64-bit integer values.
The _InterlockedExchangeAdd_acq and _InterlockedExchangeAdd64_acq intrinsic functions are the same as the corresponding functions without the _acq suffix except that the operation is performed with acquire semantics, which is useful when entering a critical section.
There is no version of this function that uses release semantics.
In Visual C++ 2005, these functions behave as read-write memory barriers. For more information, see _ReadWriteBarrier.
These routines are only available as intrinsics. Thus, they are intrinsic whether or not /Oi or #pragma intrinsic is used. It is not possible to use #pragma function on these intrinsics.
Example
For a sample of how to use _InterlockedExchangeAdd, see _InterlockedDecrement.