delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/07/11/22:13:24

Xref: news2.mv.net comp.os.msdos.djgpp:5873
From: Charles Sandmann <sandmann AT clio DOT rice DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: How much stack left?
Date: Thu, 11 Jul 1996 08:12:22 CDT
Organization: Rice University, Houston, Texas
Lines: 21
Message-ID: <31e4fdb6.sandmann@clio.rice.edu>
References: <Pine DOT SUN DOT 3 DOT 91 DOT 960710132041 DOT 4676B-100000 AT is>
Reply-To: sandmann AT clio DOT rice DOT edu
NNTP-Posting-Host: clio.rice.edu
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

> > In V2, how can I find at run time how much free stack space is left?
> You can get the address of the farthest (lowest) location of the stack (by
> calling `alloca (256K)' at the beginning of `main') and then look at the

I don't think this will work - and will probably overrun the stack with
bad consequences.

In general, finding out the base of the stack is a very difficult task 
in V2, especially since a DPMI provider may chose to give it to you at
a non-contiguous point.  In general, it's usually at (see <stubinfo.h>)
_stubinfo + sizeof(_GO32_StubInfo).

You can also check this plus the stklen variable, get the size, and
subtract from the current %esp via an asm() block.  If this value is
far from the stubinfo value above, it's probably in a different memory
zone.

It probably ought to just be a variable, as someone sent a patch for.
I have an ugly routine someplace which determines the amount of 
stack used so far (and also how much is left) - I probably ought to
just package them up.

- Raw text -


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