home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!spool.mu.edu!uwm.edu!ogicse!das-news.harvard.edu!cantaloupe.srv.cs.cmu.edu!crabapple.srv.cs.cmu.edu!andrew.cmu.edu!eb15+
- From: eb15+@andrew.cmu.edu (Edward D. Berger)
- Newsgroups: comp.sys.amiga.programmer
- Subject: StackSwap() examples???
- Message-ID: <0edqpyy00WB_N3a0NE@andrew.cmu.edu>
- Date: 4 Sep 92 06:06:54 GMT
- Article-I.D.: andrew.0edqpyy00WB_N3a0NE
- Organization: Pittsburgh Supercomputing Center, Carnegie Mellon, Pittsburgh, PA
- Lines: 43
-
- I currently have a function that can check my program's stacksize against
- a minimum value. I would like to change this from just checking the
- amount available to changing it automatically so that the user doesn't
- ever have to see a "Stack size is too low" abort message, if they do
- something like change an Icon's tooltype to my program and start it that
- way. In the NATDEV20 autodocs there is a function StackSwap() and I
- would like to see an example of how to use it. How to allocate the
- memory correctly, what to copy over to the allocated memory, etc.
-
- Here is my current function:
- #define MIN_STACK 18000
-
- BOOL check_stacksize()
- {
- BOOL success = FALSE;
- register struct Process *Process;
- struct CommandLineInterface *CLI;
- long stacktest = MIN_STACK;
-
- /* Checking Stack Size is greater than MIN_STACK */
-
- Process=FindTask(0L);
-
- if (CLI=(struct CommandLineInterface *)(Process->pr_CLI<<2))
- /* Process is from CLI, Actual stack is: CLI->cli_DefaultStack<<2 */
-
- {
- if ((CLI->cli_DefaultStack<<2)>=stacktest) success = TRUE;
- }
-
- else
- /* Process is from WB, Actual stack is: Process->pr_StackSize */
-
- {
- if ((Process->pr_StackSize)>=stacktest) success = TRUE;
- }
-
- return(success);
- }
-
-
- -Ed Berger
- eb15@andrew.cmu.edu
-