From 52b33dcfd85ac6c61056832abbaca7beb5bd387d Mon Sep 17 00:00:00 2001 From: jruoho Date: Fri, 17 Dec 2010 07:10:37 +0000 Subject: [PATCH] Add __insn_barrier(3). XXX: Someone more knowledgeable may want to check this. --- distrib/sets/lists/comp/mi | 5 ++- share/man/man3/Makefile | 5 +-- share/man/man3/__insn_barrier.3 | 64 +++++++++++++++++++++++++++++++++ share/man/man3/cdefs.3 | 11 +++--- 4 files changed, 77 insertions(+), 8 deletions(-) create mode 100644 share/man/man3/__insn_barrier.3 diff --git a/distrib/sets/lists/comp/mi b/distrib/sets/lists/comp/mi index 7683ad27ab9f..f792315786e1 100644 --- a/distrib/sets/lists/comp/mi +++ b/distrib/sets/lists/comp/mi @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1551 2010/12/16 23:01:56 joerg Exp $ +# $NetBSD: mi,v 1.1552 2010/12/17 07:10:37 jruoho Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -4910,6 +4910,7 @@ ./usr/share/man/cat3/__builtin_object_size.0 comp-c-catman .cat ./usr/share/man/cat3/__constfunc.0 comp-c-catman .cat ./usr/share/man/cat3/__dead.0 comp-c-catman .cat +./usr/share/man/cat3/__insn_barrier.0 comp-c-catman .cat ./usr/share/man/cat3/__noinline.0 comp-c-catman .cat ./usr/share/man/cat3/__packed.0 comp-c-catman .cat ./usr/share/man/cat3/__pure.0 comp-c-catman .cat @@ -10994,6 +10995,7 @@ ./usr/share/man/html3/__builtin_object_size.html comp-c-htmlman html ./usr/share/man/html3/__constfunc.html comp-c-htmlman html ./usr/share/man/html3/__dead.html comp-c-htmlman html +./usr/share/man/html3/__insn_barrier.html comp-c-htmlman html ./usr/share/man/html3/__noinline.html comp-c-htmlman html ./usr/share/man/html3/__packed.html comp-c-htmlman html ./usr/share/man/html3/__pure.html comp-c-htmlman html @@ -16878,6 +16880,7 @@ ./usr/share/man/man3/__builtin_object_size.3 comp-c-man .man ./usr/share/man/man3/__constfunc.3 comp-c-man .man ./usr/share/man/man3/__dead.3 comp-c-man .man +./usr/share/man/man3/__insn_barrier.3 comp-c-man .man ./usr/share/man/man3/__noinline.3 comp-c-man .man ./usr/share/man/man3/__packed.3 comp-c-man .man ./usr/share/man/man3/__pure.3 comp-c-man .man diff --git a/share/man/man3/Makefile b/share/man/man3/Makefile index 8ab8a6d43053..c60d5f425364 100644 --- a/share/man/man3/Makefile +++ b/share/man/man3/Makefile @@ -1,8 +1,9 @@ -# $NetBSD: Makefile,v 1.61 2010/12/16 17:47:54 jruoho Exp $ +# $NetBSD: Makefile,v 1.62 2010/12/17 07:10:38 jruoho Exp $ # @(#)Makefile 8.2 (Berkeley) 12/13/93 MAN= _DIAGASSERT.3 __CONCAT.3 __UNCONST.3 CMSG_DATA.3 \ - __arraycount.3 assert.3 attribute.3 bits.3 bitstring.3 \ + __arraycount.3 __insn_barrier.3 \ + assert.3 attribute.3 bits.3 bitstring.3 \ cdefs.3 dirent.3 dlfcn.3 dl_iterate_phdr.3 end.3 \ fast_divide32.3 ffs32.3 gcq.3 \ ilog2.3 intro.3 inttypes.3 iso646.3 \ diff --git a/share/man/man3/__insn_barrier.3 b/share/man/man3/__insn_barrier.3 new file mode 100644 index 000000000000..fe765d30c000 --- /dev/null +++ b/share/man/man3/__insn_barrier.3 @@ -0,0 +1,64 @@ +.\" $NetBSD: __insn_barrier.3,v 1.1 2010/12/17 07:10:38 jruoho Exp $ +.\" +.\" Copyright (c) 2010 Jukka Ruohonen +.\" All rights reserved. +.\" +.\" 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 December 17, 2010 +.Dt __INSN_BARRIER 3 +.Os +.Sh NAME +.Nm __insn_barrier +.Nd compiler reorder barrier +.Sh SYNOPSIS +.In sys/cdefs.h +.Ft void +.Fn __insn_barrier +.Sh DESCRIPTION +The +.Fn __insn_barrier +macro prevents +.Tn GCC +from moving code across the barrier. +In other words, the compiler is not allowed to reorder read and write +commands below the barrier with the code preceding the barrier. +Like with the +.Em volatile +type qualifier, +.Fn __insn_barrier +may be necessary in some corner cases to prevent the compiler +from misoptimizing. +.Sh SEE ALSO +.Xr gcc 1 , +.Xr cdefs 3 +.Rs +.%A Paul E. McKenney +.%T Memory Barriers: a Hardware View for Software Hackers +.%D June 7, 2010 +.%U http://www.rdrop.com/users/paulmck/scalability/paper/whymb.2010.06.07c.pdf +.Re +.Sh HISTORY +The +.Fn __insn_barrier +macro first appeared in +.Nx 2.0 . diff --git a/share/man/man3/cdefs.3 b/share/man/man3/cdefs.3 index cc792f443187..e4e251e42502 100644 --- a/share/man/man3/cdefs.3 +++ b/share/man/man3/cdefs.3 @@ -1,4 +1,4 @@ -.\" $NetBSD: cdefs.3,v 1.1 2010/12/16 10:19:14 jruoho Exp $ +.\" $NetBSD: cdefs.3,v 1.2 2010/12/17 07:10:38 jruoho Exp $ .\" .\" Copyright (c) 2010 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd December 16, 2010 +.Dd December 17, 2010 .Dt CDEFS 3 .Os .Sh NAME @@ -54,10 +54,11 @@ type qualifier from .Tn C99 . .It Macros and definitions specific to compilers, preprocessors, and linkers; see -.Xr attribute 3 , .Xr __CONCAT 3 , +.Xr __UNCONST 3 , +.Xr __insn_barrier 3 , and -.Xr __UNCONST 3 . +.Xr attribute 3 . .It Utility macros provided for convenience; see .Xr __arraycount 3 @@ -87,7 +88,7 @@ included as the first thing right after any possible copyright texts; */ #include -__RCSID("$NetBSD: cdefs.3,v 1.1 2010/12/16 10:19:14 jruoho Exp $"); +__RCSID("$NetBSD: cdefs.3,v 1.2 2010/12/17 07:10:38 jruoho Exp $"); .Ed .Pp It is possible to identify the