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 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.
February 6, 2019 | OpenBSD-current |