# 2.11BSD#431 - /usr/src/bin/sh/stak.c

##### Functions

    cpystak           X
    endstak           X
    getstak           X
    locstak           X
    savstak           X
    stakchk           X
    tdystak           X

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

#### Defined functions

cpystak defined in line 81; used 3 times

- in /usr/src/bin/sh/io.c line 123
- in /usr/src/bin/sh/service.c line 84
- in /usr/src/bin/sh/stak.h line 54

endstak defined in line 53; used 6 times

- in line 84
- in /usr/src/bin/sh/expand.c line 185
- in /usr/src/bin/sh/service.c line 395
- in /usr/src/bin/sh/stak.h line 44-49(2)
- in /usr/src/bin/sh/word.c line 53

getstak defined in line 22; used 14 times

- in /usr/src/bin/sh/cmd.c line 41, 54, 160, 208, 220, 231, 252, 266, 284, 354
- in /usr/src/bin/sh/name.c line 272, 332
- in /usr/src/bin/sh/service.c line 317
- in /usr/src/bin/sh/stak.h line 57

locstak defined in line 34; used 9 times

- in line 84
- in /usr/src/bin/sh/expand.c line 169
- in /usr/src/bin/sh/io.c line 125
- in /usr/src/bin/sh/macro.c line 201
- in /usr/src/bin/sh/service.c line 104, 384
- in /usr/src/bin/sh/stak.h line 34-39(2)
- in /usr/src/bin/sh/word.c line 24

savstak defined in line 47; used 2 times

- in /usr/src/bin/sh/stak.h line 78
- in /usr/src/bin/sh/xec.c line 32

stakchk defined in line 74; used 1 times

- in /usr/src/bin/sh/main.c line 147

tdystak defined in line 62; used 3 times

- in /usr/src/bin/sh/macro.c line 200
- in /usr/src/bin/sh/main.c line 146
- in /usr/src/bin/sh/xec.c line 407

#### Defined variables

sccsid defined in line 2; never used

Last modified: 1983-08-12 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 738 |