STACK(9) - NetBSD Manual Pages

Command: Section: Arch: Collection:  
STACK(9)               NetBSD Kernel Developer's Manual               STACK(9)


NAME
STACK -- stack macros
SYNOPSIS
#include <sys/param.h> type STACK_ALLOC(sp, size); type STACK_MAX(sp, size); type STACK_ALIGN(sp, bytes); type STACK_GROW(sp, size); type STACK_SHRINK(sp, size);
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. 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.
SEE ALSO
param(3), queue(3) NetBSD 9.1 April 8, 2011 NetBSD 9.1
Powered by man-cgi (2024-03-20). Maintained for NetBSD by Kimmo Suominen. Based on man-cgi by Panagiotis Christias.