home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / prog / c / rconfig.lha / RConfig_v1.1 / tests / 3b / test3b.c < prev   
C/C++ Source or Header  |  1992-09-20  |  911b  |  46 lines

  1. /*
  2.  * RConfig Validation Suite by Anthon Pang, Omni Communications Products
  3.  *
  4.  * Object Code: better stkchk (dynastack)
  5.  * Assigned Test # 3b
  6.  * Requirements: Compile with -bs -bd -at; process result with stkchk.rexx
  7.  *   Use small stack (ie 8K)
  8.  * Desired Observation(s):
  9.  *   Recursive loop chews up stack space, printing the contents (address value)
  10.  *   of _stkbase; _stkbase changes as dynastack code builds extension stack
  11.  *   during execution
  12.  */
  13.  
  14. #include <stdio.h>
  15.  
  16. #include "rlib.h"
  17.  
  18. void proc(z)
  19. int z;
  20. {
  21.     char y[127];
  22.     extern long _stkbase;
  23.  
  24.     if (z >= 100)
  25.         return;
  26.     else {
  27.         /* recursion */
  28.         printf("stackbase: %ld  iteration: %d\n",_stkbase,z);
  29.         proc(z+1);
  30.  
  31.         /* unwind stack */
  32.         printf("stackbase: %ld  iteration: %d\n",_stkbase,z);
  33.     }
  34. }
  35.  
  36. void main() {
  37.     char x[2048];
  38.  
  39.     x[0] = 'X';
  40.     proc(0);
  41.  
  42.     puts("Done.\n");
  43.  
  44.     exit(0);
  45. }
  46.