#ifndef lint static char sccsid[] = "@(#)stak.c 4.2 8/11/83"; #endif # /* * UNIX shell * * S. R. Bourne * Bell Telephone Laboratories * */ #include "defs.h" STKPTR stakbot=nullstr; /* ======== storage allocation ======== */ STKPTR getstak(asize) INT asize; { /* allocate requested stack */ REG STKPTR oldstak; REG INT size; size=round(asize,BYTESPERWORD); oldstak=stakbot; staktop = stakbot += size; return(oldstak); } STKPTR locstak() { /* set up stack for local use * should be followed by `endstak' */ IF brkend-stakbotADR(x) DO free(stakbsy); stakbsy = stakbsy->word; OD staktop=stakbot=max(ADR(x),ADR(stakbas)); rmtemp(x); } stakchk() { IF (brkend-stakbas)>BRKINCR+BRKINCR THEN setbrk(-BRKINCR); FI } STKPTR cpystak(x) STKPTR x; { return(endstak(movstr(x,locstak()))); }