STACK(9) BSD 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)BSD April 8, 2011 BSD
Check Out this Related Man Page
STACK(9) BSD 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)BSD April 8, 2011 BSD
Hi, I am writing a C program under SCO Unix. I have a memory stack problem but do not know how to go about fixing it. I have tried running INSURE but that does not detect any problems.
Essentially the problem is that the memory address shifts on return from a routine. I pass a pointer to... (3 Replies)
can anyone explain how the local variables are acessed from a stack frame of that particular function..since stacks can only push or pop values and stack pointer always points to top of the stack and the frame pointer always points to the end of the previous stack frame..how local variables are... (4 Replies)
Hi,
Can someone please explain how is the control stack cleared when we exit from a function?or who clears the rescords in the control stack?
Thanks (1 Reply)
Hi,
In Linux how to find out what will be the stack size allocated for a process?
Actually i have to fork n number of processess, and will call exec. I will be execing an executable which is already multithreaded and each thread size is defined. My doubt is how to know if the size of the... (2 Replies)
Hi,
Please see this:
When i make a declaration as:
char *i, j, *k;
and then do
sprintf( k, "print.sh %s", i );
the program works fine.
But when i change the declaration to:
char *i, *k;
and then do
sprintf( k, "print.sh %s", i );
I get a segmentation fault at the 'sprintf'... (16 Replies)
Like you can see in the title this is my problem! Here is what appears in the terminal
:confused::confused::confused:
*** stack smashing detected ***: ./a.out terminated
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6(__fortify_fail+0x48)... (2 Replies)
Forgive me if this sounds like a newbie question. Any time you obtain a stack address from a pointer, what is this relative to by default? Is it the extra segment, the stack segment, what? How do you change change the relative positioning in memory? Thanks in advance (1 Reply)
I'm trying to create a simplified version of dc to learn from. The first thing I notice is that the main stack stores strings. How would I implement a string stack in C? How is something like this:
struct StringStack
{
const unsigned int pysicalSize; // physical size of the stack... (3 Replies)
Our stack used to be FreeBSD - Lighttpd - MySQL - Perl - Python - C++, which abbreviates to flimppc++ and pronounced as flimpsy.
Not great, but still better than our newer stack: Linux - Lighttpd - MariaDB - Perl - Python - C++, which abbreviates to llimppc++. The phonetic meaning behind that... (2 Replies)
Hi,
I am working in UEFI EDK2 Bios source. We created a platform related new package in the EDK2 source. I find a strange issue with the platform related code we added.
When I did source level debugging I noticed the
local variable in a C function is not getting created in stack when its... (6 Replies)
I am trying to illustrate the reverse order of parameters on the stack when passed to a function in C:
#include <stdio.h>
void p(int p1, int p2, double p3)
{
printf("params:\n"
"1) %p offset = %li\n"
"2) %p offset = %li\n"
... (5 Replies)