OSDN Git Service

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