Freigeben über


_InterlockedXor, _InterlockedXor64

Microsoft Specific

Used to perform an atomic operation (in this case, the exclusive or XOR operation) on a variable shared by multiple threads.

long _InterlockedXor(
   long volatile * Value,
   long Mask
);
long _InterlockedXor_acq(
   long volatile * Value,
   long Mask
);
long _InterlockedXor_rel(
   long volatile * Value,
   long Mask
);
char _InterlockedXor8(
   char volatile * Value,
   char Mask
);
char _InterlockedXor8_acq(
   char volatile * Value,
   char Mask
);
char _InterlockedXor8_rel(
   char volatile * Value,
   char Mask
);
short _InterlockedXor16(
   short volatile * Value,
   short Mask
);
short _InterlockedXor16_acq(
   short volatile * Value,
   short Mask
);
short _InterlockedXor16_rel(
   short volatile * Value,
   short Mask
);
__int64 _InterlockedXor64(
   __int64 volatile * Value,
   __int64 Mask
);
__int64 _InterlockedXor64_acq(
   __int64 volatile * Value,
   __int64 Mask
);
__int64 _InterlockedXor64_rel(
   __int64 volatile * Value,
   __int64 Mask
);

Parameters

  • [in, out] Value
    A pointer to the first operand, to be replaced by the result.

  • [in] Mask
    The second operand.

Return Value

The original value of the first operand.

Requirements

Intrinsic

Architecture

_InterlockedXor

x86, IPF, x64

_InterlockedXor_acq

IPF

_InterlockedXor_rel

IPF

_InterlockedXor8

x86, IPF, x64

_InterlockedXor8_acq

IPF

_InterlockedXor8_rel

IPF

_InterlockedXor16

x86, IPF, x64

_InterlockedXor16_acq

IPF

_InterlockedXor16_rel

IPF

_InterlockedXor64

IPF, x64

_InterlockedXor64_acq

IPF

_InterlockedXor64_rel

IPF

Header file <intrin.h>

Remarks

The number in the name of each function specifies the bit size of the arguments.

These functions behave as read-write memory barriers. For more information, see _ReadWriteBarrier.

The IPF-specific _InterlockedXor_acq, _InterlockedXor8_acq, _InterlockedXor16_acq, and _InterlockedXor64_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 _InterlockedXor_rel, _InterlockedXor8_rel, _InterlockedXor16_rel, and _InterlockedXor64_rel intrinsic functions 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.

Example

// _InterLockedXor.cpp
#include <stdio.h>
#include <intrin.h>

#pragma intrinsic(_InterlockedXor)

int main()
{
        long data1 = 0xFF00FF00;
        long data2 = 0x00FFFF00;
        long retval;
        retval = _InterlockedXor(&data1, data2);
        printf_s("0x%x 0x%x 0x%x", data1, data2, retval); 
}
0xffff0000 0xffff00 0xff00ff00

See Also

Reference

Compiler Intrinsics

Conflicts with the x86 Compiler