main.c
Go to the documentation of this file.
00001 /* STARTUP PROCEDURE FOR UNIX FORTRAN PROGRAMS */
00002 
00003 #include "stdio.h"
00004 #include "signal1.h"
00005 
00006 #ifndef SIGIOT
00007 #ifdef SIGABRT
00008 #define SIGIOT SIGABRT
00009 #endif
00010 #endif
00011 
00012 #ifndef KR_headers
00013 #undef VOID
00014 #include "stdlib.h"
00015 #ifdef __cplusplus
00016 extern "C" {
00017 #endif
00018 #endif
00019 
00020 #ifndef VOID
00021 #define VOID void
00022 #endif
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027 
00028 #ifdef NO__STDC
00029 #define ONEXIT onexit
00030 extern VOID f_exit();
00031 #else
00032 #ifndef KR_headers
00033 extern void f_exit(void);
00034 #ifndef NO_ONEXIT
00035 #define ONEXIT atexit
00036 extern int atexit(void (*)(void));
00037 #endif
00038 #else
00039 #ifndef NO_ONEXIT
00040 #define ONEXIT onexit
00041 extern VOID f_exit();
00042 #endif
00043 #endif
00044 #endif
00045 
00046 #ifdef KR_headers
00047 extern VOID f_init(), sig_die();
00048 extern int MAIN__();
00049 #define Int /* int */
00050 #else
00051 extern void f_init(void), sig_die(const char*, int);
00052 extern int MAIN__(void);
00053 #define Int int
00054 #endif
00055 
00056 static VOID sigfdie(Sigarg)
00057 {
00058 Use_Sigarg;
00059 sig_die("Floating Exception", 1);
00060 }
00061 
00062 
00063 static VOID sigidie(Sigarg)
00064 {
00065 Use_Sigarg;
00066 sig_die("IOT Trap", 1);
00067 }
00068 
00069 #ifdef SIGQUIT
00070 static VOID sigqdie(Sigarg)
00071 {
00072 Use_Sigarg;
00073 sig_die("Quit signal", 1);
00074 }
00075 #endif
00076 
00077 
00078 static VOID sigindie(Sigarg)
00079 {
00080 Use_Sigarg;
00081 sig_die("Interrupt", 0);
00082 }
00083 
00084 static VOID sigtdie(Sigarg)
00085 {
00086 Use_Sigarg;
00087 sig_die("Killed", 0);
00088 }
00089 
00090 #ifdef SIGTRAP
00091 static VOID sigtrdie(Sigarg)
00092 {
00093 Use_Sigarg;
00094 sig_die("Trace trap", 1);
00095 }
00096 #endif
00097 
00098 
00099 int xargc;
00100 char **xargv;
00101 
00102 #ifdef __cplusplus
00103         }
00104 #endif
00105 
00106  int
00107 #ifdef KR_headers
00108 main(argc, argv) int argc; char **argv;
00109 #else
00110 main(int argc, char **argv)
00111 #endif
00112 {
00113 xargc = argc;
00114 xargv = argv;
00115 signal1(SIGFPE, sigfdie);       /* ignore underflow, enable overflow */
00116 #ifdef SIGIOT
00117 signal1(SIGIOT, sigidie);
00118 #endif
00119 #ifdef SIGTRAP
00120 signal1(SIGTRAP, sigtrdie);
00121 #endif
00122 #ifdef SIGQUIT
00123 if(signal1(SIGQUIT,sigqdie) == SIG_IGN)
00124         signal1(SIGQUIT, SIG_IGN);
00125 #endif
00126 if(signal1(SIGINT, sigindie) == SIG_IGN)
00127         signal1(SIGINT, SIG_IGN);
00128 signal1(SIGTERM,sigtdie);
00129 
00130 #ifdef pdp11
00131         ldfps(01200); /* detect overflow as an exception */
00132 #endif
00133 
00134 f_init();
00135 #ifndef NO_ONEXIT
00136 ONEXIT(f_exit);
00137 #endif
00138 MAIN__();
00139 #ifdef NO_ONEXIT
00140 f_exit();
00141 #endif
00142 exit(0);        /* exit(0) rather than return(0) to bypass Cray bug */
00143 return 0;       /* For compilers that complain of missing return values; */
00144                 /* others will complain that this is unreachable code. */
00145 }
00146 #ifdef __cplusplus
00147 }
00148 #endif


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:56