/* TestSignal.c June 21, 1982 4:55 PM */ #include <Alloc.h> #include <Signal.h> #include <Env.h> extern int *Alloc(); extern Deb(); extern int *MyFrame(); extern struct ZN *GetAll(); struct ZN *sysZone; int sig1, sig2, sig3; int sigResult; int *sigVec; /* TEMP */ int adrPA, adrPS, adrPU, adrPUE, adrGetSigVec; /* TEMP */ main() { struct Seal s1, su, sa, su2; /* TEMP */ adrs(); /* TEMP */ sysZone = GetAll(); sigResult = CONTINUE; sigVec = Alloc(sysZone, 100); SigInit(sigVec, 100, adrGetSigVec); TestPurger(); if (ENABLE(ANY, adrPA, &sa)) { Deb("Continue from ANY"); }; sig1=CODE();sig2=CODE();sig3=CODE(); if (ENABLE(sig1, adrPS, &s1)) { Deb("Continue from Sig1"); P5() }; else { ENABLE(UNWIND, adrPU, &su); ENABLE(UNWIND, adrPU, &su2); P2(); }; Deb("Called P2 from Test"); EnableUnwind(&su); P2();}; Deb(msg) char *msg; { Wf1("%s\r", msg); getchar(); }; int PS(sig, code, seal) int sig, code; struct Seal *seal; { Deb("Sig Caught"); return sigResult; }; int PU(sig, code, seal) int sig, code; struct Seal *seal; { Deb("Unwinding"); }; int PA(sig, code, seal) int sig, code; struct Seal *seal; { Deb("Any Caught"); return sigResult; }; EnableUnwind(seal) struct Seal *seal; { ENABLEWithFrame(UNWIND, adrPUE, seal, MyFrame()); }; PUE(sign, code, seal) int sign, code; struct Seal *seal; { Deb("Unwinding, the hard way"); }; P2() { P3(); Deb("Called P3 from P2"); }; P3() { struct Seal s3; ENABLE(UNWIND, adrPU, &s3); P4(); Deb("Called P4 from P3"); }; P4() { SIGNAL(sig1, 3); Deb("Resumed after raising sig1 in P4"); }; P5() { Deb("Call P5 from Continue code in Test"); }; TestPurger() { struct Seal1 seal, seal2; ENABLE(sig1, adrPU, &seal); DISABLE(&seal); ENABLE(sig1, adrPU, &seal2); /* 1 */ TP1(); /* 2 */ ENABLE(sig1, adrPU, &seal2); }; /* 1 */ TP1() { struct Seal1 seal; ENABLE(sig1, adrPU, &seal); /* 2 */ TP2(); /* 3 */ TP3(); /* 3 */ ENABLE(sig1, adrPU, &seal); /* 2 */ }; TP2() { TP3(); }; /* 3 */ TP3() { struct Seal1 seal; ENABLE(sig1, adrPU, &seal); /* 3 */ }; int *GetSigVec() { return sigVec; }; adrs() /* TEMP until &P works */ { #asm MOV ←adrPA,OFFSET ←PA MOV ←adrPS,OFFSET ←PS MOV ←adrPU,OFFSET ←PU MOV ←adrPUE,OFFSET ←PUE MOV ←adrGetSigVec,OFFSET ←GetSigVec #endasm };