xref: /openbsd-src/share/man/man9/atomic_swap_uint.9 (revision b6a8cdec0644848be2c33a0b98958bac4cee0f95)
1*b6a8cdecSdlg.\" $OpenBSD: atomic_swap_uint.9,v 1.6 2014/07/18 10:40:14 dlg Exp $
21c7e942eSdlg.\"
31c7e942eSdlg.\" Copyright (c) 2014 David Gwynne <dlg@openbsd.org>
41c7e942eSdlg.\" All rights reserved.
51c7e942eSdlg.\"
61c7e942eSdlg.\" Permission to use, copy, modify, and distribute this software for any
71c7e942eSdlg.\" purpose with or without fee is hereby granted, provided that the above
81c7e942eSdlg.\" copyright notice and this permission notice appear in all copies.
91c7e942eSdlg.\"
101c7e942eSdlg.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
111c7e942eSdlg.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
121c7e942eSdlg.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
131c7e942eSdlg.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
141c7e942eSdlg.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
151c7e942eSdlg.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
161c7e942eSdlg.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
171c7e942eSdlg.\"
18*b6a8cdecSdlg.Dd $Mdocdate: July 18 2014 $
193be71636Sdlg.Dt ATOMIC_SWAP_UINT 9
201c7e942eSdlg.Os
211c7e942eSdlg.Sh NAME
221c7e942eSdlg.Nm atomic_swap_uint ,
231c7e942eSdlg.Nm atomic_swap_ulong ,
241c7e942eSdlg.Nm atomic_swap_ptr
251c7e942eSdlg.Nd atomic swap operations
261c7e942eSdlg.Sh SYNOPSIS
271c7e942eSdlg.In sys/atomic.h
281c7e942eSdlg.Ft unsigned int
291c7e942eSdlg.Fn atomic_swap_uint "volatile unsigned int *p" "unsigned int new"
301c7e942eSdlg.Ft unsigned long
311c7e942eSdlg.Fn atomic_swap_ulong "volatile unsigned long *p" "unsigned long new"
321c7e942eSdlg.Ft void *
33*b6a8cdecSdlg.Fn atomic_swap_ptr "volatile void *p" "void *new"
341c7e942eSdlg.Sh DESCRIPTION
351c7e942eSdlgThe atomic_swap set of functions provide an interface for atomically
361c7e942eSdlgperforming swap operations with respect to interrupts and multiple
371c7e942eSdlgprocessors in the system.
381c7e942eSdlg.Pp
391c7e942eSdlgThe value referenced by the pointer
401c7e942eSdlg.Fa p
411c7e942eSdlgis replaced by the value
421c7e942eSdlg.Fa new .
43c468d2a2Sdlg.Sh CONTEXT
44c468d2a2Sdlg.Fn atomic_swap_uint ,
45c468d2a2Sdlg.Fn atomic_swap_ulong ,
46c468d2a2Sdlgand
47c468d2a2Sdlg.Fn atomic_swap_ptr
48c468d2a2Sdlgcan all be called during autoconf, from process context, or from interrupt context.
491c7e942eSdlg.Sh RETURN VALUES
501c7e942eSdlgThese functions return the value at
511c7e942eSdlg.Fa p
521c7e942eSdlgas it was before the swap operation.
531c7e942eSdlg.Sh SEE ALSO
541c7e942eSdlg.Xr atomic_cas_uint 9
551c7e942eSdlg.Sh HISTORY
561c7e942eSdlgThe atomic_swap functions first appeared in
576cd55c5fSdlg.Nx 5.0
586cd55c5fSdlgand
591c7e942eSdlg.Ox 5.5 .
60