1994-06-24 11:31:16 +00:00
|
|
|
/* $Id$ */
|
1988-06-22 16:57:09 +00:00
|
|
|
|
|
|
|
/* The Return Status Block contains, in push order:
|
|
|
|
FIL, LIN, LB, PC, PI, rsbcode
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "logging.h"
|
|
|
|
#include "global.h"
|
|
|
|
#include "mem.h"
|
|
|
|
#include "rsb.h"
|
|
|
|
#include "proctab.h"
|
|
|
|
#include "linfil.h"
|
|
|
|
#include "shadow.h"
|
2019-03-17 14:42:00 +00:00
|
|
|
#include "segment.h"
|
|
|
|
#include "text.h"
|
1988-06-22 16:57:09 +00:00
|
|
|
#include "warn.h"
|
Cut down some clang warnings
Edit C code to reduce warnings from clang. Most warnings are for
implicit declarations of functions, but some warnings want me to add
parentheses or curly braces, or to cast arguments for printf().
Make a few other changes, like declaring float_cst() in h/con_float to
be static, and using C99 bool in ego/ra/makeitems.c and
ego/share/makecldef.c. Such changes don't silence warnings; I make
such changes while I silence warnings in the same file. In
float_cst(), rename parameter `str` to `float_str`, so it doesn't
share a name with the global variable `str`.
Remove `const` from `newmodule(const char *)` in mach/proto/as to
silence a warning. I wrongly added the `const` in d347207.
For warnings about implicit declarations of functions, the fix is to
declare the function before calling it. For example, my OpenBSD
system needs <sys/wait.h> to declare wait().
In util/int, add "whatever.h" to declare more functions. Remove old
declarations from "mem.h", to prefer the newer declarations of the
same functions in "data.h" and "stack.h".
2019-10-23 20:06:36 +00:00
|
|
|
#include "whatever.h"
|
1988-06-22 16:57:09 +00:00
|
|
|
|
|
|
|
/* offsets to be added to a local base */
|
|
|
|
int rsb_rsbcode;
|
|
|
|
int rsb_PI;
|
|
|
|
int rsb_PC;
|
|
|
|
int rsb_LB;
|
|
|
|
int rsb_LIN;
|
|
|
|
int rsb_FIL;
|
|
|
|
int rsbsize;
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
void init_rsb(void)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
rsb_rsbcode = 0;
|
|
|
|
rsb_PI = wsize;
|
|
|
|
rsb_PC = rsb_PI + psize;
|
|
|
|
rsb_LB = rsb_PC + psize;
|
|
|
|
rsb_LIN = rsb_LB + psize;
|
|
|
|
rsb_FIL = rsb_LIN + LINSIZE;
|
|
|
|
rsbsize = rsb_FIL + psize;
|
|
|
|
}
|
|
|
|
|
2019-03-17 14:42:00 +00:00
|
|
|
void pushrsb(int rsbcode)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
/* fill Return Status Block */
|
1989-11-22 13:38:37 +00:00
|
|
|
incSP((size)rsbsize);
|
1988-06-22 16:57:09 +00:00
|
|
|
|
|
|
|
st_stdp(SP + rsb_FIL, getFIL());
|
|
|
|
st_prot(SP + rsb_FIL, psize);
|
|
|
|
|
|
|
|
st_stn(SP + rsb_LIN, (long)getLIN(), LINSIZE);
|
|
|
|
st_prot(SP + rsb_LIN, LINSIZE);
|
|
|
|
|
|
|
|
st_stdp(SP + rsb_LB, LB);
|
|
|
|
st_prot(SP + rsb_LB, psize);
|
|
|
|
|
|
|
|
st_stip(SP + rsb_PC, PC);
|
|
|
|
st_prot(SP + rsb_PC, psize);
|
|
|
|
|
|
|
|
st_stn(SP + rsb_PI, PI, psize);
|
|
|
|
st_prot(SP + rsb_PI, psize);
|
|
|
|
|
1989-11-22 13:38:37 +00:00
|
|
|
st_stw(SP + rsb_rsbcode, (long)rsbcode);
|
1988-06-22 16:57:09 +00:00
|
|
|
st_prot(SP + rsb_rsbcode, wsize);
|
|
|
|
|
|
|
|
newLB(SP);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
2019-03-17 14:42:00 +00:00
|
|
|
int poprsb(int rtt) /* set to 1 if working for RTT */
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
/* pops the RSB and returns the rsbcode, for further testing */
|
|
|
|
register int rsbcode;
|
|
|
|
|
|
|
|
#ifdef LOGGING
|
|
|
|
{
|
|
|
|
/* check SP */
|
|
|
|
register ptr properSP = LB - proctab[PI].pr_nloc;
|
|
|
|
|
|
|
|
if (SP < properSP)
|
|
|
|
warning(rtt ? WRTTSTL : WRETSTL);
|
|
|
|
if (SP > properSP)
|
|
|
|
warning(rtt ? WRTTSTS : WRETSTS);
|
|
|
|
}
|
1991-12-17 15:28:58 +00:00
|
|
|
#endif /* LOGGING */
|
1988-06-22 16:57:09 +00:00
|
|
|
|
|
|
|
/* discard stack up to RSB */
|
|
|
|
newSP(LB);
|
|
|
|
|
|
|
|
/* get RSB code and test it for applicability */
|
1989-11-22 13:38:37 +00:00
|
|
|
rsbcode = st_lduw(SP + rsb_rsbcode);
|
1988-06-22 16:57:09 +00:00
|
|
|
if ((rsbcode & RSBMASK) != RSBCODE) /* no RSB at all */
|
|
|
|
return rsbcode;
|
|
|
|
|
|
|
|
if (rsbcode != RSB_STP) {
|
|
|
|
/* Restore registers PI, PC, LB, LIN and FIL
|
|
|
|
from Return Status Block
|
|
|
|
*/
|
|
|
|
PI = st_lds(SP + rsb_PI, psize);
|
|
|
|
newPC(st_ldip(SP + rsb_PC));
|
|
|
|
newLB(st_lddp(SP + rsb_LB));
|
|
|
|
putLIN((long) st_ldu(SP + rsb_LIN, LINSIZE));
|
|
|
|
putFIL(st_lddp(SP + rsb_FIL));
|
|
|
|
|
|
|
|
/* remove RSB */
|
|
|
|
st_dec(rsbsize);
|
|
|
|
|
|
|
|
pop_frames();
|
|
|
|
}
|
|
|
|
|
|
|
|
return rsbcode;
|
|
|
|
}
|
|
|
|
|