共用方式為


_InterlockedIncrement Intrinsic Functions 

Microsoft Specific

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

long _InterlockedIncrement(
   long * lpAddend
);
long _InterlockedIncrement_acq(
   long * lpAddend
);
long _InterlockedIncrement_rel(
   long * lpAddend
);
short _InterlockedIncrement16(
   short * lpAddend
);
short _InterlockedIncrement16_acq(
   short * lpAddend
);
short _InterlockedIncrement16_rel(
   short * lpAddend
);
__int64 _InterlockedIncrement64(
   __int64 * lpAddend
);
__int64 _InterlockedIncrement64_acq(
   __int64 * lpAddend
);
__int64 _InterlockedIncrement64_rel(
   __int64 * lpAddend
);

Parameters

  • [in, out] lpAddend
    Pointer to the variable to be incremented.

Return Value

Windows 98, Windows NT 4.0 and later: The return value is the resulting incremented value.

Windows 95, Windows NT 3.51 and earlier: If the result of the operation is zero, the return value is zero. If the result of the operation is less than zero, the return value is negative, but it is not necessarily equal to the result. If the result of the operation is greater than zero, the return value is positive, but it is not necessarily equal to the result.

Requirements

Intrinsic Architecture

_InterlockedIncrement

x86, IPF, x64

_InterlockedIncrement_acq

IPF

_InterlockedIncrement_rel

IPF

_InterlockedIncrement16

x86, IPF, x64

_InterlockedIncrement16_acq

IPF

_InterlockedIncrement16_rel

IPF

_InterlockedIncrement64

IPF, x64

_InterlockedIncrement64_acq

IPF

_InterlockedIncrement64_rel

IPF

Header file <intrin.h>

Remarks

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

While the _InterlockedIncrement function operates on 32-bit integer values, _InterlockedIncrement16 operates on 16-bit integer values and _InterlockedIncrement64 operates on 64-bit integer values.

The _InterlockedIncrement_acq, _InterlockedIncrement16_acq, and _InterlockedIncrement64_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.

The _InterlockedIncrement_rel, _InterlockedIncrement16_rel, and _InterlockedIncrement64_rel intrinsic function are the same as the corresponding functions without the _rel suffix except that the operation is performed with release semantics, which is useful when leaving a critical section.

The variable pointed to by the lpAddend parameter must be aligned on a 32-bit boundary; otherwise, this function fails on multiprocessor x86 systems and any non-x86 systems.

In Visual C++ 2005, these functions behave as read-write memory barriers. For more information, see _ReadWriteBarrier.

The Win32 function is declared in Wdm.h or Ntddk.h.

These routines are only available as intrinsics.

Example

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

END Microsoft Specific

See Also

Reference

Compiler Intrinsics
C++ Keywords