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