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