- NetBSD Manual Pages
STACK(9) NetBSD Kernel Developer's Manual STACK(9)
Powered by man-cgi (2020-09-24).
Maintained for NetBSD
by Kimmo Suominen.
Based on man-cgi by Panagiotis Christias.
STACK -- stack macros
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.
The STACK_ALLOC() macro returns a pointer to allocated stack space of
some size. Given the returned pointer sp and size, STACK_MAX() returns
the maximum stack address of the allocated stack space. The
STACK_ALIGN() macro can be used to align the stack pointer sp by the
specified amount of bytes.
Two basic operations are common to all stacks: a data item is added
(``push'') to the location pointed by sp or a data item is removed
(``pop'') from the stack. The stack pointer must be subsequently
adjusted by the size of the data item. The STACK_GROW() and
STACK_SHRINK() macros adjust the stack pointer sp by given size.
A stack may grow either up or down. The described macros take this into
account by using the __MACHINE_STACK_GROWS_UP preprocessor define.
NetBSD 9.99 April 8, 2011 NetBSD 9.99