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

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

unix.superglobalmegacorp.com

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