OSDN Git Service

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