__fetch_and_and, __fetch_and_andlp

Purpose

Clears bits in the word or doubleword specified byaddr by AND-ing that value with the value specified by val, in a single atomic operation, and returns the original value of addr.

Prototype

unsigned int __fetch_and_and (volatile unsigned int* addr, unsigned int val);

unsigned long __fetch_and_andlp (volatile unsigned long* addr, unsigned long val);

Parameters

addr
The address of the variable to be ANDed. Must be aligned on a 4-byte boundary for a single word and on an 8-byte boundary for a doubleword.
value
The value by which the value in addr is to be ANDed.

Usage

This operation is useful when a variable containing bit flags is shared between several threads or processes.

__fetch_and_andlp is valid only in 64-bit mode.