Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 #include <elf.h>
00051 #ifndef _SYS_TYPES_H
00052 #include <sys/types.h>
00053 #endif
00054
00055
00056 #include "defs.h"
00057 #include "glob.h"
00058 #include "erglob.h"
00059 #include "erlib.h"
00060 #include "errors.h"
00061 #include "file_util.h"
00062 #include "tracing.h"
00063 #include "symtab.h"
00064 #include "wn.h"
00065 #include "pu_info.h"
00066 #include "ir_bread.h"
00067 #include "anl_driver.h"
00068 #include "w2c_driver.h"
00069 #include "w2f_driver.h"
00070 #include "instr_reader.h"
00071 #include "be_symtab.h"
00072
00073
00074 BOOL Prompf_anl_loaded = FALSE;
00075 BOOL Purple_loaded = FALSE;
00076 BOOL Whirl2f_loaded = FALSE;
00077 BOOL Whirl2c_loaded = FALSE;
00078
00079
00080
00081
00082 #include "w2c_weak.h"
00083 #include "w2f_weak.h"
00084
00085 #if !(defined(__linux__) || defined(__CYGWIN__))
00086 #pragma weak Anl_Cleanup
00087 #endif
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 void
00103 Cleanup_Files (BOOL report,
00104 BOOL delete_dotofile )
00105 {
00106
00107 Set_Error_Line (ERROR_LINE_UNKNOWN);
00108
00109
00110 if ( Src_File != NULL && Src_File != stdin && fclose (Src_File) ) {
00111 if ( report )
00112 ErrMsg ( EC_Src_Close, Src_File_Name, errno );
00113 }
00114 Src_File = NULL;
00115
00116
00117 Free_Input_Info ();
00118
00119
00120 if ( Obj_File != NULL ) {
00121 if (delete_dotofile) {
00122 if (unlink ( Obj_File_Name) ) {
00123 if ( report )
00124 ErrMsg ( EC_Obj_Close, Obj_File_Name, errno );
00125 }
00126 } else if (Obj_File != (FILE *) MMAPPED_FILE) {
00127 if ( fclose (Obj_File) ) {
00128 if ( report )
00129 ErrMsg ( EC_Obj_Close, Obj_File_Name, errno );
00130 }
00131 }
00132 }
00133 Obj_File = NULL;
00134
00135
00136 if ( Lst_File != NULL && Lst_File != stdout && fclose (Lst_File) ) {
00137 if ( report )
00138 ErrMsg ( EC_Lst_Close, Lst_File_Name, errno );
00139 }
00140 Lst_File = NULL;
00141
00142
00143 if ( Tlog_File != NULL && Tlog_File != stdout && fclose (Tlog_File) ) {
00144 if ( report )
00145 ErrMsg ( EC_Tlog_Close, Tlog_File_Name, errno );
00146 }
00147 Lst_File = NULL;
00148
00149 if (Whirl2c_loaded)
00150 W2C_Cleanup();
00151 if (Whirl2f_loaded)
00152 W2F_Cleanup();
00153 #if !(defined(__linux__) || defined(__alpha) || defined(__CYGWIN__))
00154 if (Prompf_anl_loaded)
00155 Anl_Cleanup();
00156 #endif
00157
00158
00159 Set_Trace_File ( NULL );
00160
00161
00162 Tim_File = NULL;
00163
00164
00165 Set_Error_File ( NULL );
00166 Set_Error_Source ( NULL );
00167 }
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180 void
00181 Terminate (INT status)
00182 {
00183
00184 Cleanup_Files ( FALSE, TRUE);
00185
00186 exit (status);
00187 }
00188
00189
00190 void
00191 Early_Terminate (INT status)
00192 {
00193
00194
00195
00196 if (CURRENT_SYMTAB > GLOBAL_SYMTAB && Scope_tab[CURRENT_SYMTAB].preg_tab != NULL) {
00197 Scope_tab[CURRENT_SYMTAB].preg_tab->Un_register(Be_preg_tab);
00198 Be_preg_tab.Clear();
00199 }
00200 for (SYMTAB_IDX scope_level = CURRENT_SYMTAB;
00201 scope_level >= GLOBAL_SYMTAB;
00202 --scope_level)
00203 {
00204 if (Scope_tab[scope_level].st_tab != NULL
00205 && Be_scope_tab[scope_level].be_st_tab != NULL)
00206 {
00207 Scope_tab[scope_level].st_tab->
00208 Un_register(*Be_scope_tab[scope_level].be_st_tab);
00209 Be_scope_tab[scope_level].be_st_tab->Clear();
00210 }
00211 }
00212
00213 Terminate(status);
00214 }