NAME
atomic_cas_uint,
atomic_cas_ulong,
atomic_cas_ptr —
atomic compare-and-swap
operations
SYNOPSIS
#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);
DESCRIPTION
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.
CONTEXT
atomic_cas_uint(),
atomic_cas_ulong(), and
atomic_cas_ptr() can all be called during autoconf,
from process context, or from interrupt context.
RETURN VALUES
These functions return the value at p as it was before the attempt to swap it.
SEE ALSO
HISTORY
The atomic_cas functions first appeared in NetBSD 5.0 and OpenBSD 5.5.