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
00051
00052
00053
00054
00055 #if ! defined(BUILD_OS_DARWIN)
00056 #include <elf.h>
00057 #endif
00058 #ifndef _SYS_TYPES_H
00059 #include <sys/types.h>
00060 #endif
00061
00062 #include "defs.h"
00063 #include "glob.h"
00064 #include "erglob.h"
00065 #include "erlib.h"
00066 #include "errors.h"
00067 #include "file_util.h"
00068 #include "tracing.h"
00069 #include "symtab.h"
00070 #include "wn.h"
00071 #include "pu_info.h"
00072 #include "ir_bread.h"
00073 #ifndef BUILD_SKIP_PROMPF
00074 #include "anl_driver.h"
00075 #endif
00076 #include "w2c_driver.h"
00077 #include "w2f_driver.h"
00078 #include "instr_reader.h"
00079 #include "be_symtab.h"
00080
00081
00082 BOOL Prompf_anl_loaded = FALSE;
00083 BOOL Purple_loaded = FALSE;
00084 BOOL Whirl2f_loaded = FALSE;
00085 BOOL Whirl2c_loaded = FALSE;
00086
00087
00088
00089
00090 #include "w2c_weak.h"
00091 #include "w2f_weak.h"
00092
00093 #if !(defined(__linux__) || defined(BUILD_OS_DARWIN))
00094 #ifndef BUILD_SKIP_PROMPF
00095 #pragma weak Anl_Cleanup
00096 #endif
00097 #endif
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112 void
00113 Cleanup_Files (BOOL report,
00114 BOOL delete_dotofile )
00115 {
00116
00117 Set_Error_Line (ERROR_LINE_UNKNOWN);
00118
00119
00120 if ( Src_File != NULL && Src_File != stdin && fclose (Src_File) ) {
00121 if ( report )
00122 ErrMsg ( EC_Src_Close, Src_File_Name, errno );
00123 }
00124 Src_File = NULL;
00125
00126
00127 Free_Input_Info ();
00128
00129
00130 if ( Obj_File != NULL ) {
00131 if (delete_dotofile) {
00132 if (unlink ( Obj_File_Name) ) {
00133 if ( report )
00134 ErrMsg ( EC_Obj_Close, Obj_File_Name, errno );
00135 }
00136 } else if (Obj_File != (FILE *) MMAPPED_FILE) {
00137 if ( fclose (Obj_File) ) {
00138 if ( report )
00139 ErrMsg ( EC_Obj_Close, Obj_File_Name, errno );
00140 }
00141 }
00142 }
00143 Obj_File = NULL;
00144
00145
00146 if ( Lst_File != NULL && Lst_File != stdout && fclose (Lst_File) ) {
00147 if ( report )
00148 ErrMsg ( EC_Lst_Close, Lst_File_Name, errno );
00149 }
00150 Lst_File = NULL;
00151
00152
00153 if ( Tlog_File != NULL && Tlog_File != stdout && fclose (Tlog_File) ) {
00154 if ( report )
00155 ErrMsg ( EC_Tlog_Close, Tlog_File_Name, errno );
00156 }
00157 Lst_File = NULL;
00158
00159 if (Whirl2c_loaded)
00160 W2C_Cleanup();
00161 if (Whirl2f_loaded)
00162 W2F_Cleanup();
00163 #if !(defined( __linux__) || defined(BUILD_OS_DARWIN))
00164 #ifndef BUILD_SKIP_PROMPF
00165 if (Prompf_anl_loaded)
00166 Anl_Cleanup();
00167 #endif
00168 #endif
00169
00170
00171 Set_Trace_File ( NULL );
00172
00173
00174 Close_Feedback_Files();
00175
00176
00177 Tim_File = NULL;
00178
00179
00180 Set_Error_File ( NULL );
00181 Set_Error_Source ( NULL );
00182 }
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195 void
00196 Terminate (INT status)
00197 {
00198
00199 Cleanup_Files ( FALSE, TRUE);
00200
00201 exit (status);
00202 }
00203
00204
00205 void
00206 Early_Terminate (INT status)
00207 {
00208
00209
00210
00211 if (CURRENT_SYMTAB > GLOBAL_SYMTAB && Scope_tab[CURRENT_SYMTAB].preg_tab != NULL) {
00212 Scope_tab[CURRENT_SYMTAB].preg_tab->Un_register(Be_preg_tab);
00213 Be_preg_tab.Clear();
00214 }
00215 for (SYMTAB_IDX scope_level = CURRENT_SYMTAB;
00216 scope_level >= GLOBAL_SYMTAB;
00217 --scope_level)
00218 {
00219 if (Scope_tab[scope_level].st_tab != NULL
00220 && Be_scope_tab[scope_level].be_st_tab != NULL)
00221 {
00222 Scope_tab[scope_level].st_tab->
00223 Un_register(*Be_scope_tab[scope_level].be_st_tab);
00224 Be_scope_tab[scope_level].be_st_tab->Clear();
00225 }
00226 }
00227
00228 Terminate(status);
00229 }