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 #ifndef GCC_FIXLIB_H
00026 #define GCC_FIXLIB_H
00027
00028 #include "auto-host.h"
00029 #include "ansidecl.h"
00030 #include "config.h"
00031 #include "system.h"
00032
00033 #include "gnu-regex.h"
00034 #include "machname.h"
00035 #include "libiberty.h"
00036
00037 #ifndef STDIN_FILENO
00038 # define STDIN_FILENO 0
00039 #endif
00040 #ifndef STDOUT_FILENO
00041 # define STDOUT_FILENO 1
00042 #endif
00043
00044 typedef int t_success;
00045
00046 #define FAILURE (-1)
00047 #define SUCCESS 0
00048 #define PROBLEM 1
00049
00050 #define SUCCEEDED(p) ((p) == SUCCESS)
00051 #define SUCCESSFUL(p) SUCCEEDED (p)
00052 #define FAILED(p) ((p) < SUCCESS)
00053 #define HADGLITCH(p) ((p) > SUCCESS)
00054
00055 #ifndef DEBUG
00056 # define STATIC static
00057 #else
00058 # define STATIC
00059 #endif
00060
00061 #define tSCC static const char
00062 #define tCC const char
00063 #define tSC static char
00064
00065
00066
00067
00068 #ifndef MAXPATHLEN
00069 # define MAXPATHLEN 4096
00070 #endif
00071
00072 #ifndef EXIT_SUCCESS
00073 # define EXIT_SUCCESS 0
00074 #endif
00075 #ifndef EXIT_FAILURE
00076 # define EXIT_FAILURE 1
00077 #endif
00078
00079 #define EXIT_BROKEN 3
00080
00081 #define NUL '\0'
00082
00083 #ifndef NOPROCESS
00084 #define NOPROCESS ((pid_t) -1)
00085 #define NULLPROCESS ((pid_t)0)
00086
00087 #define EXIT_PANIC 99
00088 #endif
00089
00090 #define IGNORE_ARG(a) ((void)(a))
00091
00092 typedef enum t_bool
00093 {
00094 BOOL_FALSE, BOOL_TRUE
00095 } t_bool;
00096
00097 typedef int apply_fix_p_t;
00098
00099 #define APPLY_FIX 0
00100 #define SKIP_FIX 1
00101
00102 #define ENV_TABLE \
00103 _ENV_( pz_machine, BOOL_TRUE, "TARGET_MACHINE", \
00104 "output from config.guess" ) \
00105 \
00106 _ENV_( pz_orig_dir, BOOL_TRUE, "ORIGDIR", \
00107 "directory of fixincl and applyfix" ) \
00108 \
00109 _ENV_( pz_src_dir, BOOL_TRUE, "SRCDIR", \
00110 "directory of original files" ) \
00111 \
00112 _ENV_( pz_input_dir, BOOL_TRUE, "INPUT", \
00113 "current directory for fixincl" ) \
00114 \
00115 _ENV_( pz_dest_dir, BOOL_TRUE, "DESTDIR", \
00116 "output directory" ) \
00117 \
00118 _ENV_( pz_verbose, BOOL_FALSE, "VERBOSE", \
00119 "amount of user entertainment" ) \
00120 \
00121 _ENV_( pz_find_base, BOOL_TRUE, "FIND_BASE", \
00122 "leader to trim from file names" )
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134 typedef enum
00135 {
00136 TT_TEST, TT_EGREP, TT_NEGREP, TT_FUNCTION
00137 } te_test_type;
00138
00139 typedef struct test_desc tTestDesc;
00140
00141 struct test_desc
00142 {
00143 te_test_type type;
00144 const char *pz_test_text;
00145 regex_t *p_test_regex;
00146 };
00147
00148 typedef struct patch_desc tPatchDesc;
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160 #define FD_MACH_ONLY 0x0000
00161 #define FD_MACH_IFNOT 0x0001
00162 #define FD_SHELL_SCRIPT 0x0002
00163 #define FD_SUBROUTINE 0x0004
00164 #define FD_REPLACEMENT 0x0008
00165 #define FD_SKIP_TEST 0x8000
00166
00167 typedef struct fix_desc tFixDesc;
00168 struct fix_desc
00169 {
00170 tCC* fix_name;
00171 tCC* file_list;
00172 tCC** papz_machs;
00173 int test_ct;
00174 int fd_flags;
00175 tTestDesc* p_test_desc;
00176 tCC** patch_args;
00177 long unused;
00178 };
00179
00180 typedef struct {
00181 int type_name_len;
00182 tCC* pz_type;
00183 tCC* pz_TYPE;
00184 tCC* pz_gtype;
00185 } t_gnu_type_map;
00186
00187 extern int gnu_type_map_ct;
00188
00189 #ifdef HAVE_MMAP_FILE
00190 #define UNLOAD_DATA() do { if (curr_data_mapped) { \
00191 munmap ((void*)pz_curr_data, data_map_size); close (data_map_fd); } \
00192 else free ((void*)pz_curr_data); } while(0)
00193 #else
00194 #define UNLOAD_DATA() free ((void*)pz_curr_data)
00195 #endif
00196
00197
00198
00199
00200 char * load_file_data PARAMS(( FILE* fp ));
00201
00202 #ifdef IS_CXX_HEADER_NEEDED
00203 t_bool is_cxx_header PARAMS(( tCC* filename, tCC* filetext ));
00204 #endif
00205
00206 #ifdef SKIP_QUOTE_NEEDED
00207 tCC* skip_quote PARAMS(( char q, char* text ));
00208 #endif
00209
00210 void compile_re PARAMS(( tCC* pat, regex_t* re, int match,
00211 tCC *e1, tCC *e2 ));
00212
00213 void apply_fix PARAMS(( tFixDesc* p_fixd, tCC* filname ));
00214 apply_fix_p_t
00215 run_test PARAMS(( tCC* t_name, tCC* f_name, tCC* text ));
00216
00217 #ifdef SEPARATE_FIX_PROC
00218 char* make_raw_shell_str
00219 PARAMS(( char* pz_d, tCC* pz_s, size_t smax ));
00220 #endif
00221
00222 #ifdef MN_NAME_PAT
00223 void mn_get_regexps
00224 PARAMS(( regex_t** label_re, regex_t** name_re,
00225 tCC *who ));
00226 #endif
00227 #endif