Restored acciddental check-in.
[official-gcc.git] / fixincludes / fixlib.h
blob4993d1bd654fed73a1a799cadb6f83e14b0ac901
2 /* Install modified versions of certain ANSI-incompatible system header
3 files which are fixed to work correctly with ANSI C and placed in a
4 directory that GCC will search.
6 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
7 Free Software Foundation, Inc.
9 This file is part of GCC.
11 GCC is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2, or (at your option)
14 any later version.
16 GCC is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with GCC; see the file COPYING. If not, write to
23 the Free Software Foundation, 59 Temple Place - Suite 330,
24 Boston, MA 02111-1307, USA. */
26 #ifndef GCC_FIXLIB_H
27 #define GCC_FIXLIB_H
29 #include "config.h"
30 #include "system.h"
31 #include <signal.h>
33 #include "xregex.h"
34 #include "libiberty.h"
36 #ifndef STDIN_FILENO
37 # define STDIN_FILENO 0
38 #endif
39 #ifndef STDOUT_FILENO
40 # define STDOUT_FILENO 1
41 #endif
43 typedef int t_success;
45 #define FAILURE (-1)
46 #define SUCCESS 0
47 #define PROBLEM 1
49 #define SUCCEEDED(p) ((p) == SUCCESS)
50 #define SUCCESSFUL(p) SUCCEEDED (p)
51 #define FAILED(p) ((p) < SUCCESS)
52 #define HADGLITCH(p) ((p) > SUCCESS)
54 #ifndef DEBUG
55 # define STATIC static
56 #else
57 # define STATIC
58 #endif
60 #define tSCC static const char
61 #define tCC const char
62 #define tSC static char
64 /* If this particular system's header files define the macro `MAXPATHLEN',
65 we happily take advantage of it; otherwise we use a value which ought
66 to be large enough. */
67 #ifndef MAXPATHLEN
68 # define MAXPATHLEN 4096
69 #endif
71 #ifndef EXIT_SUCCESS
72 # define EXIT_SUCCESS 0
73 #endif
74 #ifndef EXIT_FAILURE
75 # define EXIT_FAILURE 1
76 #endif
78 #define EXIT_BROKEN 3
80 #define NUL '\0'
82 #ifndef NOPROCESS
83 #define NOPROCESS ((pid_t) -1)
84 #define NULLPROCESS ((pid_t)0)
86 #define EXIT_PANIC 99
87 #endif /* NOPROCESS */
89 #define IGNORE_ARG(a) ((void)(a))
91 typedef enum t_bool
93 BOOL_FALSE, BOOL_TRUE
94 } t_bool;
96 typedef int apply_fix_p_t; /* Apply Fix Predicate Type */
98 #define APPLY_FIX 0
99 #define SKIP_FIX 1
101 #define ENV_TABLE \
102 _ENV_( pz_machine, BOOL_TRUE, "TARGET_MACHINE", \
103 "output from config.guess" ) \
105 _ENV_( pz_orig_dir, BOOL_TRUE, "ORIGDIR", \
106 "directory of fixincl and applyfix" ) \
108 _ENV_( pz_src_dir, BOOL_TRUE, "SRCDIR", \
109 "directory of original files" ) \
111 _ENV_( pz_input_dir, BOOL_TRUE, "INPUT", \
112 "current directory for fixincl" ) \
114 _ENV_( pz_dest_dir, BOOL_TRUE, "DESTDIR", \
115 "output directory" ) \
117 _ENV_( pz_mn_name_pat, BOOL_FALSE, "MN_NAME_PAT", \
118 "regex matching forbidden identifiers" ) \
120 _ENV_( pz_verbose, BOOL_FALSE, "VERBOSE", \
121 "amount of user entertainment" ) \
123 _ENV_( pz_find_base, BOOL_TRUE, "FIND_BASE", \
124 "leader to trim from file names" )
126 #define _ENV_(v,m,n,t) extern tCC* v;
127 ENV_TABLE
128 #undef _ENV_
130 /* Test Descriptor
132 Each fix may have associated tests that determine
133 whether the fix needs to be applied or not.
134 Each test has a type (from the te_test_type enumeration);
135 associated test text; and, if the test is TT_EGREP or
136 the negated form TT_NEGREP, a pointer to the compiled
137 version of the text string.
140 typedef enum
142 TT_TEST, TT_EGREP, TT_NEGREP, TT_FUNCTION
143 } te_test_type;
145 typedef struct test_desc tTestDesc;
147 struct test_desc
149 te_test_type type;
150 const char *pz_test_text;
151 regex_t *p_test_regex;
154 typedef struct patch_desc tPatchDesc;
156 /* Fix Descriptor
158 Everything you ever wanted to know about how to apply
159 a particular fix (which files, how to qualify them,
160 how to actually make the fix, etc...)
162 NB: the FD_ defines are BIT FLAGS, even though
163 some are mutually exclusive
166 #define FD_MACH_ONLY 0x0000
167 #define FD_MACH_IFNOT 0x0001
168 #define FD_SHELL_SCRIPT 0x0002
169 #define FD_SUBROUTINE 0x0004
170 #define FD_REPLACEMENT 0x0008
171 #define FD_SKIP_TEST 0x8000
173 typedef struct fix_desc tFixDesc;
174 struct fix_desc
176 tCC* fix_name; /* Name of the fix */
177 tCC* file_list; /* List of files it applies to */
178 tCC** papz_machs; /* List of machine/os-es it applies to */
179 int test_ct;
180 int fd_flags;
181 tTestDesc* p_test_desc;
182 tCC** patch_args;
183 long unused;
186 typedef struct {
187 int type_name_len;
188 tCC* pz_type;
189 tCC* pz_TYPE;
190 tCC* pz_gtype;
191 } t_gnu_type_map;
193 extern int gnu_type_map_ct;
195 #ifdef HAVE_MMAP_FILE
196 #define UNLOAD_DATA() do { if (curr_data_mapped) { \
197 munmap ((void*)pz_curr_data, data_map_size); close (data_map_fd); } \
198 else free ((void*)pz_curr_data); } while(0)
199 #else
200 #define UNLOAD_DATA() free ((void*)pz_curr_data)
201 #endif
204 * Exported procedures
206 char * load_file_data ( FILE* fp );
208 #ifdef IS_CXX_HEADER_NEEDED
209 t_bool is_cxx_header ( tCC* filename, tCC* filetext );
210 #endif /* IS_CXX_HEADER_NEEDED */
212 #ifdef SKIP_QUOTE_NEEDED
213 tCC* skip_quote ( char q, char* text );
214 #endif
216 void compile_re ( tCC* pat, regex_t* re, int match, tCC *e1, tCC *e2 );
218 void apply_fix ( tFixDesc* p_fixd, tCC* filname );
219 apply_fix_p_t
220 run_test ( tCC* t_name, tCC* f_name, tCC* text );
222 #ifdef SEPARATE_FIX_PROC
223 char* make_raw_shell_str ( char* pz_d, tCC* pz_s, size_t smax );
224 #endif
226 t_bool mn_get_regexps ( regex_t** label_re, regex_t** name_re, tCC *who );
227 #endif /* ! GCC_FIXLIB_H */