Partager via


_InterlockedExchange Intrinsic Functions 

Microsoft Specific

Provide compiler intrinsic support for the Win32 Platform SDK InterlockedExchange function.

long _InterlockedExchange(
   long * Target,
   long Value
);
long _InterlockedExchange_acq(
   long * Target,
   long Value
);
__int64 _InterlockedExchange64(
   __int64 * Target,
   __int64 Value
);
__int64 _InterlockedExchange64_acq(
   __int64 * Target,
   __int64 Value
);

Parameters

  • [in, out] Target
    Pointer to the value to be exchanged. The function sets this variable to Value and returns its prior value.
  • [in] Value
    Value to be exchanged with the value pointed to by Target.

Return Value

Returns the initial value pointed to by Target.

Requirements

Intrinsic Architecture

_InterlockedExchange

x86, IPF, x64

_InterlockedExchange_acq

IPF

_InterlockedExchange64

IPF, x64

_InterlockedExchange64_acq

IPF

Header file <intrin.h>

Remarks

There are several variations on _InterlockedExchange that vary based on the data types they involve and whether processor-specific acquire or release semantics is used.

While the _InterlockedExchange function operates on 32-bit integer values, _InterlockedExchange64 operates on 64-bit integer values.

The _InterlockedExchange_acq and _InterlockedExchange64_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.

Example

For a sample of how to use _InterlockedExchange, see _InterlockedDecrement.

END Microsoft Specific

See Also

Reference

Compiler Intrinsics
C++ Keywords