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