__smp_btr -- Bit Test and Reset Atomically

Format

#include <builtin.h>

unsigned int __smp_btr(unsigned int *pBits, unsigned int bit)

Language Level: None
__smp_btr tests and resets a bit within a 4 byte memory operand. The address of the memory operand is pBits and the bit number is bit. Bits are numbered 0 through 31 with 0 being the least significant bit. The test and reset operation is atomic even on multiple-processor machines.

Return Value
The original value of the selected bit is returned as an unsigned integer.

Example
This example tests and resets bit 8 of a 32-bit unsigned integer.

#include <stdio.h>
#include <builtin.h>
unsigned int mem = 0x01010101;
int main(void)
{
   if (__smp_btr(&mem, 8))
   {
      printf("Bit 8 should now be zero.\n");
   }
   printf("mem = %.8x\n", mem);
   /***************************************
      The output should be:
      Bit 8 should now be zero.
      mem = 01010001
   ***************************************/
   return 0;
}


__btr -- Test and Reset a Bit
__bts -- Test and Set a Bit
__smp_bts -- Bit Test and Set Atomically