OSDN Git Service

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