Annotation of researchv10no/cmd/compat/dosig.c, revision 1.1.1.1

1.1       root        1: #define FBSD
                      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: #ifdef FBSD
                     14: sigcatch(signum,faultcode,myaddr,stpc,stps) int signum;
                     15: #else
                     16: sigcatch(signum) int signum;
                     17: #endif
                     18: {
                     19:        unsigned short *pcptr;
                     20:        extern getregs();
                     21:        if(incompat) {
                     22:                /* hurry up and get the registers before they are destroyed */
                     23:                getregs();
                     24:        } else {
                     25:                /* we were in native mode simulating a sys call */
                     26:                /* set it up with the old values */
                     27:                dosig(signum, pc);
                     28:                /* go back where we were doing the sys call */
                     29:                return(0);
                     30:        }
                     31:        /* figure out the pc */
                     32: #ifdef FBSD
                     33:        pcptr = (unsigned short *) &stpc;
                     34: #else
                     35:        pcptr = (unsigned short *)((char *)&pcptr + 20);
                     36: #endif
                     37:        pc = (unsigned short *) *pcptr;
                     38:        /* get the psl with condition codes */
                     39:        /* requires UNIX-32V patch to not clear out condition codes */
                     40: #ifdef FBSD
                     41:        psl = 0x83c00000 | (stps & 017);
                     42: #else
                     43:        psl = 0x83c00000 | (*(pcptr - 6) & 017);
                     44: #endif
                     45:        /* actually do the thing */
                     46:        if(sigvals[signum] != (unsigned int)SIG_DFL && (sigvals[signum] & (unsigned int)SIG_IGN) == 0)
                     47:                dosig(signum, pc);
                     48:        /* go back to compatability mode and the signal routine there */
                     49:        incompat++;
                     50:        compat();
                     51: }
                     52: /* routine to set up pdp11 space for return from a signal */
                     53: dosig(signum, from) {
                     54:        unsigned short *sp;
                     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: }

unix.superglobalmegacorp.com

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