_interlockedbittestandset, _interlockedbittestandset64
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

_interlockedbittestandset, _interlockedbittestandset64

Updated: March 2011

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

[in] a

A pointer to the memory to examine.

[in] b

The bit position to test.

The bit at the position specified before it is set.




x86, x64



Header file <intrin.h>

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

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

This routine is only available as an intrinsic.




March 2011

Clarified the return value.

Information enhancement.

© 2015 Microsoft