delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1997/04/11/00:02:35

From: sandmann AT clio DOT rice DOT edu (Charles Sandmann)
Message-Id: <9704110346.AA15819@clio.rice.edu>
Subject: Re: stackavail() ?
To: k3040e4 AT c210 DOT edvz DOT uni-linz DOT ac DOT at (Oberhumer Markus)
Date: Thu, 10 Apr 1997 22:46:48 -0600 (CDT)
Cc: djgpp-workers AT delorie DOT com
In-Reply-To: <199704102250.SAA19142@delorie.com> from "Oberhumer Markus" at Apr 11, 97 00:47:10 am

> 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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019