1.\" $OpenBSD: atomic_sub_int.9,v 1.6 2014/07/23 08:07:35 guenther 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 23 2014 $ 19.Dt ATOMIC_SUB_INT 9 20.Os 21.Sh NAME 22.Nm atomic_sub_int , 23.Nm atomic_sub_int_nv , 24.Nm atomic_sub_long , 25.Nm atomic_sub_long_nv 26.Nd atomic subtraction operations 27.Sh SYNOPSIS 28.In sys/atomic.h 29.Ft void 30.Fn atomic_sub_int "volatile unsigned int *p" "unsigned int v" 31.Ft unsigned int 32.Fn atomic_sub_int_nv "volatile unsigned int *p" "unsigned int v" 33.Ft void 34.Fn atomic_sub_long "volatile unsigned long *p" "unsigned long v" 35.Ft unsigned long 36.Fn atomic_sub_long_nv "volatile unsigned long *p" "unsigned long v" 37.Sh DESCRIPTION 38The atomic_sub set of functions provide an interface for atomically 39performing sub and sub-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 decremented by the value 45.Fa v . 46.Sh CONTEXT 47.Fn atomic_sub_int , 48.Fn atomic_sub_int_nv , 49.Fn atomic_sub_long , 50and 51.Fn atomic_sub_long_nv 52can all be called during autoconf, from process context, or from interrupt context. 53.Sh RETURN VALUES 54.Nm atomic_sub_int 55and 56.Nm atomic_sub_long 57perform the subtraction without returning any knowledge of the value at 58.Fa p . 59.Pp 60.Nm atomic_sub_int_nv 61and 62.Nm atomic_sub_long_nv 63return the value at 64.Fa p 65after the subtraction was performed. 66.Sh SEE ALSO 67.Xr atomic_add_int 9 , 68.Xr atomic_dec_int 9 69.Sh HISTORY 70The atomic_sub functions first appeared in 71.Ox 5.5 . 72