1.\" $OpenBSD: atomic_swap_uint.9,v 1.6 2014/07/18 10:40:14 dlg Exp $ 2.\" 3.\" Copyright (c) 2014 David Gwynne <dlg@openbsd.org> 4.\" All rights reserved. 5.\" 6.\" Permission to use, copy, modify, and distribute this software for any 7.\" purpose with or without fee is hereby granted, provided that the above 8.\" copyright notice and this permission notice appear in all copies. 9.\" 10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17.\" 18.Dd $Mdocdate: July 18 2014 $ 19.Dt ATOMIC_SWAP_UINT 9 20.Os 21.Sh NAME 22.Nm atomic_swap_uint , 23.Nm atomic_swap_ulong , 24.Nm atomic_swap_ptr 25.Nd atomic swap operations 26.Sh SYNOPSIS 27.In sys/atomic.h 28.Ft unsigned int 29.Fn atomic_swap_uint "volatile unsigned int *p" "unsigned int new" 30.Ft unsigned long 31.Fn atomic_swap_ulong "volatile unsigned long *p" "unsigned long new" 32.Ft void * 33.Fn atomic_swap_ptr "volatile void *p" "void *new" 34.Sh DESCRIPTION 35The atomic_swap set of functions provide an interface for atomically 36performing swap operations with respect to interrupts and multiple 37processors in the system. 38.Pp 39The value referenced by the pointer 40.Fa p 41is replaced by the value 42.Fa new . 43.Sh CONTEXT 44.Fn atomic_swap_uint , 45.Fn atomic_swap_ulong , 46and 47.Fn atomic_swap_ptr 48can all be called during autoconf, from process context, or from interrupt context. 49.Sh RETURN VALUES 50These functions return the value at 51.Fa p 52as it was before the swap operation. 53.Sh SEE ALSO 54.Xr atomic_cas_uint 9 55.Sh HISTORY 56The atomic_swap functions first appeared in 57.Nx 5.0 58and 59.Ox 5.5 . 60