1.\" $NetBSD: __insn_barrier.3,v 1.1 2010/12/17 07:10:38 jruoho Exp $ 2.\" 3.\" Copyright (c) 2010 Jukka Ruohonen <jruohonen@iki.fi> 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 15.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25.\" POSSIBILITY OF SUCH DAMAGE. 26.\" 27.Dd December 17, 2010 28.Dt __INSN_BARRIER 3 29.Os 30.Sh NAME 31.Nm __insn_barrier 32.Nd compiler reorder barrier 33.Sh SYNOPSIS 34.In sys/cdefs.h 35.Ft void 36.Fn __insn_barrier 37.Sh DESCRIPTION 38The 39.Fn __insn_barrier 40macro prevents 41.Tn GCC 42from moving code across the barrier. 43In other words, the compiler is not allowed to reorder read and write 44commands below the barrier with the code preceding the barrier. 45Like with the 46.Em volatile 47type qualifier, 48.Fn __insn_barrier 49may be necessary in some corner cases to prevent the compiler 50from misoptimizing. 51.Sh SEE ALSO 52.Xr gcc 1 , 53.Xr cdefs 3 54.Rs 55.%A Paul E. McKenney 56.%T Memory Barriers: a Hardware View for Software Hackers 57.%D June 7, 2010 58.%U http://www.rdrop.com/users/paulmck/scalability/paper/whymb.2010.06.07c.pdf 59.Re 60.Sh HISTORY 61The 62.Fn __insn_barrier 63macro first appeared in 64.Nx 2.0 . 65