_interlockedbittestandset, _interlockedbittestandset64

Microsoft Specific

Generate the lock bts instruction, which examines bit b of the address a and returns its current value before setting it to 1.

unsigned char _interlockedbittestandset(
   long *a,
   long b
);
unsigned char _interlockedbittestandset64(
   __int64 *a,
   __int64 b
);

Parameters

  • [in] a
    A pointer to the memory to examine.

  • [in] b
    The bit position to test.

Return Value

The bit at the position specified before it is set.

Requirements

Intrinsic

Architecture

_interlockedbittestandset

x86, x64

_interlockedbittestandset64

x64

Header file <intrin.h>

Remarks

As a result of the lock bts instruction, the bit is set to 1. The operation is atomic.

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

This routine is only available as an intrinsic.

See Also

Reference

Compiler Intrinsics

Conflicts with the x86 Compiler

Change History

Date

History

Reason

March 2011

Clarified the return value.

Information enhancement.