Annotation of 3BSD/cmd/lisp/inits.c, revision 1.1

1.1     ! root        1: #include "global.h"
        !             2: #include <signal.h>
        !             3: /************************************************************************/
        !             4: /*                                                                      */
        !             5: /*   file: inits.i                                                      */
        !             6: /*   contents: initialization routines                                  */
        !             7: /*                                                                      */
        !             8: 
        !             9: 
        !            10: /* initial **************************************************************/
        !            11: /* initializes the parts of the system that cannot be automatically    */
        !            12: /* accomplished in the declarations.                                   */
        !            13: 
        !            14: int reborn=0;  /*  flag to tell whether we are in fast-load version  */
        !            15: extern char *stabf;
        !            16: extern int fvirgin;
        !            17: extern int keywait;
        !            18: extern sigstruck, sigdelay;
        !            19: initial()
        !            20: {
        !            21:        int sigalrmh(), sigfpeh(),  siginth();
        !            22:        lispval Isstatus(),Istsrch();
        !            23: 
        !            24:        if( signal(SIGINT,SIG_IGN) != SIG_IGN)
        !            25:              signal(SIGINT,siginth);
        !            26:        if( signal(SIGHUP,SIG_IGN) != SIG_IGN)
        !            27:              signal(SIGHUP,siginth);
        !            28:        signal(SIGFPE,siginth);
        !            29:        signal(SIGALRM,siginth);
        !            30:        /* signals SIGBUS and SIGSEGV will be set up when the status list
        !            31:           is set up when the lisp is virgin, and will be set up according
        !            32:           to the current value on the status list if the lisp is reborn
        !            33:        */
        !            34: 
        !            35:        if( reborn ) {
        !            36:                register FILE *p = _iob + 3;
        !            37:                static FILE empty;
        !            38:                for(; p < _iob + _NFILE; p++)
        !            39:                        *p = empty;
        !            40:                np = lbot = orgnp;
        !            41:                stabf = 0;
        !            42:                fvirgin = 1;
        !            43:                loading->clb = nil;
        !            44: 
        !            45:                /* set up SIGBUS and SIGSEGV from current value 
        !            46:                   of status flag dumpcore
        !            47:                */
        !            48:                Isstatus(matom("dumpcore"),
        !            49:                         (Istsrch(matom("dumpcore")))->cdr->cdr->cdr);
        !            50: 
        !            51:                makenv();
        !            52:                return;
        !            53:        }
        !            54:        for (hash=0;hash<HASHTOP;hash++) hasht[hash] = (struct atom *) CNIL;
        !            55:        
        !            56:        sbrk( NBPG-(((int)sbrk(0)) % NBPG) );   /* even up the break */
        !            57:        makevals();
        !            58: 
        !            59:        orgnp = np;
        !            60:        makenv();
        !            61: 
        !            62: }
        !            63: 
        !            64: static
        !            65: makenv()
        !            66: {
        !            67:        register lispval env, temp;
        !            68:        register char *p, *q;
        !            69:        register struct argent *lbot, *np;
        !            70:        char **envp, envstr[64];
        !            71:        extern char **environ;
        !            72: 
        !            73:        lbot = np;
        !            74:        env = nil;
        !            75:        np++->val = env;
        !            76:        for (envp=environ; *envp!=NULL; envp++) ;
        !            77:        while (--envp >= environ) {
        !            78:                for(p= *envp,q=envstr; (*q++ = *p++)!='=';);
        !            79:                *--q = 0;
        !            80:                /* at this point lbot->val==env, so it is protected
        !            81:                   from gc */
        !            82:                lbot->val = temp = newdot();
        !            83:                temp->cdr = env;
        !            84:                env = temp;
        !            85:                temp = newdot();
        !            86:                temp->car = matom(envstr);
        !            87:                temp->cdr = matom(p);
        !            88:                env->car = temp;
        !            89:        }
        !            90:        matom("environment")->clb = env;
        !            91: }
        !            92: 
        !            93: siginth(signo){
        !            94:        signal(signo,siginth);
        !            95:        sigstruck |= (1 << signo);
        !            96:        /*if(signo==SIGBUS || signo==SIGBUS || keywait)*/
        !            97:                sigcall(signo);
        !            98: }
        !            99: sigcall(which)
        !           100: register which;
        !           101: {
        !           102:        extern lispval Lfuncal();
        !           103:        extern lispval sigacts[16];
        !           104:        struct argent *oldlbot, *oldnp, saved;
        !           105: 
        !           106:        if(sigacts[which]!=((lispval) 0)) {
        !           107:                oldlbot = lbot;
        !           108:                oldnp = np;
        !           109:                lbot = np;
        !           110:                np -> val = sigacts[which];
        !           111:                INRNP;
        !           112:                np -> val = inewint(which);
        !           113:                INRNP;
        !           114:                Lfuncal();
        !           115:                lbot = oldlbot;
        !           116:                np = oldnp;
        !           117:        }
        !           118:        sigstruck &= ~ (1<<which);
        !           119: }
        !           120: delayoff(){
        !           121:        sigdelay = FALSE;
        !           122:        if(sigstruck)
        !           123:                dosig();
        !           124: }
        !           125: dosig()
        !           126: {
        !           127:        register int i; int which;
        !           128:        if(!sigdelay) 
        !           129:                for(which=0, i = 1;  i <= 65536;  which++,i<<=1) {
        !           130:                        keywait = FALSE;
        !           131:                        if(sigstruck & i)
        !           132:                                sigcall(which);
        !           133:                }
        !           134: }
        !           135: badmemr(number)
        !           136: {
        !           137:        signal(number,badmemr);
        !           138:        fflush(stdout);
        !           139:        error("Internal bad memory reference, you are advised to (reset).",FALSE);
        !           140: }

unix.superglobalmegacorp.com

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