252u3129@fergvax.unl.edu (Mike Gleason) (09/25/90)
How can you set the stack size using Think C? In Think Pascal, I could just fill in a number in the "Run Options" and that would do it. Heck, while I'm at it, is the order and way I'm initializing everything correct? InitGraf(&thePort); InitFonts(); InitWindows(); InitMenus(); TEInit(); InitDialogs(NULL); MaxApplZone(); ----> SetApplLimit(ApplicZone() + STACKSIZE); for (i=0; i<HOWMANYMASTERS; i++) MoreMasters(); FlushEvents(everyEvent, 0); InitCursor(); The arrow is my best guess at setting the stack size. I've seen MaxApplZone come after SetApplLimit, but if I do that, it hangs... A _____________________________________________________________________________ * Mike Gleason 252u3129@fergvax.unl.edu * "Don't you f*ckin' look at me!" -- D. Hopper cosc006@unlcdc2.unl.edu
kurash@ascutney.dartmouth.edu (Mark Valence) (09/26/90)
In article <1990Sep25.000749.230@hoss.unl.edu> 252u3129@fergvax.unl.edu (Mike Gleason) writes: >How can you set the stack size using Think C? In Think Pascal, I could >just fill in a number in the "Run Options" and that would do it. Heck, >while I'm at it, is the order and way I'm initializing everything >correct? > > InitGraf(&thePort); > InitFonts(); > InitWindows(); > InitMenus(); > TEInit(); > InitDialogs(NULL); > MaxApplZone(); >----> SetApplLimit(ApplicZone() + STACKSIZE); > for (i=0; i<HOWMANYMASTERS; i++) > MoreMasters(); > FlushEvents(everyEvent, 0); > InitCursor(); > >The arrow is my best guess at setting the stack size. I've seen >MaxApplZone come after SetApplLimit, but if I do that, it hangs... >A > > >_____________________________________________________________________________ > * Mike Gleason 252u3129@fergvax.unl.edu > * "Don't you f*ckin' look at me!" -- D. Hopper cosc006@unlcdc2.unl.edu This is how I mimic LSP's code: long GetSP (); { register long localSP; asm { MOVEA.L SP, localSP }; return(localSP); } The only reason I use localSP is so that LightSpeed can change it's calling conventions (i.e. stack based vs. register based return values), and I will still be able to compile and run this code. Use this routine as follows: InitGraf(@thePort); . . . SetApplLimit(GetSP() - STACKSIZE); . . . Note: That's *supposed* to be a minus sign. There is a good reason why reversing the order of the SetApplLimit and MaxApplZone calls causes your Mac to crash. It's actually the order of ApplicZone and MaxApplZone coupled with the call to SetApplLimit that is causing the problem. If you use GetSP, you will be abel to order MaxApplZone and SetApplLimit the way you see it elsewhere. The order of your Init calls is fine. Mark.