diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2014-01-30 00:44:21 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2014-01-30 00:44:21 +0000 |
commit | b0f3f95a88480b3247a472e8a44069649ae41388 (patch) | |
tree | 28716ec0b034764da5fb3b63a9eefebda6d348b3 /share/man/man9 | |
parent | 33b6901eeca8912b5b807204e38f2dedeb23b8da (diff) |
add an MI api for atomic ops in the kernel. this api has its origins in
solaris, but we found it via netbsd.
this provides an MI implementation by using gccs atomic builtins. if an
arch wants to provide a better implementation it can simply provide the
specific bit of the api it wants to replace as a macro.
we're being conservative with this API and only providing it in the
kernel, and only for uints, ulongs, and pointers.
discussed at n2k14 and with hackers at length.
ok kettenis@
Diffstat (limited to 'share/man/man9')
-rw-r--r-- | share/man/man9/Makefile | 26 | ||||
-rw-r--r-- | share/man/man9/atomic.9 | 30 | ||||
-rw-r--r-- | share/man/man9/atomic_add.9 | 69 | ||||
-rw-r--r-- | share/man/man9/atomic_cas.9 | 61 | ||||
-rw-r--r-- | share/man/man9/atomic_dec.9 | 68 | ||||
-rw-r--r-- | share/man/man9/atomic_inc.9 | 68 | ||||
-rw-r--r-- | share/man/man9/atomic_sub.9 | 69 | ||||
-rw-r--r-- | share/man/man9/atomic_swap.9 | 56 | ||||
-rw-r--r-- | share/man/man9/membar.9 | 93 |
9 files changed, 532 insertions, 8 deletions
diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index 3096174874b..459f5c83f29 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -1,11 +1,12 @@ -# $OpenBSD: Makefile,v 1.195 2014/01/22 00:09:02 tedu Exp $ +# $OpenBSD: Makefile,v 1.196 2014/01/30 00:44:20 dlg Exp $ # $NetBSD: Makefile,v 1.4 1996/01/09 03:23:01 thorpej Exp $ # Makefile for section 9 (kernel function and variable) manual pages. -MAN= altq.9 aml_evalnode.9 atomic.9 audio.9 autoconf.9 bio_register.9 \ - boot.9 \ - buffercache.9 bus_dma.9 bus_space.9 copy.9 crypto.9 delay.9 \ +MAN= altq.9 aml_evalnode.9 atomic.9 atomic_add.9 atomic_cas.9 atomic_dec.9 \ + atomic_inc.9 atomic_sub.9 atomic_swap.9 audio.9 autoconf.9 \ + bio_register.9 boot.9 buffercache.9 bus_dma.9 bus_space.9 \ + copy.9 crypto.9 delay.9 \ disk.9 disklabel.9 dma_alloc.9 dohooks.9 dopowerhooks.9 \ domountroothooks.9 doshutdownhooks.9 dostartuphooks.9 \ evcount.9 extent.9 fb_setup.9 file.9 fork1.9 \ @@ -17,7 +18,7 @@ MAN= altq.9 aml_evalnode.9 atomic.9 audio.9 autoconf.9 bio_register.9 \ iic.9 intro.9 inittodr.9 \ kern.9 km_alloc.9 knote.9 kthread.9 ktrace.9 \ loadfirmware.9 lock.9 log.9 \ - malloc.9 mbuf.9 mbuf_tags.9 md5.9 mi_switch.9 microtime.9 \ + malloc.9 membar.9 mbuf.9 mbuf_tags.9 md5.9 mi_switch.9 microtime.9 \ mountroothook_establish.9 mutex.9 namei.9 \ panic.9 pci_conf_read.9 pci_intr_map.9 pfind.9 physio.9 pmap.9 \ pool.9 powerhook_establish.9 ppsratecheck.9 printf.9 psignal.9 \ @@ -36,6 +37,18 @@ MAN= altq.9 aml_evalnode.9 atomic.9 audio.9 autoconf.9 bio_register.9 \ MLINKS+=aml_evalnode.9 aml_evalname.9 aml_evalnode.9 aml_find_node.9 \ aml_evalnode.9 aml_freevalue.9 aml_evalnode.9 aml_val2int.9 MLINKS+=atomic.9 atomic_setbits_int.9 atomic.9 atomic_clearbits_int.9 +MLINKS+=atomic_add.9 atomic_add_int.9 atomic_add.9 atomic_add_long.9 \ + atomic_add.9 atomic_add_int_nv.9 atomic_add.9 atomic_add_long_nv.9 +MLINKS+=atomic_cas.9 atomic_cas_uint.9 atomic_cas.9 atomic_cas_ulong.9 \ + atomic_cas.9 atomic_cas_ptr.9 +MLINKS+=atomic_dec.9 atomic_dec_int.9 atomic_dec.9 atomic_dec_long.9 \ + atomic_dec.9 atomic_dec_int_nv.9 atomic_dec.9 atomic_dec_long_nv.9 +MLINKS+=atomic_inc.9 atomic_inc_int.9 atomic_inc.9 atomic_inc_long.9 \ + atomic_inc.9 atomic_inc_int_nv.9 atomic_inc.9 atomic_inc_long_nv.9 +MLINKS+=atomic_sub.9 atomic_sub_int.9 atomic_sub.9 atomic_sub_long.9 \ + atomic_sub.9 atomic_sub_int_nv.9 atomic_sub.9 atomic_sub_long_nv.9 \ +MLINKS+=atomic_swap.9 atomic_swap_uint.9 atomic_swap.9 atomic_swap_ulong.9 \ + atomic_swap.9 atomic_swap_ptr.9 MLINKS+=autoconf.9 config_init.9 autoconf.9 config_search.9 \ autoconf.9 config_rootsearch.9 autoconf.9 config_found_sm.9 \ autoconf.9 config_found.9 autoconf.9 config_rootfound.9 \ @@ -211,6 +224,9 @@ MLINKS+=lock.9 lockinit.9 lock.9 lockmgr.9 lock.9 lockstatus.9 \ lock.9 simple_lock_try.9 lock.9 simple_unlock.9 MLINKS+=log.9 addlog.9 MLINKS+=malloc.9 free.9 +MLINKS+=membar.9 membar_enter.9 membar.9 membar_exit.9 \ + membar.9 membar_producer.9 membar.9 membar_consumer.9 \ + membar.9 membar_sync.9 MLINKS+=mbuf.9 m_copym2.9 mbuf.9 m_copym.9 mbuf.9 m_free.9 mbuf.9 MFREE.9 \ mbuf.9 m_get.9 mbuf.9 MGET.9 mbuf.9 m_getclr.9 mbuf.9 m_gethdr.9 \ mbuf.9 MGETHDR.9 mbuf.9 m_prepend.9 mbuf.9 M_PREPEND.9 \ diff --git a/share/man/man9/atomic.9 b/share/man/man9/atomic.9 index 75755deef28..33e967e4171 100644 --- a/share/man/man9/atomic.9 +++ b/share/man/man9/atomic.9 @@ -1,4 +1,4 @@ -.\" $OpenBSD: atomic.9,v 1.5 2013/06/04 19:27:03 schwarze Exp $ +.\" $OpenBSD: atomic.9,v 1.6 2014/01/30 00:44:20 dlg Exp $ .\" .\" Copyright (c) 2007 Artur Grabowski <art@openbsd.org> .\" All rights reserved. @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: June 4 2013 $ +.Dd $Mdocdate: January 30 2014 $ .Dt ATOMIC 9 .Os .Sh NAME @@ -24,7 +24,7 @@ .Nm atomic_clearbits_int .Nd interface to perform atomic operations on data .Sh SYNOPSIS -.In machine/atomic.h +.In sys/atomic.h .Ft void .Fn atomic_setbits_int "unsigned int *p" "unsigned int b" .Ft void @@ -35,6 +35,23 @@ The set of functions provide an interface for changing data atomically with respect to interrupts and multiple processors in the system. .Pp +There are several sets of atomic memory operations available: +.Pp +.Bl -tag -width "atomic_swap(9)" -offset indent +.It Xr atomic_add 9 +These functions perform atomic addition operations. +.It Xr atomic_cas 9 +These functions perform atomic compare-and-swap operations. +.It Xr atomic_dec 9 +These functions perform atomic decrement operations. +.It Xr atomic_inc 9 +These functions perform atomic increment operations. +.It Xr atomic_sub 9 +These functions perform atomic subtraction operations. +.It Xr atomic_swap 9 +These functions perform atomic swap operations. +.El +.Pp The .Fn atomic_setbits_int function sets the bits in @@ -56,6 +73,13 @@ It is equivalent to .Bd -literal -offset indent *p &= ~b; .Ed +.Sh SEE ALSO +.Xr atomic_add 9 , +.Xr atomic_cas 9 , +.Xr atomic_dec 9 , +.Xr atomic_inc 9 , +.Xr atomic_sub 9 , +.Xr atomic_swap 9 .Sh HISTORY The .Nm diff --git a/share/man/man9/atomic_add.9 b/share/man/man9/atomic_add.9 new file mode 100644 index 00000000000..6256811d970 --- /dev/null +++ b/share/man/man9/atomic_add.9 @@ -0,0 +1,69 @@ +.\" $OpenBSD: atomic_add.9,v 1.1 2014/01/30 00:44:20 dlg Exp $ +.\" +.\" Copyright (c) 2014 David Gwynne <dlg@openbsd.org> +.\" All rights reserved. +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: January 30 2014 $ +.Dt ATOMIC_ADD 9 +.Os +.Sh NAME +.Nm atomic_add_int , +.Nm atomic_add_int_nv , +.Nm atomic_add_long , +.Nm atomic_add_long_nv +.Nd atomic addition operations +.Sh SYNOPSIS +.In sys/atomic.h +.Ft void +.Fn atomic_add_int "volatile unsigned int *p" "unsigned int v" +.Ft unsigned int +.Fn atomic_add_int_nv "volatile unsigned int *p" "unsigned int v" +.Ft void +.Fn atomic_add_long "volatile unsigned long *p" "unsigned long v" +.Ft unsigned long +.Fn atomic_add_long_nv "volatile unsigned long *p" "unsigned long v" +.Sh DESCRIPTION +The +.Nm atomic_add +set of functions provide an interface for atomically performing add +and add-and-fetch operations with respect to interrupts and multiple +processors in the system. +.Pp +The value referenced by the pointer +.Fa p +is incremented by the value +.Fa v . +.Sh RETURN VALUES +.Nm atomic_add_int +and +.Nm atomic_add_long +perform the addition without returning any knowledge of the value at the +.Fa p . +.Pp +.Nm atomic_add_int_nv +and +.Nm atomic_add_long_nv +return the value at +.Fa p +after the addition was performed. +.Sh SEE ALSO +.Xr atomic 9 , +.Xr atomic_inc 9 , +.Xr atomic_sub 9 +.Sh HISTORY +The +.Nm atomic_add +functions first appeared in +.Ox 5.5 . diff --git a/share/man/man9/atomic_cas.9 b/share/man/man9/atomic_cas.9 new file mode 100644 index 00000000000..8d1df477f68 --- /dev/null +++ b/share/man/man9/atomic_cas.9 @@ -0,0 +1,61 @@ +.\" $OpenBSD: atomic_cas.9,v 1.1 2014/01/30 00:44:20 dlg Exp $ +.\" +.\" Copyright (c) 2014 David Gwynne <dlg@openbsd.org> +.\" All rights reserved. +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: January 30 2014 $ +.Dt ATOMIC_CAS 9 +.Os +.Sh NAME +.Nm atomic_cas_uint , +.Nm atomic_cas_ulong , +.Nm atomic_cas_ptr +.Nd atomic compare-and-swap operations +.Sh SYNOPSIS +.In sys/atomic.h +.Ft unsigned int +.Fn atomic_cas_uint "volatile unsigned int *p" "unsigned int expected" "unsigned int new" +.Ft unsigned long +.Fn atomic_cas_ulong "volatile unsigned long *p" "unsigned long expected" "unsigned long new" +.Ft void * +.Fn atomic_cas_ptr "volatile void **p" "void *expected" "void *new" +.Sh DESCRIPTION +The +.Nm atomic_cas +set of functions provide an interface for atomically performing +compare-and-swap operations with respect to interrupts and multiple +processors in the system. +.Pp +The value referenced by the pointer +.Fa p +is compared against +.Fa expected . +If the these values are equal then +.Fa new +replaces the value stored at +.Fa p . +.Ed +.Sh RETURN VALUES +These functions return the value at +.Fa p +as it was before the attempt to swap it. +.Sh SEE ALSO +.Xr atomic 9 , +.Xr atomic_swap 9 +.Sh HISTORY +The +.Nm atomic_cas +functions first appeared in +.Ox 5.5 . diff --git a/share/man/man9/atomic_dec.9 b/share/man/man9/atomic_dec.9 new file mode 100644 index 00000000000..c10279228b0 --- /dev/null +++ b/share/man/man9/atomic_dec.9 @@ -0,0 +1,68 @@ +.\" $OpenBSD: atomic_dec.9,v 1.1 2014/01/30 00:44:20 dlg Exp $ +.\" +.\" Copyright (c) 2014 David Gwynne <dlg@openbsd.org> +.\" All rights reserved. +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: January 30 2014 $ +.Dt ATOMIC_DEC 9 +.Os +.Sh NAME +.Nm atomic_dec_int , +.Nm atomic_dec_int_nv , +.Nm atomic_dec_long , +.Nm atomic_dec_long_nv +.Nd atomic decrement operations +.Sh SYNOPSIS +.In sys/atomic.h +.Ft void +.Fn atomic_dec_int "volatile unsigned int *p" +.Ft unsigned int +.Fn atomic_dec_int_nv "volatile unsigned int *p" +.Ft void +.Fn atomic_dec_long "volatile unsigned long *p " +.Ft unsigned long +.Fn atomic_dec_long_nv "volatile unsigned long *p" +.Sh DESCRIPTION +The +.Nm atomic_dec +set of functions provide an interface for atomically performing +decrement and decrement-and-fetch operations with respect to +interrupts and multiple processors in the system. +.Pp +The value referenced by the pointer +.Fa p +is decremented by 1. +.Sh RETURN VALUES +.Nm atomic_dec_int +and +.Nm atomic_dec_long +perform the decrement without returning any knowledge of the value at the +.Fa p . +.Pp +.Nm atomic_dec_int_nv +and +.Nm atomic_dec_long_nv +return the value at +.Fa p +after the decrement was performed. +.Sh SEE ALSO +.Xr atomic 9 , +.Xr atomic_add 9 , +.Xr atomic_inc 9 +.Sh HISTORY +The +.Nm atomic_add +functions first appeared in +.Ox 5.5 . diff --git a/share/man/man9/atomic_inc.9 b/share/man/man9/atomic_inc.9 new file mode 100644 index 00000000000..c4baf8dcea5 --- /dev/null +++ b/share/man/man9/atomic_inc.9 @@ -0,0 +1,68 @@ +.\" $OpenBSD: atomic_inc.9,v 1.1 2014/01/30 00:44:20 dlg Exp $ +.\" +.\" Copyright (c) 2014 David Gwynne <dlg@openbsd.org> +.\" All rights reserved. +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: January 30 2014 $ +.Dt ATOMIC_INC 9 +.Os +.Sh NAME +.Nm atomic_inc_int , +.Nm atomic_inc_int_nv , +.Nm atomic_inc_long , +.Nm atomic_inc_long_nv +.Nd atomic increment operations +.Sh SYNOPSIS +.In sys/atomic.h +.Ft void +.Fn atomic_inc_int "volatile unsigned int *p" +.Ft unsigned int +.Fn atomic_inc_int_nv "volatile unsigned int *p" +.Ft void +.Fn atomic_inc_long "volatile unsigned long *p " +.Ft unsigned long +.Fn atomic_inc_long_nv "volatile unsigned long *p" +.Sh DESCRIPTION +The +.Nm atomic_inc +set of functions provide an interface for atomically performing +increment and increment-and-fetch operations +with respect to interrupts and multiple processors in the system. +.Pp +The value referenced by the pointer +.Fa p +is incremented by 1. +.Sh RETURN VALUES +.Nm atomic_inc_int +and +.Nm atomic_inc_long +perform the increment without returning any knowledge of the value at the +.Fa p . +.Pp +.Nm atomic_inc_int_nv +and +.Nm atomic_inc_long_nv +return the value at +.Fa p +after the increment was performed. +.Sh SEE ALSO +.Xr atomic 9 , +.Xr atomic_add 9 , +.Xr atomic_dec 9 +.Sh HISTORY +The +.Nm atomic_add +functions first appeared in +.Ox 5.5 . diff --git a/share/man/man9/atomic_sub.9 b/share/man/man9/atomic_sub.9 new file mode 100644 index 00000000000..f0d0b4e2f1a --- /dev/null +++ b/share/man/man9/atomic_sub.9 @@ -0,0 +1,69 @@ +.\" $OpenBSD: atomic_sub.9,v 1.1 2014/01/30 00:44:20 dlg Exp $ +.\" +.\" Copyright (c) 2014 David Gwynne <dlg@openbsd.org> +.\" All rights reserved. +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: January 30 2014 $ +.Dt ATOMIC_SUB 9 +.Os +.Sh NAME +.Nm atomic_sub_int , +.Nm atomic_sub_int_nv , +.Nm atomic_sub_long , +.Nm atomic_sub_long_nv +.Nd atomic subtraction operations +.Sh SYNOPSIS +.In sys/atomic.h +.Ft void +.Fn atomic_sub_int "volatile unsigned int *p" "unsigned int v" +.Ft unsigned int +.Fn atomic_sub_int_nv "volatile unsigned int *p" "unsigned int v" +.Ft void +.Fn atomic_sub_long "volatile unsigned long *p" "unsigned long v" +.Ft unsigned long +.Fn atomic_sub_long_nv "volatile unsigned long *p" "unsigned long v" +.Sh DESCRIPTION +The +.Nm atomic_sub +set of functions provide an interface for atomically performing sub +and sub-and-fetch operations with respect to interrupts and multiple +processors in the system. +.Pp +The value referenced by the pointer +.Fa p +is incremented by the value +.Fa v . +.Sh RETURN VALUES +.Nm atomic_sub_int +and +.Nm atomic_sub_long +perform the subtraction without returning any knowledge of the value at the +.Fa p . +.Pp +.Nm atomic_sub_int_nv +and +.Nm atomic_sub_long_nv +return the value at +.Fa p +after the subtraction was performed. +.Sh SEE ALSO +.Xr atomic 9 , +.Xr atomic_add 9 , +.Xr atomic_dec 9 +.Sh HISTORY +The +.Nm atomic_sub +functions first appeared in +.Ox 5.5 . diff --git a/share/man/man9/atomic_swap.9 b/share/man/man9/atomic_swap.9 new file mode 100644 index 00000000000..03cf52aeec1 --- /dev/null +++ b/share/man/man9/atomic_swap.9 @@ -0,0 +1,56 @@ +.\" $OpenBSD: atomic_swap.9,v 1.1 2014/01/30 00:44:20 dlg Exp $ +.\" +.\" Copyright (c) 2014 David Gwynne <dlg@openbsd.org> +.\" All rights reserved. +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: January 30 2014 $ +.Dt ATOMIC_SWAP 9 +.Os +.Sh NAME +.Nm atomic_swap_uint , +.Nm atomic_swap_ulong , +.Nm atomic_swap_ptr +.Nd atomic swap operations +.Sh SYNOPSIS +.In sys/atomic.h +.Ft unsigned int +.Fn atomic_swap_uint "volatile unsigned int *p" "unsigned int new" +.Ft unsigned long +.Fn atomic_swap_ulong "volatile unsigned long *p" "unsigned long new" +.Ft void * +.Fn atomic_swap_ptr "volatile void **p" "void *new" +.Sh DESCRIPTION +The +.Nm atomic_swap +set of functions provide an interface for atomically performing +swap operations with respect to interrupts and multiple processors +in the system. +.Pp +The value referenced by the pointer +.Fa p +is replaced by the value +.Fa new . +.Sh RETURN VALUES +These functions return the value at +.Fa p +as it was before the swap operation. +.Sh SEE ALSO +.Xr atomic 9 , +.Xr atomic_cas 9 +.Sh HISTORY +The +.Nm atomic_swap +functions first appeared in +.Ox 5.5 . diff --git a/share/man/man9/membar.9 b/share/man/man9/membar.9 new file mode 100644 index 00000000000..5af1ca06517 --- /dev/null +++ b/share/man/man9/membar.9 @@ -0,0 +1,93 @@ +.\" $OpenBSD: membar.9,v 1.1 2014/01/30 00:44:20 dlg Exp $ +.\" +.\" Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to The NetBSD Foundation +.\" by Jason R. Thorpe. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd $Mdocdate: January 30 2014 $ +.Dt MEMBAR 9 +.Os +.Sh NAME +.Nm membar_enter , +.Nm membar_exit , +.Nm membar_producer , +.Nm membar_consumer , +.Nm membar_sync +.Nd memory access barrier operations +.Sh SYNOPSIS +.In sys/atomic.h +.Ft void +.Fn membar_enter "void" +.Ft void +.Fn membar_exit "void" +.Ft void +.Fn membar_producer "void" +.Ft void +.Fn membar_consumer "void" +.Ft void +.Fn membar_sync "void" +.Sh DESCRIPTION +The +.Nm membar +set of functions provide an interface for issuing memory barrier +access operations with respect to multiple processors in the system. +.Bl -tag -width "mem" +.It Fn membar_enter +Any store preceding +.Fn membar_enter +will reach global visibility before all loads and stores following it. +.Pp +.Fn membar_enter +is typically used in code that implements locking primitives to ensure +that a lock protects its data. +.It Fn membar_exit +All loads and stores preceding +.Fn membar_exit +will reach global visibility before any store that follows it. +.Pp +.Fn membar_exit +is typically used in code that implements locking primitives to ensure +that a lock protects its data. +.It Fn membar_producer +All stores preceding the memory barrier will reach global visibility +before any stores after the memory barrier reach global visibility. +.It Fn membar_consumer +All loads preceding the memory barrier will complete before any loads +after the memory barrier complete. +.It Fn membar_sync +All loads and stores preceding the memory barrier will complete and +reach global visibility before any loads and stores after the memory +barrier complete and reach global visibility. +.El +.Sh SEE ALSO +.Xr atomic 9 +.Sh HISTORY +The +.Nm membar_ops +functions first appeared in +.Nx 5.0 +and +.Ox 5.5 . |