Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

_InterlockedExchangePointer Intrinsic Functions

Microsoft Specific

Perform an atomic exchange operation, which copies the address passed in as the second argument to the first and returns the original address of the first.

void * _InterlockedExchangePointer(
   void * volatile * Target,
   void * Value
void * _InterlockedExchangePointer_acq(
   void * volatile * Target,
   void * Value

[in, out] Target

Pointer to the pointer to the value to exchange. The function sets the value to Value and returns its previous value.

[in] Value

Value to be exchanged with the value pointed to by Target.

The function returns the initial value pointed to by Target.




IPF, x64



Note   On the x86 architecture, _InterlockedExchangePointer is a macro that calls _InterlockedExchange.

Header file <intrin.h>

On a 64-bit system, the parameters are 64 bits and must be aligned on 64-bit boundaries; otherwise, the function fails. On a 32-bit system, the parameters are 32 bits and must be aligned on 32-bit boundaries.

Use _InterlockedExchangePointer_acq if you need acquire semantics, such as at the beginning of 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.

Community Additions

© 2015 Microsoft