Annotation of 42BSD/games/compat/dosig.c, revision 1.1.1.1

1.1       root        1: static char sccsid[] = "@(#)dosig.c    4.2  83/07/31";
                      2: 
                      3: /*
                      4:  * Handle signal trapping from version 6 or
                      5:  * version 7 compatability mode programs.
                      6:  *     Art Wetzel      November 1979
                      7:  */
                      8: 
                      9: #ifdef TRACE
                     10: #include <stdio.h>
                     11: #endif
                     12: #include <signal.h>
                     13: #include "defs.h"
                     14: 
                     15: unsigned int  sigvals[NSIG+1];
                     16: 
                     17: /* actual catch point for all signals */
                     18: sigcatch(signum, faultcode, scp)
                     19:        int signum, faultcode;
                     20:        struct sigcontext *scp;
                     21: {
                     22:        unsigned short *pcptr;
                     23:        extern getregs();
                     24:        if(incompat) {
                     25:                /* hurry up and get the registers before they are destroyed */
                     26:                getregs();
                     27:        } else {
                     28:                /* we were in native mode simulating a sys call */
                     29:                /* set it up with the old values */
                     30:                dosig(signum, pc);
                     31:                /* go back where we were doing the sys call */
                     32:                return(0);
                     33:        }
                     34:        /* figure out the pc */
                     35:        pcptr = (unsigned short *) &scp->sc_pc;
                     36:        pc = (unsigned short *) *pcptr;
                     37:        /* get the psl with condition codes */
                     38:        psl = 0x83c00000 | (scp->sc_ps & 017);
                     39:        /* actually do the thing */
                     40:        if (sigvals[signum] != (unsigned int)SIG_DFL &&
                     41:            (sigvals[signum] & (unsigned int)SIG_IGN) == 0)
                     42:                dosig(signum, pc);
                     43:        /* go back to compatability mode and the signal routine there */
                     44:        sigsetmask(scp->sc_mask);
                     45:        incompat++;
                     46:        compat();
                     47: }
                     48: 
                     49: /* routine to set up pdp11 space for return from a signal */
                     50: dosig(signum, from)
                     51:        int signum, from;
                     52: {
                     53:        unsigned short *sp;
                     54: 
                     55: #ifdef TRACE
                     56:        fprintf(stderr,"Caught sig %d from 0%o -> 0%o\n",signum,(pc-1),*(pc-1));
                     57: #endif
                     58:        /* where is the stack */
                     59:        sp = (unsigned short *)regs[6];
                     60:        /* stack up psw condition codes so rti works */
                     61:        *(--sp) = psl & 017;
                     62:        /* stack pc */
                     63:        *(--sp) = (unsigned short)(int)pc;
                     64:        /* reset stack pointer */
                     65:        regs[6] = (unsigned short)(int)sp;
                     66:        /* reset pc to signal catching routine */
                     67:        pc = (unsigned short *)sigvals[signum];
                     68:        signal(signum, SIG_DFL);
                     69: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.