xref: /openbsd/share/man/man9/atomic_add_int.9 (revision 09467b48)
1.\" $OpenBSD: atomic_add_int.9,v 1.6 2014/02/13 12:05:05 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: February 13 2014 $
19.Dt ATOMIC_ADD_INT 9
20.Os
21.Sh NAME
22.Nm atomic_add_int ,
23.Nm atomic_add_int_nv ,
24.Nm atomic_add_long ,
25.Nm atomic_add_long_nv
26.Nd atomic addition operations
27.Sh SYNOPSIS
28.In sys/atomic.h
29.Ft void
30.Fn atomic_add_int "volatile unsigned int *p" "unsigned int v"
31.Ft unsigned int
32.Fn atomic_add_int_nv "volatile unsigned int *p" "unsigned int v"
33.Ft void
34.Fn atomic_add_long "volatile unsigned long *p" "unsigned long v"
35.Ft unsigned long
36.Fn atomic_add_long_nv "volatile unsigned long *p" "unsigned long v"
37.Sh DESCRIPTION
38The atomic_add set of functions provide an interface for atomically
39performing add and add-and-fetch operations with respect to interrupts
40and multiple processors in the system.
41.Pp
42The value referenced by the pointer
43.Fa p
44is incremented by the value
45.Fa v .
46.Sh CONTEXT
47.Fn atomic_add_int ,
48.Fn atomic_add_int_nv ,
49.Fn atomic_add_long ,
50and
51.Fn atomic_add_long_nv
52can all be called during autoconf, from process context, or from interrupt context.
53.Sh RETURN VALUES
54.Nm atomic_add_int
55and
56.Nm atomic_add_long
57perform the addition without returning any knowledge of the value at
58.Fa p .
59.Pp
60.Nm atomic_add_int_nv
61and
62.Nm atomic_add_long_nv
63return the value at
64.Fa p
65after the addition was performed.
66.Sh SEE ALSO
67.Xr atomic_inc_int 9 ,
68.Xr atomic_sub_int 9
69.Sh HISTORY
70The atomic_add functions first appeared in
71.Nx 5.0
72and
73.Ox 5.5 .
74