_InterlockedOr, _InterlockedOr64

Microsoft Specific

Perform an atomic operation (in this case, the OR operation) on a variable shared by multiple threads.

long _InterlockedOr(
   long volatile * Value,
   long Mask
);
long _InterlockedOr_acq(
   long volatile * Value,
   long Mask
);
long _InterlockedOr_rel(
   long volatile * Value,
   long Mask
);
char _InterlockedOr8(
   char volatile * Value,
   long Mask
);
char _InterlockedOr8_acq(
   char volatile * Value,
   char Mask
);
char _InterlockedOr8_rel(
   char volatile * Value,
   char Mask
);
short _InterlockedOr16(
   short volatile * Value,
   short Mask
);
short _InterlockedOr16_acq(
   short volatile * Value,
   short Mask
);
short _InterlockedOr16_rel(
   short volatile * Value,
   short Mask
);
__int64 _InterlockedOr64(
   __int64 volatile * Value,
   __int64 Mask
);
__int64 _InterlockedOr64_acq(
   __int64 volatile * Value,
   __int64 Mask
);
__int64 _InterlockedOr64_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 pointed to by the first parameter.

Requirements

Intrinsic

Architecture

_InterlockedOr

x86, IPF, x64

_InterlockedOr_acq

IPF

_InterlockedOr_rel

IPF

_InterlockedOr8

x86, IPF, x64

_InterlockedOr8_acq

IPF

_InterlockedOr8_rel

IPF

_InterlockedOr16

x86, IPF, x64

_InterlockedOr16_acq

IPF

_InterlockedOr16_rel

IPF

_InterlockedOr64

IPF, x64

_InterlockedOr64_acq

IPF

_InterlockedOr64_rel

IPF

Header file <intrin.h>

Remarks

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

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

The IPF-specific _InterlockedOr_acq, _InterlockedOr8_acq, _InterlockedOr16_acq, and _InterlockedOr64_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 _InterlockedOr_rel, _InterlockedOr8_rel, _InterlockedOr16_rel, and _InterlockedOr64_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

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

#pragma intrinsic(_InterlockedOr)

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

0xffffff00 0xffff00 0xff00ff00

See Also

Concepts

Compiler Intrinsics