InterlockedExchangeAdd function (wdm.h)
The InterlockedExchangeAdd routine adds a value to a given integer as an atomic operation and returns the original value of the given integer.
LONG InterlockedExchangeAdd(
[in, out] LONG volatile *Addend,
[in] LONG Value
);
[in, out] Addend
A pointer to an integer variable.
[in] Value
Specifies the value to be added to Addend.
InterlockedExchangeAdd returns the original value of the Addend variable when the call occurred.
InterlockedExchangeAdd should be used instead of ExInterlockedAddUlong because it is both faster and more efficient.
InterlockedExchangeAdd is implemented inline by the compiler when appropriate and possible. It does not require a spin lock and can therefore be safely used on pageable data.
InterlockedExchangeAdd is atomic only with respect to other InterlockedXxx calls.
Interlocked operations cannot be used on non-cached memory.
Requirement | Value |
---|---|
Minimum supported client | Available starting with Windows 2000. |
Target Platform | Universal |
Header | wdm.h (include Wdm.h, Ntddk.h, Ntifs.h, Miniport.h) |
Library | OneCoreUAP.lib on Windows 10 |
IRQL | Any level |