Mail Archives: djgpp-workers/1997/04/11/00:02:35
> I'm searching for a fast and reliable implementation to determine the
> available stack space, e.g.
>
> unsigned stackavail( void );
1) Look at the stack size variable
2) Look at the current ESP
3) Try to figure out where the start of the stack is. It's usually
immediately after the info block, but if you are in a different
memory block and it's not contiguous it will be the start of the
second memory block (since this is the first call to sbrk).
4) From the above you should be able to tell if you are where you
think you are, validate it, and compute a stackavail value.
If none of this makes sense, read crt0.s again.
- Raw text -