home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!crdgw1!newsun!damurphy
- From: damurphy@wc.novell.com (Duane A Murphy)
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: How to increase stack size ???
- Message-ID: <1992Sep2.154822.12924@novell.com>
- Date: 2 Sep 92 15:48:22 GMT
- References: <1992Sep1.145611.1@uwovax.uwo.ca>
- Sender: usenet@novell.com (The Netnews Manager)
- Organization: Novell, Inc. - Walnut Creek
- Lines: 50
- Nntp-Posting-Host: optics
-
- In article <1992Sep1.145611.1@uwovax.uwo.ca> tschneid@uwovax.uwo.ca writes:
- >
- >I am working on a port of Gunplot 3.2 to the Mac. So far I have most
- >of the basics working (only a few bugs left) ... however, I keep
- >running out of stack space. I did some reading and found out that the
- >Mac only provides 8k of stack space and that it can be changed by doing
- >something like (in VERY rough C pseudo-code)
- >
- > THz newapplimit;
- >
- > newapplimit = 300*1024; /* give app 300k */
- > SetApplLimit(ApplLimit()+newapplimit);
- > MaxApplLimit();
- >
- >Unfortunately, this does not work ...
- >
- >Can anyone enlighten me? I would like to set up a fixed stack size of
- >32k (i.e. not dependent on the memory allotted by the user in the
- >applications info box). I am using Think C 5.02.
- >
- >Thanks,
- >Todd Schneider
-
- I also ran into a stack limitation problem. Actually the stack is handled
- differently on different machines. It is not consistent. "Small" machines
- have an 8K stack. "Large" machines have a 24K stack. There is a low memory
- global "DefltStack" that determines the stack size at startup. Dont mess
- with this, it affects everyone.
-
- After a few days of trying to figure out how the stack space is managed;
- that is what pointers in the heap kept track of the stack to detect a
- stack heap collision, we came up with the following very simple solution.
-
- #define STACK_MIN 0x8000L
- pascal Ptr StackPtr(void) = {0x2e8f}; /* MOVE A7, (A7) */
-
- int main(void)
- {
- SetApplLimit(StackPtr() - STACK_MIN);
- ...
-
- The StackPtr() function came from the net (thanks to whomever suggested
- this). The stack has no direct pointers to set its limits. It is actuall
- controlled by heap limit pointers, namely ApplLimit. This moves ApplLimit
- the where the current stack is at down the size of the stack that you
- want.
-
- Hope this helps,
- ...Duane Murphy
- Novell, Walnut Creek
-