diff options
Diffstat (limited to 'static/netbsd/man9/STACK.9')
| -rw-r--r-- | static/netbsd/man9/STACK.9 | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/static/netbsd/man9/STACK.9 b/static/netbsd/man9/STACK.9 new file mode 100644 index 00000000..f459d5cb --- /dev/null +++ b/static/netbsd/man9/STACK.9 @@ -0,0 +1,97 @@ +.\" $NetBSD: STACK.9,v 1.2 2011/04/08 07:55:04 jruoho Exp $ +.\" +.\" Copyright (c) 2010 The NetBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to The NetBSD Foundation +.\" by Jukka Ruohonen. +.\" +.\" 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 April 8, 2011 +.Dt STACK 9 +.Os +.Sh NAME +.Nm STACK +.Nd stack macros +.Sh SYNOPSIS +.In sys/param.h +.Ft type +.Fn STACK_ALLOC "sp" "size" +.Ft type +.Fn STACK_MAX "sp" "size" +.Ft type +.Fn STACK_ALIGN "sp" "bytes" +.Ft type +.Fn STACK_GROW "sp" "size" +.Ft type +.Fn STACK_SHRINK "sp" "size" +.Sh DESCRIPTION +A stack is an area of memory with a fixed origin but with a variable size. +A stack pointer points to the most recently referenced location on the stack. +Initially, when the stack has a size of zero, +the stack pointer points to the origin of the stack. +When data items are added to the stack, +the stack pointer moves away from the origin. +.Pp +The +.Fn STACK_ALLOC +macro returns a pointer to allocated stack space of some +.Fa size . +Given the returned pointer +.Fa sp +and +.Fa size , +.Fn STACK_MAX +returns the maximum stack address of the allocated stack space. +The +.Fn STACK_ALIGN +macro can be used to align the stack pointer +.Fa sp +by the specified amount of +.Fa bytes . +.Pp +Two basic operations are common to all stacks: +a data item is added +.Pq Dq push +to the location pointed by +.Fa sp +or a data item is removed +.Pq Dq pop +from the stack. +The stack pointer must be subsequently adjusted by the size of the data item. +The +.Fn STACK_GROW +and +.Fn STACK_SHRINK +macros adjust the stack pointer +.Fa sp +by given +.Fa size . +.Pp +A stack may grow either up or down. +The described macros take this into account by using the +.Dv __MACHINE_STACK_GROWS_UP +preprocessor define. +.Sh SEE ALSO +.Xr param 3 , +.Xr queue 3 |
