date and time created 82/05/12 10:51:48 by rrh
authorRobert R. Henry <rrh@ucbvax.Berkeley.EDU>
Thu, 13 May 1982 01:51:48 +0000 (17:51 -0800)
committerRobert R. Henry <rrh@ucbvax.Berkeley.EDU>
Thu, 13 May 1982 01:51:48 +0000 (17:51 -0800)
SCCS-vsn: old/games.vax/compat/Original/dosig.c 1.1

usr/src/old/games.vax/compat/Original/dosig.c [new file with mode: 0644]

diff --git a/usr/src/old/games.vax/compat/Original/dosig.c b/usr/src/old/games.vax/compat/Original/dosig.c
new file mode 100644 (file)
index 0000000..5fb1b2e
--- /dev/null
@@ -0,0 +1,57 @@
+#
+static char sccsid[] = "       dosig.c 1.1     82/05/12        ";
+
+/*     Handle signal trapping from version 6 or version 7 compatability
+ *     mode programs.
+ *     Art Wetzel      November 1979
+ */
+#ifdef TRACE
+#include <stdio.h>
+#endif
+#include <signal.h>
+#include "defs.h"
+unsigned int  sigvals[NSIG+1];
+/* actual catch point for all signals */
+sigcatch(signum) int signum; {
+       unsigned short *pcptr;
+       extern getregs();
+       if(incompat) {
+               /* hurry up and get the registers before they are destroyed */
+               getregs();
+       } else {
+               /* we were in native mode simulating a sys call */
+               /* set it up with the old values */
+               dosig(signum, pc);
+               /* go back where we were doing the sys call */
+               return(0);
+       }
+       /* figure out the pc */
+       pcptr = (unsigned short *)((char *)&pcptr + 20);
+       pc = (unsigned short *) *pcptr;
+       /* get the psl with condition codes */
+       /* requires UNIX-32V patch to not clear out condition codes */
+       psl = 0x83c00000 | (*(pcptr - 6) & 017);
+       /* actually do the thing */
+       if(sigvals[signum] != (unsigned int)SIG_DFL && (sigvals[signum] & (unsigned int)SIG_IGN) == 0)
+               dosig(signum, pc);
+       /* go back to compatability mode and the signal routine there */
+       incompat++;
+       compat();
+}
+/* routine to set up pdp11 space for return from a signal */
+dosig(signum, from) {
+       unsigned short *sp;
+#ifdef TRACE
+       fprintf(stderr,"Caught sig %d from 0%o -> 0%o\n",signum,(pc-1),*(pc-1));
+#endif
+       /* where is the stack */
+       sp = (unsigned short *)regs[6];
+       /* stack up psw condition codes so rti works */
+       *(--sp) = psl & 017;
+       /* stack pc */
+       *(--sp) = (unsigned short)(int)pc;
+       /* reset stack pointer */
+       regs[6] = (unsigned short)(int)sp;
+       /* reset pc to signal catching routine */
+       pc = (unsigned short *)sigvals[signum];
+}