]>
Commit | Line | Data |
---|---|---|
1f414ac4 | 1 | /* -*- Mode: C -*- */ |
0083c904 BK |
2 | |
3 | autogen definitions inclhack; | |
4 | ||
5 | /* | |
6 | * Define all the fixes we know about for repairing damaged headers | |
7 | */ | |
8 | ||
9 | /* | |
10 | * sys/wait.h on AIX 3.2.5 puts the declaration of wait3 before the definition | |
11 | * of struct rusage, so the prototype (added by fixproto) causes havoc. | |
12 | */ | |
13 | fix = { | |
14 | hackname = aix_syswait; | |
15 | files = sys/wait.h; | |
16 | select = "bos325,"; | |
17 | sed = "/^extern pid_t wait3();$/i\\\n" | |
18 | "struct rusage;\n"; | |
19 | }; | |
20 | ||
21 | ||
22 | /* | |
23 | * sys/signal.h on some versions of AIX uses volatile in the typedef of | |
24 | * sig_atomic_t, which causes gcc to generate a warning about duplicate | |
25 | * volatile when a sig_atomic_t variable is declared volatile, as | |
26 | * required by ANSI C. | |
27 | */ | |
28 | fix = { | |
29 | hackname = aix_volatile; | |
30 | files = sys/signal.h; | |
31 | select = "typedef volatile int sig_atomic_t"; | |
32 | sed = "s/typedef volatile int sig_atomic_t" | |
33 | "/typedef int sig_atomic_t/"; | |
34 | }; | |
35 | ||
36 | ||
37 | /* | |
38 | * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX. | |
39 | */ | |
40 | fix = { | |
41 | hackname = alpha_getopt; | |
42 | files = "stdio.h"; | |
43 | files = "stdlib.h"; | |
44 | select = 'getopt\(int, char \*\['; | |
45 | sed = 's/getopt(int, char \*\[\],[ ]*char \*)/' | |
46 | 'getopt(int, char *const[], const char *)/'; | |
47 | }; | |
48 | ||
49 | ||
50 | /* | |
8f34d1e9 | 51 | * Remove erroneous parentheses in sym.h on Alpha OSF/1. |
0083c904 BK |
52 | */ |
53 | fix = { | |
54 | hackname = alpha_parens; | |
55 | files = sym.h; | |
56 | select = '#ifndef\(__mips64\)'; | |
57 | sed = "s/#ifndef(__mips64)/#ifndef __mips64/"; | |
58 | }; | |
59 | ||
60 | ||
61 | /* | |
62 | * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0 | |
63 | */ | |
64 | fix = { | |
65 | hackname = alpha_sbrk; | |
66 | files = unistd.h; | |
67 | select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\("; | |
68 | sed = "s/char\\([ \t]*\\*[\t ]*sbrk[ \t]*(\\)/void\\1/"; | |
69 | }; | |
70 | ||
71 | ||
72 | /* | |
73 | * Fix this ARM/RISCiX file where ___type is a Compiler | |
74 | * hint that is specific to the Norcroft compiler. | |
75 | */ | |
76 | fix = { | |
77 | hackname = arm_norcroft_hint; | |
c6a1d2ff | 78 | select = "___type p_type"; |
0083c904 BK |
79 | files = "X11/Intrinsic.h"; |
80 | sed = "s/___type p_type/p_type/"; | |
81 | }; | |
82 | ||
83 | ||
84 | /* | |
85 | * Fix this ARM/RISCiX file to avoid interfering | |
86 | * with the use of __wchar_t in cc1plus. | |
87 | */ | |
88 | fix = { | |
89 | hackname = arm_wchar; | |
90 | files = stdlib.h; | |
91 | select = "#[ \t]*define[ \t]*__wchar_t"; | |
92 | sed = "s/\\(#[ \t]*ifndef[ \t]*\\)__wchar_t/\\1_GCC_WCHAR_T/"; | |
93 | sed = "s/\\(#[ \t]*define[ \t]*\\)__wchar_t/\\1_GCC_WCHAR_T/"; | |
94 | }; | |
95 | ||
96 | ||
97 | /* | |
98 | * This file in A/UX 3.0.x/3.1.x contains an __asm directive for c89; | |
99 | * gcc doesn't understand it. | |
100 | */ | |
101 | fix = { | |
102 | hackname = aux_asm; | |
103 | files = sys/param.h; | |
104 | select = "#ifndef NOINLINE"; | |
105 | sed = "s|#ifndef NOINLINE" | |
106 | "|#if !defined(NOINLINE) \\&\\& !defined(__GNUC__)|"; | |
107 | }; | |
108 | ||
109 | ||
110 | /* | |
111 | * For C++, avoid any typedef or macro definition of bool, | |
112 | * and use the built in type instead. | |
8f34d1e9 | 113 | * HP/UX 10.20 also has it in curses_colr/curses.h. |
0083c904 BK |
114 | */ |
115 | fix = { | |
116 | hackname = avoid_bool; | |
117 | files = curses.h; | |
b080ce78 | 118 | files = curses_colr/curses.h; |
0083c904 BK |
119 | files = term.h; |
120 | files = tinfo.h; | |
121 | ||
122 | sed = "/^#[ \t]*define[ \t][ \t]*bool[ \t][ \t]*char[ \t]*$/i\\\n" | |
123 | "#ifndef __cplusplus\n"; | |
124 | ||
125 | sed = "/^#[ \t]*define[ \t][ \t]*bool[ \t][ \t]*char[ \t]*$/a\\\n" | |
126 | "#endif\n"; | |
127 | ||
128 | sed = "/^typedef[ \t][ \t]*char[ \t][ \t]*bool[ \t]*;/i\\\n" | |
129 | "#ifndef __cplusplus\n"; | |
130 | ||
131 | sed = "/^typedef[ \t][ \t]*char[ \t][ \t]*bool[ \t]*;/a\\\n" | |
132 | "#endif\n"; | |
26e2e81d RL |
133 | |
134 | sed = "/^[ ]*typedef[ \t][ \t]*unsigned char[ \t][ \t]*bool[ \t]*;/i\\\n" | |
135 | "#ifndef __cplusplus\n"; | |
136 | ||
137 | sed = "/^[ ]*typedef[ \t][ \t]*unsigned char[ \t][ \t]*bool[ \t]*;/a\\\n" | |
138 | "#endif\n"; | |
fbc35bc1 JL |
139 | |
140 | sed = "/^typedef[ \t][ \t]*int[ \t][ \t]*bool[ \t]*;/i\\\n" | |
141 | "#ifndef __cplusplus\n"; | |
142 | ||
143 | sed = "/^typedef[ \t][ \t]*int[ \t][ \t]*bool[ \t]*;/a\\\n" | |
144 | "#endif\n"; | |
145 | ||
146 | sed = "/^[ ]*typedef[ \t][ \t]*unsigned int[ \t][ \t]*bool[ \t]*;/i\\\n" | |
147 | "#ifndef __cplusplus\n"; | |
148 | ||
149 | sed = "/^[ ]*typedef[ \t][ \t]*unsigned int[ \t][ \t]*bool[ \t]*;/a\\\n" | |
150 | "#endif\n"; | |
0083c904 BK |
151 | }; |
152 | ||
153 | ||
0083c904 BK |
154 | /* |
155 | * Fix `typedef struct term;' on hppa1.1-hp-hpux9. | |
156 | */ | |
157 | fix = { | |
158 | hackname = bad_struct_term; | |
159 | files = curses.h; | |
160 | select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;"; | |
161 | sed = "s/^[ \t]*typedef[ \t][ \t]*" | |
162 | "\\(struct[ \t][ \t]*term[ \t]*;[ \t]*\\)$/\\1/"; | |
163 | }; | |
164 | ||
165 | ||
166 | /* | |
167 | * Fix one other error in this file: | |
168 | * a mismatched quote not inside a C comment. | |
169 | */ | |
170 | fix = { | |
171 | hackname = badquote; | |
172 | files = sundev/vuid_event.h; | |
173 | sed = "s/doesn't/does not/"; | |
174 | }; | |
175 | ||
176 | ||
177 | /* | |
178 | * Fix #defines under Alpha OSF/1: | |
179 | * The following files contain '#pragma extern_prefix "_FOO"' followed by | |
180 | * a '#define something(x,y,z) _FOOsomething(x,y,z)'. The intent of these | |
181 | * statements is to reduce namespace pollution. While these macros work | |
182 | * properly in most cases, they don't allow you to take a pointer to the | |
183 | * "something" being modified. To get around this limitation, change these | |
184 | * statements to be of the form '#define something _FOOsomething'. | |
185 | */ | |
186 | fix = { | |
187 | hackname = bad_lval; | |
0083c904 BK |
188 | files = libgen.h; |
189 | files = dirent.h; | |
190 | files = ftw.h; | |
191 | files = grp.h; | |
192 | files = ndbm.h; | |
193 | files = pthread.h; | |
194 | files = pwd.h; | |
195 | files = signal.h; | |
196 | files = standards.h; | |
197 | files = stdlib.h; | |
198 | files = string.h; | |
199 | files = stropts.h; | |
200 | files = time.h; | |
201 | files = unistd.h; | |
202 | sed = | |
203 | "s/^[ \t]*#[ \t]*define[ \t]*\\([^(]*\\)\\(([^)]*)\\)[ \t]*" | |
204 | "\\(_.\\)\\1\\2[ \t]*$/#define \\1 \\3\\1/"; | |
205 | }; | |
206 | ||
207 | ||
208 | /* | |
209 | * check for broken assert.h that needs stdio.h | |
210 | */ | |
211 | fix = { | |
212 | hackname = broken_assert_stdio; | |
213 | files = assert.h; | |
214 | select = stderr; | |
215 | bypass = "include.*stdio.h"; | |
216 | sed = "1i\\\n" | |
217 | "#include <stdio.h>\n"; | |
218 | }; | |
219 | ||
220 | ||
221 | /* | |
222 | * check for broken assert.h that needs stdlib.h | |
223 | */ | |
224 | fix = { | |
225 | hackname = broken_assert_stdlib; | |
226 | files = assert.h; | |
227 | select = 'exit *\(|abort *\('; | |
228 | bypass = "include.*stdlib.h"; | |
229 | sed = "1i\\\n" | |
230 | "#ifdef __cplusplus\\\n" | |
231 | "#include <stdlib.h>\\\n" | |
232 | "#endif\n"; | |
233 | }; | |
234 | ||
235 | ||
236 | /* | |
237 | * Note that BSD43_* are used on recent MIPS systems. | |
238 | */ | |
239 | fix = { | |
240 | hackname = bsd43_io_macros; | |
241 | select = "BSD43__IO"; | |
242 | /* | |
243 | * Put single quotes aroung the character that appears after '(' | |
244 | * and before ',', UNLESS it is a 'c' or 'g' or 'x'. | |
245 | */ | |
246 | sed = "/[ \t]BSD43__IO[A-Z]*[ \t]*(/" 's/(\(.\),/(\'\1\',/'; | |
247 | sed = "/#[ \t]*define[ \t]*[ \t]BSD43__IO/" 's/\'\([cgx]\)\'/\1/g'; | |
248 | }; | |
249 | ||
8f34d1e9 BK |
250 | |
251 | /* | |
252 | * Fix <c_asm.h> on Digital UNIX V4.0: | |
253 | * It contains a prototype for a DEC C internal asm() function, | |
254 | * clashing with gcc's asm keyword. So protect this with __DECC. | |
255 | */ | |
256 | fix = { | |
257 | hackname = dec_intern_asm; | |
258 | files = c_asm.h; | |
adc8046e AO |
259 | sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n"; |
260 | sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n" | |
8f34d1e9 BK |
261 | "#endif\n"; |
262 | }; | |
263 | ||
264 | ||
265 | #ifdef no_more | |
0083c904 BK |
266 | /* |
267 | * And also with the HP-UX 10 and HP-UX 11 sys/pci.h file | |
268 | */ | |
269 | fix = { | |
270 | hackname = cxx_cmnt_hpux; | |
271 | files = sys/pci.h; | |
272 | select = "System Private Structures"; | |
273 | sed = "s|//.*$||g"; | |
274 | }; | |
275 | ||
276 | ||
277 | /* | |
278 | * Turning // comments into normal comments trashes this IRIX 4.0.1 | |
279 | * header file, which embeds // comments inside multi-line | |
280 | * comments. If this looks like the IRIX header file, we refix it by | |
281 | * just throwing away the // comments. | |
282 | */ | |
283 | fix = { | |
284 | hackname = cxx_cmnt_irix; | |
285 | files = fam.h; | |
286 | select = indigo.esd; | |
287 | sed = "s|//.*$||g"; | |
288 | }; | |
289 | ||
290 | ||
291 | /* | |
292 | * Same problem with a file from SunOS 4.1.3 : a header file containing | |
293 | * the string "//" embedded in "/ * * /" | |
294 | */ | |
295 | fix = { | |
296 | hackname = cxx_cmnt_sunos; | |
297 | files = sbusdev/audiovar.h; | |
298 | files = sys/audiovar.h; | |
299 | sed = "s|//.*$||g"; | |
300 | }; | |
301 | ||
302 | ||
303 | /* | |
304 | * There is a similar problem with the VxWorks drv/netif/if_med.h file. | |
305 | */ | |
306 | fix = { | |
307 | hackname = cxx_cmnt_vxworks; | |
308 | files = drv/netif/if_med.h; | |
309 | select = "Wind River"; | |
310 | sed = "s|//.*$||g"; | |
311 | }; | |
312 | #endif | |
313 | ||
314 | /* | |
315 | * Remove the double-slash comments | |
316 | * They *must* be removed so it will not create nested comments!! | |
8f34d1e9 BK |
317 | * However, they will *not* be removed if the file name ends with |
318 | * any of "++", ".hh" or ".H", or if the file name contains "cxx/". | |
0083c904 BK |
319 | * |
320 | * There *used* to be a number of similar problems in various OSes: | |
321 | ||
322 | * Turning // comments into normal comments trashes this IRIX 4.0.1 | |
323 | * header file, which embeds // comments inside multi-line | |
324 | * comments. If this looks like the IRIX header file, we refix it by | |
325 | * just throwing away the // comments. | |
326 | ||
327 | * Same problem with a file from SunOS 4.1.3 : a header file containing | |
328 | * the string "//" embedded in "/ * * /" | |
329 | ||
330 | * There is a similar problem with the VxWorks drv/netif/if_med.h file. | |
331 | ||
332 | * And also with the HP-UX 10 and HP-UX 11 sys/pci.h file | |
0083c904 | 333 | |
8f34d1e9 BK |
334 | * Now that we delete the // comments instead of converting them to / * * /, |
335 | * traditional hacks like irix_bogus_cxx_cmnt, no longer work (which | |
336 | * strangely enough was also used on alpha-dec-osf4.0d). If we skip the | |
337 | * hack whenever we see ``"//"'', then the need for the secondary hack | |
338 | * disappears. Note: it is painful to ensure that the first quote | |
339 | * exists, so we just check for the trailing quote directly abutting | |
340 | * the //. Note: We should never touch a line that has // completely | |
341 | * within quotes but this is somewhat hard to check for. | |
0083c904 | 342 | |
8f34d1e9 BK |
343 | * Ultimately, this fix ought to go inside of C code where |
344 | * we can do a better analysis on the need and method for fixing. | |
0083c904 BK |
345 | */ |
346 | fix = { | |
8f34d1e9 | 347 | hackname = no_double_slash; |
0083c904 | 348 | /* |
7db774d2 BK |
349 | * Test that the file-to-fix does not from a C++ directory |
350 | * Also, only accept double slashes that are not part of URL's | |
351 | * and are not the end of a quoted string. | |
0083c904 | 352 | */ |
c6a1d2ff | 353 | test = '-z `echo ${file} | egrep \'(CC|cxx|\+\+)/\' `'; |
7db774d2 | 354 | select = '(^|[^:])//[^"*]'; |
c6a1d2ff BK |
355 | sed = 's,^//.*$,,'; |
356 | sed = 's,[^:]//[^"].*$,,'; | |
0083c904 BK |
357 | }; |
358 | ||
359 | ||
360 | /* | |
361 | * Fix these Sun OS files to avoid an invalid identifier in an #ifdef. | |
362 | */ | |
363 | fix = { | |
364 | hackname = ecd_cursor; | |
365 | files = "sunwindow/win_lock.h"; | |
366 | files = "sunwindow/win_cursor.h"; | |
367 | sed = "s/ecd.cursor/ecd_cursor/"; | |
368 | }; | |
369 | ||
26e2e81d RL |
370 | /* |
371 | * On SCO OpenServer 5.0.0 through (at least) 5.0.5 <sys/stat.h> contains | |
372 | * tiny static wrappers that aren't C++ safe. | |
373 | */ | |
374 | fix = { | |
375 | hackname = sco5_stat_wrappers; | |
376 | mach = "i*86-*-sco3.2v5*"; | |
377 | files = "sys/stat.h"; | |
378 | ||
379 | sed = "/^static int[ \t]*[a-z]*stat(/i\\\n" | |
380 | "#ifdef __cplusplus\\\n" | |
381 | "extern \"C\"\\\n" | |
382 | "{\\\n" | |
383 | "#endif\\\n"; | |
384 | ||
385 | sed = "/^}$/a\\\n" | |
386 | "#ifdef __cplusplus\\\n" | |
387 | "}\\\n" | |
388 | "#endif \/* __cplusplus *\/\\\n"; | |
389 | }; | |
390 | ||
0083c904 BK |
391 | |
392 | ||
393 | /* | |
394 | * Fix else directives that contain non-commentary text | |
395 | * | |
396 | * The fixinc_eol stuff is to work around a bug in the sed | |
397 | */ | |
398 | fix = { | |
399 | hackname = else_label; | |
400 | select = "^[ \t]*#[ \t]*else[ \t]+[!-.0-~]"; | |
401 | sed = ":loop\n" | |
402 | '/\\\\$/' "N\n" | |
403 | 's/\\\\$/\\\\+++fixinc_eol+++/' "\n" | |
404 | '/\\\\$/' "b loop\n" | |
405 | 's/\\\\+++fixinc_eol+++/\\\\/g' "\n" | |
406 | ||
407 | "s%^\\([ \t]*#[ \t]*else\\)[ \t]*/[^*].*%\\1%\n" | |
408 | "s%^\\([ \t]*#[ \t]*else\\)[ \t]*[^/ \t].*%\\1%"; | |
409 | }; | |
410 | ||
411 | ||
412 | /* | |
413 | * Fix endif directives that contain non-commentary text | |
414 | */ | |
415 | fix = { | |
416 | hackname = endif_label; | |
417 | /* | |
418 | * Select files that contain '#endif' directives with | |
419 | * some sort of following junk. (Between the ascii '.' | |
420 | * and '0' lies the character '/'. This will *NOT* | |
421 | * match '#endif / * foo * /', but it also wont match | |
422 | * '#endif / done' either. | |
423 | * | |
424 | * We use the pattern [!-.0-z{|}~] instead of [^/ \t] to match a noncomment | |
425 | * following #else or #endif because some buggy egreps think [^/] matches | |
426 | * newline, and they thus think `#else ' matches | |
427 | * `#e[ndiflse]*[ \t]+[^/ \t]'. | |
428 | * [!-.0-~] does not work properly on AIX 4.1. | |
429 | */ | |
430 | select = "^[ \t]*#[ \t]*endif[ \t]+[!-.0-z\{\|\}\~]"; | |
431 | ||
432 | /* | |
433 | * First, join the continued input lines. | |
434 | * IF the resulting line is an endif preprocessing directive, | |
435 | * then trim off the following patterns: | |
436 | * 1. sequences that start with '/' and is *NOT* followed by '*' | |
437 | * 2. Sequences that start with '*' and is *NOT* followed by '/' | |
438 | * 3. sequences that do not start with any of '/', '*', '\t' or ' '. | |
439 | * | |
440 | * The fixinc_eol stuff is to work around a bug in the sed | |
441 | */ | |
442 | sed = ":loop\n" | |
443 | '/\\\\$/' "N\n" | |
444 | 's/\\\\$/\\\\+++fixinc_eol+++/' "\n" | |
445 | '/\\\\$/' "b loop\n" | |
446 | 's/\\\\+++fixinc_eol+++/\\\\/g' "\n" | |
447 | ||
448 | "s%^\\([ \t]*#[ \t]*endif\\)[ \t]*/[^*].*%\\1%\n" | |
449 | "s%^\\([ \t]*#[ \t]*endif\\)[ \t]*\\*[^/].*%\\1%\n" | |
450 | "s%^\\([ \t]*#[ \t]*endif\\)[ \t]*[^/* \t].*%\\1%"; | |
451 | }; | |
452 | ||
453 | ||
454 | /* | |
455 | * Fix HP's use of ../machine/inline.h to refer to | |
456 | * /usr/include/machine/inline.h | |
457 | */ | |
458 | fix = { | |
459 | hackname = hp_inline; | |
460 | files = sys/spinlock.h; | |
461 | select = 'include.*"\.\./machine/'; | |
462 | sed = "s,\"../machine/inline.h\",<machine/inline.h>,"; | |
463 | sed = "s,\"../machine/psl.h\",<machine/psl.h>,"; | |
464 | }; | |
465 | ||
466 | ||
467 | /* | |
468 | * Check for (...) in C++ code in HP/UX sys/file.h. | |
469 | */ | |
470 | fix = { | |
471 | hackname = hp_sysfile; | |
472 | files = sys/file.h; | |
473 | select = "HPUX_SOURCE"; | |
474 | sed = 's/(\.\.\.)/(struct file * ...)/'; | |
475 | }; | |
476 | ||
477 | ||
478 | /* | |
479 | * sys/mman.h on HP/UX is not C++ ready, | |
480 | * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX. | |
8f34d1e9 BK |
481 | * |
482 | * rpc/types.h on OSF1/2.0 is not C++ ready, even though NO_IMPLICIT_EXTERN_C | |
483 | * is defined for the alpha. The problem is the declaration of malloc. | |
0083c904 BK |
484 | */ |
485 | fix = { | |
8f34d1e9 | 486 | hackname = cxx_unready; |
0083c904 | 487 | files = sys/mman.h; |
8f34d1e9 | 488 | files = rpc/types.h; |
0083c904 BK |
489 | bypass = '"C"|__BEGIN_DECLS'; |
490 | ||
491 | sed = "1i\\\n" | |
492 | "#ifdef __cplusplus\\\n" | |
493 | "extern \"C\" {\\\n" | |
494 | "#endif\\\n\n"; | |
495 | sed = "$a\\\n" | |
496 | "#ifdef __cplusplus\\\n" | |
497 | "}\\\n" | |
498 | "#endif\n"; | |
499 | }; | |
500 | ||
501 | ||
502 | /* | |
503 | * HPUX 10.x sys/param.h defines MAXINT which clashes with values.h | |
504 | */ | |
505 | fix = { | |
506 | hackname = hpux_maxint; | |
507 | files = sys/param.h; | |
508 | sed = "/^#[ \t]*define[ \t]*MAXINT[ \t]/i\\\n" | |
509 | "#ifndef MAXINT\n"; | |
510 | ||
511 | sed = "/^#[ \t]*define[ \t]*MAXINT[ \t]/a\\\n" | |
512 | "#endif\n"; | |
513 | }; | |
514 | ||
515 | ||
516 | /* | |
517 | * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl | |
518 | */ | |
519 | fix = { | |
520 | hackname = hpux_systime; | |
521 | files = sys/time.h; | |
522 | select = "^extern struct sigevent;"; | |
523 | sed = "s/^extern struct sigevent;/struct sigevent;/"; | |
524 | }; | |
525 | ||
526 | ||
527 | /* | |
8f34d1e9 BK |
528 | * Determine if we're on Interactive Unix 2.2 or later, in which case we |
529 | * need to fix some additional files. This is the same test for ISC that | |
530 | * Autoconf uses. On Interactive 2.2, certain traditional Unix | |
531 | * definitions (notably getc and putc in stdio.h) are omitted if __STDC__ | |
532 | * is defined, not just if _POSIX_SOURCE is defined. This makes it | |
533 | * impossible to compile any nontrivial program except with -posix. | |
0083c904 BK |
534 | */ |
535 | fix = { | |
536 | hackname = interactv_add1; | |
537 | ||
8f34d1e9 BK |
538 | test = " -d /etc/conf/kconfig.d"; |
539 | test = ' -n "`grep _POSIX_VERSION /usr/include/sys/unistd.h`"'; | |
0083c904 BK |
540 | |
541 | files = "stdio.h"; | |
542 | files = "math.h"; | |
543 | files = "ctype.h"; | |
544 | files = "sys/limits.h"; | |
545 | files = "sys/fcntl.h"; | |
546 | files = "sys/dirent.h"; | |
547 | ||
548 | sed = "s/!defined(__STDC__) && !defined(_POSIX_SOURCE)/" | |
549 | "!defined(_POSIX_SOURCE)/"; | |
550 | }; | |
551 | ||
552 | fix = { | |
553 | hackname = interactv_add2; | |
554 | ||
8f34d1e9 BK |
555 | test = " -d /etc/conf/kconfig.d"; |
556 | test = ' -n "`grep _POSIX_VERSION /usr/include/sys/unistd.h`"'; | |
0083c904 BK |
557 | |
558 | files = math.h; | |
559 | sed = "s/fmod(double)/fmod(double, double)/"; | |
560 | }; | |
561 | ||
562 | fix = { | |
563 | hackname = interactv_add3; | |
564 | ||
8f34d1e9 BK |
565 | test = " -d /etc/conf/kconfig.d"; |
566 | test = ' -n "`grep _POSIX_VERSION /usr/include/sys/unistd.h`"'; | |
0083c904 BK |
567 | |
568 | files = sys/limits.h; | |
569 | ||
570 | sed = "/CHILD_MAX/s,/\\* Max, Max,"; | |
571 | sed = "/OPEN_MAX/s,/\\* Max, Max,"; | |
572 | }; | |
573 | ||
574 | ||
575 | /* | |
8f34d1e9 | 576 | * Fix various _IO* defines, but do *not* quote the characters cgxtf. |
0083c904 BK |
577 | */ |
578 | fix = { | |
579 | hackname = io_def_quotes; | |
49da3efb | 580 | select = "[ \t]*[ \t](_|DES)IO[A-Z]*[ \t]*\\( *[^,']"; |
5403593a BK |
581 | sed = "s/\\([ \t]*[ \t]_IO[A-Z]*[ \t]*(\\)\\([^,']\\),/\\1'\\2',/"; |
582 | sed = "s/\\([ \t]*[ \t]DESIO[A-Z]*[ \t]*(\\)\\([^,']\\),/\\1'\\2',/"; | |
8f34d1e9 | 583 | sed = "/#[ \t]*define[ \t]*[ \t]_IO/" "s/'\\([cgxtf]\\)'/\\1/g"; |
0083c904 BK |
584 | sed = "/#[ \t]*define[ \t]*[ \t]DESIOC/" 's/\'\([cdgx]\)\'/\1/g'; |
585 | }; | |
586 | ||
587 | ||
588 | /* | |
589 | * Fix CTRL macros | |
590 | */ | |
591 | fix = { | |
592 | hackname = ioctl_fix_ctrl; | |
593 | select = "CTRL[ \t]"; | |
594 | ||
595 | sed = "/[^A-Z0-9_]CTRL[ \t]*(/" | |
596 | "s/\\([^']\\))/'\\1')/"; | |
597 | ||
598 | sed = "/[^A-Z0-9]_CTRL[ \t]*(/" | |
599 | "s/\\([^']\\))/'\\1')/"; | |
600 | ||
601 | sed = "/#[ \t]*define[ \t]*[ \t]CTRL/" | |
602 | "s/'\\([cgx]\\)'/\\1/g"; | |
603 | ||
604 | sed = "/#[ \t]*define[ \t]*[ \t]_CTRL/" | |
605 | "s/'\\([cgx]\\)'/\\1/g"; | |
606 | ||
607 | sed = "/#[ \t]*define[ \t]*[ \t]BSD43_CTRL/" | |
608 | "s/'\\([cgx]\\)'/\\1/g"; | |
609 | }; | |
610 | ||
611 | ||
612 | /* | |
613 | * Check for missing ';' in struct | |
614 | */ | |
615 | fix = { | |
616 | hackname = ip_missing_semi; | |
617 | files = netinet/ip.h; | |
618 | sed = "/^struct/,/^};/s/}$/};/"; | |
619 | }; | |
620 | ||
621 | ||
622 | /* | |
623 | * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr | |
624 | * in prototype without previous definition. | |
625 | */ | |
626 | fix = { | |
627 | hackname = irix_multiline_cmnt; | |
628 | files = sys/types.h; | |
629 | ||
630 | sed = "s@type of the result@type of the result */@"; | |
631 | sed = "s@of the sizeof@/* of the sizeof@"; | |
632 | }; | |
633 | ||
634 | ||
635 | /* | |
636 | * Some IRIX header files contain the string "//" | |
637 | */ | |
638 | fix = { | |
639 | hackname = irix_sockaddr; | |
640 | files = rpc/auth.h; | |
641 | select = "authdes_create.*struct sockaddr"; | |
642 | sed = "/authdes_create.*struct sockaddr/i\\\n" | |
643 | "struct sockaddr;\n"; | |
644 | }; | |
645 | ||
646 | ||
647 | /* | |
648 | * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s | |
649 | * in prototype without previous definition. | |
650 | */ | |
651 | fix = { | |
652 | hackname = irix_struct__file; | |
653 | files = rpc/xdr.h; | |
654 | sed = "/xdrstdio_create.*struct __file_s/i\\\n" | |
655 | "struct __file_s;\n"; | |
656 | }; | |
657 | ||
658 | ||
659 | /* | |
660 | * Fixing ISC fmod declaration | |
661 | */ | |
662 | fix = { | |
663 | hackname = isc_fmod; | |
664 | files = math.h; | |
665 | select = 'fmod\(double\)'; | |
666 | sed = "s/fmod(double)/fmod(double, double)/"; | |
667 | }; | |
668 | ||
669 | ||
670 | /* | |
671 | * Fix nested comments in Motorola's <limits.h> and <sys/limits.h> | |
672 | */ | |
673 | fix = { | |
674 | hackname = motorola_nested; | |
8f34d1e9 | 675 | mach = "m68k-motorola-sysv*"; |
0083c904 BK |
676 | files = limits.h; |
677 | files = sys/limits.h; | |
678 | sed = "s@^\\(#undef[ \t][ \t]*PIPE_BUF[ \t]*" | |
679 | "/\\* max # bytes atomic in write to a\\)$@\\1 */@"; | |
680 | sed = "s@\\(/\\*#define\tHUGE_VAL\t3.40282346638528860e+38 \\)" | |
681 | "\\(/\\*error value returned by Math lib\\*/\\)$@\\1*/ \\2@"; | |
682 | }; | |
683 | ||
684 | ||
685 | /* | |
686 | * Fixing nested comments in ISC <sys/limits.h> | |
687 | */ | |
688 | fix = { | |
689 | hackname = isc_sys_limits; | |
690 | files = sys/limits.h; | |
691 | select = CHILD_MAX; | |
692 | sed = "/CHILD_MAX/s,/\\* Max, Max,"; | |
693 | sed = "/OPEN_MAX/s,/\\* Max, Max,"; | |
694 | }; | |
695 | ||
696 | ||
697 | /* | |
698 | * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3 | |
699 | * use / * * / to concatenate tokens. | |
700 | */ | |
701 | fix = { | |
702 | hackname = kandr_concat; | |
703 | files = "sparc/asm_linkage.h"; | |
704 | files = "sun3/asm_linkage.h"; | |
705 | files = "sun3x/asm_linkage.h"; | |
706 | files = "sun4/asm_linkage.h"; | |
707 | files = "sun4c/asm_linkage.h"; | |
708 | files = "sun4m/asm_linkage.h"; | |
709 | files = "sun4c/debug/asm_linkage.h"; | |
710 | files = "sun4m/debug/asm_linkage.h"; | |
711 | files = "arm/as_support.h"; | |
712 | files = "arm/mc_type.h"; | |
713 | files = "arm/xcb.h"; | |
714 | files = "dev/chardefmac.h"; | |
715 | files = "dev/ps_irq.h"; | |
716 | files = "dev/screen.h"; | |
717 | files = "dev/scsi.h"; | |
718 | files = "sys/tty.h"; | |
719 | files = "Xm.acorn/XmP.h"; | |
720 | files = bsd43/bsd43_.h; | |
721 | select = '/\*\*/'; | |
8f34d1e9 | 722 | sed = 's|/\*\*/|##|g'; |
0083c904 BK |
723 | }; |
724 | ||
725 | ||
726 | /* | |
727 | * In limits.h, put #ifndefs around things that are supposed to be defined | |
728 | * in float.h to avoid redefinition errors if float.h is included first. | |
729 | * On HP/UX this patch does not work, because on HP/UX limits.h uses | |
730 | * multi line comments and the inserted #endif winds up inside the | |
731 | * comment. Fortunately, HP/UX already uses #ifndefs in limits.h; if | |
732 | * we find a #ifndef FLT_MIN we assume that all the required #ifndefs | |
733 | * are there, and we do not add them ourselves. | |
734 | * Also fix a nested comment problem in sys/limits.h on Motorola sysV68 R3V7.1 | |
735 | */ | |
736 | fix = { | |
737 | hackname = limits_ifndefs; | |
738 | files = "limits.h"; | |
149911d4 | 739 | files = "sys/limits.h"; |
0083c904 BK |
740 | bypass = "ifndef[ \t]+FLT_MIN"; |
741 | ||
742 | sed = "/[ \t]FLT_MIN[ \t]/i\\\n#ifndef FLT_MIN\n"; | |
743 | sed = "/[ \t]FLT_MIN[ \t]/a\\\n#endif\n"; | |
744 | sed = "/[ \t]FLT_MAX[ \t]/i\\\n#ifndef FLT_MAX\n"; | |
745 | sed = "/[ \t]FLT_MAX[ \t]/a\\\n#endif\n"; | |
746 | sed = "/[ \t]FLT_DIG[ \t]/i\\\n#ifndef FLT_DIG\n"; | |
747 | sed = "/[ \t]FLT_DIG[ \t]/a\\\n#endif\n"; | |
748 | sed = "/[ \t]DBL_MIN[ \t]/i\\\n#ifndef DBL_MIN\n"; | |
749 | sed = "/[ \t]DBL_MIN[ \t]/a\\\n#endif\n"; | |
750 | sed = "/[ \t]DBL_MAX[ \t]/i\\\n#ifndef DBL_MAX\n"; | |
751 | sed = "/[ \t]DBL_MAX[ \t]/a\\\n#endif\n"; | |
752 | sed = "/[ \t]DBL_DIG[ \t]/i\\\n#ifndef DBL_DIG\n"; | |
753 | sed = "/[ \t]DBL_DIG[ \t]/a\\\n#endif\n"; | |
754 | sed = "/^\\(\\/\\*#define\tHUGE_VAL\t3\\.[0-9e+]* *\\)\\/\\*/s//\\1/"; | |
755 | }; | |
756 | ||
757 | ||
758 | /* | |
759 | * Delete the '#define void int' line from curses.h on Lynx | |
760 | */ | |
761 | fix = { | |
762 | hackname = lynx_void_int; | |
763 | files = curses.h; | |
764 | select = "#[ \t]*define[ \t]+void[ \t]+int"; | |
765 | sed = "/#[ \t]*define[ \t][ \t]*void[ \t]int/d"; | |
766 | }; | |
767 | ||
768 | ||
769 | /* | |
770 | * Fix fcntl prototype in fcntl.h on LynxOS. | |
771 | */ | |
772 | fix = { | |
773 | hackname = lynxos_fcntl_proto; | |
774 | files = fcntl.h; | |
8f34d1e9 BK |
775 | select = 'fcntl.*\(int, int, int\)'; |
776 | sed = 's/\(fcntl.*(int, int, \)int)/\1...)/'; | |
0083c904 BK |
777 | }; |
778 | ||
779 | ||
780 | /* | |
8f34d1e9 BK |
781 | * libm.a on m88k-motorola-sysv3 contains a stupid optimization for |
782 | * function hypot(), which returns the second argument without even | |
783 | * looking at its value, if the other is 0.0. Another drawback is | |
784 | * that fix-header doesn't fix fabs' prototype, and I have no idea why. | |
0083c904 BK |
785 | */ |
786 | fix = { | |
787 | hackname = m88k_bad_hypot_opt; | |
788 | mach = "m88k-motorola-sysv3*"; | |
789 | files = "math.h"; | |
790 | ||
791 | sed = "s/extern double floor(), ceil(), fmod(), fabs();/" | |
792 | "extern double floor(), ceil(), fmod(), fabs _PARAMS((double));/"; | |
793 | ||
794 | sed = "/^extern double hypot();$/a\\\n" | |
795 | "\\/* Workaround a stupid Motorola optimization if one\\\n" | |
796 | " of x or y is 0.0 and the other is negative! *\\/\\\n" | |
797 | "#ifdef __STDC__\\\n" | |
798 | "static __inline__ double fake_hypot (double x, double y)\\\n" | |
799 | "#else\\\n" | |
800 | "static __inline__ double fake_hypot (x, y)\\\n" | |
801 | "\tdouble x, y;\\\n" | |
802 | "#endif\\\n" | |
803 | "{\\\n" | |
804 | "\treturn fabs (hypot (x, y));\\\n" | |
805 | "}\\\n" | |
806 | "#define hypot\tfake_hypot\n"; | |
807 | }; | |
808 | ||
809 | ||
810 | /* | |
8f34d1e9 BK |
811 | * Fix incorrect S_IF* definitions on m88k-sysv3. |
812 | */ | |
0083c904 BK |
813 | fix = { |
814 | hackname = m88k_bad_s_if; | |
815 | mach = "m88k-*-sysv3*"; | |
816 | files = sys/stat.h; | |
817 | select = "#define[ \t]+S_IS[A-Z]*(m)[ \t]"; | |
818 | ||
819 | sed = "s/^\\(#define[ \t]*S_IS[A-Z]*(m)\\)[ \t]*" | |
820 | "(m[ \t]*&[ \t]*\\(S_IF[A-Z][A-Z][A-Z][A-Z]*\\)[ \t]*)/" | |
821 | "\\1 (((m)\\&S_IFMT)==\\2)/"; | |
822 | ||
823 | sed = "s/^\\(#define[ \t]*S_IS[A-Z]*(m)\\)[ \t]*" | |
824 | "(m[ \t]*&[ \t]*\\(0[0-9]*\\)[ \t]*)/" | |
825 | "\\1 (((m)\\&S_IFMT)==\\2)/"; | |
826 | }; | |
827 | ||
828 | ||
829 | /* | |
830 | * Put cpp wrappers around these include files to avoid redeclaration | |
831 | * errors during multiple inclusion on m88k-tektronix-sysv3. | |
832 | */ | |
833 | fix = { | |
834 | hackname = m88k_multi_incl; | |
835 | mach = "m88k-tektronix-sysv3*"; | |
836 | files = "time.h"; | |
837 | bypass = "#ifndef"; | |
838 | shell = | |
839 | "echo Fixing $file, to protect against multiple inclusion. >&2 | |
840 | cpp_wrapper=`echo $file | sed -e 's,\\.,_,g' -e 's,/,_,g'` | |
8f34d1e9 BK |
841 | echo \"#ifndef __GCC_GOT_${cpp_wrapper}_\" |
842 | echo \"#define __GCC_GOT_${cpp_wrapper}_\" | |
843 | cat | |
844 | echo \"#endif /* ! __GCC_GOT_${cpp_wrapper}_ */\""; | |
0083c904 BK |
845 | }; |
846 | ||
847 | ||
848 | /* | |
8f34d1e9 | 849 | * Fix non-ansi machine name defines |
c6a1d2ff BK |
850 | * File selection is split into two parts: the shell version as |
851 | * a single patch, and the program version with each patch separate. | |
8f34d1e9 BK |
852 | * Each is substantially faster for the particular environment. |
853 | * You have a dual maintenance problem here. | |
0083c904 BK |
854 | */ |
855 | fix = { | |
856 | hackname = machine_name; | |
857 | /* | |
858 | * Select '#if.*' and '#elif" with possible non-ansi symbols | |
859 | * The only non-ansi symbols we know about start with one of: | |
860 | * MRS_bhimnprstuv | |
861 | * If any are added to the substitution list, then add it to | |
862 | * the selection list as well. Hopefully we can avoid names | |
863 | * starting with "d" and "l", because this pattern would then | |
864 | * match "defined" and "lint" as well. I suppose we could add | |
865 | * a "bypass = lint" if we had to though. | |
866 | * | |
867 | * The fixinc_eol stuff is to work around a bug in the sed | |
868 | */ | |
869 | select = "^#[ \t]*(if|elif).*" | |
870 | "[^a-zA-Z0-9_](_*[MSRrhim]|[Mbimnpstuv])[a-zA-Z0-9_]"; | |
871 | exesel = "^#[ \t]*(if|elif).*[^a-zA-Z0-9_]" | |
872 | "(" | |
873 | "M32" | |
7db774d2 BK |
874 | "|_*MIPSE[LB]" |
875 | "|_*SYSTYPE_[A-Z0-9]" | |
876 | "|_*[Rr][34]000" | |
877 | "|_*host_mips" | |
878 | "|_*i386" | |
879 | "|_*mips" | |
0083c904 BK |
880 | "|bsd4" |
881 | "|is68k" | |
882 | "|m[68]8k" | |
883 | "|mc680" | |
884 | "|news" | |
885 | "|ns32000" | |
886 | "|pdp11" | |
887 | "|pyr" | |
888 | "|sel" | |
889 | "|sony_news" | |
890 | "|sparc" | |
891 | "|sun" | |
892 | "|tahoe" | |
893 | "|tower" | |
894 | "|u370" | |
895 | "|u3b" | |
896 | "|unix" | |
897 | "|vax" | |
898 | ")"; | |
899 | ||
900 | sed = ":loop\n" | |
901 | '/\\\\$/' "N\n" | |
902 | 's/\\\\$/\\\\+++fixinc_eol+++/' "\n" | |
903 | '/\\\\$/' "b loop\n" | |
904 | 's/\\\\+++fixinc_eol+++/\\\\/g' "\n" | |
905 | ||
906 | "/#[\t ]*[el]*if/ {\n" | |
907 | "\ts/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g\n" | |
908 | ||
909 | "\ts/ M32 / __M32__ /g\n" | |
910 | "\ts/ _*MIPSE\\([LB]\\) / __MIPSE\\1__ /g\n" | |
911 | "\ts/ _*SYSTYPE_\\([A-Z0-9]*\\) / __SYSTYPE_\\1__ /g\n" | |
912 | "\ts/ _*\\([Rr][34]\\)000 / __\\1000__ /g\n" | |
913 | "\ts/ _*host_mips / __host_mips__ /g\n" | |
914 | "\ts/ _*i386 / __i386__ /g\n" | |
915 | "\ts/ _*mips / __mips__ /g\n" | |
916 | "\ts/ bsd4\\([0-9]\\) / __bsd4\\1__ /g\n" | |
917 | "\ts/ is68k / __is68k__ /g\n" | |
918 | "\ts/ m68k / __m68k__ /g\n" | |
919 | "\ts/ m88k / __m88k__ /g\n" | |
920 | "\ts/ mc680\\([0-9]\\)0 / __mc680\\10__ /g\n" | |
921 | "\ts/ news\\([0-9]*\\) / __news\\1__ /g\n" | |
922 | "\ts/ ns32000 / __ns32000__ /g\n" | |
923 | "\ts/ pdp11 / __pdp11__ /g\n" | |
924 | "\ts/ pyr / __pyr__ /g\n" | |
925 | "\ts/ sel / __sel__ /g\n" | |
926 | "\ts/ sony_news / __sony_news__ /g\n" | |
927 | "\ts/ sparc / __sparc__ /g\n" | |
928 | "\ts/ sun\\([a-z0-9]*\\) / __sun\\1__ /g\n" | |
929 | "\ts/ tahoe / __tahoe__ /g\n" | |
930 | "\ts/ tower\\([_0-9]*\\) / __tower\\1__ /g\n" | |
931 | "\ts/ u370 / __u370__ /g\n" | |
932 | "\ts/ u3b\\([0-9]*\\) / __u3b\\1__ /g\n" | |
933 | "\ts/ unix / __unix__ /g\n" | |
934 | "\ts/ vax / __vax__ /g\n" | |
935 | ||
936 | "\ts/ \\([a-zA-Z0-9_][a-zA-Z0-9_]*\\) /\\1/g\n\t}"; | |
937 | }; | |
938 | ||
939 | ||
940 | /* | |
941 | * Some math.h files define struct exception, which conflicts with | |
942 | * the class exception defined in the C++ file std/stdexcept.h. We | |
943 | * redefine it to __math_exception. This is not a great fix, but I | |
944 | * haven't been able to think of anything better. | |
945 | */ | |
946 | fix = { | |
947 | hackname = math_exception; | |
948 | files = math.h; | |
949 | select = "struct exception"; | |
950 | sed = "/struct exception/i\\\n" | |
951 | "#ifdef __cplusplus\\\n" | |
952 | "#define exception __math_exception\\\n" | |
953 | "#endif\n"; | |
954 | sed = "/struct exception/a\\\n" | |
955 | "#ifdef __cplusplus\\\n" | |
956 | "#undef exception\\\n" | |
957 | "#endif\n"; | |
958 | ||
959 | sed = "/matherr/i\\\n" | |
960 | "#ifdef __cplusplus\\\n" | |
961 | "#define exception __math_exception\\\n" | |
962 | "#endif\n"; | |
963 | ||
964 | sed = "/matherr/a\\\n" | |
965 | "#ifdef __cplusplus\\\n" | |
966 | "#undef exception\\\n" | |
967 | "#endif\n"; | |
c6a1d2ff BK |
968 | |
969 | #ifdef MATH_EXCEPTION_FIXED | |
970 | ||
971 | I think this patch needs some more thinking. | |
972 | This is from SVR4.2 (With '#' replaced with '@'). | |
973 | Perhaps we could do without the "/matherr/a" entries? | |
974 | Can we bypass the entire fix if someone was astute | |
975 | enough to have '#ifdef __cplusplus' anywhere in the file? | |
976 | ||
977 | ||
978 | *** /usr/include/math.h Fri Apr 3 18:54:59 1998 | |
979 | --- math.h Sun May 9 07:28:58 1999 | |
980 | *************** | |
981 | *** 25,31 **** | |
982 | --- 25,37 ---- | |
983 | ||
984 | @ifndef __cplusplus | |
985 | ||
986 | + @ifdef __cplusplus | |
987 | + @define exception __math_exception | |
988 | + @endif | |
989 | struct exception | |
990 | + @ifdef __cplusplus | |
991 | + @undef exception | |
992 | + @endif | |
993 | { | |
994 | int type; | |
995 | char *name; | |
996 | *************** | |
997 | *** 34,40 **** | |
998 | --- 40,58 ---- | |
999 | double retval; | |
1000 | }; | |
1001 | ||
1002 | + @ifdef __cplusplus | |
1003 | + @define exception __math_exception | |
1004 | + @endif | |
1005 | + @ifdef __cplusplus | |
1006 | + @define exception __math_exception | |
1007 | + @endif | |
1008 | extern int matherr(struct exception *); | |
1009 | + @ifdef __cplusplus | |
1010 | + @undef exception | |
1011 | + @endif | |
1012 | + @ifdef __cplusplus | |
1013 | + @undef exception | |
1014 | + @endif | |
1015 | ||
1016 | @endif /*__cplusplus*/ | |
1017 | #endif | |
0083c904 BK |
1018 | }; |
1019 | ||
1020 | ||
1021 | /* | |
1022 | * In math.h, put #ifndefs around things that might be defined | |
1023 | * in a gcc specific math-*.h file. | |
1024 | */ | |
1025 | fix = { | |
1026 | hackname = math_gcc_ifndefs; | |
1027 | files = math.h; | |
0083c904 | 1028 | |
8f34d1e9 BK |
1029 | shell = |
1030 | /* | |
1031 | * First see if we have a definition for DBL_MAX in float.h | |
1032 | * If we do, we will replace the one in math.h with that one. | |
1033 | */ | |
0083c904 | 1034 | |
8f34d1e9 BK |
1035 | /* |
1036 | * IF we have such a define *and* HUGE_VAL is defined to be DBL_MAX | |
1037 | * *and* DBL_MAX is _not_ defined in the current file (math.h), | |
1038 | * THEN replace the defined value of HUGE_VAL | |
1039 | * ELSE just copy stdin to stdout so the main filter can process it | |
1040 | */ | |
0083c904 | 1041 | |
8f34d1e9 BK |
1042 | /* |
1043 | * Put conditional guards around the HUGE_VAL definition. | |
1044 | */ | |
0083c904 | 1045 | |
8f34d1e9 BK |
1046 | "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h " |
1047 | "2>/dev/null`\n\n" | |
0083c904 | 1048 | |
8f34d1e9 BK |
1049 | "\tif ( test -n \"${dbl_max_def}\" \\\n" |
1050 | "\t\t-a -n \"`egrep '#define[ \t]*HUGE_VAL[ \t]+DBL_MAX' $file`\" \\\n" | |
1051 | "\t\t-a -z \"`egrep '#define[ \t]+DBL_MAX[ \t]+' $file`\"\n" | |
1052 | "\t ) > /dev/null 2>&1\n" | |
1053 | "\tthen sed -e '/define[ \t]HUGE_VAL[ \t]DBL_MAX/s/DBL_MAX/$dbl_max_def/'" | |
1054 | "\n\telse cat ; fi |\n" | |
1055 | ||
5aa8e979 KG |
1056 | "\tsed -e '/define[ \t]HUGE_VAL[ \t]/i\\\n#ifndef HUGE_VAL\n' " |
1057 | "-e '/define[ \t]HUGE_VAL[ \t]/a\\\n#endif\n'"; | |
0083c904 BK |
1058 | }; |
1059 | ||
1060 | ||
1061 | /* | |
1062 | * nested comment | |
1063 | */ | |
1064 | fix = { | |
1065 | hackname = nested_comment; | |
1066 | files = rpc/rpc.h; | |
1067 | sed = 's@^\(/\*.*rpc/auth_des.h>.*\)/\*@\1*/ /*@'; | |
1068 | }; | |
1069 | ||
1070 | ||
1071 | /* | |
1072 | * fix bogus recursive stdlib.h in NEWS-OS 4.0C | |
1073 | */ | |
1074 | fix = { | |
1075 | hackname = news_os_recursion; | |
1076 | files = stdlib.h; | |
1077 | select = "#include <stdlib.h>"; | |
1078 | sed = "/^#include <stdlib.h>/i\\\n" | |
1079 | "#ifdef BOGUS_RECURSION\n"; | |
1080 | sed = "/^#include <stdlib.h>/a\\\n" | |
1081 | "#endif\n"; | |
1082 | }; | |
1083 | ||
1084 | ||
1085 | /* | |
1086 | * NeXT 3.2 adds const prefix to some math functions. | |
1087 | * These conflict with the built-in functions. | |
1088 | */ | |
1089 | fix = { | |
1090 | hackname = next_math_prefix; | |
1091 | files = ansi/math.h; | |
1092 | select = "^extern.*double.*__const__.*"; | |
1093 | ||
1094 | sed = "/^extern.*double.*__const__.*sqrt(/s/__const__//"; | |
1095 | sed = "/^extern.*double.*__const__.*fabs(/s/__const__//"; | |
1096 | sed = "/^extern.*double.*__const__.*cos(/s/__const__//"; | |
1097 | sed = "/^extern.*double.*__const__.*hypot(/s/__const__//"; | |
1098 | sed = "/^extern.*double.*__const__.*sin(/s/__const__//"; | |
1099 | }; | |
1100 | ||
1101 | ||
1102 | /* | |
1103 | * NeXT 3.2 uses the word "template" as a parameter for some | |
1104 | * functions. GCC reports an invalid use of a reserved key word | |
1105 | * with the built-in functions. NeXT 3.2 includes the keyword | |
1106 | * volatile in the prototype for abort(). This conflicts with | |
1107 | * the built-in definition. | |
1108 | */ | |
1109 | fix = { | |
1110 | hackname = next_template; | |
1111 | files = bsd/libc.h; | |
1112 | select = template; | |
1113 | ||
1114 | sed = '/\(.*template\)/s/template//'; | |
1115 | sed = "/extern.*volatile.*void.*abort/s/volatile//"; | |
1116 | }; | |
1117 | ||
1118 | ||
1119 | /* | |
1120 | * NeXT 3.2 includes the keyword volatile in the abort() and exit() | |
1121 | * function prototypes. That conflicts with the built-in functions. | |
1122 | */ | |
1123 | fix = { | |
1124 | hackname = next_volitile; | |
1125 | files = ansi/stdlib.h; | |
1126 | select = volatile; | |
1127 | ||
1128 | sed = "/extern.*volatile.*void.*exit/s/volatile//"; | |
1129 | sed = "/extern.*volatile.*void.*abort/s/volatile//"; | |
1130 | }; | |
1131 | ||
1132 | ||
1133 | /* | |
1134 | * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1. | |
1135 | * Note that version 3 of the NeXT system has wait.h in a different directory, | |
1136 | * so that this code won't do anything. But wait.h in version 3 has a | |
1137 | * conditional, so it doesn't need this fix. So everything is okay. | |
1138 | */ | |
1139 | fix = { | |
1140 | hackname = next_wait_union; | |
1141 | files = sys/wait.h; | |
1142 | ||
1143 | select = 'wait\(union wait'; | |
1144 | ||
1145 | sed = "s@wait(union wait@wait(void@"; | |
1146 | }; | |
1147 | ||
1148 | ||
1149 | /* | |
1150 | * a missing semi-colon at the end of the nodeent structure definition. | |
1151 | */ | |
1152 | fix = { | |
1153 | hackname = nodeent_syntax; | |
1154 | files = netdnet/dnetdb.h; | |
1155 | sed = "s/char.*na_addr *$/char *na_addr;/"; | |
1156 | }; | |
1157 | ||
1158 | ||
1159 | /* | |
1160 | * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by | |
1161 | * defining regex.h related types. This causes libg++ build and usage | |
1162 | * failures. Fixing this correctly requires checking and modifying 3 files. | |
1163 | */ | |
1164 | fix = { | |
1165 | hackname = osf_namespace_a; | |
1166 | files = reg_types.h; | |
1167 | files = sys/lc_core.h; | |
8f34d1e9 BK |
1168 | test = " -r reg_types.h"; |
1169 | test = " -r sys/lc_core.h"; | |
1170 | test = " -n \"`grep '} regex_t;' reg_types.h`\""; | |
1171 | test = " -z \"`grep __regex_t regex.h`\""; | |
0083c904 BK |
1172 | |
1173 | sed = "s/regex_t/__regex_t/g"; | |
1174 | sed = "s/regoff_t/__regoff_t/g"; | |
1175 | sed = "s/regmatch_t/__regmatch_t/g"; | |
1176 | }; | |
1177 | ||
1178 | fix = { | |
1179 | hackname = osf_namespace_b; | |
1180 | files = regex.h; | |
8f34d1e9 BK |
1181 | test = " -r reg_types.h"; |
1182 | test = " -r sys/lc_core.h"; | |
1183 | test = " -n \"`grep '} regex_t;' reg_types.h`\""; | |
1184 | test = " -z \"`grep __regex_t regex.h`\""; | |
1185 | ||
0083c904 BK |
1186 | sed = "/#include <reg_types.h>/a\\\n" |
1187 | "typedef __regex_t\tregex_t;\\\n" | |
1188 | "typedef __regoff_t\tregoff_t;\\\n" | |
1189 | "typedef __regmatch_t\tregmatch_t;\n"; | |
1190 | }; | |
1191 | ||
1192 | ||
1193 | /* | |
1194 | * Fix __page_size* declarations in pthread.h AIX 4.1.[34]. | |
1195 | * The original ones fail if uninitialized externs are not common. | |
1196 | * This is the default for all ANSI standard C++ compilers. | |
1197 | */ | |
1198 | fix = { | |
1199 | hackname = pthread_page_size; | |
1200 | files = pthread.h; | |
1201 | select = "^int __page_size"; | |
1202 | sed = "s/^int __page_size/extern int __page_size/"; | |
1203 | }; | |
1204 | ||
1205 | ||
1206 | /* | |
1207 | * Fix return type of fread and fwrite on sysV68 | |
1208 | */ | |
1209 | #ifdef LATER | |
1210 | fix = { | |
1211 | hackname = read_ret_type; | |
1212 | files = stdio.h; | |
1213 | sed = "s/^\\(extern int\tfclose(), fflush()\\), " | |
1214 | "\\(fread(), fwrite()\\)\\(.*\\)$" | |
1215 | "/extern unsigned int\t\\2;\\\n\\1\\3/"; | |
1216 | }; | |
1217 | #endif | |
1218 | ||
1219 | ||
1220 | /* | |
1221 | * function class(double x) conflicts with C++ keyword on rs/6000 | |
1222 | */ | |
1223 | fix = { | |
1224 | hackname = rs6000_double; | |
1225 | files = math.h; | |
1226 | select = '[^a-zA-Z_]class\('; | |
1227 | ||
1228 | sed = "/class[(]/i\\\n#ifndef __cplusplus\n"; | |
1229 | sed = "/class[(]/a\\\n#endif\n"; | |
1230 | }; | |
1231 | ||
1232 | ||
1233 | /* | |
1234 | * Wrong fchmod prototype on RS/6000. | |
1235 | */ | |
1236 | fix = { | |
1237 | hackname = rs6000_fchmod; | |
1238 | files = sys/stat.h; | |
1239 | select = 'fchmod\(char'; | |
1240 | sed = 's/fchmod(char \*/fchmod(int/'; | |
1241 | }; | |
1242 | ||
1243 | ||
1244 | /* | |
1245 | * parameters conflict with C++ new on rs/6000 | |
1246 | */ | |
1247 | fix = { | |
1248 | hackname = rs6000_param; | |
1249 | files = "stdio.h"; | |
1250 | files = "unistd.h"; | |
1251 | ||
1252 | sed = 's@rename(const char \*old, const char \*new)@' | |
1253 | 'rename(const char *_old, const char *_new)@'; | |
1254 | }; | |
1255 | ||
1256 | ||
1257 | /* | |
1258 | * Sony NEWSOS 5.0 does not support the complete ANSI C standard. | |
1259 | */ | |
1260 | #ifdef SONY | |
1261 | fix = { | |
1262 | hackname = sony_ctype; | |
1263 | files = ctype.h; | |
8f34d1e9 BK |
1264 | test = " -x /bin/sony"; |
1265 | test = " ! -z \"`if /bin/sony ; then echo true ; fi`\""; | |
0083c904 BK |
1266 | sed = "s/__ctype/_ctype/g"; |
1267 | }; | |
1268 | #endif | |
1269 | ||
1270 | /* | |
1271 | * Incorrect #include in Sony News-OS 3.2. | |
1272 | */ | |
1273 | fix = { | |
1274 | hackname = sony_include; | |
1275 | files = machine/machparam.h; | |
1276 | select = '"\.\./machine/endian.h"'; | |
1277 | sed = 's@"../machine/endian.h"@<machine/endian.h>@'; | |
1278 | }; | |
1279 | ||
1280 | ||
1281 | /* | |
1282 | * Sony NEWSOS 5.0 does not support the complete ANSI C standard. | |
1283 | */ | |
1284 | #ifdef SONY | |
1285 | fix = { | |
1286 | hackname = sony_stdio; | |
1287 | files = stdio.h; | |
8f34d1e9 BK |
1288 | test = " -x /bin/sony"; |
1289 | test = " ! -z \"`if /bin/sony ; then echo true ; fi`\""; | |
0083c904 BK |
1290 | sed = "s/__filbuf/_filbuf/g\n" |
1291 | "s/__flsbuf/_flsbuf/g\n" | |
1292 | "s/__iob/_iob/g"; | |
1293 | }; | |
1294 | #endif | |
1295 | ||
1296 | /* | |
1297 | * Add a `static' declaration of `getrnge' into <regexp.h>. | |
1298 | * | |
1299 | * Don't do this if there is already a `static void getrnge' declaration | |
1300 | * present, since this would cause a redeclaration error. Solaris 2.x has | |
1301 | * such a declaration. | |
1302 | */ | |
1303 | #ifdef SVR4 | |
1304 | fix = { | |
1305 | hackname = static_getrnge; | |
1306 | files = regexp.h; | |
1307 | bypass = "static void getrnge"; | |
1308 | sed = "/^static int[ \t]*size;/c\\\n" | |
1309 | "static int size ;\\\n\\\n" | |
1310 | "static int getrnge ();"; | |
1311 | }; | |
1312 | #endif | |
1313 | ||
1314 | /* | |
1315 | * a missing semi-colon at the end of the statsswtch structure definition. | |
1316 | */ | |
1317 | fix = { | |
1318 | hackname = statsswtch; | |
1319 | files = rpcsvc/rstat.h; | |
1320 | select = "boottime$"; | |
1321 | sed = "s/boottime$/boottime;/"; | |
1322 | }; | |
1323 | ||
1324 | ||
1325 | /* | |
1326 | * Don't use or define the name va_list in stdio.h. | |
1327 | * This is for ANSI and also to interoperate properly with gcc's varargs.h. | |
1328 | * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list | |
1329 | */ | |
1330 | fix = { | |
1331 | hackname = stdio_va_list; | |
1332 | files = stdio.h; | |
1333 | ||
1334 | /* | |
1335 | * Use __gnuc_va_list in arg types in place of va_list. | |
1336 | * On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the | |
1337 | * trailing parentheses and semicolon save all other systems from this. | |
1338 | * Define __va_list__ (something harmless and unused) instead of va_list. | |
1339 | * Don't claim to have defined va_list. | |
1340 | */ | |
1341 | shell = | |
1342 | "if ( egrep \"__need___va_list\" $file ) > /dev/null 2>&1 ; then | |
1343 | : | |
1344 | else | |
1345 | echo \"#define __need___va_list\" | |
1346 | echo \"#include <stdarg.h>\" | |
1347 | fi | |
1348 | ||
1349 | sed -e 's@ va_list @ __gnuc_va_list @' \\ | |
1350 | -e 's@ va_list)@ __gnuc_va_list)@' \\ | |
1351 | -e 's@ _BSD_VA_LIST_));@ __gnuc_va_list));@' \\ | |
1352 | -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \\ | |
1353 | -e 's@ va_list@ __va_list__@' \\ | |
1354 | -e 's@\\*va_list@*__va_list__@' \\ | |
1355 | -e 's@ __va_list)@ __gnuc_va_list)@' \\ | |
1356 | -e 's@GNUC_VA_LIST@GNUC_Va_LIST@' \\ | |
1357 | -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \\ | |
1358 | -e 's@VA_LIST@DUMMY_VA_LIST@' \\ | |
1359 | -e 's@_Va_LIST@_VA_LIST@'"; | |
1360 | }; | |
1361 | ||
1362 | ||
1363 | /* | |
1364 | * Check for strict ansi compliance | |
1365 | */ | |
1366 | #ifdef STRICT_ANSI | |
1367 | fix = { | |
1368 | hackname = strict_ansi; | |
1369 | select = "__STDC__[ \t]*[=!]=[ \t]*[01]"; | |
1370 | sed = "s/__STDC__[ \t]*==[ \t]*0/!defined (__STRICT_ANSI__)/g"; | |
1371 | sed = "s/__STDC__[ \t]*!=[ \t]*0/defined (__STRICT_ANSI__)/g"; | |
1372 | sed = "s/__STDC__[ \t]*==[ \t]*1/defined (__STRICT_ANSI__)/g"; | |
1373 | sed = "s/__STDC__[ \t]*!=[ \t]*1/!defined (__STRICT_ANSI__)/g"; | |
1374 | }; | |
1375 | #endif | |
1376 | ||
1377 | /* | |
1378 | * Fix bogus #ifdef on SunOS 4.1. | |
1379 | */ | |
1380 | fix = { | |
1381 | hackname = sun_bogus_ifdef; | |
1382 | files = "hsfs/hsfs_spec.h"; | |
1383 | files = "hsfs/iso_spec.h"; | |
1384 | select = '#ifdef __i386__ || __vax__'; | |
1385 | sed = "s/\\#ifdef __i386__ || __vax__/\\#if __i386__ || __vax__/g"; | |
1386 | }; | |
1387 | ||
1388 | ||
1389 | /* | |
1390 | * Fix bogus #ifdef on SunOS 4.1. | |
1391 | */ | |
1392 | fix = { | |
1393 | hackname = sun_bogus_ifdef_sun4c; | |
1394 | files = "hsfs/hsnode.h"; | |
1395 | select = '#ifdef __i386__ || __sun4c__'; | |
1396 | sed = "s/\\#ifdef __i386__ || __sun4c__/\\#if __i386__ || __sun4c__/g"; | |
1397 | }; | |
1398 | ||
1399 | ||
1400 | /* | |
1401 | * Fix the CAT macro in SunOS memvar.h. | |
1402 | */ | |
1403 | fix = { | |
1404 | hackname = sun_catmacro; | |
1405 | files = pixrect/memvar.h; | |
b75b4e92 | 1406 | select = "^#define[ \t]+CAT\\(a,b\\)"; |
0083c904 BK |
1407 | sed = "/^#define[ \t]CAT(a,b)/ i\\\n" |
1408 | "#ifdef __STDC__ \\\n" | |
1409 | "#define CAT(a,b) a##b\\\n" | |
1410 | "#else\n"; | |
1411 | ||
1412 | sed = "/^#define[ \t]CAT(a,b)/ a\\\n" | |
1413 | "#endif\n"; | |
1414 | }; | |
1415 | ||
1416 | ||
1417 | /* | |
1418 | * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1. | |
1419 | * Also fix return type of {m,re}alloc in <malloc.h> on sysV68 | |
1420 | */ | |
1421 | fix = { | |
1422 | hackname = sun_malloc; | |
1423 | files = malloc.h; | |
1424 | ||
1425 | sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g"; | |
1426 | sed = "s/int[ \t][ \t]*free/void\tfree/g"; | |
1427 | sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g"; | |
1428 | sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g"; | |
1429 | }; | |
1430 | ||
1431 | ||
1432 | /* | |
1433 | * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin | |
1434 | * declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because | |
1435 | * many other systems have similar text but correct versions of the file. | |
1436 | * To ensure only Sun's is fixed, we grep for a likely unique string. | |
1437 | * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t ) | |
1438 | */ | |
1439 | fix = { | |
1440 | hackname = sun_memcpy; | |
1441 | files = memory.h; | |
1442 | select = "/\\*\t@\\(#\\)" | |
1443 | "(head/memory.h\t50.1\t " | |
1444 | "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/"; | |
1445 | ||
1446 | sed = "1i\\\n/* This file was generated by fixincludes */\\\n" | |
1447 | "#ifndef __memory_h__\\\n" | |
1448 | "#define __memory_h__\\\n\\\n" | |
1449 | "#ifdef __STDC__\\\n" | |
1450 | "extern void *memccpy();\\\n" | |
1451 | "extern void *memchr();\\\n" | |
1452 | "extern void *memcpy();\\\n" | |
1453 | "extern void *memset();\\\n" | |
1454 | "#else\\\n" | |
1455 | "extern char *memccpy();\\\n" | |
1456 | "extern char *memchr();\\\n" | |
1457 | "extern char *memcpy();\\\n" | |
1458 | "extern char *memset();\\\n" | |
1459 | "#endif /* __STDC__ */\\\n\\\n" | |
1460 | "extern int memcmp();\\\n\\\n" | |
1461 | "#endif /* __memory_h__ */\n"; | |
1462 | ||
1463 | sed = "1,$d"; | |
1464 | }; | |
1465 | ||
1466 | ||
1467 | /* | |
1468 | * Check for yet more missing ';' in struct (in SunOS 4.0.x) | |
1469 | */ | |
1470 | fix = { | |
1471 | hackname = sun_rusers_semi; | |
1472 | files = rpcsvc/rusers.h; | |
1473 | select = "_cnt$"; | |
1474 | sed = "/^struct/,/^};/s/_cnt$/_cnt;/"; | |
1475 | }; | |
1476 | ||
1477 | ||
1478 | /* | |
1479 | * signal.h on SunOS defines signal using (), | |
1480 | * which causes trouble when compiling with g++ -pedantic. | |
1481 | */ | |
1482 | fix = { | |
1483 | hackname = sun_signal; | |
1484 | files = sys/signal.h; | |
1485 | files = signal.h; | |
1486 | select = "^void\t" '\(\*signal\(\)\)\(\);'; | |
1487 | ||
1488 | sed = "/^void\t" '(\*signal())();$/i' "\\\n" | |
1489 | "#ifdef __cplusplus" "\\\n" | |
1490 | "void\t(*signal(...))(...);" "\\\n" | |
1491 | "#else" "\n"; | |
1492 | ||
1493 | sed = "/^void\t" '(\*signal())();$/a' "\\\n" | |
1494 | '#endif' "\n"; | |
1495 | }; | |
1496 | ||
1497 | ||
1498 | /* | |
ef16b5e5 JL |
1499 | * Apply fix this to all OSs since this problem seems to effect |
1500 | * more than just SunOS. In general, fixes which are triggered | |
1501 | * by a specific target are bad. | |
0083c904 BK |
1502 | */ |
1503 | fix = { | |
1504 | hackname = sun_auth_proto; | |
1505 | files = rpc/auth.h; | |
1506 | files = rpc/clnt.h; | |
1507 | files = rpc/svc.h; | |
1508 | files = rpc/xdr.h; | |
0083c904 BK |
1509 | /* |
1510 | * Select those files containing '(*name)()' but *not* | |
1511 | * containing '(*name)(junk)'. The change would be innocuous | |
1512 | * but there is no point bothering if the fix is not needed. | |
1513 | */ | |
1514 | select = '\(\*[a-z][a-z_]*\)\(\)'; | |
1515 | bypass = '\(\*[a-z][a-z_]*\)\(' "[ \t]*[a-zA-Z.].*" '\)'; | |
1516 | sed = 's' | |
1517 | '/^\(.*(\*[a-z][a-z_]*)(\)' '\();.*\)' | |
1518 | "/\\\n" | |
1519 | "#ifdef __cplusplus\\\n" | |
1520 | '\1...\2' "\\\n" | |
1521 | "#else\\\n" | |
1522 | '\1\2' "\\\n" | |
1523 | "#endif" | |
1524 | "/"; | |
1525 | }; | |
1526 | ||
1527 | ||
0083c904 BK |
1528 | /* |
1529 | * math.h on SunOS 4 puts the declaration of matherr before the definition | |
1530 | * of struct exception, so the prototype (added by fixproto) causes havoc. | |
1531 | */ | |
1532 | fix = { | |
1533 | hackname = sunos_matherr_decl; | |
1534 | files = math.h; | |
1535 | /* | |
8f34d1e9 BK |
1536 | * Once a declaration for 'struct exception' is found, |
1537 | * stop trying to insert a forward reference for it. | |
0083c904 | 1538 | */ |
8f34d1e9 | 1539 | sed = "/^struct exception/,$b"; |
0083c904 BK |
1540 | sed = "/matherr/i\\\nstruct exception;\n"; |
1541 | }; | |
1542 | ||
1543 | ||
1544 | /* | |
1545 | * Correct the return type for strlen in strings.h in SunOS 4. | |
1546 | */ | |
1547 | fix = { | |
1548 | hackname = sunos_strlen; | |
1549 | files = strings.h; | |
1550 | sed = "s/int[ \t]*strlen();/__SIZE_TYPE__ strlen();/"; | |
1551 | }; | |
1552 | ||
1553 | ||
1554 | /* | |
1555 | * Solaris math.h and floatingpoint.h define __P without protection, | |
1556 | * which conflicts with the fixproto definition. The fixproto | |
1557 | * definition and the Solaris definition are used the same way. | |
1558 | */ | |
1559 | #ifdef SVR4 | |
1560 | fix = { | |
1561 | hackname = svr4__p; | |
1562 | files = math.h; | |
1563 | files = floatingpoint.h; | |
1564 | select = "^#define[ \t]*__P"; | |
1565 | sed = "/^#define[ \t]*__P/i\\\n#ifndef __P\n"; | |
1566 | sed = "/^#define[ \t]*__P/a\\\n#endif\n"; | |
1567 | }; | |
1568 | #endif | |
1569 | ||
1570 | /* | |
1571 | * Disable apparent native compiler optimization cruft in SVR4.2 <string.h> | |
1572 | * that is visible to any ANSI compiler using this include. Simply | |
1573 | * delete the lines that #define some string functions to internal forms. | |
1574 | */ | |
1575 | #ifdef SVR4 | |
1576 | fix = { | |
1577 | hackname = svr4_disable_opt; | |
1578 | files = string.h; | |
1579 | select = '#define.*__std_hdr_'; | |
1580 | sed = '/#define.*__std_hdr_/d'; | |
1581 | }; | |
1582 | #endif | |
1583 | ||
1584 | /* | |
1585 | * Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__. | |
1586 | */ | |
1587 | #ifdef SVR4 | |
1588 | fix = { | |
1589 | hackname = svr4_endian; | |
1590 | files = sys/endian.h; | |
1591 | bypass = '__GNUC__'; | |
1592 | ||
1593 | sed = "/#\tifdef\t__STDC__/i\\\n" | |
1594 | "# if !defined (__GNUC__) && !defined (__GNUG__)\n"; | |
1595 | ||
1596 | sed = "/#\t\tinclude\t<sys\\/byteorder.h>/s/\t\t/ /"; | |
1597 | ||
1598 | sed = "/# include\t<sys\\/byteorder.h>/i\\\n" | |
1599 | "# endif /* !defined (__GNUC__) && !defined (__GNUG__) */\n"; | |
1600 | }; | |
1601 | #endif | |
1602 | ||
1603 | /* | |
1604 | * Remove useless extern keyword from struct forward declarations | |
1605 | * in <sys/stream.h> and <sys/strsubr.h> | |
1606 | */ | |
1607 | #ifdef SVR4 | |
1608 | fix = { | |
1609 | hackname = svr4_extern_struct; | |
1610 | files = sys/stream.h; | |
1611 | files = sys/strsubr.h; | |
1612 | select = 'extern struct [a-z_]*;'; | |
1613 | sed = 's/extern struct \([a-z][a-z_]*\)/struct \1/'; | |
1614 | }; | |
1615 | #endif | |
1616 | ||
1617 | /* | |
1618 | * Fix declarations of `ftw' and `nftw' in <ftw.h>. On some/most SVR4 | |
1619 | * systems the file <ftw.h> contains extern declarations of these | |
1620 | * functions followed by explicitly `static' definitions of these | |
1621 | * functions... and that's not allowed according to ANSI C. (Note | |
1622 | * however that on Solaris, this header file glitch has been pre-fixed by | |
1623 | * Sun. In the Solaris version of <ftw.h> there are no static | |
1624 | * definitions of any function so we don't need to do any of this stuff | |
1625 | * when on Solaris. | |
1626 | */ | |
1627 | #ifdef SVR4 | |
1628 | #ifndef SOLARIS | |
1629 | fix = { | |
1630 | hackname = svr4_ftw; | |
1631 | files = ftw.h; | |
1632 | select = '^extern int ftw\(const'; | |
1633 | ||
1634 | sed = '/^extern int ftw(const/i' "\\\n" | |
1635 | "#if !defined(_STYPES)\\\n" | |
1636 | "static\\\n" | |
1637 | "#else\\\n" | |
1638 | "extern\\\n" | |
1639 | "#endif"; | |
1640 | sed = 's/extern \(int ftw(const.*\)$/\1/'; | |
1641 | sed = "/^extern int nftw/i\\\n" | |
1642 | "#if defined(_STYPES)\\\n" | |
1643 | "static\\\n" | |
1644 | "#else\\\n" | |
1645 | "extern\\\n" | |
1646 | "#endif"; | |
1647 | sed = 's/extern \(int nftw.*\)$/\1/'; | |
1648 | sed = "/^extern int ftw(),/c\\\n" | |
1649 | "#if !defined(_STYPES)\\\n" | |
1650 | "static\\\n" | |
1651 | "#else\\\n" | |
1652 | "extern\\\n" | |
1653 | "#endif\\\n" | |
1654 | " int ftw();\\\n" | |
1655 | "#if defined(_STYPES)\\\n" | |
1656 | "static\\\n" | |
1657 | "#else\\\n" | |
1658 | "extern\\\n" | |
1659 | "#endif\\\n" | |
1660 | " int nftw();"; | |
1661 | }; | |
1662 | #endif | |
1663 | #endif | |
1664 | ||
1665 | ||
1666 | /* | |
1667 | * Fix broken decl of getcwd present on some svr4 systems. | |
1668 | */ | |
1669 | #ifdef SVR4 | |
1670 | fix = { | |
1671 | hackname = svr4_getcwd; | |
1672 | files = stdlib.h; | |
1673 | files = unistd.h; | |
1674 | select = 'getcwd\(char \*, int\)'; | |
1675 | ||
1676 | sed = 's/getcwd(char \*, int)/getcwd(char *, size_t)/'; | |
1677 | }; | |
1678 | #endif | |
1679 | ||
1680 | /* | |
1681 | * set ifdef _KERNEL | |
1682 | */ | |
1683 | #ifdef SVR4 | |
1684 | fix = { | |
1685 | hackname = svr4_kernel; | |
1686 | files = fs/rfs/rf_cache.h; | |
1687 | files = sys/erec.h; | |
1688 | files = sys/err.h; | |
1689 | files = sys/char.h; | |
1690 | files = sys/getpages.h; | |
1691 | files = sys/map.h; | |
1692 | files = sys/cmn_err.h; | |
1693 | files = sys/kdebugger.h; | |
1694 | bypass = '_KERNEL'; | |
1695 | sed = "1i\\\n#ifdef _KERNEL"; | |
1696 | sed = "$a\\\n#endif /* _KERNEL */"; | |
1697 | }; | |
1698 | #endif | |
1699 | ||
1700 | /* | |
1701 | * Delete any #defines of `__i386' which may be present in <ieeefp.h>. They | |
1702 | * tend to conflict with the compiler's own definition of this symbol. (We | |
1703 | * will use the compiler's definition.) | |
1704 | * Likewise __sparc, for Solaris, and __i860, and a few others | |
1705 | * (guessing it is necessary for all of them). | |
1706 | */ | |
1707 | #ifdef SVR4 | |
1708 | fix = { | |
1709 | hackname = svr4_mach_defines; | |
1710 | files = ieeefp.h; | |
1711 | select = "#define[ \t]*__(i386|i860|mips|sparc|m88k|m68k)[ \t]"; | |
1712 | sed = "/#define[ \t]*__\\(i386|i860|mips|sparc|m88k|m68k\\)[ \t]/d"; | |
1713 | }; | |
1714 | #endif | |
1715 | ||
1716 | /* | |
1717 | * Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>. | |
1718 | */ | |
1719 | #ifdef SVR4 | |
1720 | fix = { | |
1721 | hackname = svr4_mkdev; | |
1722 | files = sys/mkdev.h; | |
1723 | ||
1724 | sed = "/^dev_t makedev(const/c\\\n" | |
1725 | "static dev_t makedev(const major_t, const minor_t);"; | |
1726 | ||
1727 | sed = "/^dev_t makedev()/c\\\n" | |
1728 | "static dev_t makedev();"; | |
1729 | ||
1730 | sed = "/^major_t major(const/c\\\n" | |
1731 | "static major_t major(const dev_t);"; | |
1732 | ||
1733 | sed = "/^major_t major()/c\\\n" | |
1734 | "static major_t major();"; | |
1735 | ||
1736 | sed = "/^minor_t minor(const/c\\\n" | |
1737 | "static minor_t minor(const dev_t);"; | |
1738 | ||
1739 | sed = "/^minor_t minor()/c\\\n" | |
1740 | "static minor_t minor();"; | |
1741 | }; | |
1742 | #endif | |
1743 | ||
1744 | /* | |
1745 | * Fix reference to NC_NPI_RAW in <sys/netcspace.h>. | |
1746 | * Also fix types of array initializers. | |
1747 | */ | |
1748 | #ifdef SVR4 | |
1749 | fix = { | |
1750 | hackname = svr4_netcspace; | |
1751 | files = sys/netcspace.h; | |
1752 | select = 'NC_NPI_RAW'; | |
1753 | sed = 's/NC_NPI_RAW/NC_TPI_RAW/g'; | |
1754 | sed = 's/NC_/(unsigned long) NC_/'; | |
1755 | }; | |
1756 | #endif | |
1757 | ||
1758 | /* | |
1759 | * Fix reference to NMSZ in <sys/adv.h>. | |
1760 | */ | |
1761 | #ifdef SVR4 | |
1762 | fix = { | |
1763 | hackname = svr4_nmsz; | |
1764 | files = sys/adv.h; | |
1765 | select = '\[NMSZ\]'; | |
1766 | sed = 's/\[NMSZ\]/\[RFS_NMSZ\]/g'; | |
1767 | }; | |
1768 | #endif | |
1769 | ||
1770 | /* | |
1771 | * Completely replace <sys/varargs.h> with a file that includes gcc's | |
1772 | * stdarg.h or varargs.h files as appropriate. | |
1773 | */ | |
1774 | #ifdef SVR4 | |
1775 | fix = { | |
1776 | hackname = svr4_no_varargs; | |
1777 | files = sys/varargs.h; | |
1778 | shell = "cat > /dev/null\n" | |
1779 | "cat << _EOF_\n" | |
1780 | "/* This file was generated by fixincludes. */\n" | |
1781 | "#ifndef _SYS_VARARGS_H\n" | |
1782 | "#define _SYS_VARARGS_H\n\n" | |
1783 | ||
1784 | "#ifdef __STDC__\n" | |
1785 | "#include <stdarg.h>\n" | |
1786 | "#else\n" | |
1787 | "#include <varargs.h>\n" | |
1788 | "#endif\n\n" | |
1789 | ||
1790 | "#endif /* _SYS_VARARGS_H */\n" | |
1791 | "_EOF_"; | |
1792 | }; | |
1793 | #endif | |
1794 | ||
1795 | /* | |
1796 | * Fix broken decl of profil present on some svr4 systems. | |
1797 | */ | |
1798 | #ifdef SVR4 | |
1799 | fix = { | |
1800 | hackname = svr4_profil; | |
1801 | files = stdlib.h; | |
1802 | files = unistd.h; | |
1803 | ||
1804 | sed = 's/profil(unsigned short \*, unsigned int, ' | |
1805 | 'unsigned int, unsigned int)' | |
1806 | '/profil(unsigned short *, size_t, int, unsigned)/'; | |
1807 | }; | |
1808 | #endif | |
1809 | ||
1810 | /* | |
1811 | * Convert functions to prototype form, and fix arg names in <sys/stat.h>. | |
1812 | */ | |
1813 | #ifdef SVR4 | |
1814 | fix = { | |
1815 | hackname = svr4_proto_form; | |
1816 | files = sys/stat.h; | |
1817 | select = 'const extern'; | |
1818 | ||
1819 | sed = "/^stat([ \t]*[^c]/ {\nN\nN\n" | |
1820 | "s/(.*)\\n/( /\n" | |
1821 | "s/;\\n/, /\n" | |
1822 | "s/;$/)/\n" "}"; | |
1823 | ||
1824 | sed = "/^lstat([ \t]*[^c]/ {\nN\nN\n" | |
1825 | "s/(.*)\\n/( /\n" | |
1826 | "s/;\\n/, /\n" | |
1827 | "s/;$/)/\n" "}"; | |
1828 | ||
1829 | sed = "/^fstat([ \t]*[^i]/ {\nN\nN\n" | |
1830 | "s/(.*)\\n/( /\n" | |
1831 | "s/;\\n/, /\n" | |
1832 | "s/;$/)/\n" "}"; | |
1833 | ||
1834 | sed = "/^mknod([ \t]*[^c]/{\nN\nN\nN\n" | |
1835 | "s/(.*)\\n/( /\n" | |
1836 | "s/;\\n/, /g\n" | |
1837 | "s/;$/)/\n" "}"; | |
1838 | ||
1839 | sed = "1,$s/\\([^A-Za-z]\\)path\\([^A-Za-z]\\)/\\1__path\\2/g"; | |
1840 | sed = "1,$s/\\([^A-Za-z]\\)buf\\([^A-Za-z]\\)/\\1__buf\\2/g"; | |
1841 | sed = "1,$s/\\([^A-Za-z]\\)fd\\([^A-Za-z]\\)/\\1__fd\\2/g"; | |
1842 | sed = "1,$s/ret\\([^u]\\)/__ret\\1/g"; | |
1843 | sed = "1,$s/\\([^_]\\)mode\\([^_]\\)/\\1__mode\\2/g"; | |
1844 | sed = "1,$s/\\([^_r]\\)dev\\([^_]\\)/\\1__dev\\2/g"; | |
1845 | }; | |
1846 | #endif | |
1847 | ||
1848 | /* | |
1849 | * Add a prototyped declaration of mmap to <sys/mman.h>. | |
1850 | */ | |
1851 | #ifdef SVR4 | |
1852 | fix = { | |
1853 | hackname = svr4_proto_mmap; | |
1854 | files = sys/mman.h; | |
1855 | select = '^extern caddr_t mmap();$'; | |
1856 | sed = '/^extern caddr_t mmap();$/c' "\\\n" | |
1857 | "#ifdef __STDC__\\\n" | |
1858 | "extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\\\n" | |
1859 | "#else /* !defined(__STDC__) */\\\n" | |
1860 | "extern caddr_t mmap ();\\\n" | |
1861 | "#endif /* !defined(__STDC__) */\\\n"; | |
1862 | }; | |
1863 | #endif | |
1864 | ||
1865 | /* | |
1866 | * Add a #define of _SIGACTION_ into <sys/signal.h>. | |
1867 | */ | |
1868 | #ifdef SVR4 | |
1869 | fix = { | |
1870 | hackname = svr4_sigaction; | |
1871 | files = sys/signal.h; | |
1872 | sed = "/^struct sigaction {/i\\\n" | |
1873 | "#define _SIGACTION_"; | |
1874 | sed = 's/(void *(\*)())/(void (*)(int))/'; | |
1875 | }; | |
1876 | #endif | |
1877 | ||
1878 | /* | |
1879 | * Put storage class at start of decl, to avoid warning. | |
1880 | */ | |
1881 | #ifdef SVR4 | |
1882 | fix = { | |
1883 | hackname = svr4_storage_class; | |
1884 | files = rpc/types.h; | |
1885 | select = 'const extern'; | |
1886 | sed = 's/const extern/extern const/g'; | |
1887 | }; | |
1888 | #endif | |
1889 | ||
1890 | /* | |
1891 | * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn} | |
1892 | * in string.h on sysV68 | |
1893 | * Correct the return type for strlen in string.h on Lynx. | |
1894 | * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0. | |
1895 | * Add missing const for strdup on OSF/1 V3.0. | |
1896 | * On sysV88 layout is slightly different. | |
1897 | */ | |
1898 | fix = { | |
1899 | hackname = systypes; | |
1900 | files = "sys/types.h"; | |
1901 | files = "stdlib.h"; | |
1902 | files = "sys/stdtypes.h"; | |
1903 | files = "stddef.h"; | |
1904 | files = "memory.h"; | |
1905 | files = "unistd.h"; | |
1906 | select = "typedef[ \t]+[a-z_][ \ta-z_]*[ \t]" | |
1907 | "(size|ptrdiff|wchar)_t"; | |
1908 | ||
1909 | sed = "/^[ \t]*\\*[ \t]*typedef unsigned int size_t;/N"; | |
1910 | ||
1911 | sed = "s/^\\([ \t]*\\*[ \t]*typedef unsigned int size_t;\\n" | |
1912 | "[ \t]*\\*\\/\\)/\\1\\\n" | |
1913 | "#ifndef __SIZE_TYPE__\\\n" | |
1914 | "#define __SIZE_TYPE__ long unsigned int\\\n" | |
1915 | "#endif\\\n" | |
1916 | "typedef __SIZE_TYPE__ size_t;\\\n/"; | |
1917 | ||
1918 | sed = "/typedef[ \t][ \t]*[a-z_][ \ta-z_]*[ \t]size_t/i\\\n" | |
1919 | "#ifndef __SIZE_TYPE__\\\n" | |
1920 | "#define __SIZE_TYPE__ long unsigned int\\\n" | |
1921 | "#endif\n"; | |
1922 | ||
1923 | sed = "s/typedef[ \t][ \t]*[a-z_][ \ta-z_]*[ \t]size_t/" | |
1924 | "typedef __SIZE_TYPE__ size_t/"; | |
1925 | ||
1926 | sed = "/typedef[ \t][ \t]*[a-z_][ \ta-z_]*[ \t]ptrdiff_t/i\\\n" | |
1927 | "#ifndef __PTRDIFF_TYPE__\\\n" | |
1928 | "#define __PTRDIFF_TYPE__ long int\\\n" | |
1929 | "#endif\n"; | |
1930 | ||
1931 | sed = "s/typedef[ \t][ \t]*[a-z_][ \ta-z_]*[ \t]ptrdiff_t/" | |
1932 | "typedef __PTRDIFF_TYPE__ ptrdiff_t/"; | |
1933 | ||
1934 | sed = "/typedef[ \t][ \t]*[a-z_][ \ta-z_]*[ \t]wchar_t/i\\\n" | |
1935 | "#ifndef __WCHAR_TYPE__\\\n" | |
1936 | "#define __WCHAR_TYPE__ int\\\n" | |
1937 | "#endif\\\n" | |
1938 | "#ifndef __cplusplus\n"; | |
1939 | ||
1940 | sed = "/typedef[ \t][ \t]*[a-z_][ \ta-z_]*[ \t]wchar_t/a\\\n" | |
1941 | "#endif\n"; | |
1942 | ||
1943 | sed = "s/typedef[ \t][ \t]*[a-z_][ \ta-z_]*[ \t]wchar_t/" | |
1944 | "typedef __WCHAR_TYPE__ wchar_t/"; | |
1945 | }; | |
1946 | ||
1947 | ||
1948 | /* | |
1949 | * Fix return type of exit and abort in <stdlib.h> on SunOS 4.1. | |
1950 | * Also wrap protection around size_t for m88k-sysv3 systems. | |
1951 | * We use a funny name to ensure it follows 'systypes' fix. | |
1952 | */ | |
1953 | fix = { | |
1954 | hackname = systypes_for_aix; | |
1955 | files = sys/types.h; | |
1956 | select = "typedef[ \t][ \t]*[A-Za-z_][ \tA-Za-z_]*[ \t]size_t"; | |
1957 | bypass = "_GCC_SIZE_T"; | |
1958 | ||
1959 | sed = "/typedef[ \t][ \t]*[A-Za-z_][ \tA-Za-z_]*[ \t]size_t/i\\\n" | |
1960 | "#ifndef _GCC_SIZE_T\\\n" | |
1961 | "#define _GCC_SIZE_T\n"; | |
1962 | ||
1963 | sed = "/typedef[ \t][ \t]*[A-Za-z_][ \tA-Za-z_]*[ \t]size_t/a\\\n" | |
1964 | "#endif\n"; | |
1965 | }; | |
1966 | ||
1967 | ||
1968 | /* | |
1969 | * if the #if says _cplusplus, not the double underscore __cplusplus | |
1970 | * that it should be | |
1971 | */ | |
1972 | fix = { | |
1973 | hackname = sysv68_string; | |
1974 | files = string.h; | |
1975 | ||
1976 | sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/"; | |
1977 | sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/"; | |
1978 | sed = "s/strdup(char \\*s1);/strdup(const char *s1);/"; | |
1979 | sed = "/^extern char$/N"; | |
1980 | sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/"; | |
1981 | sed = "/^\tstrncmp(),$/N"; | |
1982 | sed = "s/^\\(\tstrncmp()\\),\\n\\(\tstrlen(),\\)$/\\1;\\\n" | |
1983 | "extern unsigned int\\\n\\2/"; | |
1984 | sed = "/^extern int$/N"; | |
1985 | sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/"; | |
1986 | }; | |
1987 | ||
1988 | ||
1989 | /* | |
ef16b5e5 JL |
1990 | * Fix return type of exit and abort in <stdlib.h> |
1991 | * Also wrap protection around size_t. | |
0083c904 BK |
1992 | */ |
1993 | fix = { | |
1994 | hackname = sysz_stdlib_for_sun; | |
0083c904 BK |
1995 | files = stdlib.h; |
1996 | ||
1997 | sed = "s/int\tabort/void\tabort/g"; | |
1998 | sed = "s/int\tfree/void\tfree/g"; | |
1999 | sed = "s/char[ \t]*\\*[ \t]*calloc/void \\*\tcalloc/g"; | |
2000 | sed = "s/char[ \t]*\\*[ \t]*malloc/void \\*\tmalloc/g"; | |
2001 | sed = "s/char[ \t]*\\*[ \t]*realloc/void \\*\trealloc/g"; | |
2002 | sed = "s/int[ \t][ \t]*exit/void\texit/g"; | |
2003 | ||
2004 | sed = "/typedef[ \ta-zA-Z_]*[ \t]size_t[ \t]*;/i\\\n" | |
2005 | "#ifndef _GCC_SIZE_T\\\n" | |
2006 | "#define _GCC_SIZE_T\n"; | |
2007 | ||
2008 | sed = "/typedef[ \ta-zA-Z_]*[ \t]size_t[ \t]*;/a\\\n" | |
2009 | "#endif\n"; | |
2010 | }; | |
2011 | ||
2012 | ||
2013 | /* | |
2014 | * Fix this Sun file to avoid interfering with stddef.h. | |
2015 | * We use a funny name to ensure it follows 'systypes' fix. | |
2016 | */ | |
2017 | fix = { | |
2018 | hackname = sysz_stdtypes_for_sun; | |
2019 | files = sys/stdtypes.h; | |
2020 | sed = "/[\t ]size_t.*;/i\\\n" | |
2021 | "#ifndef _GCC_SIZE_T\\\n" | |
2022 | "#define _GCC_SIZE_T\n"; | |
2023 | ||
2024 | sed = "/[\t ]size_t.*;/a\\\n" | |
2025 | "#endif\n"; | |
2026 | ||
2027 | sed = "/[\t ]ptrdiff_t.*;/i\\\n" | |
2028 | "#ifndef _GCC_PTRDIFF_T\\\n" | |
2029 | "#define _GCC_PTRDIFF_T\n"; | |
2030 | ||
2031 | sed = "/[\t ]ptrdiff_t.*;/a\\\n" | |
2032 | "#endif\n"; | |
2033 | ||
2034 | sed = "/[\t ]wchar_t.*;/i\\\n" | |
2035 | "#ifndef _GCC_WCHAR_T\\\n" | |
2036 | "#define _GCC_WCHAR_T\n"; | |
2037 | ||
2038 | sed = "/[\t ]wchar_t.*;/a\\\n" | |
2039 | "#endif\n"; | |
2040 | }; | |
2041 | ||
2042 | ||
2043 | /* | |
2044 | * Fix this file to avoid interfering with stddef.h, | |
2045 | * but don't mistakenly match ssize_t present in AIX for the ps/2, | |
2046 | * or typedefs which use (but do not set) size_t. | |
2047 | */ | |
2048 | fix = { | |
2049 | hackname = tinfo_cplusplus; | |
2050 | files = tinfo.h; | |
2051 | sed = "s/[ \t]_cplusplus/ __cplusplus/"; | |
2052 | }; | |
2053 | ||
2054 | ||
2055 | /* | |
2056 | * Cancel out ansi_compat.h on Ultrix. Replace it with empty file. | |
2057 | */ | |
2058 | fix = { | |
2059 | hackname = ultrix_ansi_compat; | |
2060 | files = ansi_compat.h; | |
2061 | select = ULTRIX; | |
2062 | sed = "1i\\\n/* This file intentionally left blank. */\n"; | |
2063 | sed = "1,$d"; | |
2064 | }; | |
2065 | ||
2066 | ||
1f414ac4 BK |
2067 | /* |
2068 | * Ultrix V4.[35] puts the declaration of uname before the definition | |
2069 | * of struct utsname, so the prototype (added by fixproto) causes havoc. | |
2070 | */ | |
2071 | fix = { | |
2072 | hackname = ultrix_fix_fixproto; | |
2073 | files = sys/utsname.h; | |
2074 | select = ULTRIX; | |
2075 | sed = "/^[ \t]*extern[ \t]*int[ \t]*uname();$/i\\\n" | |
2076 | "struct utsname;\n"; | |
2077 | }; | |
2078 | ||
2079 | ||
0083c904 BK |
2080 | /* |
2081 | * parameter to atof not const on DECstation Ultrix V4.0 and NEWS-OS 4.2R. | |
2082 | * also get rid of bogus inline definitions in HP-UX 8.0 | |
2083 | */ | |
2084 | fix = { | |
2085 | hackname = ultrix_atof_param; | |
2086 | files = math.h; | |
2087 | ||
2088 | sed = "s@atof(\\([ \t]*char[ \t]*\\*[^)]*\\))@atof(const \\1)@"; | |
2089 | sed = "s@inline int abs(int [a-z][a-z]*) {.*}@extern \"C\" int abs(int);@"; | |
2090 | sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@"; | |
2091 | sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@"; | |
2092 | sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@"; | |
2093 | }; | |
2094 | ||
2095 | ||
2096 | /* | |
2097 | * parameters not const on DECstation Ultrix V4.0 and OSF/1. | |
2098 | */ | |
2099 | fix = { | |
2100 | hackname = ultrix_const; | |
2101 | files = stdio.h; | |
2102 | ||
2103 | sed = 's@perror( char \*__s );@perror( const char *__s );@'; | |
2104 | sed = 's@fputs( char \*__s,@fputs( const char *__s,@'; | |
2105 | sed = 's@fopen( char \*__filename, char \*__type );@' | |
2106 | 'fopen( const char *__filename, const char *__type );@'; | |
2107 | sed = 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@'; | |
2108 | sed = 's@fscanf( FILE \*__stream, char \*__format,@' | |
2109 | 'fscanf( FILE *__stream, const char *__format,@'; | |
2110 | sed = 's@scanf( char \*__format,@scanf( const char *__format,@'; | |
2111 | sed = 's@sscanf( char \*__s, char \*__format,@' | |
2112 | 'sscanf( const char *__s, const char *__format,@'; | |
2113 | sed = 's@popen(char \*, char \*);@popen(const char *, const char *);@'; | |
2114 | sed = 's@tempnam(char\*,char\*);@tempnam(const char*,const char*);@'; | |
2115 | }; | |
2116 | ||
2117 | ||
2118 | /* | |
2119 | * Check for bad #ifdef line (in Ultrix 4.1) | |
2120 | */ | |
2121 | fix = { | |
2122 | hackname = ultrix_ifdef; | |
2123 | select = "#ifdef KERNEL"; | |
2124 | files = sys/file.h; | |
2125 | sed = "s/#ifdef KERNEL/#if defined(KERNEL)/"; | |
2126 | }; | |
2127 | ||
2128 | ||
2129 | /* | |
2130 | * Avoid nested comments on Ultrix 4.3. | |
2131 | */ | |
2132 | fix = { | |
2133 | hackname = ultrix_nested_cmnt; | |
2134 | files = rpc/svc.h; | |
2135 | sed = "s@^\\( \\*\tint protocol; \\)/\\*@\\1*/ /*@"; | |
2136 | }; | |
2137 | ||
2138 | ||
2139 | /* | |
2140 | * Check for superfluous `static' (in Ultrix 4.2) | |
2141 | * On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken. | |
2142 | */ | |
2143 | fix = { | |
2144 | hackname = ultrix_static; | |
2145 | files = machine/cpu.h; | |
2146 | select = '#include "r[34]_cpu'; | |
2147 | sed = "s/^static struct tlb_pid_state/struct tlb_pid_state/"; | |
2148 | sed = 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/'; | |
2149 | sed = 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/'; | |
2150 | }; | |
2151 | ||
2152 | ||
2153 | /* | |
2154 | * Fix multiple defines for NULL | |
2155 | */ | |
2156 | fix = { | |
2157 | hackname = undefine_null; | |
2158 | select = "^#[ \t]*define[ \t]*[ \t]NULL[ \t]"; | |
2159 | bypass = "#[ \t]*(ifn|un)def[ \t]*[ \t]NULL($|[ \t])"; | |
2160 | sed = "/^#[ \t]*define[ \t][ \t]*NULL[ \t]/i\\\n" | |
2161 | "#undef NULL\n"; | |
2162 | }; | |
2163 | ||
2164 | ||
2165 | /* | |
2166 | * Fix definitions of macros used by va-i960.h in VxWorks header file. | |
2167 | */ | |
2168 | fix = { | |
2169 | hackname = va_i960_macro; | |
2170 | files = arch/i960/archI960.h; | |
2171 | select = "__(vsiz|vali|vpad|alignof__)"; | |
2172 | sed = "s/__vsiz/__vxvsiz/"; | |
2173 | sed = "s/__vali/__vxvali/"; | |
2174 | sed = "s/__vpad/__vxvpad/"; | |
2175 | sed = "s/__alignof__/__vxalignof__/"; | |
2176 | }; | |
2177 | ||
2178 | ||
2179 | /* | |
2180 | * AIX headers define NULL to be cast to a void pointer, | |
2181 | * which is illegal in ANSI C++. | |
2182 | */ | |
2183 | fix = { | |
2184 | hackname = void_null; | |
2185 | files = curses.h; | |
2186 | files = dbm.h; | |
2187 | files = locale.h; | |
2188 | files = stdio.h; | |
2189 | files = stdlib.h; | |
2190 | files = string.h; | |
2191 | files = time.h; | |
2192 | files = unistd.h; | |
2193 | files = sys/dir.h; | |
2194 | files = sys/param.h; | |
2195 | files = sys/types.h; | |
2196 | select = "#[ \t]*define[ \t][ \t]*NULL[ \t].*void"; | |
2197 | sed = "s/^#[ \t]*define[ \t]*NULL[ \t]*((void[ \t]*\\*)0)" | |
2198 | "/#define NULL 0/"; | |
2199 | }; | |
2200 | ||
2201 | ||
2202 | /* | |
2203 | * Make VxWorks header which is almost gcc ready fully gcc ready. | |
2204 | */ | |
2205 | fix = { | |
2206 | hackname = vxworks_gcc_problem; | |
2207 | files = types/vxTypesBase.h; | |
2208 | select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__"; | |
2209 | ||
2210 | sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/" | |
2211 | "#if 1/"; | |
2212 | ||
2213 | sed = "/[ \t]size_t/i\\\n" | |
2214 | "#ifndef _GCC_SIZE_T\\\n" | |
2215 | "#define _GCC_SIZE_T\n"; | |
2216 | ||
2217 | sed = "/[ \t]size_t/a\\\n" | |
2218 | "#endif\n"; | |
2219 | ||
2220 | sed = "/[ \t]ptrdiff_t/i\\\n" | |
2221 | "#ifndef _GCC_PTRDIFF_T\\\n" | |
2222 | "#define _GCC_PTRDIFF_T\n"; | |
2223 | ||
2224 | sed = "/[ \t]ptrdiff_t/a\\\n" | |
2225 | "#endif\n"; | |
2226 | ||
2227 | sed = "/[ \t]wchar_t/i\\\n" | |
2228 | "#ifndef _GCC_WCHAR_T\\\n" | |
2229 | "#define _GCC_WCHAR_T\n"; | |
2230 | ||
2231 | sed = "/[ \t]wchar_t/a\\\n" | |
2232 | "#endif\n"; | |
2233 | }; | |
2234 | ||
2235 | ||
2236 | /* | |
2237 | * Fix VxWorks <time.h> to not require including <vxTypes.h>. | |
2238 | */ | |
2239 | fix = { | |
2240 | hackname = vxworks_needs_vxtypes; | |
2241 | files = time.h; | |
2242 | select = "uint_t[ \t][ \t]*_clocks_per_sec"; | |
2243 | sed = "s/uint_t/unsigned int/"; | |
2244 | }; | |
2245 | ||
2246 | ||
2247 | /* | |
2248 | * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>. | |
2249 | */ | |
2250 | fix = { | |
2251 | hackname = vxworks_needs_vxworks; | |
2252 | files = sys/stat.h; | |
8f34d1e9 BK |
2253 | test = " -r types/vxTypesOld.h"; |
2254 | test = " -n \"`egrep '#include' $file`\""; | |
2255 | test = " -n \"`egrep ULONG $file`\""; | |
0083c904 BK |
2256 | select = "#[ \t]define[ \t][ \t]*__INCstath"; |
2257 | ||
2258 | sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n" | |
2259 | "#include <types/vxTypesOld.h>\n"; | |
2260 | }; | |
2261 | ||
2262 | ||
2263 | /* | |
2264 | * Another bad dependency in VxWorks 5.2 <time.h>. | |
2265 | */ | |
2266 | fix = { | |
2267 | hackname = vxworks_time; | |
2268 | files = time.h; | |
2269 | select = "VOIDFUNCPTR"; | |
8f34d1e9 | 2270 | test = " -r vxWorks.h"; |
0083c904 BK |
2271 | sed = "/VOIDFUNCPTR/i\\\n" |
2272 | "#ifndef __gcc_VOIDFUNCPTR_defined\\\n" | |
2273 | "#ifdef __cplusplus\\\n" | |
2274 | "typedef void (*__gcc_VOIDFUNCPTR) (...);\\\n" | |
2275 | "#else\\\n" | |
2276 | "typedef void (*__gcc_VOIDFUNCPTR) ();\\\n" | |
2277 | "#endif\\\n" | |
2278 | "#define __gcc_VOIDFUNCPTR_defined\\\n" | |
2279 | "#endif\n"; | |
2280 | ||
2281 | sed = "s/VOIDFUNCPTR/__gcc_VOIDFUNCPTR/g"; | |
2282 | }; | |
2283 | ||
2284 | ||
2285 | /* | |
2286 | * There are several name conflicts with C++ reserved words in X11 header | |
2287 | * files. These are fixed in some versions, so don't do the fixes if | |
2288 | * we find __cplusplus in the file. These were found on the RS/6000. | |
2289 | */ | |
2290 | fix = { | |
2291 | hackname = x11_class; | |
2292 | files = X11/ShellP.h; | |
2293 | bypass = __cplusplus; | |
2294 | sed = "/char \\*class;/i\\\n" | |
2295 | "#ifdef __cplusplus\\\n" | |
2296 | "\tchar *c_class;\\\n" | |
2297 | "#else\n"; | |
2298 | sed = "/char \\*class;/a\\\n" | |
2299 | "#endif\n"; | |
2300 | }; | |
2301 | ||
2302 | ||
2303 | /* | |
2304 | * class in Xm/BaseClassI.h | |
2305 | */ | |
2306 | fix = { | |
2307 | hackname = x11_class_usage; | |
2308 | files = Xm/BaseClassI.h; | |
2309 | bypass = "__cplusplus"; | |
2310 | sed = "s/ class[)]/ c_class)/g"; | |
2311 | }; | |
2312 | ||
2313 | ||
2314 | /* | |
2315 | * new in Xm/Traversal.h | |
2316 | */ | |
2317 | fix = { | |
2318 | hackname = x11_new; | |
2319 | files = Xm/Traversal.h; | |
2320 | bypass = __cplusplus; | |
2321 | ||
2322 | sed = "/Widget\told, new;/i\\\n" | |
2323 | "#ifdef __cplusplus\\\n" | |
2324 | "\tWidget\told, c_new;\\\n" | |
2325 | "#else\n"; | |
2326 | ||
2327 | sed = "/Widget\told, new;/a\\\n" | |
2328 | "#endif\n"; | |
2329 | ||
2330 | sed = "s/Widget new,/Widget c_new,/g"; | |
2331 | }; | |
2332 | ||
2333 | ||
2334 | /* | |
2335 | * Incorrect sprintf declaration in X11/Xmu.h | |
2336 | */ | |
2337 | fix = { | |
2338 | hackname = x11_sprintf; | |
2339 | files = X11*/Xmu.h; | |
2340 | sed = "s,^extern char \\*\tsprintf();$,#ifndef __STDC__\\\n" | |
2341 | "extern char *\tsprintf();\\\n" | |
2342 | "#endif /* !defined __STDC__ */,"; | |
2343 | }; | |
2344 | ||
2345 | ||
c095d84a BK |
2346 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
2347 | * | |
2348 | * UNDO BROKEN FIXES | |
2349 | * | |
2350 | * We sure do hope that broken fixes and needed fixes are never | |
2351 | * applied to the same file!! :-} | |
2352 | */ | |
2353 | ||
0083c904 BK |
2354 | /* |
2355 | * Purge some HP-UX 11 files that are only borken after they are "fixed". | |
2356 | */ | |
2357 | fix = { | |
2358 | hackname = zzz_ki_iface; | |
2359 | files = sys/ki_iface.h; | |
2360 | select = 'These definitions are for HP Internal developers'; | |
2361 | shell = | |
8f34d1e9 | 2362 | "echo \"Removing incorrect fix to <$file>\" >&2\n" |
c095d84a | 2363 | "rm -f ${DESTDIR}/$file ${DESTDIR}/fixinc.tmp\n" |
8f34d1e9 | 2364 | "cat > /dev/null"; |
0083c904 BK |
2365 | }; |
2366 | ||
2367 | ||
2368 | /* | |
2369 | * Purge some HP-UX 11 files that are only borken after they are "fixed". | |
2370 | */ | |
2371 | fix = { | |
2372 | hackname = zzz_ki; | |
2373 | files = sys/ki.h; | |
2374 | select = '11.00 HP-UX LP64'; | |
2375 | shell = | |
8f34d1e9 | 2376 | "echo \"Removing incorrect fix to <$file>\" >&2\n" |
c095d84a | 2377 | "rm -f ${DESTDIR}/$file ${DESTDIR}/fixinc.tmp\n" |
8f34d1e9 | 2378 | "cat > /dev/null"; |
0083c904 BK |
2379 | }; |
2380 | ||
2381 | ||
2382 | /* | |
2383 | * Purge some HP-UX 11 files that are only borken after they are "fixed". | |
2384 | */ | |
2385 | fix = { | |
2386 | hackname = zzz_ki_calls; | |
2387 | files = sys/ki_calls.h; | |
ccce12f3 | 2388 | select = 'kthread_create_caller_t'; |
0083c904 | 2389 | shell = |
8f34d1e9 | 2390 | "echo \"Removing incorrect fix to <$file>\" >&2\n" |
c095d84a | 2391 | "rm -f ${DESTDIR}/$file ${DESTDIR}/fixinc.tmp\n" |
8f34d1e9 | 2392 | "cat > /dev/null"; |
0083c904 BK |
2393 | }; |
2394 | ||
2395 | ||
2396 | /* | |
2397 | * Purge some HP-UX 11 files that are only borken after they are "fixed". | |
2398 | */ | |
2399 | fix = { | |
2400 | hackname = zzz_ki_defs; | |
2401 | files = sys/ki_defs.h; | |
2402 | select = 'Kernel Instrumentation Definitions'; | |
2403 | shell = | |
8f34d1e9 | 2404 | "echo \"Removing incorrect fix to <$file>\" >&2\n" |
c095d84a | 2405 | "rm -f ${DESTDIR}/$file ${DESTDIR}/fixinc.tmp\n" |
8f34d1e9 BK |
2406 | "cat > /dev/null"; |
2407 | }; | |
2408 | ||
2409 | ||
2410 | /* | |
2411 | * This file on SunOS 4 has a very large macro. When the sed loop | |
2412 | * tries pull it in, it overflows the pattern space size of the SunOS | |
2413 | * sed (GNU sed does not have this problem). Since the file does not | |
2414 | * require fixing, we remove it from the fixed directory. | |
2415 | */ | |
2416 | fix = { | |
2417 | hackname = zzz_bad_fixes; | |
2418 | files = sundev/ipi_error.h; | |
2419 | /* shouldn't there be a select expression here??? */ | |
2420 | shell = | |
2421 | "echo \"Removing incorrect fix to <$file>\" >&2\n" | |
c095d84a | 2422 | "rm -f ${DESTDIR}/$file ${DESTDIR}/fixinc.tmp\n" |
8f34d1e9 | 2423 | "cat > /dev/null"; |
0083c904 BK |
2424 | }; |
2425 | ||
2426 | ||
2427 | /* | |
2428 | * Purge some HP-UX 11 files that are only borken after they are "fixed". | |
2429 | */ | |
2430 | fix = { | |
2431 | hackname = zzz_time; | |
2432 | files = sys/time.h; | |
ccce12f3 | 2433 | select = '11.0 and later representation of ki time'; |
0083c904 | 2434 | shell = |
8f34d1e9 | 2435 | "echo \"Removing incorrect fix to <$file>\" >&2\n" |
c095d84a | 2436 | "rm -f ${DESTDIR}/$file ${DESTDIR}/fixinc.tmp\n" |
8f34d1e9 | 2437 | "cat > /dev/null"; |
0083c904 BK |
2438 | }; |
2439 | ||
2440 | ||
2441 | /*EOF*/ |