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