---
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 atomic and cannot be reordered. It also implies a memory barrier.

## COPYRIGHT
