1: /* stak.h 4.1 82/05/07 */
2:
3: #
4: /*
5: * UNIX shell
6: *
7: * S. R. Bourne
8: * Bell Telephone Laboratories
9: *
10: */
11:
12: /* To use stack as temporary workspace across
13: * possible storage allocation (eg name lookup)
14: * a) get ptr from `relstak'
15: * b) can now use `pushstak'
16: * c) then reset with `setstak'
17: * d) `absstak' gives real address if needed
18: */
19: #define relstak() (staktop-stakbot)
20: #define absstak(x) (stakbot+Rcheat(x))
21: #define setstak(x) (staktop=absstak(x))
22: #define pushstak(c) (*staktop++=(c))
23: #define zerostak() (*staktop=0)
24:
25: /* Used to address an item left on the top of
26: * the stack (very temporary)
27: */
28: #define curstak() (staktop)
29:
30: /* `usestak' before `pushstak' then `fixstak'
31: * These routines are safe against heap
32: * being allocated.
33: */
34: #define usestak() {locstak();}
35:
36: /* for local use only since it hands
37: * out a real address for the stack top
38: */
39: STKPTR locstak();
40:
41: /* Will allocate the item being used and return its
42: * address (safe now).
43: */
44: #define fixstak() endstak(staktop)
45:
46: /* For use after `locstak' to hand back
47: * new stack top and then allocate item
48: */
49: STKPTR endstak();
50:
51: /* Copy a string onto the stack and
52: * allocate the space.
53: */
54: STKPTR cpystak();
55:
56: /* Allocate given ammount of stack space */
57: STKPTR getstak();
58:
59: /* A chain of ptrs of stack blocks that
60: * have become covered by heap allocation.
61: * `tdystak' will return them to the heap.
62: */
63: BLKPTR stakbsy;
64:
65: /* Base of the entire stack */
66: STKPTR stakbas;
67:
68: /* Top of entire stack */
69: STKPTR brkend;
70:
71: /* Base of current item */
72: STKPTR stakbot;
73:
74: /* Top of current item */
75: STKPTR staktop;
76:
77: /* Used with tdystak */
78: STKPTR savstak();
Defined macros
Usage of this include