1: #
   2: /*
   3:  * UNIX shell
   4:  *
   5:  * S. R. Bourne
   6:  * Bell Telephone Laboratories
   7:  *
   8:  */
   9: 
  10: #include    "defs.h"
  11: 
  12: STKPTR      stakbot=nullstr;
  13: 
  14: 
  15: 
  16: /* ========	storage allocation	======== */
  17: 
  18: STKPTR  getstak(asize)
  19:     INT     asize;
  20: {   /* allocate requested stack */
  21:     REG STKPTR  oldstak;
  22:     REG INT     size;
  23: 
  24:     size=round(asize,BYTESPERWORD);
  25:     oldstak=stakbot;
  26:     staktop = stakbot += size;
  27:     return(oldstak);
  28: }
  29: 
  30: STKPTR  locstak()
  31: {   /* set up stack for local use
  32: 	 * should be followed by `endstak'
  33: 	 */
  34:     IF brkend-stakbot<BRKINCR
  35:     THEN    setbrk(brkincr);
  36:         IF brkincr < BRKMAX
  37:         THEN    brkincr += 256;
  38:         FI
  39:     FI
  40:     return(stakbot);
  41: }
  42: 
  43: STKPTR  savstak()
  44: {
  45:     assert(staktop==stakbot);
  46:     return(stakbot);
  47: }
  48: 
  49: STKPTR  endstak(argp)
  50:     REG STRING  argp;
  51: {   /* tidy up after `locstak' */
  52:     REG STKPTR  oldstak;
  53:     *argp++=0;
  54:     oldstak=stakbot; stakbot=staktop=round(argp,BYTESPERWORD);
  55:     return(oldstak);
  56: }
  57: 
  58: VOID    tdystak(x)
  59:     REG STKPTR  x;
  60: {
  61:     /* try to bring stack back to x */
  62:     WHILE ADR(stakbsy)>ADR(x)
  63:     DO free(stakbsy);
  64:        stakbsy = stakbsy->word;
  65:     OD
  66:     staktop=stakbot=max(ADR(x),ADR(stakbas));
  67:     rmtemp(x);
  68: }
  69: 
  70: stakchk()
  71: {
  72:     IF (brkend-stakbas)>BRKINCR+BRKINCR
  73:     THEN    setbrk(-BRKINCR);
  74:     FI
  75: }
  76: 
  77: STKPTR  cpystak(x)
  78:     STKPTR      x;
  79: {
  80:     return(endstak(movstr(x,locstak())));
  81: }

Defined functions

cpystak defined in line 77; used 3 times
endstak defined in line 49; used 6 times
getstak defined in line 18; used 14 times
locstak defined in line 30; used 8 times
savstak defined in line 43; used 2 times
stakchk defined in line 70; used 1 times
tdystak defined in line 58; used 3 times
Last modified: 1981-07-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 807
Valid CSS Valid XHTML 1.0 Strict