### __btr -- Test and Reset a Bit

Format

>     #include <builtin.h>

>     unsigned int __btr(unsigned int *pBits, unsigned int bit)

Language Level: None
__ 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 only atomic on uni-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 (__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;
    }

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