1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28 /* All Rights Reserved */ 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 /* 32 * UNIX shell 33 */ 34 35 /* To use stack as temporary workspace across 36 * possible storage allocation (eg name lookup) 37 * a) get ptr from `relstak' 38 * b) can now use `pushstak' 39 * c) then reset with `setstak' 40 * d) `absstak' gives real address if needed 41 */ 42 #define relstak() (staktop-stakbot) 43 #define absstak(x) (stakbot+Rcheat(x)) 44 #define setstak(x) (staktop=absstak(x)) 45 #define pushstak(c) (*staktop++=(c)) 46 #define zerostak() (*staktop=0) 47 48 /* Used to address an item left on the top of 49 * the stack (very temporary) 50 */ 51 #define curstak() (staktop) 52 53 /* `usestak' before `pushstak' then `fixstak' 54 * These routines are safe against heap 55 * being allocated. 56 */ 57 #define usestak() {locstak();} 58 59 /* for local use only since it hands 60 * out a real address for the stack top 61 */ 62 extern unsigned char *locstak(); 63 64 /* Will allocate the item being used and return its 65 * address (safe now). 66 */ 67 #define fixstak() endstak(staktop) 68 69 /* For use after `locstak' to hand back 70 * new stack top and then allocate item 71 */ 72 extern unsigned char *endstak(); 73 74 /* Copy a string onto the stack and 75 * allocate the space. 76 */ 77 extern unsigned char *cpystak(); 78 79 /* Copy a string onto the stack, checking for stack overflow 80 * as the copy is done. Same calling sequence as "movstr". 81 */ 82 extern unsigned char *movstrstak(); 83 84 /* Move bytes onto the stack, checking for stack overflow 85 * as the copy is done. Same calling sequence as the C 86 * library routine "memcpy". 87 */ 88 extern unsigned char *memcpystak(); 89 90 /* Allocate given ammount of stack space */ 91 extern unsigned char *getstak(); 92 93 /* Grow the data segment to include a given location */ 94 extern void growstak(); 95 96 /* A chain of ptrs of stack blocks that 97 * have become covered by heap allocation. 98 * `tdystak' will return them to the heap. 99 */ 100 extern struct blk *stakbsy; 101 102 /* Base of the entire stack */ 103 extern unsigned char *stakbas; 104 105 /* Top of entire stack */ 106 extern unsigned char *brkend; 107 108 /* Base of current item */ 109 extern unsigned char *stakbot; 110 111 /* Top of current item */ 112 extern unsigned char *staktop; 113 114 /* Used with tdystak */ 115 extern unsigned char *savstak(); 116