---
name: "__test_and_set_bit"
section: "9"
platform: "linux"
package: "linux-manual-4.9"
version: "4.9.228-1"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/__test_and_set_bit"
---

# \_\_test\_and\_set\_bit(9)

Set a bit and return its old value

## NAME

\_\_test\_and\_set\_bit - Set a bit and return its old value

## SYNOPSIS

**bool \_\_test\_and\_set\_bit(long** *nr***, volatile unsigned long \*** *addr***);**

## ARGUMENTS

*nr*

Bit to set

*addr*

Address to count from

## DESCRIPTION

This operation is non-atomic and can be reordered. If two examples of this operation race, one can appear to succeed but actually fail. You must protect multiple accesses with a lock.

## COPYRIGHT
