Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
main.c
Go to the documentation of this file.
00001 /*
00002 
00003   Copyright (C) 2000, 2001 Silicon Graphics, Inc.  All Rights Reserved.
00004 
00005   This program is free software; you can redistribute it and/or modify it
00006   under the terms of version 2.1 of the GNU Lesser General Public License 
00007   as published by the Free Software Foundation.
00008 
00009   This program is distributed in the hope that it would be useful, but
00010   WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00012 
00013   Further, this software is distributed without any warranty that it is
00014   free of the rightful claim of any third person regarding infringement 
00015   or the like.  Any license provided herein, whether implied or 
00016   otherwise, applies only to this software file.  Patent licenses, if
00017   any, provided herein do not apply to combinations of this program with 
00018   other software, or any other product whatsoever.  
00019 
00020   You should have received a copy of the GNU Lesser General Public 
00021   License along with this program; if not, write the Free Software 
00022   Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, 
00023   USA.
00024 
00025   Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pky,
00026   Mountain View, CA 94043, or:
00027 
00028   http://www.sgi.com
00029 
00030   For further information regarding this notice, see:
00031 
00032   http://oss.sgi.com/projects/GenInfo/NoticeExplan
00033 
00034 */
00035 
00036 
00037 /* $Header: /m_home/m_utkej/Argonne/cvs2svn/cvs/Open64/osprey1.0/libF77/main.c,v 1.1.1.1 2002-05-22 20:09:12 dsystem Exp $ */
00038 /*      3.0 SID #       1.2     */
00039 /* STARTUP PROCEDURE FOR UNIX FORTRAN PROGRAMS */
00040 
00041 #include <stdio.h>
00042 #include <signal.h>
00043 #include <stdlib.h>
00044 #include <ulocks.h>
00045 #include <unistd.h>
00046 #include "cmplrs/host.h"
00047 
00048 int f77argc;
00049 char **f77argv;
00050 extern int __trap_fpe_override;
00051 extern void s_abort(void), MAIN__(void), f_exit(void);
00052 
00053 /* To get a nice error instead of an RLD error */
00054 #pragma weak MAIN__ = ___MAIN__ 
00055 
00056 extern void     __mp_check_setup(void);
00057 #pragma weak __mp_check_setup
00058 static void (*__mp_ptr)() = __mp_check_setup;
00059 
00060 static void sigdie(register char *, int32 );
00061 
00062 static void sigfdie(void), sigidie(void), sigqdie(void), sigindie(void),
00063     sigtdie(void);      /* DAG */
00064 
00065 main(argc, argv, arge)
00066 int argc;
00067 char **argv;
00068 char **arge;
00069 {
00070 
00071 f77argc = argc;
00072 f77argv = argv;
00073 #ifdef sgi
00074 /* do not override signal handling for trap handler,
00075    set by crt1text: readenv_sigfpe */
00076 
00077 if (! __trap_fpe_override )
00078         signal(SIGFPE, sigfdie);        /* ignore underflow, enable overflow */
00079 #else
00080 signal(SIGFPE, sigfdie);        /* ignore underflow, enable overflow */
00081 #endif
00082 signal(SIGIOT, sigidie);
00083 if( signal(SIGQUIT,sigqdie) == SIG_IGN ) signal(SIGQUIT, SIG_IGN);      /* DAG */
00084 if( signal(SIGINT, sigindie) == SIG_IGN ) signal(SIGINT, SIG_IGN);
00085 signal(SIGTERM,sigtdie);
00086 
00087 /* Unresolved weak symbols are given the value zero */
00088 if (__mp_ptr != 0) (*__mp_ptr)();
00089 
00090 MAIN__();
00091 #ifndef FTN90_IO
00092 f_exit();
00093 #endif
00094 exit(0);
00095 return (0); /* make compiler shut up */
00096 }
00097 
00098 
00099 static void     /* DAG */
00100 sigfdie(void)
00101 {
00102 sigdie("Floating Exception", 1);
00103 }
00104 
00105 
00106 
00107 static void     /* DAG */
00108 sigidie(void)
00109 {
00110 sigdie("IOT Trap", 1);
00111 }
00112 
00113 
00114 static void     /* DAG */
00115 sigqdie(void)
00116 {
00117 sigdie("Quit signal", 1);
00118 }
00119 
00120 
00121 
00122 static void     /* DAG */
00123 sigindie(void)
00124 {
00125 sigdie("Interrupt", 0);
00126 }
00127 
00128 
00129 
00130 static void     /* DAG */
00131 sigtdie(void)
00132 {
00133 sigdie("Killed", 0);
00134 }
00135 
00136 
00137 
00138 void
00139 sigdie(register char *s, int32 coredump)
00140 {
00141 /* print error message, then clear buffers */
00142 fprintf(stderr, "%s\n", s);
00143 fflush(stderr);
00144 
00145 if(coredump)
00146         {
00147         /* now get a core */
00148         signal(SIGIOT, SIG_DFL);        /* DAG */
00149         abort();
00150         }
00151 else
00152         {
00153             int gid;
00154             gid = getpgrp();
00155             signal(SIGINT, SIG_IGN );
00156             gid = kill( -gid, SIGINT );
00157 #ifndef FTN90_IO
00158             f_exit();
00159 #endif
00160             exit(1);
00161         }
00162 }
00163 
00164 void
00165 f_abort(void)
00166 {
00167   s_abort();
00168 }
00169 
00170 
00171 void ___MAIN__(void)
00172 {
00173    fprintf(stderr, "No Fortran MAIN program to execute.\n");
00174    exit(1);
00175 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines