Annotation of 43BSD/usr.lib/libF77/main.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1980 Regents of the University of California.
        !             3:  * All rights reserved.  The Berkeley software License Agreement
        !             4:  * specifies the terms and conditions for redistribution.
        !             5:  *
        !             6:  *     @(#)main.c      5.2     6/26/85
        !             7:  */
        !             8: #include <stdio.h>
        !             9: #include <signal.h>
        !            10: #include "../libI77/fiodefs.h"
        !            11: 
        !            12: int xargc;
        !            13: char **xargv;
        !            14: 
        !            15: main(argc, argv, arge)
        !            16: int argc;
        !            17: char **argv;
        !            18: char **arge;
        !            19: {
        !            20: int sigdie();
        !            21: long int (*sigf)();
        !            22: int signum;
        !            23: 
        !            24: xargc = argc;
        !            25: xargv = argv;
        !            26: 
        !            27: for (signum=1; signum<=16; signum++)
        !            28: {
        !            29:        if((sigf=signal(signum, sigdie)) != SIG_DFL) signal(signum, sigf);
        !            30: }
        !            31: 
        !            32: #ifdef pdp11
        !            33:        ldfps(01200); /* detect overflow as an exception */
        !            34: #endif
        !            35: 
        !            36: f_init();
        !            37: MAIN_();
        !            38: f_exit();
        !            39: return 0;
        !            40: }
        !            41: 
        !            42: struct action {
        !            43:        char *mesg;
        !            44:        int   core;
        !            45: } sig_act[16] = {
        !            46:        {"Hangup", 0},                  /* SIGHUP  */
        !            47:        {"Interrupt!", 0},              /* SIGINT  */
        !            48:        {"Quit!", 1},                   /* SIGQUIT */
        !            49:        {"Illegal ", 1},                /* SIGILL  */
        !            50:        {"Trace Trap", 1},              /* SIGTRAP */
        !            51:        {"IOT Trap", 1},                /* SIGIOT  */
        !            52:        {"EMT Trap", 1},                /* SIGEMT  */
        !            53:        {"Arithmetic Exception", 1},    /* SIGFPE  */
        !            54:        { 0, 0},                        /* SIGKILL */
        !            55:        {"Bus error", 1},               /* SIGBUS  */
        !            56:        {"Segmentation violation", 1},  /* SIGSEGV */
        !            57:        {"Sys arg", 1},                 /* SIGSYS  */
        !            58:        {"Open pipe", 0},               /* SIGPIPE */
        !            59:        {"Alarm", 0},                   /* SIGALRM */
        !            60:        {"Terminated", 0},              /* SIGTERM */
        !            61:        {"Sig 16", 0},                  /* unassigned */
        !            62: };
        !            63: 
        !            64: struct action act_fpe[] = {
        !            65:        {"Integer overflow", 1},
        !            66:        {"Integer divide by 0", 1},
        !            67:        {"Floating point overflow trap", 1},
        !            68:        {"Floating divide by zero trap", 1},
        !            69:        {"Floating point underflow trap", 1},
        !            70:        {"Decimal overflow", 1},
        !            71:        {"Subscript range", 1},
        !            72:        {"Floating point overflow", 0},
        !            73:        {"Floating divide by zero", 0},
        !            74:        {"Floating point underflow", 0},
        !            75: };
        !            76: 
        !            77: struct action act_ill[] = {
        !            78:        {"addr mode", 1},
        !            79:        {"instruction", 1},
        !            80:        {"operand", 0},
        !            81: };
        !            82: 
        !            83: #if    vax
        !            84: sigdie(s, t, sc)
        !            85: int s; int t; struct sigcontext *sc;
        !            86: 
        !            87: #else  pdp11
        !            88: sigdie(s, t, pc)
        !            89: int s; int t; long pc;
        !            90: 
        !            91: #endif
        !            92: {
        !            93: extern unit units[];
        !            94: register struct action *act = &sig_act[s-1];
        !            95: /* print error message, then flush buffers */
        !            96: 
        !            97: if (s == SIGHUP || s == SIGINT || s == SIGQUIT)
        !            98:        signal(s, SIG_IGN);     /* don't allow it again */
        !            99: else
        !           100:        signal(s, SIG_DFL);     /* shouldn't happen again, but ... */
        !           101: 
        !           102: if (act->mesg)
        !           103:        {
        !           104:        fprintf(units[STDERR].ufd, "*** %s", act->mesg);
        !           105:        if (s == SIGFPE)
        !           106:                {
        !           107:                if (t >= 1 && t <= 10)
        !           108:                        fprintf(units[STDERR].ufd, ": %s", act_fpe[t-1].mesg);
        !           109:                else
        !           110:                        fprintf(units[STDERR].ufd, ": Type=%d?", t);
        !           111:                }
        !           112:        else if (s == SIGILL)
        !           113:                {
        !           114:                if (t == 4) t = 2;      /* 4.0bsd botch */
        !           115:                if (t >= 0 && t <= 2)
        !           116:                        fprintf(units[STDERR].ufd, "%s", act_ill[t].mesg);
        !           117:                else
        !           118:                        fprintf(units[STDERR].ufd, "compat mode: Code=%d", t);
        !           119:                }
        !           120:        putc('\n', units[STDERR].ufd);
        !           121:        }
        !           122: f77_abort( s, act->core );
        !           123: }

unix.superglobalmegacorp.com

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