home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 620.lha / MinStack / MinStack.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-17  |  792 b   |  38 lines

  1. ; /*
  2. dcc -r -v minstack.c -o minstack
  3. quit
  4. *   ^^ This is PURE code!
  5. */
  6.  
  7. /*
  8.  * Minstack.c
  9.  * (C) Copyright 1992 by Olaf Seibert. All rights reserved.
  10.  *
  11.  * Ensures a minimum stacksize by only upping the stack size to the
  12.  * required amount.
  13.  */
  14.  
  15. #include <exec/types.h>
  16. #include <libraries/dosextens.h>
  17. #include "functions.h"
  18. #include <stddef.h>
  19.  
  20. __stkargs int _main(int len, char *cmdline)
  21. /* int main(int argc, char **argv) */
  22. {
  23.     long stack;
  24.     struct Process *proc;
  25.     struct CommandLineInterface *cli;
  26.  
  27.     stack = atoi(cmdline);
  28.     stack = (stack + 3) / 4;
  29.     proc = (struct Process *)FindTask(NULL);
  30.     if (proc->pr_Task.tc_Node.ln_Type == NT_PROCESS) {
  31.     cli = BADDR(proc->pr_CLI);
  32.     if (cli) {
  33.         if (cli->cli_DefaultStack < stack)
  34.         cli->cli_DefaultStack = stack;
  35.     }
  36.     }
  37. }
  38.