| ATOMIC_CAS_UINT(9) | Kernel Developer's Manual | ATOMIC_CAS_UINT(9) |
atomic_cas_uint,
atomic_cas_ulong,
atomic_cas_ptr — atomic
compare-and-swap operations
#include
<sys/atomic.h>
unsigned int
atomic_cas_uint(volatile unsigned int
*p, unsigned int expected,
unsigned int new);
unsigned long
atomic_cas_ulong(volatile unsigned
long *p, unsigned long expected,
unsigned long new);
void *
atomic_cas_ptr(volatile void *p,
void *expected, void *new);
The atomic_cas set of functions provide an interface for atomically performing compare-and-swap operations with respect to interrupts and multiple processors in the system.
The value referenced by the pointer p is compared against expected. If these values are equal then new replaces the value stored at p.
atomic_cas_uint(),
atomic_cas_ulong(), and
atomic_cas_ptr() can all be called during autoconf,
from process context, or from interrupt context.
These functions return the value at p as it was before the attempt to swap it.
The atomic_cas functions first appeared in NetBSD 5.0 and OpenBSD 5.5.
| February 6, 2019 | Debian |