home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / amiga / programm / 13082 < prev    next >
Encoding:
Internet Message Format  |  1992-09-04  |  1.7 KB

  1. 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+
  2. From: eb15+@andrew.cmu.edu (Edward D. Berger)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: StackSwap() examples???
  5. Message-ID: <0edqpyy00WB_N3a0NE@andrew.cmu.edu>
  6. Date: 4 Sep 92 06:06:54 GMT
  7. Article-I.D.: andrew.0edqpyy00WB_N3a0NE
  8. Organization: Pittsburgh Supercomputing Center, Carnegie Mellon, Pittsburgh, PA
  9. Lines: 43
  10.  
  11. I currently have a function that can check my program's stacksize against
  12. a minimum value.  I would like to change this from just checking the
  13. amount available to changing it automatically so that the user doesn't
  14. ever have to see a "Stack size is too low" abort message, if they do
  15. something like change an Icon's tooltype to my program and start it that
  16. way.  In the NATDEV20 autodocs there is a function StackSwap() and I
  17. would like to see an example of how to use it.  How to allocate the
  18. memory correctly, what to copy over to the allocated memory, etc.
  19.  
  20. Here is my current function:
  21. #define MIN_STACK  18000
  22.  
  23. BOOL check_stacksize()
  24.   {
  25.     BOOL success = FALSE;
  26.     register struct Process *Process;
  27.     struct CommandLineInterface *CLI;
  28.     long stacktest = MIN_STACK;
  29.  
  30.     /* Checking Stack Size is greater than  MIN_STACK */
  31.  
  32.     Process=FindTask(0L);
  33.  
  34.     if (CLI=(struct CommandLineInterface *)(Process->pr_CLI<<2))
  35. /* Process is from CLI, Actual stack is: CLI->cli_DefaultStack<<2 */
  36.  
  37.       {
  38.        if ((CLI->cli_DefaultStack<<2)>=stacktest) success = TRUE;
  39.       }
  40.  
  41.     else
  42. /* Process is from WB, Actual stack is: Process->pr_StackSize */
  43.  
  44.       {
  45.        if ((Process->pr_StackSize)>=stacktest) success = TRUE;
  46.       }
  47.  
  48.     return(success);
  49.   }
  50.  
  51.  
  52. -Ed Berger
  53. eb15@andrew.cmu.edu
  54.