xref: /netbsd-src/external/gpl3/gcc/dist/fixincludes/inclhack.def (revision 37afb7eb6895c833050f8bfb1d1bb2f99f332539)
1/* -*- Mode: C -*-  */
2
3autogen definitions fixincl;
4
5/* Define all the fixes we know about for repairing damaged headers.
6   Please see the README before adding or changing entries in this file.
7
8   This is the sort command:
9
10   blocksort output=inclhack.sorted \
11          pattern='^/\*$' \
12          trailer='^/\*EOF\*[/]' \
13          input=inclhack.def \
14          key='hackname[ 	]*=[ 	]*(.*);'
15
16   Set up a debug test so we can make the templates emit special
17   code while debugging these fixes:  */
18
19#ifdef DEBUG
20FIXINC_DEBUG = yes;
21#endif
22
23/* On AIX when _LARGE_FILES is defined stdio.h defines fopen to
24 * fopen64 etc. and this causes problems when building with g++
25 * because cstdio udefs everything from stdio.h, leaving us with
26 * ::fopen has not been declared errors. This fixes stdio.h to
27 * undef those defines and use __asm__ to alias the symbols if
28 * building with g++ and -D_LARGE_FILES
29 */
30fix = {
31    hackname  = AAB_aix_stdio;
32    files     = stdio.h;
33    select    = "define fopen fopen64";
34    mach      = "*-*-aix*";
35    test-text = ''; /* no way to test */
36
37    c_fix     = wrap;
38
39    c_fix_arg = "";
40
41    c_fix_arg = <<- _EOArg_
42
43	#if defined __GNUG__ && defined _LARGE_FILES && defined __cplusplus
44	#define __need__aix_stdio_h_fix
45	#ifdef __need__aix_stdio_h_fix
46	#undef fseeko
47	#undef ftello
48	#undef fgetpos
49	#undef fsetpos
50	#undef fopen
51	#undef freopen
52	/* Alias the symbols using asm */
53	extern "C" {
54	extern int fgetpos(FILE *, fpos64_t *) __asm__("fgetpos64");
55	extern FILE *fopen(const char *, const char *) __asm__("fopen64");
56	extern FILE *freopen(const char *, const char *, FILE *) __asm__("freopen64");
57	extern int fseeko(FILE *, off64_t, int) __asm__("fseeko64");
58	extern int fsetpos(FILE *, const fpos64_t *) __asm__("fsetpos64");
59	extern off64_t ftello(FILE *) __asm__("ftello64");
60	}
61	#endif
62	#endif
63
64	_EOArg_;
65};
66
67
68/* On AIX when _LARGE_FILES is defined fcntl.h defines open to
69 * open64 and creat to creat64.  This fixes fcntl.h to
70 * undef those defines and use __asm__ to alias the symbols if
71 * building with g++ and -D_LARGE_FILES
72 */
73fix = {
74    hackname  = AAB_aix_fcntl;
75    files     = fcntl.h;
76    select    = "define open[ \t]open64";
77    mach      = "*-*-aix*";
78    test-text = ''; /* no way to test */
79
80    c_fix     = wrap;
81
82    c_fix_arg = "";
83
84    c_fix_arg = <<- _EOArg_
85
86	#if defined __GNUG__ && defined _LARGE_FILES && defined __cplusplus
87	#define __need__aix_fcntl_h_fix
88	#ifdef __need__aix_fcntl_h_fix
89	#undef open
90	#undef creat
91	#undef openat
92	/* Alias the symbols using asm */
93	extern "C" {
94	extern int open(const char *, int, ...) __asm__("open64");
95	extern int creat(const char *, mode_t) __asm__("creat64");
96	#if (_XOPEN_SOURCE >= 700)
97	extern int openat(int, const char *, int, ...) __asm__("open64at");
98	#endif
99	}
100	#endif
101	#endif
102
103	_EOArg_;
104};
105
106
107/*
108 *  On Mac OS 10.3.9, the 'long double' functions are available in
109 *  libSystem, but are not prototyped in math.h.
110 */
111fix = {
112  hackname  = AAB_darwin7_9_long_double_funcs;
113  mach      = "*-*-darwin7.9*";
114  files     = architecture/ppc/math.h;
115  bypass    = "powl";
116  replace = <<- _EndOfHeader_
117	/* This file prototypes the long double functions available on Mac OS
118	   10.3.9.  */
119	#ifndef __MATH__
120	# undef __APPLE_CC__
121	# define __APPLE_CC__  1345
122	# include_next <architecture/ppc/math.h>
123	# undef __APPLE_CC__
124	# define __APPLE_CC__ 1
125	# ifndef __LIBMLDBL_COMPAT
126	#  ifdef __LONG_DOUBLE_128__
127	#   define __LIBMLDBL_COMPAT(sym) __asm("_" #sym "$LDBL128")
128	#  else
129	#   define __LIBMLDBL_COMPAT(sym)
130	#  endif /* __LONG_DOUBLE_128__ */
131	# endif /* __LIBMLDBL_COMPAT */
132	# ifdef __cplusplus
133	   extern "C" {
134	# endif
135	  extern long double acosl( long double ) __LIBMLDBL_COMPAT(acosl);
136	  extern long double asinl( long double ) __LIBMLDBL_COMPAT(asinl);
137	  extern long double atanl( long double ) __LIBMLDBL_COMPAT(atanl);
138	  extern long double atan2l( long double, long double ) __LIBMLDBL_COMPAT(atan2l);
139	  extern long double cosl( long double ) __LIBMLDBL_COMPAT(cosl);
140	  extern long double sinl( long double ) __LIBMLDBL_COMPAT(sinl);
141	  extern long double tanl( long double ) __LIBMLDBL_COMPAT(tanl);
142	  extern long double acoshl( long double ) __LIBMLDBL_COMPAT(acoshl);
143	  extern long double asinhl( long double ) __LIBMLDBL_COMPAT(asinhl);
144	  extern long double atanhl( long double ) __LIBMLDBL_COMPAT(atanhl);
145	  extern long double coshl( long double ) __LIBMLDBL_COMPAT(coshl);
146	  extern long double sinhl( long double ) __LIBMLDBL_COMPAT(sinhl);
147	  extern long double tanhl( long double ) __LIBMLDBL_COMPAT(tanhl);
148	  extern long double expl( long double ) __LIBMLDBL_COMPAT(expl);
149	  extern long double exp2l( long double ) __LIBMLDBL_COMPAT(exp2l);
150	  extern long double expm1l( long double ) __LIBMLDBL_COMPAT(expm1l);
151	  extern long double logl( long double ) __LIBMLDBL_COMPAT(logl);
152	  extern long double log10l( long double ) __LIBMLDBL_COMPAT(log10l);
153	  extern long double log2l( long double ) __LIBMLDBL_COMPAT(log2l);
154	  extern long double log1pl( long double ) __LIBMLDBL_COMPAT(log1pl);
155	  extern long double logbl( long double ) __LIBMLDBL_COMPAT(logbl);
156	  extern long double modfl( long double, long double * ) __LIBMLDBL_COMPAT(modfl);
157	  extern long double ldexpl( long double, int ) __LIBMLDBL_COMPAT(ldexpl);
158	  extern long double frexpl( long double, int * ) __LIBMLDBL_COMPAT(frexpl);
159	  extern int ilogbl( long double ) __LIBMLDBL_COMPAT(ilogbl);
160	  extern long double scalbnl( long double, int ) __LIBMLDBL_COMPAT(scalbnl);
161	  extern long double scalblnl( long double, long int ) __LIBMLDBL_COMPAT(scalblnl);
162	  extern long double fabsl( long double ) __LIBMLDBL_COMPAT(fabsl);
163	  extern long double cbrtl( long double ) __LIBMLDBL_COMPAT(cbrtl);
164	  extern long double hypotl( long double, long double ) __LIBMLDBL_COMPAT(hypotl);
165	  extern long double powl( long double, long double ) __LIBMLDBL_COMPAT(powl);
166	  extern long double sqrtl( long double ) __LIBMLDBL_COMPAT(sqrtl);
167	  extern long double erfl( long double ) __LIBMLDBL_COMPAT(erfl);
168	  extern long double erfcl( long double ) __LIBMLDBL_COMPAT(erfcl);
169	  extern long double lgammal( long double ) __LIBMLDBL_COMPAT(lgammal);
170	  extern long double tgammal( long double ) __LIBMLDBL_COMPAT(tgammal);
171	  extern long double ceill( long double ) __LIBMLDBL_COMPAT(ceill);
172	  extern long double floorl( long double ) __LIBMLDBL_COMPAT(floorl);
173	  extern long double nearbyintl( long double ) __LIBMLDBL_COMPAT(nearbyintl);
174	  extern long double rintl( long double ) __LIBMLDBL_COMPAT(rintl);
175	  extern long int lrintl( long double ) __LIBMLDBL_COMPAT(lrintl);
176	  extern long long int llrintl( long double ) __LIBMLDBL_COMPAT(llrintl);
177	  extern long double roundl( long double ) __LIBMLDBL_COMPAT(roundl);
178	  extern long int lroundl( long double ) __LIBMLDBL_COMPAT(lroundl);
179	  extern long long int llroundl( long double ) __LIBMLDBL_COMPAT(llroundl);
180	  extern long double truncl( long double ) __LIBMLDBL_COMPAT(truncl);
181	  extern long double fmodl( long double, long double) __LIBMLDBL_COMPAT(fmodl);
182	  extern long double remainderl( long double, long double ) __LIBMLDBL_COMPAT(remainderl);
183	  extern long double remquol( long double, long double, int * ) __LIBMLDBL_COMPAT(remquol);
184	  extern long double copysignl( long double, long double ) __LIBMLDBL_COMPAT(copysignl);
185	  extern long double nanl( const char * ) __LIBMLDBL_COMPAT(nanl);
186	  extern long double nextafterl( long double, long double ) __LIBMLDBL_COMPAT(nextafterl);
187	  extern long double nexttowardl( long double, long double ) __LIBMLDBL_COMPAT(nexttowardl);
188	  extern long double fdiml( long double, long double ) __LIBMLDBL_COMPAT(fdiml);
189	  extern long double fmaxl( long double, long double ) __LIBMLDBL_COMPAT(fmaxl);
190	  extern long double fminl( long double, long double ) __LIBMLDBL_COMPAT(fminl);
191	  extern long double fmal( long double, long double, long double ) __LIBMLDBL_COMPAT(fmal);
192	# ifdef __cplusplus
193	   }
194	# endif
195	#endif /* __MATH__ */
196	_EndOfHeader_;
197};
198
199/*
200 *  This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n)
201 */
202fix = {
203    hackname = AAB_fd_zero_asm_posix_types_h;
204    files    = asm/posix_types.h;
205    mach     = 'i[34567]86-*-linux*';
206    bypass   = '} while';
207    bypass   = 'x86_64';
208    bypass   = 'posix_types_64';
209
210    /*
211     * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not
212     * the start, so that if #include_next gets another instance of
213     * the wrapper, this will follow the #include_next chain until
214     * we arrive at the real <asm/posix_types.h>.
215     */
216    replace  = <<-  _EndOfHeader_
217	/* This file fixes a bug in the __FD_ZERO macro
218	   for older versions of the Linux kernel. */
219	#ifndef _POSIX_TYPES_H_WRAPPER
220	#include <features.h>
221	 #include_next <asm/posix_types.h>
222
223	#if defined(__FD_ZERO) && !defined(__GLIBC__)
224	#undef __FD_ZERO
225	#define __FD_ZERO(fdsetp) \
226	  do { \
227	    int __d0, __d1; \
228		__asm__ __volatile__("cld ; rep ; stosl" \
229			: "=&c" (__d0), "=&D" (__d1) \
230			: "a" (0), "0" (__FDSET_LONGS), \
231			  "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \
232	  } while (0)
233	#endif
234
235	#define _POSIX_TYPES_H_WRAPPER
236	#endif /* _POSIX_TYPES_H_WRAPPER */
237	_EndOfHeader_;
238};
239
240
241/*
242 *  This fixes __FD_ZERO bug for glibc-1.x
243 */
244fix = {
245    hackname = AAB_fd_zero_gnu_types_h;
246    files    = gnu/types.h;
247    mach     = 'i[34567]86-*-linux*';
248
249    /*
250     * Define _TYPES_H_WRAPPER at the end of the wrapper, not
251     * the start, so that if #include_next gets another instance of
252     * the wrapper, this will follow the #include_next chain until
253     * we arrive at the real <gnu/types.h>.
254     */
255    replace  = <<-  _EndOfHeader_
256	/* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */
257	#ifndef _TYPES_H_WRAPPER
258	#include <features.h>
259	#include_next <gnu/types.h>
260
261	#if defined(__FD_ZERO) && !defined(__GLIBC__)
262	#undef __FD_ZERO
263	# define __FD_ZERO(fdsetp) \
264	  do { \
265	    int __d0, __d1; \
266	        __asm__ __volatile__("cld ; rep ; stosl" \
267	        : "=&c" (__d0), "=&D" (__d1) \
268	        : "a" (0), "0" (__FDSET_LONGS), \
269	          "1" ((__fd_set *) (fdsetp)) :"memory"); \
270	  } while (0)
271	#endif
272
273	#define _TYPES_H_WRAPPER
274	#endif /* _TYPES_H_WRAPPER */
275	_EndOfHeader_;
276};
277
278
279/*
280 *  This fixes __FD_ZERO bug for glibc-2.0.x
281 */
282fix = {
283    hackname = AAB_fd_zero_selectbits_h;
284    files    = selectbits.h;
285    mach     = 'i[34567]86-*-linux*';
286
287    /*
288     * Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not
289     * the start, so that if #include_next gets another instance of
290     * the wrapper, this will follow the #include_next chain until
291     * we arrive at the real <selectbits.h>.
292     */
293    replace  = <<-  _EndOfHeader_
294	/* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */
295	#ifndef _SELECTBITS_H_WRAPPER
296	  #include <features.h>
297	  #include_next <selectbits.h>
298
299	  #if defined(__FD_ZERO) && defined(__GLIBC__) \\
300	  && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\
301	  && __GLIBC_MINOR__ == 0
302	     #undef __FD_ZERO
303	     #define __FD_ZERO(fdsetp) \\
304	     do { \\
305	        int __d0, __d1; \\
306	      __asm__ __volatile__ ("cld; rep; stosl" \\
307                        : "=&c" (__d0), "=&D" (__d1) \\
308                        : "a" (0), "0" (sizeof (__fd_set) \\
309                                        / sizeof (__fd_mask)), \\
310                          "1" ((__fd_mask *) (fdsetp)) \\
311                        : "memory"); \\
312	      } while (0)
313	  #endif
314
315	  #define _SELECTBITS_H_WRAPPER
316	#endif /* _SELECTBITS_H_WRAPPER */
317	_EndOfHeader_;
318};
319
320
321/*
322 * Solaris <sys/varargs.h> is a DDK (aka kernel-land) header providing
323 * the same interface as <stdarg.h>.  No idea why they couldn't have just
324 * used the standard header.
325 */
326fix = {
327    hackname = AAB_solaris_sys_varargs_h;
328    files    = "sys/varargs.h";
329    mach     = '*-*-solaris*';
330    replace  = <<-  _EndOfHeader_
331	#ifdef __STDC__
332	  #include <stdarg.h>
333	#else
334	  #include <varargs.h>
335	#endif
336	_EndOfHeader_;
337};
338
339
340/*
341 *  Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
342 *  declaration on Sun OS 4.x.  We must only fix this on Sun OS 4.x, because
343 *  many other systems have similar text but correct versions of the file.
344 *  To ensure only Sun's is fixed, we grep for a likely unique string.
345 *  Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
346 */
347fix = {
348    hackname = AAB_sun_memcpy;
349    files    = memory.h;
350    select   = "/\\*\t@\\(#\\)"
351             "(head/memory.h\t50.1\t "
352             "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
353
354    replace = <<-  _EndOfHeader_
355	/* This file was generated by fixincludes */
356	#ifndef __memory_h__
357	  #define __memory_h__
358
359	  #ifdef __STDC__
360	    extern void *memccpy();
361	    extern void *memchr();
362	    extern void *memcpy();
363	    extern void *memset();
364	  #else
365	    extern char *memccpy();
366	    extern char *memchr();
367	    extern char *memcpy();
368	    extern char *memset();
369	  #endif /* __STDC__ */
370
371	  extern int memcmp();
372
373	#endif /* __memory_h__ */
374	_EndOfHeader_;
375};
376
377/*
378 * Fix assert.h on VxWorks:
379 */
380fix = {
381    hackname    = AAB_vxworks_assert;
382    files       = assert.h;
383    mach        = "*-*-vxworks*";
384
385    replace     = <<- _EndOfHeader_
386	#ifndef _ASSERT_H
387	#define _ASSERT_H
388
389	#ifdef assert
390	#undef assert
391	#endif
392
393	#if defined(__STDC__) || defined(__cplusplus)
394	extern void __assert (const char*);
395	#else
396	extern void __assert ();
397	#endif
398
399	#ifdef NDEBUG
400	#define assert(ign) ((void)0)
401	#else
402
403	#define ASSERT_STRINGIFY(str) ASSERT_STRINGIFY_HELPER(str)
404	#define ASSERT_STRINGIFY_HELPER(str) #str
405
406	#define assert(test) ((void) \
407	        ((test) ? ((void)0) : \
408	        __assert("Assertion failed: " ASSERT_STRINGIFY(test) ", file " \
409	        __FILE__ ", line " ASSERT_STRINGIFY(__LINE__) "\n")))
410
411	#endif
412
413	#endif
414	_EndOfHeader_;
415};
416
417/*
418 * Add needed include to regs.h (NOT the gcc header) on VxWorks
419 */
420
421fix = {
422    hackname    = AAB_vxworks_regs_vxtypes;
423    files       = regs.h;
424    mach        = "*-*-vxworks*";
425
426    replace     = <<- _EndOfHeader_
427	#ifndef _REGS_H
428	#define _REGS_H
429	#include <types/vxTypesOld.h>
430	#include_next <arch/../regs.h>
431	#endif
432	_EndOfHeader_;
433};
434
435/*
436 * Make VxWorks stdint.h a bit more compliant - add typedefs
437 */
438fix = {
439    hackname    = AAB_vxworks_stdint;
440    files       = stdint.h;
441    mach        = "*-*-vxworks*";
442
443    replace     = <<- _EndOfHeader_
444	#ifndef _STDINT_H
445	#define _STDINT_H
446	/* get int*_t, uint*_t */
447	#include <types/vxTypes.h>
448
449	/* get legacy vxworks types for compatibility */
450	#include <types/vxTypesOld.h>
451
452	typedef long intptr_t;
453	typedef unsigned long uintptr_t;
454
455	typedef int64_t intmax_t;
456	typedef uint64_t uintmax_t;
457
458	typedef int8_t int_least8_t;
459	typedef int16_t int_least16_t;
460	typedef int32_t int_least32_t;
461	typedef int64_t int_least64_t;
462
463	typedef uint8_t uint_least8_t;
464	typedef uint16_t uint_least16_t;
465	typedef uint32_t uint_least32_t;
466	typedef uint64_t uint_least64_t;
467
468	typedef int8_t int_fast8_t;
469	typedef int int_fast16_t;
470	typedef int32_t int_fast32_t;
471	typedef int64_t int_fast64_t;
472
473	typedef uint8_t uint_fast8_t;
474	typedef unsigned int uint_fast16_t;
475	typedef uint32_t uint_fast32_t;
476	typedef uint64_t uint_fast64_t;
477
478	/* Ranges */
479	#define UINT8_MAX (~(uint8_t)0)
480	#define UINT8_MIN 0
481	#define UINT16_MAX (~(uint16_t)0)
482	#define UINT16_MIN 0
483	#define UINT32_MAX (~(uint32_t)0)
484	#define UINT32_MIN 0
485	#define UINT64_MAX (~(uint64_t)0)
486	#define UINT64_MIN 0
487
488	#define UINTPTR_MAX (~(uintptr_t)0)
489	#define UINTPTR_MIN 0
490
491	/* Need to do int_fast16_t as well, as type
492	   size may be architecture dependent */
493	#define UINT_FAST16_MAX (~(uint_fast16_t)0)
494	#define UINT_FAST16_MAX 0
495
496	#define INT8_MAX (UINT8_MAX>>1)
497	#define INT8_MIN (INT8_MAX+1)
498	#define INT16_MAX (UINT16_MAX>>1)
499	#define INT16_MIN (INT16_MAX+1)
500	#define INT32_MAX (UINT32_MAX>>1)
501	#define INT32_MIN (INT32_MAX+1)
502	#define INT64_MAX (UINT64_MAX>>1)
503	#define INT64_MIN (INT64_MAX+1)
504
505	#define INTPTR_MAX (UINTPTR_MAX>>1)
506	#define INTPTR_MIN (INTPTR_MAX+1)
507
508	#define INT_FAST16_MAX (UINT_FAST16_MAX>>1)
509	#define INT_FAST16_MIN (INT_FAST16_MAX+1)
510
511	/* now define equiv. constants */
512	#define UINT_FAST8_MAX UINT8_MAX
513	#define UINT_FAST8_MIN UINT_FAST8_MIN
514	#define INT_FAST8_MAX INT8_MAX
515	#define INT_FAST8_MIN INT8_MIN
516	#define UINT_FAST32_MAX UINT32_MAX
517	#define UINT_FAST32_MIN UINT32_MIN
518	#define INT_FAST32_MAX INT32_MAX
519	#define INT_FAST32_MIN INT32_MIN
520	#define UINT_FAST64_MAX UINT64_MAX
521	#define UINT_FAST64_MIN UINT64_MIN
522	#define INT_FAST64_MAX INT64_MAX
523	#define INT_FAST64_MIN INT64_MIN
524
525	#define UINT_LEAST8_MAX UINT8_MAX
526	#define UINT_LEAST8_MIN UINT8_MIN
527	#define INT_LEAST8_MAX INT8_MAX
528	#define INT_LEAST8_MIN INT8_MIN
529	#define UINT_LEAST16_MAX UINT16_MAX
530	#define UINT_LEAST16_MIN UINT16_MIN
531	#define INT_LEAST16_MAX INT16_MAX
532	#define INT_LEAST16_MIN INT16_MIN
533	#define UINT_LEAST32_MAX UINT32_MAX
534	#define UINT_LEAST32_MIN UINT32_MIN
535	#define INT_LEAST32_MAX INT32_MAX
536	#define INT_LEAST32_MIN INT32_MIN
537	#define UINT_LEAST64_MAX UINT64_MAX
538	#define UINT_LEAST64_MIN UINT64_MIN
539	#define INT_LEAST64_MAX INT64_MAX
540	#define INT_LEAST64_MIN INT64_MIN
541
542	#define UINTMAX_MAX UINT64_MAX
543	#define UINTMAX_MIN UINT64_MIN
544	#define INTMAX_MAX INT64_MAX
545	#define INTMAX_MIN INT64_MIN
546
547	#endif
548	_EndOfHeader_;
549};
550
551/*
552 *  This hack makes makes unistd.h more POSIX-compliant on VxWorks
553 */
554fix = {
555    hackname    = AAB_vxworks_unistd;
556    files       = unistd.h;
557    mach        = "*-*-vxworks*";
558
559    replace     = <<- _EndOfHeader_
560	#ifndef _UNISTD_H
561	#define _UNISTD_H
562	#include_next <unistd.h>
563	#include <ioLib.h>
564	#ifndef STDIN_FILENO
565	#define STDIN_FILENO 0
566	#endif
567	#ifndef STDOUT_FILENO
568	#define STDOUT_FILENO 1
569	#endif
570	#ifndef STDERR_FILENO
571	#define STDERR_FILENO 2
572	#endif
573	#endif /* _UNISTD_H */
574	_EndOfHeader_;
575};
576
577/*
578 * assert.h on AIX 7 redefines static_assert as _Static_assert without
579 * protecting C++.
580 */
581fix = {
582    hackname  = aix_assert;
583    mach      = "*-*-aix*";
584    files     = assert.h;
585    select    = "#define[ \t]static_assert[ \t]_Static_assert";
586    c_fix     = format;
587    c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
588    test_text = "#define static_assert _Static_assert";
589};
590
591/*
592 * complex.h on AIX 5 and AIX 6 define _Complex_I and I in terms of __I,
593 * which only is provided by AIX xlc C99.
594 */
595fix = {
596    hackname  = aix_complex;
597    mach      = "*-*-aix*";
598    files     = complex.h;
599    select    = "#define[ \t]_Complex_I[ \t]__I";
600    c_fix     = format;
601    c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
602    test_text = "#define _Complex_I	__I\n";
603};
604
605/*
606 *  malloc.h on AIX6 uses XLC++ specific builtin syntax
607 */
608fix = {
609    hackname  = aix_malloc;
610    mach      = "*-*-aix*";
611    files     = "malloc.h";
612    select    = "#ifdef __cplusplus";
613    c_fix     = format;
614    c_fix_arg = "#if (defined(__cplusplus) && defined(__IBMCPP__))";
615    test_text = "#ifdef __cplusplus";
616};
617
618/*
619 * net/if_arp.h defines a variable fc_softc instead of adding a
620 * typedef for the struct on AIX 5.2, 5.3, 6.1 and 7.1
621 */
622fix = {
623    hackname  = aix_net_if_arp;
624    mach      = "*-*-aix*";
625    files     = "net/if_arp.h";
626    select    = "^struct  fc_softc \\{";
627    c_fix     = format;
628    c_fix_arg = "typedef struct _fc_softc {";
629    test_text = "struct  fc_softc {\n  int a;\n};";
630};
631
632/*
633 *  pthread.h on AIX defines PTHREAD_ONCE_INIT, PTHREAD_MUTEX_INITIALIZER,
634 *  PTHREAD_COND_INITIALIZER and PTHREAD_RWLOCK_INITIALIZER without enough
635 *  braces.
636 */
637fix = {
638    hackname  = aix_once_init_1;
639    mach      = "*-*-aix*";
640    files     = "pthread.h";
641    select    = "#define[ \t]PTHREAD_ONCE_INIT \\\\\n"
642		"\\{ \\\\\n";
643    c_fix     = format;
644    c_fix_arg = "#define PTHREAD_ONCE_INIT \\\n"
645		"{{ \\\n";
646    test_text = "#define PTHREAD_ONCE_INIT \\\\\n"
647		"{ \\\\\n";
648};
649
650fix = {
651    hackname  = aix_once_init_2;
652    mach      = "*-*-aix*";
653    files     = "pthread.h";
654    select    = "[ \t]0 \\\\\n"
655		"\\}\n";
656    c_fix     = format;
657    c_fix_arg = "	0 \\\n"
658		"}}\n";
659    test_text = "	0 \\\\\n"
660		"}\n";
661};
662
663fix = {
664    hackname  = aix_mutex_initializer_1;
665    mach      = "*-*-aix*";
666    files     = "pthread.h";
667    select    = "#define[ \t]PTHREAD_MUTEX_INITIALIZER \\\\\n"
668		"\\{ \\\\\n";
669    c_fix     = format;
670    c_fix_arg = "#define PTHREAD_MUTEX_INITIALIZER \\\n"
671		"{{ \\\n";
672    test_text = "#define PTHREAD_MUTEX_INITIALIZER \\\\\n"
673		"{ \\\\\n";
674};
675
676fix = {
677    hackname  = aix_cond_initializer_1;
678    mach      = "*-*-aix*";
679    files     = "pthread.h";
680    select    = "#define[ \t]PTHREAD_COND_INITIALIZER \\\\\n"
681		"\\{ \\\\\n";
682    c_fix     = format;
683    c_fix_arg = "#define PTHREAD_COND_INITIALIZER \\\n"
684		"{{ \\\n";
685    test_text = "#define PTHREAD_COND_INITIALIZER \\\\\n"
686		"{ \\\\\n";
687};
688
689fix = {
690    hackname  = aix_rwlock_initializer_1;
691    mach      = "*-*-aix*";
692    files     = "pthread.h";
693    select    = "#define[ \t]PTHREAD_RWLOCK_INITIALIZER \\\\\n"
694		"\\{ \\\\\n";
695    c_fix     = format;
696    c_fix_arg = "#define PTHREAD_RWLOCK_INITIALIZER \\\n"
697		"{{ \\\n";
698    test_text = "#define PTHREAD_RWLOCK_INITIALIZER \\\\\n"
699		"{ \\\\\n";
700};
701
702/*
703 *  pthread.h on AIX 4.3.3 tries to define a macro without whitspace
704 *  which violates a requirement of ISO C.
705 */
706fix = {
707    hackname  = aix_pthread;
708    files     = "pthread.h";
709    select    = "(#define [A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
710    c_fix     = format;
711    c_fix_arg = "%1 %2";
712    test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
713                "{...init stuff...}";
714};
715
716
717/*
718 *  AIX stdint.h fixes.
719 */
720fix = {
721    hackname  = aix_stdint_1;
722    mach      = "*-*-aix*";
723    files     = stdint-aix.h, stdint.h;
724    select    = "#define[ \t]UINT8_MAX[ \t]\\(255U\\)\n"
725		"#define[ \t]UINT16_MAX[ \t]\\(65535U\\)";
726    c_fix     = format;
727    c_fix_arg = "#define UINT8_MAX	(255)\n"
728		"#define UINT16_MAX	(65535)";
729    test_text = "#define UINT8_MAX	(255U)\n"
730		"#define UINT16_MAX	(65535U)";
731};
732
733
734fix = {
735    hackname  = aix_stdint_2;
736    mach      = "*-*-aix*";
737    files     = stdint-aix.h, stdint.h;
738    select    = "#define[ \t]INTPTR_MIN[ \t]INT64_MIN\n"
739		"#define[ \t]INTPTR_MAX[ \t]INT64_MAX\n"
740		"#define[ \t]UINTPTR_MAX[ \t]UINT64_MAX\n"
741		"#else\n"
742		"#define[ \t]INTPTR_MIN[ \t]INT32_MIN\n"
743		"#define[ \t]INTPTR_MAX[ \t]INT32_MAX\n"
744		"#define[ \t]UINTPTR_MAX[ \t]UINT32_MAX";
745    c_fix     = format;
746    c_fix_arg = "#define INTPTR_MIN	(-INTPTR_MAX-1)\n"
747		"#define INTPTR_MAX	9223372036854775807L\n"
748		"#define UINTPTR_MAX	18446744073709551615UL\n"
749		"#else\n"
750		"#define INTPTR_MIN	(-INTPTR_MAX-1)\n"
751		"#define INTPTR_MAX	2147483647L\n"
752		"#define UINTPTR_MAX	4294967295UL";
753    test_text = "#define INTPTR_MIN	INT64_MIN\n"
754		"#define INTPTR_MAX	INT64_MAX\n"
755		"#define UINTPTR_MAX	UINT64_MAX\n"
756		"#else\n"
757		"#define INTPTR_MIN	INT32_MIN\n"
758		"#define INTPTR_MAX	INT32_MAX\n"
759		"#define UINTPTR_MAX	UINT32_MAX";
760};
761
762
763fix = {
764    hackname  = aix_stdint_3;
765    mach      = "*-*-aix*";
766    files     = stdint-aix.h, stdint.h;
767    select    = "#define[ \t]PTRDIFF_MIN[ \t]INT64_MIN\n"
768		"#define[ \t]PTRDIFF_MAX[ \t]INT64_MAX\n"
769		"#else\n"
770		"#define[ \t]PTRDIFF_MIN[ \t]*INT32_MIN\n"
771		"#define[ \t]PTRDIFF_MAX[ \t]*INT32_MAX";
772    c_fix     = format;
773    c_fix_arg = "#define PTRDIFF_MIN	(-9223372036854775807L - 1)\n"
774		"#define PTRDIFF_MAX	9223372036854775807L\n"
775		"#else\n"
776		"#define PTRDIFF_MIN	(-2147483647L - 1)\n"
777		"#define PTRDIFF_MAX	2147483647L";
778    test_text = "#define PTRDIFF_MIN	INT64_MIN\n"
779		"#define PTRDIFF_MAX	INT64_MAX\n"
780		"#else\n"
781		"#define PTRDIFF_MIN     INT32_MIN\n"
782		"#define PTRDIFF_MAX	INT32_MAX";
783};
784
785
786fix = {
787    hackname  = aix_stdint_4;
788    mach      = "*-*-aix*";
789    files     = stdint-aix.h, stdint.h;
790    select    = "#define[ \t]SIZE_MAX[ \t]UINT64_MAX\n"
791		"#else\n"
792		"#define[ \t]SIZE_MAX[ \t]*UINT32_MAX";
793    c_fix     = format;
794    c_fix_arg = "#define SIZE_MAX	18446744073709551615UL\n"
795		"#else\n"
796		"#define SIZE_MAX	4294967295UL";
797    test_text = "#define SIZE_MAX	UINT64_MAX\n"
798		"#else\n"
799		"#define SIZE_MAX        UINT32_MAX";
800};
801
802
803fix = {
804    hackname  = aix_stdint_5;
805    mach      = "*-*-aix*";
806    files     = stdint-aix.h, stdint.h;
807    select    = "#define[ \t]UINT8_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)\n"
808		"#define[ \t]UINT16_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)";
809    c_fix     = format;
810    c_fix_arg = "#define UINT8_C(c)	c\n"
811		"#define UINT16_C(c)	c";
812    test_text = "#define UINT8_C(c)	__CONCAT__(c,U)\n"
813		"#define UINT16_C(c)	__CONCAT__(c,U)";
814};
815
816
817/*
818 *  sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
819 *  in an otherwise harmless (and #ifed out) macro definition
820 */
821fix = {
822    hackname  = aix_sysmachine;
823    files     = sys/machine.h;
824    select    = "\\\\ +\n";
825    c_fix     = format;
826    c_fix_arg = "\\\n";
827    test_text = "#define FOO \\\n"
828    " bar \\ \n baz \\ \n bat";
829};
830
831
832/*
833 *  sys/wait.h on AIX 5.2 defines macros that have both signed and
834 *  unsigned types in conditional expressions.
835 */
836fix = {
837    hackname  = aix_syswait_2;
838    files     = sys/wait.h;
839    select    = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)';
840    c_fix     = format;
841    c_fix_arg = "? (int)%1";
842    test_text = "#define WSTOPSIG(__x)    (int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
843};
844
845
846/*
847 *  sys/signal.h on some versions of AIX uses volatile in the typedef of
848 *  sig_atomic_t, which causes gcc to generate a warning about duplicate
849 *  volatile when a sig_atomic_t variable is declared volatile, as
850 *  required by ANSI C.
851 */
852fix = {
853    hackname  = aix_volatile;
854    files     = sys/signal.h;
855    select    = "typedef volatile int sig_atomic_t";
856    c_fix     = format;
857    c_fix_arg = "typedef int sig_atomic_t";
858    test_text = "typedef volatile int sig_atomic_t;";
859};
860
861
862/*
863 *  Fix __assert declaration in assert.h on Alpha OSF/1.
864 */
865fix = {
866    hackname  = alpha___assert;
867    files     = "assert.h";
868    select    = '__assert\(char \*, char \*, int\)';
869    c_fix     = format;
870    c_fix_arg = "__assert(const char *, const char *, int)";
871    test_text = 'extern void __assert(char *, char *, int);';
872};
873
874
875/*
876 *  Fix assert macro in assert.h on Alpha OSF/1.
877 *  The superfluous int cast breaks C++.
878 */
879fix = {
880    hackname  = alpha_assert;
881    files     = "assert.h";
882    select    = "(#[ \t]*" 'define assert\(EX\).*)\(\(int\) \(EX\)\)';
883    c_fix     = format;
884    c_fix_arg = "%1(EX)";
885    test_text = '#define assert(EX) (((int) (EX)) ? (void)0 '
886                ': __assert(#EX, __FILE__, __LINE__))';
887};
888
889
890/*
891 *  Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
892 */
893fix = {
894    hackname  = alpha_getopt;
895    files     = "stdio.h";
896    files     = "stdlib.h";
897    select    = 'getopt\(int, char \*\[\], *char \*\)';
898    c_fix     = format;
899    c_fix_arg = "getopt(int, char *const[], const char *)";
900    test_text = 'extern int getopt(int, char *[], char *);';
901};
902
903
904/*
905 *  Fix missing semicolon on Alpha OSF/4 in <net/if.h>
906 */
907fix = {
908    hackname  = alpha_if_semicolon;
909    files     = net/if.h;
910    select    = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*";
911    c_fix     = format;
912    c_fix_arg = "struct sockaddr vmif_paddr;\t/*";
913    test_text = '     struct  sockaddr vmif_paddr     /* protocol address */';
914};
915
916
917/*
918 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
919 */
920fix = {
921    hackname  = alpha_parens;
922    files     = sym.h;
923    select    = '#ifndef\(__mips64\)';
924    c_fix     = format;
925    c_fix_arg = "#ifndef __mips64";
926    test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
927};
928
929
930/*
931 *  Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
932 *  And OpenBSD.
933 */
934fix = {
935    hackname = alpha_sbrk;
936    files    = unistd.h;
937    select   = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
938    c_fix     = format;
939    c_fix_arg = "void *sbrk(";
940    test_text = "extern char* sbrk(ptrdiff_t increment);";
941};
942
943
944/*
945 *  For C++, avoid any typedef or macro definition of bool,
946 *  and use the built in type instead.
947 *  HP/UX 10.20 also has it in curses_colr/curses.h.
948 */
949fix = {
950    hackname  = avoid_bool_define;
951    files     = curses.h;
952    files     = curses_colr/curses.h;
953    files     = term.h;
954    files     = tinfo.h;
955
956    select    = "#[ \t]*define[ \t]+bool[ \t]";
957    bypass    = "__cplusplus";
958
959    c_fix     = format;
960    c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
961    c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
962
963    test_text = "# define bool\t char \n";
964};
965
966
967fix = {
968    hackname = avoid_bool_type;
969    files    = curses.h;
970    files    = curses_colr/curses.h;
971    files    = term.h;
972    files    = tinfo.h;
973
974    select    = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
975    bypass    = "__cplusplus";
976
977    c_fix     = format;
978    c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
979
980    test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
981};
982
983
984/*
985 *  For C++, avoid any typedef definition of wchar_t,
986 *  and use the built in type instead.
987 *  Don't do this for headers that are smart enough to do the right
988 *  thing (recent [n]curses.h and Xlib.h).
989 *  Don't do it for <linux/nls.h> which is never used from C++ anyway,
990 *  and will be broken by the edit.
991 */
992
993fix = {
994    hackname = avoid_wchar_t_type;
995
996    select    = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
997    bypass    = "__cplusplus";
998    bypass    = "_LINUX_NLS_H";
999    bypass    = "XFree86: xc/lib/X11/Xlib\\.h";
1000
1001    c_fix     = format;
1002    c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1003
1004    test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
1005};
1006
1007
1008/*
1009 *  Fix `typedef struct term;' on hppa1.1-hp-hpux9.
1010 */
1011fix = {
1012    hackname  = bad_struct_term;
1013    files     = curses.h;
1014    select    = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
1015    c_fix     = format;
1016    c_fix_arg = "struct term;";
1017
1018    test_text = 'typedef struct term;';
1019};
1020
1021
1022/*
1023 *  Fix one other error in this file:
1024 *  a mismatched quote not inside a C comment.
1025 */
1026fix = {
1027    hackname  = badquote;
1028    files     = sundev/vuid_event.h;
1029    select    = "doesn't";
1030    c_fix     = format;
1031    c_fix_arg = "does not";
1032
1033    test_text = "/* doesn't have matched single quotes */";
1034};
1035
1036
1037/*
1038 *  check for broken assert.h that needs stdio.h
1039 */
1040fix = {
1041    hackname  = broken_assert_stdio;
1042    files     = assert.h;
1043    select    = stderr;
1044    bypass    = "include.*stdio\\.h";
1045    c_fix     = wrap;
1046    c_fix_arg = "#include <stdio.h>\n";
1047    test_text = "extern FILE* stderr;";
1048};
1049
1050
1051/*
1052 *  check for broken assert.h that needs stdlib.h
1053 */
1054fix = {
1055    hackname  = broken_assert_stdlib;
1056    files     = assert.h;
1057    select    = 'exit *\(|abort *\(';
1058    bypass    = "include.*stdlib\\.h";
1059    c_fix     = wrap;
1060    c_fix_arg = "#ifdef __cplusplus\n"
1061                "#include <stdlib.h>\n"
1062                "#endif\n";
1063    test_text = "extern void exit ( int );";
1064};
1065
1066/*
1067 *  Remove `extern double cabs' declarations from math.h.
1068 *  This conflicts with C99.  Discovered on AIX.
1069 *  Darwin hides its broken cabs in architecture-specific subdirs.
1070 */
1071fix = {
1072    hackname = broken_cabs;
1073    files    = math.h, "architecture/*/math.h";
1074    select   = "^extern[ \t]+double[ \t]+cabs";
1075
1076    sed       = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
1077    sed       = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
1078
1079    test_text = "#ifdef __STDC__\n"
1080                "extern     double   cabs(struct dbl_hypot);\n"
1081                "#else\n"
1082                "extern     double   cabs();\n"
1083                "#endif\n"
1084                "extern double cabs ( _Complex z );";
1085};
1086
1087
1088/*
1089 * Fixup Darwin's broken check for __builtin_nanf.
1090 */
1091fix = {
1092    hackname  = broken_nan;
1093    /*
1094     *  It is tempting to omit the first "files" entry.  Do not.
1095     *  The testing machinery will take the first "files" entry as the name
1096     *  of a test file to play with.  It would be a nuisance to have a directory
1097     *  with the name "*".
1098     */
1099    files     = "architecture/ppc/math.h";
1100    files     = "architecture/*/math.h";
1101    select    = '#if defined\(__APPLE_CC__\) && \(__APPLE_CC__ >= 1345\)';
1102    bypass    = "powl";
1103    c_fix     = format;
1104    c_fix_arg = "#if 1";
1105    test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
1106};
1107
1108
1109/*
1110 *  Various systems derived from BSD4.4 contain a macro definition
1111 *  for vfscanf that interacts badly with requirements of builtin-attrs.def.
1112 *  Known to be fixed in FreeBSD 5 system headers.
1113 */
1114fix = {
1115    hackname  = bsd_stdio_attrs_conflict;
1116    mach      = "*-*-*bsd*";
1117    mach      = "*-*-*darwin*";
1118    files     = stdio.h;
1119    select    = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
1120    c_fix     = format;
1121    c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
1122		'#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
1123		'int vfscanf(FILE *, const char *, __builtin_va_list) '
1124		'__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
1125    test_text = '#define  vfscanf	__svfscanf';
1126};
1127
1128/*
1129 * 'g++ -std=c++11' defines __cplusplus to 201103L, which suggests
1130 * that it conforms to ISO/IEC 14882:2011.  It currently does
1131 * not support the [[noreturn]] procedure attribute.
1132 * When it does, this hack should be removed.
1133 * SEE:  gcc.gnu.org/bugzilla/show_bug.cgi?id=51776
1134 */
1135fix = {
1136    hackname  = cdef_cplusplus;
1137    files     = sys/cdefs.h;
1138    select    = '\[\[noreturn\]\]';
1139    c_fix     = format;
1140    c_fix_arg = '__attribute__((__noreturn__))';
1141    test_text = "#define _Noreturn	[[noreturn]]";
1142};
1143
1144/*
1145 *  Fix various macros used to define ioctl numbers.
1146 *  The traditional syntax was:
1147 *
1148 *    #define _CTRL(n, x) (('n'<<8)+x)
1149 *    #define TCTRLCFOO _CTRL(T, 1)
1150 *
1151 *  but this does not work with the C standard, which disallows macro
1152 *  expansion inside strings.  We have to rewrite it thus:
1153 *
1154 *    #define _CTRL(n, x) ((n<<8)+x)
1155 *    #define TCTRLCFOO  _CTRL('T', 1)
1156 *
1157 *  The select expressions match too much, but the c_fix code is cautious.
1158 *
1159 *  CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
1160 */
1161fix = {
1162    hackname  = ctrl_quotes_def;
1163    select    = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
1164    c_fix     = char_macro_def;
1165    c_fix_arg = "CTRL";
1166
1167    /*
1168     *  This is two tests in order to ensure that the "CTRL(c)" can
1169     *  be selected in isolation from the multi-arg format
1170     */
1171    test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
1172    test_text = "#define _CTRL(c) ('c'&037)";
1173};
1174
1175/*
1176 *  Fix various macros used to define ioctl numbers.
1177 */
1178fix = {
1179    hackname  = ctrl_quotes_use;
1180    select    = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
1181    c_fix     = char_macro_use;
1182    c_fix_arg = "CTRL";
1183    test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
1184};
1185
1186
1187/*
1188 *  sys/mman.h on HP/UX is not C++ ready,
1189 *  even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
1190 *
1191 *  rpc/types.h on OSF1/2.0 is not C++ ready,
1192 *  even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
1193 *
1194 *  The problem is the declaration of malloc.
1195 */
1196fix = {
1197    hackname = cxx_unready;
1198    files    = sys/mman.h;
1199    files    = rpc/types.h;
1200    select   = '[^#]+malloc.*;';  /* Catch any form of declaration
1201				     not within a macro.  */
1202    bypass   = '"C"|__BEGIN_DECLS';
1203
1204    c_fix     = wrap;
1205    c_fix_arg = "#ifdef __cplusplus\n"
1206                "extern \"C\" {\n"
1207                "#endif\n";
1208    c_fix_arg = "#ifdef __cplusplus\n"
1209                "}\n"
1210                "#endif\n";
1211    test_text = "extern void* malloc( size_t );";
1212};
1213
1214/*
1215 *  For the AAB_darwin7_9_long_double_funcs fix to be useful,
1216 *  you have to not use "" includes.
1217 */
1218fix = {
1219    hackname  = darwin_9_long_double_funcs_2;
1220    mach      = "*-*-darwin7.9*";
1221    files     = math.h;
1222    select    = '#include[ \t]+\"';
1223    c_fix     = format;
1224    c_fix_arg = "%1<%2.h>";
1225
1226    c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
1227
1228    test_text = '#include "architecture/ppc/math.h"';
1229};
1230
1231
1232/*
1233 *  On darwin8 and earlier, mach-o/swap.h isn't properly guarded
1234 *  by 'extern "C"'.  On darwin7 some mach/ headers aren't properly guarded.
1235 */
1236fix = {
1237  hackname  = darwin_externc;
1238  mach      = "*-*-darwin*";
1239  files     = mach-o/swap.h;
1240  files     = mach/mach_time.h;
1241  files     = mach/mach_traps.h;
1242  files     = mach/message.h;
1243  files     = mach/mig.h;
1244  files     = mach/semaphore.h;
1245  bypass    = "extern \"C\"";
1246  bypass    = "__BEGIN_DECLS";
1247  c_fix     = wrap;
1248  c_fix_arg = "#ifdef __cplusplus\n"
1249              "extern \"C\" {\n"
1250              "#endif\n";
1251  c_fix_arg = "#ifdef __cplusplus\n"
1252              "}\n"
1253              "#endif\n";
1254  test_text = "extern void swap_fat_header();\n";
1255};
1256
1257
1258/*
1259 * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of
1260 * bad __GNUC__ tests.
1261 */
1262
1263fix = {
1264  hackname  = darwin_gcc4_breakage;
1265  mach      = "*-*-darwin*";
1266  files     = AvailabilityMacros.h;
1267  select    = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
1268  c_fix     = format;
1269  c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
1270  test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
1271  	      "(__GNUC_MINOR__ >= 1)\n";
1272};
1273
1274
1275/*
1276 *  __private_extern__ doesn't exist in FSF GCC.  Even if it did,
1277 *  why would you ever put it in a system header file?
1278 */
1279fix = {
1280  hackname  = darwin_private_extern;
1281  mach      = "*-*-darwin*";
1282  files     = mach-o/dyld.h;
1283  select    = "__private_extern__ [a-z_]+ _dyld_";
1284  c_fix     = format;
1285  c_fix_arg = "extern";
1286  c_fix_arg = "__private_extern__";
1287  test_text = "__private_extern__ int _dyld_func_lookup(\n"
1288	      "const char *dyld_func_name,\n"
1289	      "unsigned long *address);\n";
1290};
1291
1292
1293/*
1294 * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
1295 * unsigned constants.
1296 */
1297fix = {
1298    hackname  = darwin_stdint_1;
1299    mach      = "*-*-darwin*";
1300    files     = stdint-darwin.h, stdint.h;
1301    c_fix     = format;
1302    c_fix_arg = "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv";
1303    select    = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n"
1304		"#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)";
1305    test_text = "#define UINT8_C(v)   (v ## U)\n"
1306		"#define UINT16_C(v)  (v ## U)";
1307};
1308
1309
1310/*
1311 * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
1312 * with wrong types.
1313 */
1314fix = {
1315    hackname  = darwin_stdint_2;
1316    mach      = "*-*-darwin*";
1317    files     = stdint-darwin.h, stdint.h;
1318    c_fix     = format;
1319    c_fix_arg = "#if __WORDSIZE == 64\n"
1320		"#define INTPTR_MAX 9223372036854775807L\n"
1321		"#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1322		"#else\n"
1323		"#define INTPTR_MAX 2147483647L\n"
1324		"#define INTPTR_MIN (-INTPTR_MAX-1)\n"
1325		"#endif";
1326    select    = "#if __WORDSIZE == 64\n"
1327		"#define INTPTR_MIN[ \t]+INT64_MIN\n"
1328		"#define INTPTR_MAX[ \t]+INT64_MAX\n"
1329		"#else\n"
1330		"#define INTPTR_MIN[ \t]+INT32_MIN\n"
1331		"#define INTPTR_MAX[ \t]+INT32_MAX\n"
1332		"#endif";
1333    test_text = "#if __WORDSIZE == 64\n"
1334		"#define INTPTR_MIN        INT64_MIN\n"
1335		"#define INTPTR_MAX        INT64_MAX\n"
1336		"#else\n"
1337		"#define INTPTR_MIN        INT32_MIN\n"
1338		"#define INTPTR_MAX        INT32_MAX\n"
1339		"#endif";
1340};
1341
1342
1343/*
1344 * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
1345 */
1346fix = {
1347    hackname  = darwin_stdint_3;
1348    mach      = "*-*-darwin*";
1349    files     = stdint-darwin.h, stdint.h;
1350    c_fix     = format;
1351    c_fix_arg = "#if __WORDSIZE == 64\n"
1352		"#define UINTPTR_MAX 18446744073709551615UL\n"
1353		"#else\n"
1354		"#define UINTPTR_MAX 4294967295UL\n"
1355		"#endif";
1356    select    = "#if __WORDSIZE == 64\n"
1357		"#define UINTPTR_MAX[ \t]+UINT64_MAX\n"
1358		"#else\n"
1359		"#define UINTPTR_MAX[ \t]+UINT32_MAX\n"
1360		"#endif";
1361    test_text = "#if __WORDSIZE == 64\n"
1362		"#define UINTPTR_MAX       UINT64_MAX\n"
1363		"#else\n"
1364		"#define UINTPTR_MAX       UINT32_MAX\n"
1365		"#endif";
1366};
1367
1368
1369/*
1370 * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
1371 */
1372fix = {
1373    hackname  = darwin_stdint_4;
1374    mach      = "*-*-darwin*";
1375    files     = stdint-darwin.h, stdint.h;
1376    c_fix     = format;
1377    c_fix_arg = "#if __WORDSIZE == 64\n"
1378		"#define SIZE_MAX 18446744073709551615UL\n"
1379		"#else\n"
1380		"#define SIZE_MAX 4294967295UL\n"
1381		"#endif";
1382    select    = "#if __WORDSIZE == 64\n"
1383		"#define SIZE_MAX[ \t]+UINT64_MAX\n"
1384		"#else\n"
1385		"#define SIZE_MAX[ \t]+UINT32_MAX\n"
1386		"#endif";
1387    test_text = "#if __WORDSIZE == 64\n"
1388		"#define SIZE_MAX          UINT64_MAX\n"
1389		"#else\n"
1390		"#define SIZE_MAX          UINT32_MAX\n"
1391		"#endif";
1392};
1393
1394
1395/*
1396 * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX}
1397 * with a wrong type.
1398 */
1399fix = {
1400    hackname  = darwin_stdint_5;
1401    mach      = "*-*-darwin*";
1402    files     = stdint-darwin.h, stdint.h;
1403    c_fix     = format;
1404    c_fix_arg = "#if __WORDSIZE == 64\n"
1405		"#define INTMAX_MIN   (-9223372036854775807L - 1)\n"
1406		"#define INTMAX_MAX   9223372036854775807L\n"
1407		"#define UINTMAX_MAX  18446744073709551615UL\n"
1408		"#else\n"
1409		"#define INTMAX_MIN   (-9223372036854775807LL - 1)\n"
1410		"#define INTMAX_MAX   9223372036854775807LL\n"
1411		"#define UINTMAX_MAX  18446744073709551615ULL\n"
1412		"#endif";
1413    select    = "#define INTMAX_MIN[ \t]+INT64_MIN\n"
1414		"#define INTMAX_MAX[ \t]+INT64_MAX\n"
1415		"\n"
1416		"#define UINTMAX_MAX[ \t]+UINT64_MAX";
1417    test_text = "#define INTMAX_MIN        INT64_MIN\n"
1418		"#define INTMAX_MAX        INT64_MAX\n"
1419		"\n"
1420		"#define UINTMAX_MAX       UINT64_MAX";
1421};
1422
1423
1424/*
1425 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1426 * with a wrong type.
1427 */
1428fix = {
1429    hackname  = darwin_stdint_6;
1430    mach      = "*-*-darwin*";
1431    files     = stdint-darwin.h, stdint.h;
1432    c_fix     = format;
1433    c_fix_arg = "#if __WORDSIZE == 64\n"
1434		"#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
1435		"#define PTRDIFF_MAX 9223372036854775807L\n"
1436		"#else\n"
1437		"#define PTRDIFF_MIN (-2147483647 - 1)\n"
1438		"#define PTRDIFF_MAX 2147483647\n"
1439		"#endif";
1440    select    = "#if __WORDSIZE == 64\n"
1441		"#define PTRDIFF_MIN[ \t]+INT64_MIN\n"
1442		"#define PTRDIFF_MAX[ \t]+INT64_MAX\n"
1443		"#else\n"
1444		"#define PTRDIFF_MIN[ \t]+INT32_MIN\n"
1445		"#define PTRDIFF_MAX[ \t]+INT32_MAX\n"
1446		"#endif";
1447    test_text = "#if __WORDSIZE == 64\n"
1448		"#define PTRDIFF_MIN       INT64_MIN\n"
1449		"#define PTRDIFF_MAX       INT64_MAX\n"
1450		"#else\n"
1451		"#define PTRDIFF_MIN       INT32_MIN\n"
1452		"#define PTRDIFF_MAX       INT32_MAX\n"
1453		"#endif";
1454};
1455
1456
1457/*
1458 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1459 * with a wrong type.
1460 */
1461fix = {
1462    hackname  = darwin_stdint_7;
1463    mach      = "*-*-darwin*";
1464    files     = stdint-darwin.h, stdint.h;
1465    c_fix     = format;
1466    c_fix_arg = "#if __WORDSIZE == 64\n"
1467		"#define INTMAX_C(v)  (v ## L)\n"
1468		"#define UINTMAX_C(v) (v ## UL)\n"
1469		"#else\n"
1470		"#define INTMAX_C(v)  (v ## LL)\n"
1471		"#define UINTMAX_C(v) (v ## ULL)\n"
1472		"#endif";
1473    select    = "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n"
1474		"#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)";
1475    test_text = "#define INTMAX_C(v)  (v ## LL)\n"
1476		"#define UINTMAX_C(v) (v ## ULL)";
1477};
1478
1479
1480/*
1481 *  Fix <c_asm.h> on Digital UNIX V4.0:
1482 *  It contains a prototype for a DEC C internal asm() function,
1483 *  clashing with gcc's asm keyword.  So protect this with __DECC.
1484 */
1485fix = {
1486    hackname = dec_intern_asm;
1487    files    = c_asm.h;
1488    sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
1489    sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
1490          "#endif\n";
1491    test_text =
1492    "float fasm {\n"
1493    "    ... asm stuff ...\n"
1494    "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1495};
1496
1497
1498/*
1499 * Fix typo in <wchar.h> on DJGPP 2.03.
1500 */
1501fix = {
1502    hackname  = djgpp_wchar_h;
1503    file      = wchar.h;
1504    select    = "__DJ_wint_t";
1505    bypass    = "sys/djtypes.h";
1506    c_fix     = format;
1507    c_fix_arg = "%0\n#include <sys/djtypes.h>";
1508    c_fix_arg = "#include <stddef.h>";
1509    test_text = "#include <stddef.h>\n"
1510                "extern __DJ_wint_t x;\n";
1511};
1512
1513
1514/*
1515 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1516 */
1517fix = {
1518    hackname  = ecd_cursor;
1519    files     = "sunwindow/win_lock.h";
1520    files     = "sunwindow/win_cursor.h";
1521    select    = 'ecd\.cursor';
1522    c_fix     = format;
1523    c_fix_arg = 'ecd_cursor';
1524
1525    test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1526};
1527
1528
1529/*
1530 *  Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1531 *  neither the existence of GCC 3 nor its exact feature set yet break
1532 *  (by design?) when __GNUC__ is set beyond 2.
1533 */
1534fix = {
1535    hackname  = freebsd_gcc3_breakage;
1536    mach      = "*-*-freebsd*";
1537    files     = sys/cdefs.h;
1538    select    = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
1539    bypass    = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
1540    c_fix     = format;
1541    c_fix_arg = '%0 || __GNUC__ >= 3';
1542    test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1543};
1544
1545
1546/*
1547 *  Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
1548 *  neither the existence of GCC 4 nor its exact feature set yet break
1549 *  (by design?) when __GNUC__ is set beyond 3.
1550 */
1551fix = {
1552    hackname  = freebsd_gcc4_breakage;
1553    mach      = "*-*-freebsd*";
1554    files     = sys/cdefs.h;
1555    select    = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$';
1556    c_fix     = format;
1557    c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3';
1558    test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
1559};
1560
1561
1562/*
1563 *  Some versions of glibc don't expect the C99 inline semantics.
1564 */
1565fix = {
1566    hackname  = glibc_c99_inline_1;
1567    files     = features.h, '*/features.h';
1568    select    = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
1569    c_fix     = format;
1570    c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
1571    test_text = <<-EOT
1572	#if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
1573	    && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
1574	# define __USE_EXTERN_INLINES	1
1575	#endif
1576	EOT;
1577};
1578
1579
1580/*
1581 *  Similar, but a version that didn't have __NO_INLINE__
1582 */
1583fix = {
1584    hackname  = glibc_c99_inline_1a;
1585    files     = features.h, '*/features.h';
1586    select    = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n"
1587		"(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)";
1588    c_fix     = format;
1589    c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2";
1590    test_text = <<-EOT
1591	#if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
1592	# define __USE_EXTERN_INLINES	1
1593	#endif
1594	EOT;
1595};
1596
1597
1598/*
1599 * The glibc_c99_inline_1 fix should have fixed everything.  Unfortunately
1600 * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
1601 * The remaining glibc_c99_inline_* fixes deal with some of those headers.
1602 */
1603fix = {
1604    hackname  = glibc_c99_inline_2;
1605    files     = sys/stat.h, '*/sys/stat.h';
1606    select    = "extern __inline__ int";
1607    sed     = "s/extern int \\(stat\\)/"
1608              "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1609              "__inline__ int \\1/";
1610    sed     = "s/extern int \\([lf]stat\\)/"
1611              "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1612              "__inline__ int \\1/";
1613    sed     = "s/extern int \\(mknod\\)/"
1614              "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1615              "__inline__ int \\1/";
1616    sed     = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\(stat\\)/"
1617              "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1618              "__inline__ int __REDIRECT\\1 (\\2/";
1619    sed     = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\([lf]stat\\)/"
1620              "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1621              "__inline__ int __REDIRECT\\1 (\\2/";
1622    sed     = "s/^extern __inline__ int/"
1623              "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
1624              "__inline__ int/";
1625    test_text = <<-EOT
1626	extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
1627	extern __inline__ int
1628	__NTH (fstat64 (int __fd, struct stat64 *__statbuf))
1629	{}
1630	EOT;
1631};
1632
1633
1634fix = {
1635    hackname  = glibc_c99_inline_3;
1636    files     = bits/string2.h, '*/bits/string2.h';
1637    select    = "extern __inline";
1638    bypass    = "__extern_inline|__GNU_STDC_INLINE__";
1639    c_fix     = format;
1640    c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
1641    c_fix_arg = "^# ifdef __cplusplus$";
1642    test_text = <<-EOT
1643	# ifdef __cplusplus
1644	#  define __STRING_INLINE inline
1645	# else
1646	#  define __STRING_INLINE extern __inline
1647	# endif
1648	EOT;
1649};
1650
1651
1652fix = {
1653    hackname  = glibc_c99_inline_4;
1654    files     = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h';
1655    bypass    = "__extern_inline|__gnu_inline__";
1656    select    = "(^| )extern __inline";
1657    c_fix     = format;
1658    c_fix_arg = "%0 __attribute__ ((__gnu_inline__))";
1659    test_text = <<-EOT
1660	__extension__ extern __inline unsigned int
1661	extern __inline unsigned int
1662	EOT;
1663};
1664
1665
1666/*  glibc-2.3.5 defines pthread mutex initializers incorrectly,
1667 *  so we replace them with versions that correspond to the
1668 *  definition.
1669 */
1670fix = {
1671    hackname = glibc_mutex_init;
1672    files    = pthread.h;
1673    select   = '\{ *\{ *0, *\} *\}';
1674    sed      = "/define[ \t]\\{1,\\}PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
1675               "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
1676    sed      = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1677               "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0 }/";
1678    sed      = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1679               "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0 }/";
1680    sed      = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
1681               "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
1682    sed      = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1683               "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1684    sed      = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1685               "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0, 0 }/";
1686    sed      = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
1687               "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
1688    sed      = "/define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
1689               "N;s/^[ \t]*#[ \t]*"
1690               "\\(define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
1691               "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\\n"
1692               "#  \\1\\\n"
1693               "  { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1694               "# else\\\n"
1695               "#  \\1\\\n"
1696               "  { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
1697               "# endif/";
1698    sed      = "s/{ \\(0, 0, 0, 0, 0, 0, "
1699               "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
1700    sed      = "/define[ \t]\\{1,\\}PTHREAD_COND_INITIALIZER/"
1701               "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
1702
1703    test_text = <<- _EOText_
1704	#define PTHREAD_MUTEX_INITIALIZER \\
1705	  { { 0, } }
1706	#ifdef __USE_GNU
1707	# if __WORDSIZE == 64
1708	#  define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1709	  { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1710	#  define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1711	  { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1712	#  define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1713	  { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1714	# else
1715	#  define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
1716	  { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
1717	#  define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
1718	  { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
1719	#  define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
1720	  { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
1721	# endif
1722	#endif
1723	# define PTHREAD_RWLOCK_INITIALIZER \\
1724	  { { 0, } }
1725	# ifdef __USE_GNU
1726	#  if __WORDSIZE == 64
1727	#   define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1728	  { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,			      \\
1729	      PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1730	#  else
1731	#   define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
1732	  { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
1733	#  endif
1734	# endif
1735	#define PTHREAD_COND_INITIALIZER { { 0, } }
1736	_EOText_;
1737};
1738
1739
1740/* glibc versions before 2.5 have a version of stdint.h that defines
1741   UINT8_C and UINT16_C to produce unsigned constants, as do uClibc
1742   versions with stdint.h based on those glibc versions.  */
1743fix = {
1744    hackname  = glibc_stdint;
1745    files     = stdint.h;
1746    select    = "GNU C Library";
1747    c_fix     = format;
1748    c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
1749    c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
1750    test_text = "/* This file is part of the GNU C Library.  */\n# define UINT8_C(c)\tc ## U\n# define UINT16_C(c)\tc ## U";
1751};
1752
1753
1754/* Some versions of glibc have a version of bits/string2.h that
1755   produces "value computed is not used" warnings from strncpy; fix
1756   this definition by using __builtin_strncpy instead as in newer
1757   versions.  */
1758fix = {
1759    hackname  = glibc_strncpy;
1760    files     = bits/string2.h;
1761    bypass    = "__builtin_strncpy";
1762    c_fix     = format;
1763    c_fix_arg = "#  define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
1764    c_fix_arg = "#  define strncpy([^\n]*\\\\\n)*[^\n]*";
1765    test_text = <<-EOT
1766	#  define strncpy(dest, src, n) \
1767	  (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n)      \\
1768			  ? (strlen (src) + 1 >= ((size_t) (n))			      \\
1769			     ? (char *) memcpy (dest, src, n)			      \\
1770			     : strncpy (dest, src, n))				      \\
1771			  : strncpy (dest, src, n)))
1772	EOT;
1773
1774};
1775
1776/* glibc's tgmath.h relies on an expression that is not an integer
1777   constant expression being treated as it was by GCC 4.4 and
1778   earlier.  */
1779fix = {
1780    hackname  = glibc_tgmath;
1781    files     = tgmath.h;
1782    select    = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
1783    bypass    = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
1784    c_fix     = format;
1785    c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || (__builtin_classify_type ((type) 0) == 9 && __builtin_classify_type (__real__ ((type) 0)) == 8))";
1786    test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
1787};
1788
1789/*
1790 * Fix these files to use the types we think they should for
1791 * ptrdiff_t, size_t, and wchar_t.
1792 *
1793 * This defines the types in terms of macros predefined by our 'cpp'.
1794 * This is supposedly necessary for glibc's handling of these types.
1795 * It's probably not necessary for anyone else, but it doesn't hurt.
1796 */
1797fix = {
1798    hackname  = gnu_types;
1799    files  = "sys/types.h";
1800    files  = "stdlib.h";
1801    files  = "sys/stdtypes.h";
1802    files  = "stddef.h";
1803    files  = "memory.h";
1804    files  = "unistd.h";
1805    bypass    = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
1806    select    = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
1807    c_fix     = gnu_type;
1808    /* The Solaris 10 headers already define these types correctly.  */
1809    mach   = '*-*-solaris2.1[0-9]*';
1810    not_machine = true;
1811
1812    test_text = "typedef long int ptrdiff_t; /* long int */\n"
1813                "typedef uint_t size_t; /* uint_t */\n"
1814                "typedef ushort_t wchar_t; /* ushort_t */";
1815};
1816
1817
1818/*
1819 *  Fix HP & Sony's use of "../machine/xxx.h"
1820 *  to refer to:  <machine/xxx.h>
1821 */
1822fix = {
1823    hackname  = hp_inline;
1824    files     = sys/spinlock.h;
1825    files     = machine/machparam.h;
1826    select    = "[ \t]*#[ \t]*include[ \t]+"  '"\.\./machine/';
1827
1828    c_fix     = format;
1829    c_fix_arg = "%1<machine/%2.h>";
1830
1831    c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)"  '"\.\./machine/'
1832                '([a-z]+)\.h"';
1833
1834    test_text = ' # include "../machine/mumble.h"';
1835};
1836
1837
1838/*
1839 *  Check for (...) in C++ code in HP/UX sys/file.h.
1840 */
1841fix = {
1842    hackname  = hp_sysfile;
1843    files     = sys/file.h;
1844    select    = "HPUX_SOURCE";
1845
1846    c_fix     = format;
1847    c_fix_arg = "(struct file *, ...)";
1848    c_fix_arg = '\(\.\.\.\)';
1849
1850    test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
1851};
1852
1853
1854/*
1855 *  Un-Hide a series of five FP defines from post-1999 compliance GCC:
1856 *  FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN
1857 */
1858fix = {
1859     hackname  = hppa_hpux_fp_macros;
1860     mach      = "hppa*-hp-hpux11*";
1861     files     = math.h;
1862     select    = "#[ \t]*define[ \t]*FP_NORMAL.*\n"
1863		 "#[ \t]*define[ \t]*FP_ZERO.*\n"
1864		 "#[ \t]*define[ \t]*FP_INFINITE.*\n"
1865		 "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n"
1866		 "#[ \t]*define[ \t]*FP_NAN.*\n";
1867     c_fix     = format;
1868     c_fix_arg = <<- _EOFix_
1869	#endif /* _INCLUDE_HPUX_SOURCE */
1870
1871	#if defined(_INCLUDE_HPUX_SOURCE) || \
1872	   (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
1873	%0#endif
1874
1875	#ifdef _INCLUDE_HPUX_SOURCE
1876
1877	_EOFix_;
1878
1879     test_text =
1880            "#  define FP_NORMAL     0\n"
1881            "#  define FP_ZERO       1\n"
1882            "#  define FP_INFINITE   2\n"
1883            "#  define FP_SUBNORMAL  3\n"
1884            "#  define FP_NAN        4\n";
1885};
1886
1887
1888/*
1889 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
1890 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
1891 */
1892fix = {
1893    hackname  = hpux10_cpp_pow_inline;
1894    files     = fixinc-test-limits.h, math.h;
1895    select    = <<-	END_POW_INLINE
1896	^# +ifdef +__cplusplus
1897	 +\}
1898	 +inline +double +pow\(double +__d,int +__expon\) +\{
1899	[ 	]+return +pow\(__d,\(double\)__expon\);
1900	 +\}
1901	 +extern +"C" +\{
1902	#else
1903	# +endif
1904	END_POW_INLINE;
1905
1906    c_fix     = format;
1907    c_fix_arg = "";
1908
1909    test_text =
1910	"#    ifdef __cplusplus\n"
1911	"     }\n"
1912	"     inline double pow(double __d,int __expon) {\n"
1913	"\t return pow(__d,(double)__expon);\n"
1914	"     }\n"
1915	'     extern "C"' " {\n"
1916	"#else\n"
1917	"#    endif";
1918};
1919
1920fix = {
1921     hackname  = hpux11_cpp_pow_inline;
1922     files     = math.h;
1923     select    = " +inline double pow\\(double d,int expon\\) \\{\n"
1924                 " +return pow\\(d, \\(double\\)expon\\);\n"
1925                 " +\\}\n";
1926     c_fix     = format;
1927     c_fix_arg = "";
1928
1929     test_text =
1930            "   inline double pow(double d,int expon) {\n"
1931            "     return pow(d, (double)expon);\n"
1932            "   }\n";
1933};
1934
1935
1936/*
1937 *  Fix hpux 10.X missing ctype declarations 1
1938 */
1939fix = {
1940    hackname = hpux10_ctype_declarations1;
1941    files    = ctype.h;
1942    select   = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
1943    bypass   = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
1944    c_fix     = format;
1945    c_fix_arg = "#ifdef _PROTOTYPES\n"
1946		"extern int __tolower(int);\n"
1947		"extern int __toupper(int);\n"
1948		"#else /* NOT _PROTOTYPES */\n"
1949		"extern int __tolower();\n"
1950		"extern int __toupper();\n"
1951		"#endif /* _PROTOTYPES */\n\n"
1952		"%0\n";
1953
1954    test_text = "#  define _toupper(__c)         __toupper(__c)\n";
1955};
1956
1957
1958/*
1959 *  Fix hpux 10.X missing ctype declarations 2
1960 */
1961fix = {
1962    hackname = hpux10_ctype_declarations2;
1963    files    = ctype.h;
1964    select   = "^#  if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
1965    bypass   = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
1966    c_fix     = format;
1967    c_fix_arg = "%0\n\n"
1968		"#ifdef _PROTOTYPES\n"
1969		"     extern int _isalnum(int);\n"
1970		"     extern int _isalpha(int);\n"
1971		"     extern int _iscntrl(int);\n"
1972		"     extern int _isdigit(int);\n"
1973		"     extern int _isgraph(int);\n"
1974		"     extern int _islower(int);\n"
1975		"     extern int _isprint(int);\n"
1976		"     extern int _ispunct(int);\n"
1977		"     extern int _isspace(int);\n"
1978		"     extern int _isupper(int);\n"
1979		"     extern int _isxdigit(int);\n"
1980		"#  else /* not _PROTOTYPES */\n"
1981		"     extern int _isalnum();\n"
1982		"     extern int _isalpha();\n"
1983		"     extern int _iscntrl();\n"
1984		"     extern int _isdigit();\n"
1985		"     extern int _isgraph();\n"
1986		"     extern int _islower();\n"
1987		"     extern int _isprint();\n"
1988		"     extern int _ispunct();\n"
1989		"     extern int _isspace();\n"
1990		"     extern int _isupper();\n"
1991		"     extern int _isxdigit();\n"
1992		"#endif /* _PROTOTYPES */\n";
1993
1994    test_text = "#  if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
1995		"     extern unsigned int *__SB_masks;\n";
1996};
1997
1998
1999/*
2000 *  Fix hpux 10.X missing stdio declarations
2001 */
2002fix = {
2003    hackname = hpux10_stdio_declarations;
2004    files    = stdio.h;
2005    select   = "^#[ \t]*define _iob[ \t]*__iob";
2006    bypass   = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
2007    c_fix     = format;
2008    c_fix_arg = "%0\n\n"
2009	"#  if defined(__STDC__) || defined(__cplusplus)\n"
2010	"     extern int snprintf(char *, size_t, const char *, ...);\n"
2011	"     extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
2012	"#  else /* not __STDC__) || __cplusplus */\n"
2013	"     extern int snprintf();\n"
2014	"     extern int vsnprintf();\n"
2015	"#  endif /* __STDC__) || __cplusplus */\n";
2016
2017    test_text = "#  define _iob __iob\n";
2018};
2019
2020
2021/*
2022 *  Make sure hpux defines abs in header.
2023 */
2024fix = {
2025    hackname  = hpux11_abs;
2026    mach      = "*-hp-hpux11*";
2027    files     = stdlib.h;
2028    select    = "ifndef _MATH_INCLUDED";
2029    c_fix     = format;
2030    c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
2031    test_text = "#ifndef _MATH_INCLUDED";
2032};
2033
2034
2035/*
2036 *  Keep HP-UX 11 from stomping on C++ math namespace
2037 *  with defines for fabsf.
2038 */
2039fix = {
2040    hackname  = hpux11_fabsf;
2041    files     = math.h;
2042    select    = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
2043    bypass    = "__cplusplus";
2044
2045    c_fix     = format;
2046    c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
2047
2048    test_text =
2049    "#ifdef _PA_RISC\n"
2050    "#  define fabsf(x) ((float)fabs((double)(float)(x)))\n"
2051    "#endif";
2052};
2053
2054
2055/*
2056 *  Fix C99 constant in __POINTER_SET define.
2057 */
2058fix = {
2059    hackname  = hpux11_pthread_const;
2060    mach      = "*-hp-hpux11.[0-3]*";
2061    files     = sys/pthread.h;
2062    select    = "^#define[ \t]*__POINTER_SET[ \t]*\\(\\(void \\*\\) 1LL\\)";
2063
2064    c_fix     = format;
2065    c_fix_arg = "#define __POINTER_SET\t\t((void *) 1L)";
2066    test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
2067};
2068
2069
2070/*
2071 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
2072 * being defined by having it define _hpux_size_t instead.
2073 */
2074fix = {
2075    hackname  = hpux11_size_t;
2076    mach      = "*-hp-hpux11*";
2077    select    = "__size_t";
2078
2079    c_fix     = format;
2080    c_fix_arg = "_hpux_size_t";
2081
2082    test_text =
2083    "#define __size_t size_t\n"
2084    "       extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
2085};
2086
2087
2088/*
2089 *  Fix hpux 11.00 broken snprintf declaration
2090 *  (third argument is char *, needs to be const char * to prevent
2091 *  spurious warnings with -Wwrite-strings or in C++).
2092 */
2093fix = {
2094    hackname = hpux11_snprintf;
2095    files    = stdio.h;
2096    select   = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
2097                                    ' *(char *\*, *\.\.\.\);)';
2098    c_fix     = format;
2099    c_fix_arg = '%1 const %3';
2100
2101    test_text = "extern int snprintf(char *, size_t, char *, ...);\n"
2102                "extern int snprintf(char *, __size_t, char *, ...);\n"
2103                "extern int snprintf(char *, _hpux_size_t, char *, ...);";
2104};
2105
2106/*
2107 *  Fix hpux 11.00 broken vsnprintf declaration
2108 */
2109fix = {
2110    hackname = hpux11_vsnprintf;
2111    files    = stdio.h;
2112    select   = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
2113                                     'const char \*,) __va__list\);';
2114    c_fix     = format;
2115    c_fix_arg = "%1 __va_list);";
2116
2117    test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
2118                                     ' __va__list);';
2119};
2120
2121
2122/*
2123 *  get rid of bogus inline definitions in HP-UX 8.0
2124 */
2125fix = {
2126    hackname = hpux8_bogus_inlines;
2127    files    = math.h;
2128    select   = inline;
2129    bypass   = "__GNUG__";
2130    sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
2131           "@extern \"C\" int abs(int);@";
2132    sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
2133    sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
2134    sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
2135    test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
2136                "inline double sqr(double v) { return v**0.5; }";
2137};
2138
2139
2140/*
2141 *  Fix hpux broken ctype macros
2142 */
2143fix = {
2144    hackname = hpux_ctype_macros;
2145    files    = ctype.h;
2146    select   = '((: |\()__SB_masks \? )'
2147	       '(__SB_masks\[__(alnum|c)\] & _IS)';
2148    c_fix     = format;
2149    c_fix_arg = "%1(int)%3";
2150
2151    test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
2152		"# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
2153};
2154
2155
2156/*
2157 *  Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
2158 */
2159fix = {
2160    hackname = hpux_htonl;
2161    files    = netinet/in.h;
2162    select   = "#ifndef _XOPEN_SOURCE_EXTENDED[ \t]*\n"
2163               "(/\\*\n"
2164               " \\* Macros for number representation conversion\\.\n"
2165               " \\*/\n"
2166               "#ifndef ntohl)";
2167    c_fix     = format;
2168    c_fix_arg = "#if 1\n%1";
2169
2170    test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
2171                "/*\n"
2172                " * Macros for number representation conversion.\n"
2173                " */\n"
2174                "#ifndef ntohl\n"
2175                "#define ntohl(x)        (x)\n"
2176                "#define ntohs(x)        (x)\n"
2177                "#define htonl(x)        (x)\n"
2178                "#define htons(x)        (x)\n"
2179                "#endif\n"
2180                "#endif  /* ! _XOPEN_SOURCE_EXTENDED */";
2181};
2182
2183
2184/*
2185 * HP-UX long_double
2186 */
2187fix = {
2188    hackname  = hpux_long_double;
2189    mach      = "*-*-hpux10*";
2190    mach      = "*-*-hpux11.[012]*";
2191    files     = stdlib.h;
2192    select    = "extern[ \t]long_double[ \t]strtold";
2193    bypass    = "long_double_t";
2194    sed       = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
2195    sed       = "s/long_double/long double/g";
2196
2197    test_text = "#  ifndef _LONG_DOUBLE\n"
2198		"#    define _LONG_DOUBLE\n"
2199		"     typedef struct {\n"
2200		"       unsigned int word1, word2, word3, word4;\n"
2201		"     } long_double;\n"
2202		"#  endif /* _LONG_DOUBLE */\n"
2203		"extern long_double strtold(const char *, char **);\n";
2204};
2205
2206 /*
2207  * We cannot use the above rule on 11.31 because it removes the strtold
2208  * definition.  ia64 is OK with no hack, PA needs some help.
2209  */
2210fix = {
2211    hackname  = hpux_long_double_2;
2212    mach      = "hppa*-*-hpux11.3*";
2213    files     = stdlib.h;
2214    select    = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| defined\\(_PROTOTYPES\\) \\|\\| defined\\(_LONG_DOUBLE_STRUCT\\)";
2215    c_fix     = format;
2216    c_fix_arg = "#  if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
2217
2218    test_text = "#  if !defined(__ia64) || !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)\n";
2219};
2220
2221/*
2222 *  Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
2223 */
2224fix = {
2225    hackname = hpux_systime;
2226    files    = sys/time.h;
2227    select   = "^extern struct sigevent;";
2228
2229    c_fix     = format;
2230    c_fix_arg = "struct sigevent;";
2231
2232    test_text = 'extern struct sigevent;';
2233};
2234
2235
2236/*
2237 *  Wrap spu_info in ifdef _KERNEL.  GCC cannot handle an array of unknown
2238 *  type and mpinfou is only defined when _KERNEL is set.
2239 */
2240fix = {
2241    hackname = hpux_spu_info;
2242    mach     = "*-hp-hpux*";
2243    /*
2244     *  It is tempting to omit the first "files" entry.  Do not.
2245     *  The testing machinery will take the first "files" entry as the name
2246     *  of a test file to play with.  It would be a nuisance to have a directory
2247     *  with the name "*".
2248     */
2249    files    = "ia64/sys/getppdp.h";
2250    files    = "*/sys/getppdp.h";
2251    select   = "^.*extern.*spu_info.*";
2252
2253    c_fix     = format;
2254    c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
2255
2256    test_text = "extern union mpinfou spu_info[];";
2257};
2258
2259fix = {
2260    hackname  = hpux11_extern_sendfile;
2261    mach      = "*-hp-hpux11.[12]*";
2262    files     = sys/socket.h;
2263    select    = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
2264    c_fix     = format;
2265    c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2266    test_text = "   extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n                               const struct iovec *, int));\n";
2267};
2268
2269fix = {
2270    hackname  = hpux11_extern_sendpath;
2271    mach      = "*-hp-hpux11.[12]*";
2272    files     = sys/socket.h;
2273    select    = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
2274    c_fix     = format;
2275    c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2276    test_text = "   extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n                               const struct iovec *, int));\n";
2277};
2278
2279fix = {
2280    hackname  = hpux_extern_errno;
2281    mach      = "*-hp-hpux10.*";
2282    mach      = "*-hp-hpux11.[0-2]*";
2283    files     = errno.h;
2284    select    = "^[ \t]*extern int errno;$";
2285    c_fix     = format;
2286    c_fix_arg = "#ifdef __cplusplus\nextern \"C\" {\n#endif\n%0\n#ifdef __cplusplus\n}\n#endif";
2287    test_text = "   extern int errno;\n";
2288};
2289
2290
2291/*
2292 *  Add missing braces to pthread initializer defines.
2293 */
2294fix = {
2295    hackname  = hpux_pthread_initializers;
2296    mach      = "*-hp-hpux11.[0-3]*";
2297    files     = sys/pthread.h;
2298    sed       = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
2299		 "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
2300    sed       = "s@^[ \t]*1,[ \t]*\\\\"
2301		 "@\t{ 1, 0 }@";
2302    sed       = "/^[ \t]*0$/d";
2303    sed       = "s@__PTHREAD_MUTEX_VALID, 0"
2304		 "@{ __PTHREAD_MUTEX_VALID, 0 }@";
2305    sed       = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
2306		 "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
2307    sed       = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2308		 "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2309    sed       = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
2310		 "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
2311    sed       = "s@^[ \t]*0, 0[ \t]*\\\\"
2312		 "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
2313    sed       = "s@__PTHREAD_COND_VALID, 0"
2314		 "@{ __PTHREAD_COND_VALID, 0 }@";
2315    sed       = "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
2316		 "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
2317    sed       = "s@__PTHREAD_RWLOCK_VALID, 0"
2318		 "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
2319    sed       = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
2320		 "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
2321    sed       = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
2322		 "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
2323    test_text = "#define PTHREAD_MUTEX_INITIALIZER  {\t\t\t\t\t\\\\\n"
2324		"\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
2325		"\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
2326		"\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
2327		"\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
2328		"\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
2329		"\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
2330		"}\n";
2331};
2332
2333fix = {
2334    hackname  = hpux_c99_intptr;
2335    mach      = "*-hp-hpux11.3*";
2336    files     = stdint-hpux11.h, stdint.h;
2337    sed       = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
2338    sed       = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2339    sed       = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
2340    sed       = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
2341    sed       = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
2342    sed       = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
2343    test_text = "#define PTRDIFF_MAX	INT32_MAX\n"
2344		"#define PTRDIFF_MIN	INT32_MIN\n"
2345		"#define INTPTR_MAX	INT32_MAX\n"
2346		"#define INTPTR_MIN	INT32_MIN\n"
2347		"#define UINTPTR_MAX	UINT32_MAX\n"
2348		"#define SIZE_MAX	UINT32_MAX\n";
2349};
2350
2351/*
2352 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2353 */
2354
2355fix = {
2356    hackname  = hpux_c99_inttypes;
2357    mach      = "*-hp-hpux11.[23]*";
2358    files     = inttypes.h;
2359    files     = stdint-hpux11.h, stdint.h;
2360    sed       = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
2361    sed       = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
2362    sed       = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
2363    sed       = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@#define UINT32_C(__c) __CONCAT__(__c,u)@";
2364    test_text = "#define UINT8_C(__c)     __CONCAT_U__(__c)\n"
2365                "#define UINT16_C(__c)    __CONCAT_U__(__c)\n"
2366		"#define INT32_C(__c)     __CONCAT__(__c,l)\n"
2367		"#define UINT32_C(__c)     __CONCAT__(__c,ul)\n";
2368};
2369
2370fix = {
2371    hackname  = hpux_c99_inttypes2;
2372    mach      = "*-hp-hpux11.2*";
2373    files     = stdint-hpux11.h, stdint.h;
2374    sed       = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
2375    sed       = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
2376    sed       = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
2377    sed       = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
2378    test_text = "#  define	INT8_C(__c)	((signed char)(__c))\n"
2379                "#  define      UINT8_C(__c)    ((unsigned char)(__c))\n"
2380		"#  define      INT16_C(__c)    ((short)(__c))\n"
2381		"#  define	UINT16_C(__c)	((unsigned short)(__c))\n";
2382};
2383
2384fix = {
2385    hackname  = hpux_stdint_least_fast;
2386    mach      = "*-hp-hpux11.2*";
2387    files     = stdint-hpux11.h, stdint.h;
2388    select    =
2389        "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX";
2390    c_fix     = format;
2391    c-fix-arg = "#  define	UINT_%164_MAX	__UINT64_MAX__";
2392    test-text = "#  define       UINT_FAST64_MAX        ULLONG_MAX\n"
2393		"#  define       UINT_LEAST64_MAX        ULLONG_MAX\n";
2394	_EOFix_;
2395};
2396
2397fix = {
2398    hackname  = hpux_inttype_int8_t;
2399    mach      = "*-hp-hpux1[01].*";
2400    files     = sys/_inttypes.h;
2401    select    = "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*";
2402    c_fix     = format;
2403    c_fix_arg = "typedef signed char int%18_t;";
2404    test_text = "typedef char int_least8_t;\n"
2405                "typedef char int8_t;\n";
2406};
2407
2408fix = {
2409    hackname  = hpux_imaginary_i;
2410    mach      = "ia64-hp-hpux11.*";
2411    files     = complex.h;
2412    select    = "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*";
2413    c_fix     = format;
2414    c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
2415    test_text = "#define _Complex_I (0.f+_Imaginary_I)\n";
2416};
2417
2418/*
2419 *  Fix glibc definition of HUGE_VAL in terms of hex floating point constant
2420 */
2421fix = {
2422    hackname  = huge_val_hex;
2423    files     = bits/huge_val.h;
2424    select    = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
2425    bypass    = "__builtin_huge_val";
2426
2427    c_fix     = format;
2428    c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n";
2429
2430    test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
2431};
2432
2433
2434/*
2435 *  Fix glibc definition of HUGE_VALF in terms of hex floating point constant
2436 */
2437fix = {
2438    hackname  = huge_valf_hex;
2439    files     = bits/huge_val.h;
2440    select    = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
2441    bypass    = "__builtin_huge_valf";
2442
2443    c_fix     = format;
2444    c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n";
2445
2446    test_text = "#  define HUGE_VALF (__extension__ 0x1.0p255f)";
2447};
2448
2449
2450/*
2451 *  Fix glibc definition of HUGE_VALL in terms of hex floating point constant
2452 */
2453fix = {
2454    hackname  = huge_vall_hex;
2455    files     = bits/huge_val.h;
2456    select    = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
2457    bypass    = "__builtin_huge_vall";
2458
2459    c_fix     = format;
2460    c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n";
2461
2462    test_text = "#  define HUGE_VALL (__extension__ 0x1.0p32767L)";
2463};
2464
2465
2466/*
2467 *  Fix return type of abort and free
2468 */
2469fix = {
2470    hackname  = int_abort_free_and_exit;
2471    files     = stdlib.h;
2472    select    = "int[ \t]+(abort|free|exit)[ \t]*\\(";
2473    bypass    = "_CLASSIC_ANSI_TYPES";
2474
2475    c_fix     = format;
2476    c_fix_arg = "void\t%1(";
2477
2478    test_text = "extern int abort(int);\n"
2479                "extern int free(void*);\n"
2480                "extern int exit(void*);";
2481};
2482
2483
2484/*
2485 *  Fix various macros used to define ioctl numbers.
2486 *  The traditional syntax was:
2487 *
2488 *    #define _IO(n, x) (('n'<<8)+x)
2489 *    #define TIOCFOO _IO(T, 1)
2490 *
2491 *  but this does not work with the C standard, which disallows macro
2492 *  expansion inside strings.  We have to rewrite it thus:
2493 *
2494 *    #define _IO(n, x) ((n<<8)+x)
2495 *    #define TIOCFOO  _IO('T', 1)
2496 *
2497 *  The select expressions match too much, but the c_fix code is cautious.
2498 *
2499 *  _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
2500 */
2501fix = {
2502    hackname  = io_quotes_def;
2503    select    = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
2504    c_fix     = char_macro_def;
2505    c_fix_arg = "IO";
2506    test_text =
2507    "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
2508    "#define _IOWN(x,y,t)  (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
2509    "#define _IO(x,y)      ('x'<<8|y)";
2510    test_text =
2511    "#define XX_IO(x)        ('x'<<8|256)";
2512};
2513
2514/*
2515 *  Fix the usage of the ioctl macro numbers.
2516 */
2517fix = {
2518    hackname  = io_quotes_use;
2519    select    = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
2520                "\\( *[^,']";
2521    c_fix     = char_macro_use;
2522    c_fix_arg = "IO";
2523    test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
2524                "#define TIOCFOO \\\\\n"
2525                "BSD43__IOWR(T, 1) /* Some are multi-line */";
2526};
2527
2528
2529/*
2530 *  Check for missing ';' in struct
2531 */
2532fix = {
2533    hackname = ip_missing_semi;
2534    files    = netinet/ip.h;
2535    select   = "}$";
2536    sed      = "/^struct/,/^};/s/}$/};/";
2537    test_text=
2538    "struct mumble {\n"
2539    "  union {\n"
2540    "    int x;\n"
2541    "  }\n"
2542    "}; /* mumbled struct */\n";
2543};
2544
2545
2546/*
2547 *  Non-traditional "const" declaration in Irix's limits.h.
2548 */
2549fix = {
2550    hackname    = irix_limits_const;
2551    files       = fixinc-test-limits.h, limits.h;
2552    select      = "^extern const ";
2553    c_fix       = format;
2554    c_fix_arg   = "extern __const ";
2555    test_text   = "extern const char limit; /* test limits */";
2556};
2557
2558
2559/*
2560 *  IRIX 5.x's stdio.h declares some functions that take a va_list as
2561 *  taking char *.  However, GCC uses void * for va_list, so
2562 *  calling vfprintf with a va_list fails in C++.  */
2563fix = {
2564    hackname  = irix_stdio_va_list;
2565    files     = stdio.h;
2566
2567    select = '/\* va_list \*/ char \*';
2568    c_fix  = format;
2569    c_fix_arg = "__gnuc_va_list";
2570    test_text =
2571    "extern int printf( const char *, /* va_list */ char * );";
2572};
2573
2574
2575/*
2576 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
2577 * use / * * / to concatenate tokens.
2578 */
2579fix = {
2580    hackname = kandr_concat;
2581    files  = "sparc/asm_linkage.h";
2582    files  = "sun*/asm_linkage.h";
2583    files  = "arm/as_support.h";
2584    files  = "arm/mc_type.h";
2585    files  = "arm/xcb.h";
2586    files  = "dev/chardefmac.h";
2587    files  = "dev/ps_irq.h";
2588    files  = "dev/screen.h";
2589    files  = "dev/scsi.h";
2590    files  = "sys/tty.h";
2591    files  = "Xm.acorn/XmP.h";
2592    files  = bsd43/bsd43_.h;
2593    select = '/\*\*/';
2594    c_fix     = format;
2595    c_fix_arg = '##';
2596    test_text = "#define __CONCAT__(a,b) a/**/b";
2597};
2598
2599
2600/* The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
2601 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
2602 * constant on recent versions of g++.
2603 */
2604fix = {
2605    hackname = linux_ia64_ucontext;
2606    files = "sys/ucontext.h";
2607    mach = "ia64-*-linux*";
2608    select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)'
2609             '->sc_gr\[0\]\) - \(char \*\) 0\)';
2610    c_fix = format;
2611    c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
2612    test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
2613	"\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
2614};
2615
2616
2617/*
2618 *  Remove header file warning from sys/time.h.  Autoconf's
2619 *  AC_HEADER_TIME recommends to include both sys/time.h and time.h
2620 *  which causes warning on LynxOS.  Remove the warning.
2621 */
2622fix = {
2623    hackname  = lynxos_no_warning_in_sys_time_h;
2624    files     = sys/time.h;
2625    select    = "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
2626    c_fix     = format;
2627    c_fix_arg = "";
2628    test_text = "#warning Using <time.h> instead of <sys/time.h>";
2629};
2630
2631
2632/*
2633 *  Add missing declaration for putenv.
2634 */
2635fix = {
2636    hackname  = lynxos_missing_putenv;
2637    mach      = '*-*-lynxos*';
2638    files     = stdlib.h;
2639    bypass    = 'putenv[ \t]*\\(';
2640    select    = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2641    c_fix     = format;
2642    c_fix_arg = "%0\n"
2643        "extern int putenv				_AP((char *));";
2644    c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2645    test_text = "extern char *getenv	_AP((const char *));";
2646};
2647
2648
2649/*
2650 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
2651 *
2652 * On NetBSD, machine is a symbolic link to an architecture specific
2653 * directory name, so we can't match a specific file name here.
2654 */
2655fix = {
2656    hackname = machine_ansi_h_va_list;
2657    select   = "define[ \t]+_BSD_VA_LIST_[ \t]";
2658    bypass   = '__builtin_va_list';
2659
2660    c_fix     = format;
2661    c_fix_arg = "%1__builtin_va_list";
2662    c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
2663
2664    test_text = " # define _BSD_VA_LIST_\tchar**";
2665};
2666
2667
2668/*
2669 *  Fix non-ansi machine name defines
2670 */
2671fix = {
2672    hackname  = machine_name;
2673    c_test    = machine_name;
2674    c_fix     = machine_name;
2675
2676    test_text = "/* MACH_DIFF: */\n"
2677    "#if defined( i386 ) || defined( sparc ) || defined( vax )"
2678    "\n/* no uniform test, so be careful  :-) */";
2679};
2680
2681
2682/*
2683 *  Some math.h files define struct exception (it's in the System V
2684 *  Interface Definition), which conflicts with the class exception defined
2685 *  in the C++ file std/stdexcept.h.  We redefine it to __math_exception.
2686 *  This is not a great fix, but I haven't been able to think of anything
2687 *  better.
2688 */
2689fix = {
2690    hackname  = math_exception;
2691    files     = math.h;
2692    select    = "struct exception";
2693    /*
2694     * This should be bypassed on __cplusplus, but some supposedly C++
2695     * aware headers, such as Solaris 8 and 9, don't wrap their struct
2696     * exception either.  So currently we bypass only for glibc, based on a
2697     * comment in the fixed glibc header.  Ick.
2698     */
2699    bypass    = 'We have a problem when using C\+\+|for C\+\+, '
2700		'_[a-z0-9A-Z_]+_exception; for C, exception';
2701    c_fix     = wrap;
2702
2703    c_fix_arg = "#ifdef __cplusplus\n"
2704                "#define exception __math_exception\n"
2705                "#endif\n";
2706
2707    c_fix_arg = "#ifdef __cplusplus\n"
2708                "#undef exception\n"
2709                "#endif\n";
2710
2711    test_text = "typedef struct exception t_math_exception;";
2712};
2713
2714
2715/*
2716 *  This looks pretty broken to me.  ``dbl_max_def'' will contain
2717 *  "define DBL_MAX " at the start, when what we really want is just
2718 *  the value portion.  Can't figure out how to write a test case
2719 *  for this either  :-(
2720 */
2721fix = {
2722    hackname = math_huge_val_from_dbl_max;
2723    files    = math.h;
2724
2725    /*
2726     * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
2727     * in math.h, this fix applies.
2728     */
2729    select   = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
2730    bypass   = "define[ \t]+DBL_MAX";
2731
2732    shell    =
2733    /*
2734     *  See if we have a definition for DBL_MAX in float.h.
2735     *  If we do, we will replace the one in math.h with that one.
2736     */
2737
2738    "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
2739                   "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
2740
2741    "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
2742    "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
2743			"s@DBL_MAX@'\"$dbl_max_def@\"\n"
2744    "\telse cat\n"
2745    "\tfi";
2746
2747    test_text =
2748    "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
2749    "#define HUGE_VAL DBL_MAX";
2750};
2751
2752
2753/*
2754 *  nested comment
2755 */
2756fix = {
2757    hackname  = nested_auth_des;
2758    files     = rpc/rpc.h;
2759    select    = '(/\*.*rpc/auth_des\.h>.*)/\*';
2760    c_fix     = format;
2761    c_fix_arg = "%1*/ /*";
2762    test_text = "/*#include <rpc/auth_des.h> /* skip this */";
2763};
2764
2765
2766/*
2767 *  Some versions of NetBSD don't expect the C99 inline semantics.
2768 */
2769fix = {
2770    hackname  = netbsd_c99_inline_1;
2771    mach      = "*-*-netbsd*";
2772    files     = signal.h;
2773    select    = "extern __inline int";
2774
2775    c_fix     = format;
2776    c_fix_arg = "extern\n"
2777		"#ifdef __GNUC_STDC_INLINE__\n"
2778		"__attribute__((__gnu_inline__))\n"
2779		"#endif\n"
2780		"__inline int";
2781
2782    test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
2783};
2784
2785
2786fix = {
2787    hackname  = netbsd_c99_inline_2;
2788    mach      = "*-*-netbsd*";
2789    files     = signal.h;
2790    select    = "#define _SIGINLINE extern __inline";
2791
2792    c_fix     = format;
2793    c_fix_arg = <<- _EOArg_
2794	#ifdef __GNUC_STDC_INLINE__
2795	#define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline
2796	#else
2797	%0
2798	#endif
2799	_EOArg_;
2800
2801    test_text = "#define _SIGINLINE extern __inline";
2802};
2803
2804
2805/*
2806 * NetBSD has a semicolon after the ending '}' for some extern "C".
2807 */
2808fix = {
2809    hackname  = netbsd_extra_semicolon;
2810    mach      = "*-*-netbsd*";
2811    files     = sys/cdefs.h;
2812    select    = "#define[ \t]*__END_DECLS[ \t]*};";
2813
2814    c_fix     = format;
2815    c_fix_arg = "#define __END_DECLS }";
2816
2817    test_text = "#define __END_DECLS };";
2818};
2819
2820
2821/* newlib's stdint.h has several failures to conform to C99.  The fix
2822   for these removed a comment that can be matched to identify unfixed
2823   versions.  */
2824fix = {
2825    hackname  = newlib_stdint_1;
2826    files     = stdint-newlib.h, stdint.h;
2827    select    = "@todo - Add support for wint_t types";
2828    sed       = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
2829    sed       = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
2830    sed       = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
2831    sed       = "s@#define INT_LEAST32_MIN.*@#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
2832    sed       = "s@#define INT_LEAST32_MAX.*@#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
2833    sed       = "s@#define UINT_LEAST32_MAX.*@#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
2834    sed       = 's@#define INT_FAST\([0-9]*\)_MIN.*@#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@';
2835    sed       = 's@#define INT_FAST\([0-9]*\)_MAX.*@#define INT_FAST\1_MAX __INT_FAST\1_MAX__@';
2836    sed       = 's@#define UINT_FAST\([0-9]*\)_MAX.*@#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@';
2837    sed       = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
2838    sed       = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2839    sed       = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
2840    sed       = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@";
2841    sed       = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@";
2842    test_text = "/* @todo - Add support for wint_t types. */\n"
2843                "#define INT32_MIN (-2147483647-1)\n"
2844                "#define INT32_MAX 2147483647\n"
2845                "#define UINT32_MAX 4294967295U\n"
2846                "#define INT_LEAST32_MIN (-2147483647-1)\n"
2847                "#define INT_LEAST32_MAX 2147483647\n"
2848                "#define UINT_LEAST32_MAX 4294967295U\n"
2849                "#define INT_FAST8_MIN INT8_MIN\n"
2850                "#define INT_FAST8_MAX INT8_MAX\n"
2851                "#define UINT_FAST8_MAX UINT8_MAX\n"
2852                "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n"
2853                "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n"
2854                "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n"
2855                "#define UINT8_C(x) x##U\n"
2856                "#define UINT16_C(x) x##U";
2857};
2858
2859
2860fix = {
2861    hackname  = newlib_stdint_2;
2862    files     = stdint-newlib.h, stdint.h;
2863    select    = "@todo - Add support for wint_t types";
2864    c_fix     = format;
2865    c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n"
2866                "#define INTMAX_MIN (-INTMAX_MAX - 1)\n"
2867                "#define UINTMAX_MAX __UINTMAX_MAX__\n"
2868                "#define WCHAR_MAX __WCHAR_MAX__\n"
2869                "#define WCHAR_MIN __WCHAR_MIN__\n"
2870                "#define WINT_MAX __WINT_MAX__\n"
2871                "#define WINT_MIN __WINT_MIN__\n\n"
2872                "%0";
2873    c_fix_arg = '/\*\* Macros for minimum-width integer constant expressions \*/';
2874    test_text = "/* @todo - Add support for wint_t types. */\n"
2875                "/** Macros for minimum-width integer constant expressions */";
2876};
2877
2878
2879/*
2880 *  NeXT 3.2 adds const prefix to some math functions.
2881 *  These conflict with the built-in functions.
2882 */
2883fix = {
2884    hackname  = next_math_prefix;
2885    files     = ansi/math.h;
2886    select    = "^extern[ \t]+double[ \t]+__const__[ \t]";
2887
2888    c_fix     = format;
2889    c_fix_arg = "extern double %1(";
2890    c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
2891
2892    test_text = "extern\tdouble\t__const__\tmumble();";
2893};
2894
2895
2896/*
2897 *  NeXT 3.2 uses the word "template" as a parameter for some
2898 *  functions. GCC reports an invalid use of a reserved key word
2899 *  with the built-in functions.
2900 */
2901fix = {
2902    hackname = next_template;
2903    files    = bsd/libc.h;
2904    select   = "[ \t]template\\)";
2905
2906    c_fix     = format;
2907    c_fix_arg = "(%1)";
2908    c_fix_arg = "\\(([^)]*)[ \t]template\\)";
2909    test_text = "extern mumble( char * template); /* fix */";
2910};
2911
2912
2913/*
2914 *  NeXT 3.2 includes the keyword volatile in the abort() and  exit()
2915 *  function prototypes. That conflicts with the  built-in functions.
2916 */
2917fix = {
2918    hackname = next_volitile;
2919    files    = ansi/stdlib.h;
2920    select   = "^extern[ \t]+volatile[ \t]+void[ \t]";
2921
2922    c_fix     = format;
2923    c_fix_arg = "extern void %1(";
2924    c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
2925
2926    test_text = "extern\tvolatile\tvoid\tabort();";
2927};
2928
2929
2930/*
2931 *  NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
2932 *  Note that version 3 of the NeXT system has wait.h in a different directory,
2933 *  so that this code won't do anything.  But wait.h in version 3 has a
2934 *  conditional, so it doesn't need this fix.  So everything is okay.
2935 */
2936fix = {
2937    hackname  = next_wait_union;
2938    files     = sys/wait.h;
2939
2940    select    = 'wait\(union wait';
2941    c_fix     = format;
2942    c_fix_arg = "wait(void";
2943    test_text = "extern pid_d wait(union wait*);";
2944};
2945
2946
2947/*
2948 *  a missing semi-colon at the end of the nodeent structure definition.
2949 */
2950fix = {
2951    hackname  = nodeent_syntax;
2952    files     = netdnet/dnetdb.h;
2953    select    = "char[ \t]*\\*na_addr[ \t]*$";
2954    c_fix     = format;
2955    c_fix_arg = "%0;";
2956    test_text = "char *na_addr\t";
2957};
2958
2959/*
2960 * Fix OpenBSD's NULL definition.
2961 */
2962fix = {
2963  hackname  = openbsd_null_definition;
2964  mach      = "*-*-openbsd*";
2965  files     = locale.h, stddef.h, stdio.h, string.h,
2966  time.h, unistd.h, wchar.h, sys/param.h;
2967  select    = "__GNUG__";
2968  c_fix = format;
2969  c_fix_arg = "#ifndef NULL\n"
2970	      "#ifdef __cplusplus\n"
2971	      "#ifdef __GNUG__\n"
2972	      "#define NULL\t__null\n"
2973	      "#else\t /* ! __GNUG__  */\n"
2974	      "#define NULL\t0L\n"
2975              "#endif\t /* __GNUG__  */\n"
2976	      "#else\t /* ! __cplusplus  */\n"
2977	      "#define NULL\t((void *)0)\n"
2978              "#endif\t /* __cplusplus  */\n"
2979              "#endif\t /* !NULL  */";
2980
2981  c_fix_arg = "^#ifndef[ \t]*NULL\n"
2982	      "^#ifdef[ \t]*__GNUG__\n"
2983  	      "^#define[ \t]*NULL[ \t]*__null\n"
2984  	      "^#else\n"
2985              "^#define[ \t]*NULL[ \t]*0L\n"
2986              "^#endif\n"
2987              "^#endif";
2988  test_text =
2989	"#ifndef NULL\n"
2990	"#ifdef  __GNUG__\n"
2991	"#define NULL    __null\n"
2992	"#else\n"
2993	"#define NULL    0L\n"
2994	"#endif\n"
2995	"#endif\n";
2996};
2997
2998/*
2999 *  obstack.h used casts as lvalues.
3000 *
3001 *  We need to change postincrements of casted pointers (which are
3002 *  then dereferenced and assigned into) of the form
3003 *
3004 *    *((TYPE*)PTRVAR)++ = (VALUE)
3005 *
3006 *  into expressions like
3007 *
3008 *    ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
3009 *
3010 *  which is correct for the cases used in obstack.h since PTRVAR is
3011 *  of type char * and the value of the expression is not used.
3012 */
3013fix = {
3014    hackname  = obstack_lvalue_cast;
3015    files     = obstack.h;
3016    select    = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
3017    c_fix     = format;
3018    c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
3019    test_text = "*((void **) (h)->next_free)++ = (aptr)";
3020};
3021
3022/*
3023 * Fix OpenBSD's va_start define.
3024 */
3025fix = {
3026  hackname  = openbsd_va_start;
3027  mach      = "*-*-openbsd*";
3028  files     = stdarg.h;
3029  select    = '__builtin_stdarg_start';
3030  c_fix     = format;
3031  c_fix_arg = __builtin_va_start;
3032
3033  test_text = "#define va_start(v,l)   __builtin_stdarg_start((v),l)";
3034};
3035
3036/*
3037 *  sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
3038 *  defining regex.h related types.  This causes libg++ build and usage
3039 *  failures.  Fixing this correctly requires checking and modifying 3 files.
3040 */
3041fix = {
3042    hackname = osf_namespace_a;
3043    files    = reg_types.h;
3044    files    = sys/lc_core.h;
3045    test     = " -r reg_types.h";
3046    test     = " -r sys/lc_core.h";
3047    test     = " -n \"`grep '} regex_t;' reg_types.h`\"";
3048    test     = " -z \"`grep __regex_t regex.h`\"";
3049
3050    c_fix     = format;
3051    c_fix_arg = "__%0";
3052    c_fix_arg = "reg(ex|off|match)_t";
3053
3054    test_text = "`touch sys/lc_core.h`"
3055    "typedef struct {\n  int stuff, mo_suff;\n} regex_t;\n"
3056    "extern regex_t    re;\n"
3057    "extern regoff_t   ro;\n"
3058    "extern regmatch_t rm;\n";
3059};
3060
3061fix = {
3062    hackname = osf_namespace_c;
3063    files    = regex.h;
3064    test     = " -r reg_types.h";
3065    test     = " -r sys/lc_core.h";
3066    test     = " -n \"`grep '} regex_t;' reg_types.h`\"";
3067    test     = " -z \"`grep __regex_t regex.h`\"";
3068
3069    select    = "#include <reg_types\.h>.*";
3070    c_fix     = format;
3071    c_fix_arg = "%0\n"
3072                "typedef __regex_t\tregex_t;\n"
3073                "typedef __regoff_t\tregoff_t;\n"
3074                "typedef __regmatch_t\tregmatch_t;";
3075
3076    test_text = "#include <reg_types.h>";
3077};
3078
3079
3080/*
3081 * On broken glibc-2.3.3 systems an array of incomplete structures is
3082 * passed to __sigsetjmp.  Fix that to take a pointer instead.
3083 */
3084fix = {
3085    hackname  = pthread_incomplete_struct_argument;
3086    files     = pthread.h;
3087    select    = "struct __jmp_buf_tag";
3088    c_fix     = format;
3089    c_fix_arg = "%1 *%2%3";
3090    c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) (__env)\\[1\\](.*)$";
3091    test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask);";
3092};
3093
3094/*
3095 *  Fix return type of fread and fwrite on sysV68
3096 */
3097fix = {
3098    hackname = read_ret_type;
3099    files    = stdio.h;
3100    select   = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
3101    c_fix     = format;
3102    c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
3103    c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
3104
3105    test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
3106};
3107
3108
3109/*
3110 *  Fix casts as lvalues in glibc's <rpc/xdr.h>.
3111 */
3112fix = {
3113    hackname  = rpc_xdr_lvalue_cast_a;
3114    files     = rpc/xdr.h;
3115    select    = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
3116    c_fix     = format;
3117    c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
3118    test_text = "#define IXDR_GET_LONG(buf) \\\\\n"
3119                "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
3120};
3121
3122
3123fix = {
3124    hackname  = rpc_xdr_lvalue_cast_b;
3125    files     = rpc/xdr.h;
3126    select    = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
3127    c_fix     = format;
3128    c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
3129    test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n"
3130                "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
3131};
3132
3133
3134/*
3135 *  function class(double x) conflicts with C++ keyword on rs/6000
3136 */
3137fix = {
3138    hackname  = rs6000_double;
3139    files     = math.h;
3140    select    = '[^a-zA-Z_]class\(';
3141
3142    c_fix     = format;
3143    c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
3144    c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
3145
3146    test_text = "extern int class();";
3147};
3148
3149
3150/*
3151 *  Wrong fchmod prototype on RS/6000.
3152 */
3153fix = {
3154    hackname  = rs6000_fchmod;
3155    files     = sys/stat.h;
3156    select    = 'fchmod\(char \*';
3157    c_fix     = format;
3158    c_fix_arg = "fchmod(int";
3159    test_text = "extern int fchmod(char *, mode_t);";
3160};
3161
3162
3163/*
3164 *  parameters conflict with C++ new on rs/6000
3165 */
3166fix = {
3167    hackname  = rs6000_param;
3168    files     = "stdio.h";
3169    files     = "unistd.h";
3170
3171    select    = 'rename\(const char \*old, const char \*new\)';
3172    c_fix     = format;
3173    c_fix_arg = 'rename(const char *_old, const char *_new)';
3174
3175    test_text = 'extern int rename(const char *old, const char *new);';
3176};
3177
3178
3179/*
3180 *  Solaris 10+ <sys/feature_tests.h> defines _RESTRICT_KYWD as restrict
3181 *  for C99.  This is wrong for C++, which needs many C99 features, but
3182 *  only supports __restrict.
3183 */
3184fix = {
3185    hackname  = solaris___restrict;
3186    files     = sys/feature_tests.h;
3187    select    = "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict";
3188    mach      = "*-*-solaris2*";
3189    c_fix     = format;
3190    c_fix_arg = "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n"
3191    	        "#else\n%0\n#endif";
3192    test_text = "#define	_RESTRICT_KYWD	restrict";
3193};
3194
3195
3196/*
3197 * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of
3198 * themselves, which are Sun Studio compiler intrinsics.  Remove _Imaginary_I
3199 * and imaginary definitions which are not supported by GCC.
3200 */
3201fix = {
3202    hackname  = solaris_complex;
3203    mach      = "*-*-solaris2.*";
3204    files     = complex.h;
3205    select    = "#define[ \t]_Complex_I[ \t]_Complex_I";
3206    sed	      = "s/#define[ \t]_Complex_I[ \t]_Complex_I/"
3207		"#define\t_Complex_I\t(__extension__ 1.0iF)/";
3208    sed	      = "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d";
3209    sed	      = "/#define[ \t]imaginary[ \t]_Imaginary/d";
3210    sed       = "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/";
3211    test_text = "#define	_Complex_I	_Complex_I\n"
3212    		"#define	complex		_Complex\n"
3213		"#define	_Imaginary_I	_Imaginary_I\n"
3214		"#define	imaginary	_Imaginary\n"
3215		"#undef	I\n"
3216		"#define	I		_Imaginary_I";
3217};
3218
3219
3220/*
3221 * Solaris 10+ <complex.h> is wrapped in #ifndef __cplusplus.  Wrap in
3222 * extern "C" instead so libstdc++ can use it.
3223 */
3224fix = {
3225    hackname  = solaris_complex_cxx;
3226    mach      = "*-*-solaris2.*";
3227    files     = complex.h;
3228    sed	      = "/#if[ \t]*!defined(__cplusplus)/c\\\n"
3229    		"#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
3230    sed	      = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n"
3231		"#ifdef\t__cplusplus\\\n}\\\n#endif";
3232    test_text = "#if !defined(__cplusplus)\n"
3233		"#endif	/* !defined(__cplusplus) */";
3234};
3235
3236
3237/*
3238 *  g++ rejects functions declared with both C and C++ linkage.
3239 */
3240fix = {
3241    hackname  = solaris_cxx_linkage;
3242    mach      = '*-*-solaris2*';
3243    files     = "iso/stdlib_iso.h";
3244    select    = "(#if __cplusplus >= 199711L)\n"
3245	        "(extern \"C\\+\\+\" \\{\n)"
3246	        "(.*(bsearch|qsort).*)";
3247    c_fix     = format;
3248    c_fix_arg = "%1 && !__GNUG__\n%2%3";
3249
3250    test_text =
3251    "#if __cplusplus >= 199711L\n"
3252    "extern \"C++\" {\n"
3253    "	void *bsearch(const void *, const void *, size_t, size_t,";
3254};
3255
3256
3257/*
3258 *  Solaris <iso/stdio_iso.h> doesn't declare getc for C++ with
3259 *  _STRICT_STDC, but uses it.
3260 */
3261fix = {
3262    hackname  = solaris_getc_strict_stdc;
3263    mach      = "*-*-solaris2*";
3264    files     = "iso/stdio_iso.h";
3265    select    = "(.*&& )!defined\\(_STRICT_STDC\\)(.*)";
3266    c_fix     = format;
3267    c_fix_arg = "%1(!defined(_STRICT_STDC) || (__cplusplus >= 199711L))%2";
3268
3269    test_text =
3270    "#if	!defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)";
3271};
3272
3273
3274/*
3275 *  Before Solaris 10, <iso/setjmp_iso.h> doesn't mark longjump noreturn.
3276 */
3277fix = {
3278    hackname  = solaris_longjmp_noreturn;
3279    mach      = "*-*-solaris2*";
3280    files     = "iso/setjmp_iso.h";
3281    bypass    = "__NORETURN";
3282    select    = "(.*longjmp\\(jmp_buf.*[^)]+\\));";
3283    c_fix     = format;
3284    c_fix_arg = "%1 __attribute__ ((__noreturn__));";
3285
3286    test_text = "extern void longjmp(jmp_buf, int);";
3287};
3288
3289
3290/*
3291 * Sun Solaris 10 defines several C99 math macros in terms of
3292 * builtins specific to the Studio compiler, in particular not
3293 * compatible with the GNU compiler.
3294 */
3295fix = {
3296    hackname = solaris_math_1;
3297    select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3298    bypass = "__GNUC__";
3299    files = iso/math_c99.h;
3300    c_fix = format;
3301    c_fix_arg = "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
3302    c_fix_arg = "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
3303    test_text =
3304    '#ident	"@(#)math_c99.h	1.9	04/11/01 SMI"'"\n"
3305    "#undef	HUGE_VAL\n"
3306    "#define	HUGE_VAL	__builtin_huge_val\n"
3307    "#undef	HUGE_VALF\n"
3308    "#define	HUGE_VALF	__builtin_huge_valf\n"
3309    "#undef	HUGE_VALL\n"
3310    "#define	HUGE_VALL	__builtin_huge_vall";
3311};
3312
3313fix = {
3314    hackname = solaris_math_2;
3315    select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3316    bypass = "__GNUC__";
3317    files = iso/math_c99.h;
3318    c_fix = format;
3319    c_fix_arg = "#define\tINFINITY\t(__builtin_inff())";
3320    c_fix_arg = "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
3321    test_text =
3322    '#ident	"@(#)math_c99.h	1.9	04/11/01 SMI"'"\n"
3323    "#undef	INFINITY\n"
3324    "#define	INFINITY	__builtin_infinity";
3325};
3326
3327fix = {
3328    hackname = solaris_math_3;
3329    select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3330    bypass = "__GNUC__";
3331    files = iso/math_c99.h;
3332    c_fix = format;
3333    c_fix_arg = "#define\tNAN\t\t(__builtin_nanf(\"\"))";
3334    c_fix_arg = "^#define[ \t]+NAN[ \t]+__builtin_nan";
3335    test_text =
3336    '#ident	"@(#)math_c99.h	1.9	04/11/01 SMI"'"\n"
3337    "#undef	NAN\n"
3338    "#define	NAN	__builtin_nan";
3339};
3340
3341fix = {
3342    hackname = solaris_math_4;
3343    select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3344    bypass = "__GNUC__";
3345    files = iso/math_c99.h;
3346    c_fix = format;
3347    c_fix_arg = "#define\tfpclassify(x) \\\n"
3348                "  __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, (x))";
3349    c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
3350    test_text =
3351    '#ident	"@(#)math_c99.h	1.9	04/11/01 SMI"'"\n"
3352    "#undef	fpclassify\n"
3353    "#define	fpclassify(x)	__builtin_fpclassify(x)";
3354};
3355
3356fix = {
3357    hackname = solaris_math_8;
3358    select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI";
3359    bypass = "__GNUC__";
3360    files = iso/math_c99.h;
3361    c_fix = format;
3362    c_fix_arg = "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
3363                "\t\t\t   ? __builtin_signbitf(x) \\\n"
3364                "\t\t\t   : sizeof(x) == sizeof(long double) \\\n"
3365                "\t\t\t     ? __builtin_signbitl(x) \\\n"
3366                "\t\t\t     : __builtin_signbit(x))";
3367    c_fix_arg = "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
3368    test_text = <<- _EOText_
3369	#ident	"@(#)math_c99.h	1.9	04/11/01 SMI"
3370	#undef	signbit
3371	#define	signbit(x)	__builtin_signbit(x)
3372	_EOText_;
3373};
3374
3375fix = {
3376    hackname = solaris_math_9;
3377    select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3378    bypass = "__GNUC__";
3379    files = iso/math_c99.h;
3380    c_fix = format;
3381    c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)";
3382    c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) __builtin_[a-z]+\\(y\\)\\)";
3383    test_text =
3384    '#ident	"@(#)math_c99.h	1.9	04/11/01 SMI"'"\n"
3385    "#undef	isgreater\n"
3386    "#define	isgreater(x, y)		((x) __builtin_isgreater(y))\n"
3387    "#undef	isgreaterequal\n"
3388    "#define	isgreaterequal(x, y)	((x) __builtin_isgreaterequal(y))\n"
3389    "#undef	isless\n"
3390    "#define	isless(x, y)		((x) __builtin_isless(y))\n"
3391    "#undef	islessequal\n"
3392    "#define	islessequal(x, y)	((x) __builtin_islessequal(y))\n"
3393    "#undef	islessgreater\n"
3394    "#define	islessgreater(x, y)	((x) __builtin_islessgreater(y))\n"
3395    "#undef	isunordered\n"
3396    "#define	isunordered(x, y)	((x) __builtin_isunordered(y))";
3397};
3398
3399/*
3400 * On Solaris 11, if you do isinf(NaN) you'll get a floating point
3401 * exception.  Provide an alternative using GCC's builtin.
3402 */
3403
3404fix = {
3405    hackname  = solaris_math_10;
3406    select    = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3407    files     = iso/math_c99.h;
3408    c_fix     = format;
3409    c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)";
3410    c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
3411                "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);[ \t]*\\\\\n"
3412                "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
3413                "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*\\(-INFINITY\\);[ \t]*\\}\\)";
3414    test_text =
3415    '#pragma ident	"@(#)math_c99.h	1.12	07/01/21 SMI"'"\n"
3416    "#undef	isinf\n"
3417    "#define	isinf(x)	__extension__( \\\\\n"
3418    "			{ __typeof(x) __x_i = (x); \\\\\n"
3419    "			__x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
3420    "			__x_i == (__typeof(__x_i)) (-INFINITY); })";
3421};
3422
3423/*
3424 * Sun Solaris defines PTHREAD_MUTEX_INITIALIZER with a trailing
3425 * "0" for the last field of the pthread_mutex_t structure, which is
3426 * of type upad64_t, which itself is typedef'd to int64_t, but with
3427 * __STDC__ defined (e.g. by -ansi) it is a union. So change the
3428 * initializer to "{0}" instead
3429 */
3430fix = {
3431    hackname = solaris_mutex_init_2;
3432    select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3433    files = pthread.h;
3434    /*
3435     * On Solaris 10, this fix is unnecessary because upad64_t is
3436     * always defined correctly regardless of the definition of the
3437     * __STDC__ macro.  The first "mach" pattern matches up to
3438     * solaris9.  The second "mach" pattern will not match any two (or
3439     * more) digit solaris version, but it will match e.g. 2.5.1.
3440     */
3441    mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*';
3442    c_fix = format;
3443    c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3444                "%0\n"
3445                "#else\n"
3446                "%1, {0}}%4\n"
3447                "#endif";
3448    c_fix_arg = "(^#define[ \t]+PTHREAD_(MUTEX|COND)_INITIALIZER[ \t]+"
3449                "(|/\*.*\*/[ \t]*\\\\\n[ \t]*)\\{.*)"
3450                ",[ \t]*0\\}" "(|[ \t].*)$";
3451    test_text =
3452    '#ident "@(#)pthread.h  1.26  98/04/12 SMI"'"\n"
3453    "#define PTHREAD_MUTEX_INITIALIZER\t{{{0},0}, {{{0}}}, 0}\n"
3454    "#define PTHREAD_COND_INITIALIZER\t{{{0}, 0}, 0}\t/* DEFAULTCV */\n"
3455    "#define	PTHREAD_MUTEX_INITIALIZER		/* = DEFAULTMUTEX */	\\\\\n"
3456    "	{{0, 0, 0, DEFAULT_TYPE, _MUTEX_MAGIC}, {{{0}}}, 0}\n"
3457    "#define	PTHREAD_COND_INITIALIZER		/* = DEFAULTCV */	\\\\\n"
3458    "	{{{0, 0, 0, 0}, DEFAULT_TYPE, _COND_MAGIC}, 0}";
3459};
3460
3461
3462/*
3463 *  The pow overloads with int were removed in C++ 2011 DR 550.
3464 */
3465fix = {
3466    hackname  = solaris_pow_int_overload;
3467    mach      = '*-*-solaris2*';
3468    files     = "iso/math_iso.h";
3469    select    = "^[ \t]*inline [a-z ]* pow\\([^()]*, int [^()]*\\)"
3470		" *\\{[^{}]*\n[^{}]*\\}";
3471    c_fix     = format;
3472    c_fix_arg = "#if __cplusplus < 201103L\n%0\n#endif";
3473
3474    test_text =
3475    "	inline long double pow(long double __X, int __Y) { return\n"
3476    "		__powl(__X, (long double) (__Y)); }";
3477};
3478
3479
3480/*
3481 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
3482 *  fields of the pthread_rwlock_t structure, which are of type
3483 *  upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3484 *  defined (e.g. by -ansi) it is a union. So change the initializer
3485 *  to "{0}" instead.
3486 */
3487fix = {
3488    hackname = solaris_rwlock_init_1;
3489    select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3490    files = pthread.h;
3491    mach = '*-*-solaris*';
3492    c_fix = format;
3493    c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3494                "%0\n"
3495                "#else\n"
3496                "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
3497                "#endif";
3498    c_fix_arg = "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
3499                "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
3500
3501    test_text =
3502    '#ident "@(#)pthread.h  1.26  98/04/12 SMI"'"\n"
3503    "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
3504};
3505
3506
3507/*
3508 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
3509 * structure.  As such, it need two levels of brackets, but only
3510 * contains one.  Wrap the macro definition in an extra layer.
3511 */
3512fix = {
3513    hackname = solaris_once_init_1;
3514    select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3515    files = pthread.h;
3516    mach = '*-*-solaris*';
3517    c_fix = format;
3518    c_fix_arg = "%1{%2}%3";
3519    c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
3520    test_text =
3521    '#pragma ident	"@(#)pthread.h	1.37	04/09/28 SMI"'"\n"
3522    "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
3523};
3524
3525
3526/*
3527 * Sun Solaris defines PTHREAD_ONCE_INIT with a "0" for some
3528 *  fields of the pthread_once_t structure, which are of type
3529 *  upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3530 *  defined (e.g. by -ansi) it is a union. So change the initializer
3531 *  to "{0}" instead.  This test relies on solaris_once_init_1.
3532 */
3533fix = {
3534    hackname = solaris_once_init_2;
3535    select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3536    files = pthread.h;
3537    /*
3538     * On Solaris 10, this fix is unnecessary because upad64_t is
3539     * always defined correctly regardless of the definition of the
3540     * __STDC__ macro.  The first "mach" pattern matches up to
3541     * solaris9.  The second "mach" pattern will not match any two (or
3542     * more) digit solaris version, but it will match e.g. 2.5.1.
3543     */
3544    mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*';
3545    c_fix = format;
3546    c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3547                "%0\n"
3548                "#else\n"
3549                "%1{0}, {0}, {0}, {%3}%4\n"
3550                "#endif";
3551    c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{\\{)"
3552                "(0, 0, 0, )(PTHREAD_[A-Z_]+)(\\}\\})[ \t]*$";
3553    test_text =
3554    '#ident "@(#)pthread.h  1.26  98/04/12 SMI"'"\n"
3555    "#define PTHREAD_ONCE_INIT\t{{0, 0, 0, PTHREAD_ONCE_NOTDONE}}\n";
3556};
3557
3558
3559/*
3560 * Sun Solaris 2 has a version of sys/int_const.h that defines
3561 * UINT8_C and UINT16_C to unsigned constants.
3562 */
3563fix = {
3564    hackname  = solaris_int_const;
3565    files     = sys/int_const.h;
3566    mach      = '*-*-solaris2*';
3567    c_fix     = format;
3568    c_fix_arg = "#define\tUINT8_C(c)\t(c)\n"
3569                "%1\n"
3570                "#define\tUINT16_C(c)\t(c)";
3571    select    = "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n"
3572                "(/\*.*\*/)\n"
3573                "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*";
3574    test_text =
3575    "#define	UINT8_C(c)	__CONCAT__(c,u)\n"
3576    "/* CSTYLED */\n"
3577    "#define	UINT16_C(c)	__CONCAT__(c,u)";
3578};
3579
3580
3581/*
3582 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3583 * UINT8_MAX and UINT16_MAX to unsigned constants.
3584 */
3585fix = {
3586    hackname  = solaris_int_limits_1;
3587    files     = sys/int_limits.h;
3588    mach      = '*-*-solaris2*';
3589    c_fix     = format;
3590    c_fix_arg = "#define\tUINT8_MAX\t(255)\n"
3591                "#define\tUINT16_MAX\t(65535)";
3592    select    = "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n"
3593                "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
3594    test_text =
3595    "#define	UINT8_MAX	(255U)\n"
3596    "#define	UINT16_MAX	(65535U)";
3597};
3598
3599
3600/*
3601 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3602 * INT_FAST16 limits to wrong values for sys/int_types.h.
3603 */
3604fix = {
3605    hackname  = solaris_int_limits_2;
3606    files     = sys/int_limits.h;
3607    mach      = '*-*-solaris2*';
3608    c_fix     = format;
3609    c_fix_arg = "#define\t%1_FAST16_%2 %132_%2";
3610    select    = "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
3611    test_text =
3612    "#define	INT_FAST16_MAX INT16_MAX\n"
3613    "#define	UINT_FAST16_MAX UINT16_MAX\n"
3614    "#define	INT_FAST16_MIN	INT16_MIN";
3615};
3616
3617
3618/*
3619 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3620 * SIZE_MAX as unsigned long.
3621 */
3622fix = {
3623    hackname  = solaris_int_limits_3;
3624    files     = sys/int_limits.h;
3625    mach      = '*-*-solaris2*';
3626    c_fix     = format;
3627    c_fix_arg = "#define\tSIZE_MAX\t4294967295U";
3628    select    = "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL";
3629    test_text =
3630    "#define	SIZE_MAX	4294967295UL";
3631};
3632
3633
3634/*
3635 * Sun Solaris up to 9 has a version of sys/int_types.h that forbids use
3636 * of Standard C99 64-bit types in 32-bit mode.
3637 */
3638fix = {
3639    hackname  = solaris_int_types;
3640    select    = "__STDC__ - 0 == 0";
3641    bypass    = "_LONGLONG_TYPE";
3642    files     = sys/int_types.h;
3643    c_fix     = format;
3644    c_fix_arg =
3645    "(defined(_STDC_C99) || !defined(_STRICT_STDC) || defined(__GNUC__))";
3646    test_text =
3647    "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3648    "typedef	long long		int64_t;\n"
3649    "#endif\n\n"
3650    "#if defined(_LP64) || (__STDC__ - 0 == 0 && !defined(_NO_LONGLONG))\n"
3651    "typedef int64_t			intmax_t;\n"
3652    "#endif";
3653};
3654
3655
3656/*
3657 * Solaris 10+ <spawn.h> uses char *const argv[_RESTRICT_KYWD] in the
3658 * posix_spawn declarations, which doesn't work with C++.
3659 */
3660fix = {
3661    hackname  = solaris_posix_spawn_restrict;
3662    files     = spawn.h;
3663    mach      = '*-*-solaris2*';
3664    c_fix     = format;
3665    c_fix_arg = "%1*_RESTRICT_KYWD %2%3";
3666    select    = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)";
3667    test_text =
3668    "char *const argv[_RESTRICT_KYWD],\n"
3669    "char *const envp[_RESTRICT_KYWD]);";
3670};
3671
3672
3673/*
3674 * Before Solaris 10, <stdio.h> lacks declarations of std::__filbuf and
3675 * std::__flsbuf, but <iso/stdio_iso.h> uses them.
3676 */
3677fix = {
3678    hackname  = solaris_std___filbuf;
3679    files     = stdio.h;
3680    mach      = '*-*-solaris2*';
3681    bypass    = "using std::__filbuf";
3682    select    = "(using std::perror;\n)(#endif)";
3683    c_fix     = format;
3684    c_fix_arg = "%1#ifndef _LP64\n"
3685		"using std::__filbuf;\n"
3686		"using std::__flsbuf;\n"
3687		"#endif\n%2";
3688
3689    test_text = "using std::perror;\n"
3690		"#endif";
3691};
3692
3693
3694/*
3695 * Sun Solaris 8 has what appears to be some gross workaround for
3696 * some old version of their c++ compiler.  G++ doesn't want it
3697 * either, but doesn't want to be tied to SunPRO version numbers.
3698 */
3699fix = {
3700    hackname = solaris_stdio_tag;
3701    files    = stdio_tag.h;
3702
3703    select   = '__cplusplus < 54321L';
3704    /* In Solaris 10, the code in stdio_tag.h is conditionalized on
3705       "!defined(__GNUC__)" so we no longer need to fix it.  */
3706    bypass   = '__GNUC__';
3707    sed      = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
3708
3709    test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
3710};
3711
3712
3713/*
3714 * On Solaris 9, __va_list needs to become a typedef for
3715 * __builtin_va_list to make -Wmissing-format-attribute work.
3716 */
3717fix = {
3718    hackname = solaris_sys_va_list;
3719    files    = sys/va_list.h;
3720    mach     = '*-*-solaris2.9';
3721    select   = "#if.*__STDC__.*\n"
3722	       "typedef void \\*__va_list;\n"
3723	       "#else\n"
3724	       "typedef char \\*__va_list;\n"
3725	       "#endif";
3726
3727    c_fix    = format;
3728    c_fix_arg = "#ifdef __GNUC__\n"
3729		"typedef __builtin_va_list __va_list;\n"
3730		"#else\n"
3731		"%0\n"
3732		"#endif";
3733    test_text = "#if defined(__STDC__) && !defined(__ia64)\n"
3734    		"typedef void *__va_list;\n"
3735	        "#else\n"
3736	        "typedef char *__va_list;\n"
3737	        "#endif";
3738};
3739
3740
3741/*
3742 *  a missing semi-colon at the end of the statsswtch structure definition.
3743 */
3744fix = {
3745    hackname  = statsswtch;
3746    files     = rpcsvc/rstat.h;
3747    select    = "boottime$";
3748    c_fix     = format;
3749    c_fix_arg = "boottime;";
3750    test_text = "struct statswtch {\n  int boottime\n};";
3751};
3752
3753
3754/*
3755 *  Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
3756 *  On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
3757 *  OK too.
3758 */
3759fix = {
3760    hackname = stdio_stdarg_h;
3761    files    = stdio.h;
3762    bypass   = "include.*(stdarg\.h|machine/ansi\.h)";
3763    /*
3764     * On Solaris 10, this fix is unncessary; <stdio.h> includes
3765     * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
3766      */
3767    mach     = '*-*-solaris2.1[0-9]*';
3768    not_machine = true;
3769
3770    c_fix     = wrap;
3771
3772    c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
3773
3774    test_text = "";
3775};
3776
3777
3778/*
3779 *  Don't use or define the name va_list in stdio.h.  This is for
3780 *  ANSI.  Note _BSD_VA_LIST_ is dealt with elsewhere.  The presence
3781 *  of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to
3782 *  indicate that the header knows what it's doing -- under SUSv2,
3783 *  stdio.h is required to define va_list, and we shouldn't break
3784 *  that.
3785 */
3786fix = {
3787    hackname = stdio_va_list;
3788    files    = stdio.h;
3789    bypass   = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3790    /*
3791     * On Solaris 10, the definition in
3792     * <stdio.h> is guarded appropriately by the _XPG4 feature macro;
3793     * there is therefore no need for this fix there.
3794     */
3795    mach = '*-*-solaris2.1[0-9]*';
3796    not_machine = true;
3797
3798    /*
3799     * Use __gnuc_va_list in arg types in place of va_list.
3800     * On 386BSD use __gnuc_va_list instead of _VA_LIST_.  On Tru64 UNIX V5.1A
3801     * use __gnuc_va_list instead of __VA_LIST__.  We're hoping the
3802     * trailing parentheses and semicolon save all other systems from this.
3803     * Define __not_va_list__ (something harmless and unused)
3804     * instead of va_list.
3805     * Don't claim to have defined va_list.
3806     */
3807    sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3808	  "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3809          "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3810          "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3811          "s@ va_list@ __not_va_list__@\n"
3812          "s@\\*va_list@*__not_va_list__@\n"
3813          "s@ __va_list)@ __gnuc_va_list)@\n"
3814          "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3815           "@typedef \\1 __not_va_list__;@\n"
3816	  "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3817          "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3818          "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3819          "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3820          "s@VA_LIST@DUMMY_VA_LIST@\n"
3821          "s@_Va_LIST@_VA_LIST@";
3822    test_text = "extern void mumble( va_list);";
3823};
3824
3825
3826/*
3827 *  Fix headers that use va_list from stdio.h to use the updated
3828 *  va_list from the stdio_va_list change.  Note _BSD_VA_LIST_ is
3829 *  dealt with elsewhere.  The presence of __gnuc_va_list,
3830 *  __DJ_va_list, or _G_va_list is taken to indicate that the header
3831 *  knows what it's doing.
3832 */
3833fix = {
3834    hackname = stdio_va_list_clients;
3835    files    = com_err.h;
3836    files    = cps.h;
3837    files    = curses.h;
3838    files    = krb5.h;
3839    files    = lc_core.h;
3840    files    = pfmt.h;
3841    files    = wchar.h;
3842    files    = curses_colr/curses.h;
3843    bypass   = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3844    /* Don't fix, if we use va_list from stdarg.h, or if the use is
3845       otherwise protected.  */
3846    bypass   = 'include <stdarg\.h>|#ifdef va_start';
3847
3848    /*
3849     * Use __gnuc_va_list in arg types in place of va_list.
3850     * On 386BSD use __gnuc_va_list instead of _VA_LIST_.  On Tru64 UNIX V5.1A
3851     * use __gnuc_va_list instead of __VA_LIST__.  We're hoping the
3852     * trailing parentheses and semicolon save all other systems from this.
3853     * Define __not_va_list__ (something harmless and unused)
3854     * instead of va_list.
3855     * Don't claim to have defined va_list.
3856     */
3857    sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
3858	  "s@(va_list)&@(__gnuc_va_list)\\&@\n"
3859          "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
3860          "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
3861          "s@ va_list@ __not_va_list__@\n"
3862          "s@\\*va_list@*__not_va_list__@\n"
3863          "s@ __va_list)@ __gnuc_va_list)@\n"
3864          "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
3865           "@typedef \\1 __not_va_list__;@\n"
3866	  "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
3867          "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
3868          "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
3869          "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
3870          "s@VA_LIST@DUMMY_VA_LIST@\n"
3871          "s@_Va_LIST@_VA_LIST@";
3872    test_text = "extern void mumble( va_list);";
3873};
3874
3875
3876/*
3877 *  "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
3878 *  is "!defined( __STRICT_ANSI__ )"
3879 */
3880fix = {
3881    hackname = strict_ansi_not;
3882    select   = "^([ \t]*#[ \t]*if.*)"
3883               "(!__STDC__"
3884               "|__STDC__[ \t]*==[ \t]*0"
3885               "|__STDC__[ \t]*!=[ \t]*1"
3886               "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
3887    /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
3888    bypass = 'GNU and MIPS C compilers define __STDC__ differently';
3889    /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which
3890       is not defined by GCC, so it is safe.  */
3891    bypass = '__SCO_VERSION__.*__STDC__ != 1';
3892    c_test   = stdc_0_in_system_headers;
3893
3894    c_fix     = format;
3895    c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3896
3897    test_text = "#if !__STDC__ \n"
3898                "#if __STDC__ == 0\n"
3899                "#if __STDC__ != 1\n"
3900                "#if __STDC__ - 0 == 0"
3901               "/* not std C */\nint foo;\n"
3902               "\n#end-end-end-end-if :-)";
3903};
3904
3905/*
3906 *  "__STDC__-0==0"
3907 *  is "!defined( __STRICT_ANSI__ )" on continued #if-s
3908 */
3909fix = {
3910    hackname = strict_ansi_not_ctd;
3911    files    = math.h, limits.h, stdio.h, signal.h,
3912               stdlib.h, sys/signal.h, time.h;
3913    /*
3914     * Starting at the beginning of a line, skip white space and
3915     * a leading "(" or "&&" or "||".  One of those must be found.
3916     * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
3917     * expression.  If these are nested, then they must accumulate
3918     * because we won't match any closing parentheses.  Finally,
3919     * after skipping over all that, we must then match our suspect
3920     * phrase:  "__STDC__-0==0" with or without white space.
3921     */
3922    select   = "^([ \t]*" '(\(|&&|\|\|)'
3923               "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
3924               "[ \t(]*)"
3925               "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
3926    c_test   = stdc_0_in_system_headers;
3927
3928    c_fix     = format;
3929    c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
3930
3931    test_text = "#if 1 && \\\\\n"
3932               "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
3933               "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
3934               "|| __STDC__ - 0 == 0 ) /* not std C */\n"
3935               "int foo;\n#endif";
3936};
3937
3938
3939/*
3940 *  "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
3941 *  is "defined( __STRICT_ANSI__ )"
3942 */
3943fix = {
3944    hackname = strict_ansi_only;
3945    select   = "^([ \t]*#[ \t]*if.*)"
3946               "(__STDC__[ \t]*!=[ \t]*0"
3947               "|__STDC__[ \t]*==[ \t]*1"
3948               "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
3949               "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
3950    c_test   = stdc_0_in_system_headers;
3951
3952    c_fix     = format;
3953    c_fix_arg = "%1 defined(__STRICT_ANSI__)";
3954
3955    test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
3956};
3957
3958
3959/*
3960 *  IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
3961 *  in prototype without previous definition.
3962 */
3963fix = {
3964    hackname  = struct_file;
3965    files     = rpc/xdr.h;
3966    select    = '^.*xdrstdio_create.*struct __file_s';
3967    c_fix     = format;
3968    c_fix_arg = "struct __file_s;\n%0";
3969    test_text = "extern void xdrstdio_create( struct __file_s* );";
3970};
3971
3972
3973/*
3974 *  IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
3975 *  in prototype without previous definition.
3976 *
3977 *  Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same
3978 *  function, and does define it.
3979 */
3980fix = {
3981    hackname  = struct_sockaddr;
3982    files     = rpc/auth.h;
3983    select    = "^.*authdes_create.*struct sockaddr[^_]";
3984    bypass    = "<sys/socket\.h>";
3985    bypass    = "struct sockaddr;\n";
3986    c_fix     = format;
3987    c_fix_arg = "struct sockaddr;\n%0";
3988    test_text = "extern AUTH* authdes_create( struct sockaddr* );";
3989};
3990
3991
3992/*
3993 *  Apply fix this to all OSs since this problem seems to effect
3994 *  more than just SunOS.
3995 */
3996fix = {
3997    hackname = sun_auth_proto;
3998    files    = rpc/auth.h;
3999    files    = rpc/clnt.h;
4000    files    = rpc/svc.h;
4001    files    = rpc/xdr.h;
4002    bypass   = "__cplusplus";
4003    /*
4004     *  Select those files containing '(*name)()'.
4005     */
4006    select    = '\(\*[a-z][a-z_]*\)\(\)';
4007
4008    c_fix     = format;
4009    c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
4010                "#else\n%1();%2\n#endif";
4011    c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
4012
4013    test_text =
4014    "struct auth_t {\n"
4015    "    int (*name)(); /* C++ bad */\n"
4016    "};";
4017};
4018
4019
4020/*
4021 *  Fix bogus #ifdef on SunOS 4.1.
4022 */
4023fix = {
4024    hackname  = sun_bogus_ifdef;
4025    files     = "hsfs/hsfs_spec.h";
4026    files     = "hsfs/iso_spec.h";
4027    select    = '#ifdef(.*\|\|.*)';
4028    c_fix     = format;
4029    c_fix_arg = "#if%1";
4030
4031    test_text = "#ifdef  __i386__ || __vax__ || __sun4c__";
4032};
4033
4034
4035/*
4036 *  Fix the CAT macro in SunOS memvar.h.
4037 */
4038fix = {
4039    hackname  = sun_catmacro;
4040    files     = pixrect/memvar.h;
4041    select    = "^#define[ \t]+CAT\\(a,b\\).*";
4042    c_fix     = format;
4043
4044    c_fix_arg =
4045    "#ifdef __STDC__\n"
4046    "#  define CAT(a,b) a##b\n"
4047    "#else\n%0\n#endif";
4048
4049    test_text =
4050    "#define CAT(a,b)\ta/**/b";
4051};
4052
4053
4054/*
4055 *  Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
4056 *  Also fix return type of {m,re}alloc in <malloc.h> on sysV68
4057 */
4058fix = {
4059    hackname = sun_malloc;
4060    files    = malloc.h;
4061    bypass   = "_CLASSIC_ANSI_TYPES";
4062
4063    sed   = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
4064    sed   = "s/int[ \t][ \t]*free/void\tfree/g";
4065    sed   = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
4066    sed   = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
4067    sed   = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
4068
4069    test_text =
4070    "typedef char *\tmalloc_t;\n"
4071    "int \tfree();\n"
4072    "char*\tmalloc();\n"
4073    "char*\tcalloc();\n"
4074    "char*\trealloc();";
4075};
4076
4077
4078/*
4079 *  Check for yet more missing ';' in struct (in SunOS 4.0.x)
4080 */
4081fix = {
4082    hackname = sun_rusers_semi;
4083    files    = rpcsvc/rusers.h;
4084    select   = "_cnt$";
4085    sed      = "/^struct/,/^};/s/_cnt$/_cnt;/";
4086    test_text = "struct mumble\n  int _cnt\n};";
4087};
4088
4089
4090/*
4091 *  signal.h on SunOS defines signal using (),
4092 *  which causes trouble when compiling with g++ -pedantic.
4093 */
4094fix = {
4095    hackname = sun_signal;
4096    files    = sys/signal.h;
4097    files    = signal.h;
4098    select   = "^void\t" '\(\*signal\(\)\)\(\);.*';
4099
4100    c_fix     = format;
4101    c_fix_arg =
4102          "#ifdef __cplusplus\n"
4103          "void\t(*signal(...))(...);\n"
4104          "#else\n%0\n#endif";
4105
4106    test_text = "void\t(*signal())();";
4107};
4108
4109
4110/*
4111 *  Correct the return type for strlen in strings.h in SunOS 4.
4112 */
4113fix = {
4114    hackname = sunos_strlen;
4115    files    = strings.h;
4116    select   = "int[ \t]*strlen\\(\\);(.*)";
4117    c_fix     = format;
4118    c_fix_arg = "__SIZE_TYPE__ strlen();%1";
4119    test_text = " int\tstrlen(); /* string length */";
4120};
4121
4122
4123/*
4124 *  Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
4125 *  that is visible to any ANSI compiler using this include.  Simply
4126 *  delete the lines that #define some string functions to internal forms.
4127 */
4128fix = {
4129    hackname = svr4_disable_opt;
4130    files    = string.h;
4131    select   = '#define.*__std_hdr_';
4132    sed      = '/#define.*__std_hdr_/d';
4133    test_text = "#define strlen __std_hdr_strlen\n";
4134};
4135
4136
4137/*
4138 *   Fix broken decl of getcwd present on some svr4 systems.
4139 */
4140fix = {
4141    hackname = svr4_getcwd;
4142    files    = stdlib.h;
4143    files    = unistd.h;
4144    files    = prototypes.h;
4145    select   = 'getcwd\(char \*, int\)';
4146
4147    c_fix     = format;
4148    c_fix_arg = "getcwd(char *, size_t)";
4149
4150    test_text = "extern char* getcwd(char *, int);";
4151};
4152
4153
4154/*
4155 *   Fix broken decl of profil present on some svr4 systems.
4156 */
4157fix = {
4158    hackname = svr4_profil;
4159    files    = stdlib.h;
4160    files    = unistd.h;
4161
4162    select    =
4163    'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
4164    c_fix     = format;
4165    c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
4166
4167    test_text =
4168    'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
4169};
4170
4171
4172/*
4173 * Correct types for signal handler constants like SIG_DFL; they might be
4174 * void (*) (), and should be void (*) (int).  C++ doesn't like the
4175 * old style.
4176 */
4177fix = {
4178    hackname = svr4_sighandler_type;
4179    files = sys/signal.h;
4180    select = 'void *\(\*\)\(\)';
4181    c_fix = format;
4182    c_fix_arg = "void (*)(int)";
4183    test_text = "#define SIG_DFL (void(*)())0\n"
4184                "#define SIG_IGN (void (*)())0\n";
4185};
4186
4187
4188/*
4189 *  Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local
4190 *  function 'getrnge' in <regexp.h> before they declare it.  For these
4191 *  systems add a 'static int' declaration of 'getrnge' into <regexp.h>
4192 *  early on.
4193 *
4194 *  'getrnge' traditionally manipulates a file-scope global called 'size',
4195 *  so put the declaration right after the declaration of 'size'.
4196 *
4197 *  Don't do this if there is already a `static void getrnge' declaration
4198 *  present, since this would cause a redeclaration error.  Solaris 2.x has
4199 *  such a declaration.
4200 */
4201fix = {
4202    hackname  = svr4_undeclared_getrnge;
4203    files     = regexp.h;
4204    select    = "getrnge";
4205    bypass    = "static void getrnge";
4206    c_fix     = format;
4207    c_fix_arg = "%0\n"
4208                "static int getrnge ();";
4209    c_fix_arg = "^static int[ \t]+size;";
4210    test_text = "static int size;\n"
4211                "/* stuff which calls getrnge() */\n"
4212                "static getrnge()\n"
4213                "{}";
4214};
4215
4216
4217/*
4218 *  Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
4219 *  in string.h on sysV68
4220 *  Correct the return type for strlen in string.h on Lynx.
4221 *  Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
4222 *  Add missing const for strdup on OSF/1 V3.0.
4223 *  On sysV88 layout is slightly different.
4224 */
4225fix = {
4226    hackname = sysv68_string;
4227    files    = testing.h;
4228    files    = string.h;
4229    bypass   = "_CLASSIC_ANSI_TYPES";
4230
4231    sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
4232    sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
4233    sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
4234
4235    sed = "/^extern char$/N";
4236    sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
4237
4238    sed = "/^extern int$/N";
4239    sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
4240
4241    sed = "/^\tstrncmp(),$/N";
4242    sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
4243            '\1;' "\\\nextern unsigned int\\\n\\2/";
4244
4245    test_text =
4246    "extern int strlen();\n"
4247
4248    "extern int ffs(long);\n"
4249
4250    "extern char\n"
4251    "\t*memccpy(),\n"
4252    "\tmemcpy();\n"
4253
4254    "extern int\n"
4255    "\tstrcmp(),\n"
4256    "\tstrncmp(),\n"
4257    "\tstrlen(),\n"
4258    "\tstrspn();\n"
4259
4260    "extern int\n"
4261    "\tstrlen(), strspn();";
4262};
4263
4264
4265/*
4266 *  Fix return type of calloc, malloc, realloc, bsearch and exit
4267 */
4268fix = {
4269    hackname = sysz_stdlib_for_sun;
4270    files    = stdlib.h;
4271    bypass   = "_CLASSIC_ANSI_TYPES";
4272
4273    select    = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
4274    c_fix     = format;
4275    c_fix_arg = "void *\t%1(";
4276
4277    test_text =
4278    "extern char*\tcalloc(size_t);\n"
4279    "extern char*\tmalloc(size_t);\n"
4280    "extern char*\trealloc(void*,size_t);\n"
4281    "extern char*\tbsearch(void*,size_t,size_t);\n";
4282};
4283
4284
4285/*
4286 * __thread is now a keyword.
4287 */
4288fix = {
4289    hackname  = thread_keyword;
4290    files     = "pthread.h";
4291    files     = "bits/sigthread.h";
4292    select    = "([* ])__thread([,)])";
4293    c_fix     = format;
4294    c_fix_arg = "%1__thr%2";
4295
4296    test_text =
4297	"extern int pthread_create (pthread_t *__restrict __thread,\n"
4298	"extern int pthread_kill (pthread_t __thread, int __signo);\n"
4299	"extern int pthread_cancel (pthread_t __thread);";
4300};
4301
4302/*
4303 *  if the #if says _cplusplus, not the double underscore __cplusplus
4304 *  that it should be
4305 */
4306fix = {
4307    hackname = tinfo_cplusplus;
4308    files    = tinfo.h;
4309    select   = "[ \t]_cplusplus";
4310
4311    c_fix     = format;
4312    c_fix_arg = " __cplusplus";
4313    test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
4314};
4315
4316
4317/*
4318 *  parameters not const on DECstation Ultrix V4.0 and OSF/1.
4319 */
4320fix = {
4321    hackname  = ultrix_const;
4322    files     = stdio.h;
4323    select    = 'perror\( char \*';
4324
4325    c_fix     = format;
4326    c_fix_arg = "%1 const %3 *__";
4327    c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
4328                "[ \t]+(char|void) \\*__";
4329
4330    test_text =
4331    "extern void perror( char *__s );\n"
4332    "extern int fputs( char *__s, FILE *);\n"
4333    "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
4334    "extern int fscanf( FILE *__stream, char *__format, ...);\n"
4335    "extern int scanf( char *__format, ...);\n";
4336};
4337
4338
4339/*
4340 *  parameters not const on DECstation Ultrix V4.0 and OSF/1.
4341 */
4342fix = {
4343    hackname  = ultrix_const2;
4344    files     = stdio.h;
4345
4346    select    = '\*fopen\( char \*';
4347    c_fix     = format;
4348    c_fix_arg = "%1( const char *%3, const char *";
4349    c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
4350               "[ \t]*char[ \t]*\\*([^,]*),"
4351               "[ \t]*char[ \t]*\\*[ \t]*";
4352
4353    test_text =
4354    "extern FILE *fopen( char *__filename, char *__type );\n"
4355    "extern int sscanf( char *__s, char *__format, ...);\n"
4356    "extern FILE *popen(char *, char *);\n"
4357    "extern char *tempnam(char*,char*);\n";
4358};
4359
4360
4361/*
4362 *  Fix definitions of macros used by va-i960.h in VxWorks header file.
4363 */
4364fix = {
4365    hackname  = va_i960_macro;
4366    files     = arch/i960/archI960.h;
4367    select    = "__(vsiz|vali|vpad|alignof__)";
4368
4369    c_fix     = format;
4370    c_fix_arg = "__vx%1";
4371
4372    test_text =
4373    "extern int __vsiz vsiz;\n"
4374    "extern int __vali vali;\n"
4375    "extern int __vpad vpad;\n"
4376    "#define __alignof__(x) ...";
4377};
4378
4379
4380/*
4381 *  Define __CAN_USE_EXTERN_PREFIX on vms.
4382 */
4383fix = {
4384    hackname  = vms_define_can_use_extern_prefix;
4385    files     = "rtldef/decc$types.h";
4386    select    = "#[ \t]*else\n"
4387		"#[ \t]*if defined\\(__DECCXX\\)\n"
4388		"#[ \t]*define __CAN_USE_EXTERN_PREFIX 1\n";
4389    mach      = "*-*-*vms*";
4390    c_fix     = format;
4391
4392    c_fix_arg = "%0"
4393		"#    elif defined (__GNUC__)\n"
4394		"#\tdefine __CAN_USE_EXTERN_PREFIX 1\n";
4395
4396    test_text = "# else\n"
4397		"#    if defined(__DECCXX)\n"
4398		"#\tdefine __CAN_USE_EXTERN_PREFIX 1\n"
4399		"#    endif\n"
4400		"# endif\n";
4401};
4402
4403/*
4404 * On VMS, use pragma extern_model instead of VAX-C keywords.
4405 */
4406fix = {
4407    hackname  = vms_use_pragma_extern_model;
4408    select    = "#if defined\\(__DECC\\) \\|\\| defined\\(__DECCXX\\)\n"
4409		"# pragma extern_model __save\n";
4410    mach      = "*-*-*vms*";
4411    c_fix     = format;
4412
4413    c_fix_arg = "#if defined(__DECC) || defined(__DECCXX) || defined(__GNUC__)\n"
4414		"# pragma extern_model __save\n";
4415
4416    test_text = "#if defined(__DECC) || defined(__DECCXX)\n"
4417		"# pragma extern_model __save\n"
4418		"# pragma extern_model strict_refdef\n"
4419		"   extern struct x zz$yy;\n"
4420		"# pragma extern_model __restore\n"
4421		"#endif\n";
4422};
4423
4424/*
4425 * On VMS, disable the use of dec-c string builtins
4426 */
4427fix = {
4428    hackname  = vms_disable_decc_string_builtins;
4429    select    = "#if !defined\\(__VAX\\)\n";
4430    mach      = "*-*-*vms*";
4431    files     = "rtldef/string.h";
4432    c_fix     = format;
4433
4434    c_fix_arg = "#if !defined(__VAX) && !defined(__GNUC__)\n";
4435
4436    test_text = "#if !defined(__VAX)\n";
4437};
4438
4439/*
4440 * On VMS, change <resource.h> to <sys/resource.h> to avoid a
4441 * conflict while building gcc.  Likewise for <builtins.h>
4442 */
4443fix = {
4444    hackname  = vms_use_quoted_include;
4445    select    = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>";
4446    mach      = "*-*-*vms*";
4447    files     = rtldef/wait.h, starlet_c/pthread.h;
4448    c_fix     = format;
4449
4450    c_fix_arg = '%1<sys/%2.h>';
4451
4452    test_text = "#   include <resource.h>";
4453};
4454
4455/*
4456 * On VMS, add missing braces around sigset_t constants.
4457 */
4458fix = {
4459    hackname  = vms_add_missing_braces;
4460    select    = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)";
4461    mach      = "*-*-*vms*";
4462    files     = "rtldef/signal.h";
4463    c_fix     = format;
4464
4465    c_fix_arg = '%1 {%2} ';
4466
4467    test_text = "static const __sigset_t _SIG_EMPTY_SET  = "
4468                "{0x00000000, 0x00000000},\n"
4469                " _SIG_FULL_SET   = {0xFFFFFFFF, 0xFFFFFFFF};\n";
4470};
4471
4472/*
4473 * On VMS, fix incompatible redeclaration of hostalias.
4474 */
4475fix = {
4476    hackname  = vms_do_not_redeclare_hostalias;
4477    select    = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n"
4478                "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)";
4479    mach      = "*-*-*vms*";
4480    files     = "rtldef/resolv.h";
4481    c_fix     = format;
4482
4483    c_fix_arg = "%1\n"
4484                "/* %2 */";
4485
4486    test_text = "void		fp_nquery (const u_char *, int, FILE *);\n"
4487                "__char_ptr32	hostalias (const char *);\n";
4488};
4489
4490/*
4491 * On VMS, some DEC-C builtins are directly used.
4492 */
4493fix = {
4494    hackname  = vms_decc_builtin;
4495    select    = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)";
4496    mach      = "*-*-*vms*";
4497    files     = rtldef/string.h, rtldef/time.h, rtldef/strings.h,
4498                rtldef/socket.h;
4499    sed       = "s@__MEMSET@memset@";
4500    sed       = "s@__MEMMOVE@memmove@";
4501    sed       = "s@__MEMCPY@memcpy@";
4502    sed       = "s@__STRLEN@strlen@";
4503    sed       = "s@__STRCPY@strcpy@";
4504
4505    test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n";
4506};
4507
4508/*
4509 * On VMS, do not declare getopt and al if pointers are 64 bit.
4510 */
4511fix = {
4512    hackname  = vms_no_64bit_getopt;
4513    select    = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)|(char \\*optarg))([ \t]*\\(.*\\))?;\n";
4514    /*    select    = "^[ \t](extern[ \t))?(int[ \t](getopt|optind|opterr|optopt))|(char *optarg).*;\n"; */
4515    mach      = "*-*-*vms*";
4516    files     = rtldef/stdio.h, rtldef/unistd.h;
4517    c_fix     = format;
4518
4519    c_fix_arg = "#if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only.  */\n"
4520                "%0"
4521                "#endif\n";
4522
4523    test_text = "int getopt (int, char * const [], const char *);";
4524};
4525
4526/*
4527 * On VMS, forward declare structure before referencing them in prototypes.
4528 */
4529fix = {
4530    hackname  = vms_forward_declare_struct;
4531    select    = "(/\\* forward decls for C\\+\\+ \\*/\n)"
4532                "#ifdef __cplusplus\n";
4533    mach      = "*-*-*vms*";
4534    files     = rtldef/if.h;
4535    c_fix     = format;
4536
4537    c_fix_arg = "%1"
4538                "#if defined (__cplusplus) || defined (__GNUC__)\n";
4539
4540    test_text = "/* forward decls for C++ */\n"
4541                "#ifdef __cplusplus\n"
4542                "struct foo;\n"
4543                "#endif\n";
4544};
4545
4546/*
4547 * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions
4548 * which is not yet fully supported by gcc.
4549 */
4550fix = {
4551    hackname  = vms_use_fast_setjmp;
4552    select    = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)";
4553    mach      = "*-*-*vms*";
4554    files     = rtldef/setjmp.h;
4555    c_fix     = format;
4556
4557    c_fix_arg = "%0 defined (__GNUC__) ||";
4558
4559    test_text = "#   if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)";
4560};
4561
4562/*
4563 *  AIX and Interix headers define NULL to be cast to a void pointer,
4564 *  which is illegal in ANSI C++.
4565 */
4566fix = {
4567    hackname  = void_null;
4568    files     = curses.h;
4569    files     = dbm.h;
4570    files     = locale.h;
4571    files     = stdio.h;
4572    files     = stdlib.h;
4573    files     = string.h;
4574    files     = time.h;
4575    files     = unistd.h;
4576    files     = sys/dir.h;
4577    files     = sys/param.h;
4578    files     = sys/types.h;
4579    /* avoid changing C++ friendly NULL */
4580    bypass    = __cplusplus;
4581    bypass    = __null;
4582    select    = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
4583    c_fix     = format;
4584    c_fix_arg = "#define NULL 0";
4585    test_text = "# define\tNULL \t((void *)0)  /* typed NULL */";
4586};
4587
4588
4589/*
4590 *  Make VxWorks header which is almost gcc ready fully gcc ready.
4591 */
4592fix = {
4593    hackname = vxworks_gcc_problem;
4594    files    = types/vxTypesBase.h;
4595    select   = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
4596
4597    sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
4598          "#if 1/";
4599
4600    sed = "/[ \t]size_t/i\\\n"
4601        "#ifndef _GCC_SIZE_T\\\n"
4602        "#define _GCC_SIZE_T\n";
4603
4604    sed = "/[ \t]size_t/a\\\n"
4605        "#endif\n";
4606
4607    sed = "/[ \t]ptrdiff_t/i\\\n"
4608        "#ifndef _GCC_PTRDIFF_T\\\n"
4609        "#define _GCC_PTRDIFF_T\n";
4610
4611    sed = "/[ \t]ptrdiff_t/a\\\n"
4612        "#endif\n";
4613
4614    sed = "/[ \t]wchar_t/i\\\n"
4615        "#ifndef _GCC_WCHAR_T\\\n"
4616        "#define _GCC_WCHAR_T\n";
4617
4618    sed = "/[ \t]wchar_t/a\\\n"
4619        "#endif\n";
4620
4621    test_text =
4622    "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
4623    "typedef unsigned int size_t;\n"
4624    "typedef long ptrdiff_t;\n"
4625    "typedef unsigned short wchar_t;\n"
4626    "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
4627};
4628
4629/*
4630 *  Wrap VxWorks ioctl to keep everything pretty
4631 */
4632fix = {
4633    hackname    = vxworks_ioctl_macro;
4634    files       = ioLib.h;
4635    mach        = "*-*-vxworks*";
4636
4637    c_fix       = format;
4638    c_fix_arg   = "%0\n"
4639        "#define ioctl(fd, func, arg) (ioctl)(fd, func, (int)(arg))\n";
4640    c_fix_arg   = "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);";
4641
4642    test_text   = "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;";
4643};
4644
4645/*
4646 *  Wrap VxWorks mkdir to be posix compliant
4647 */
4648fix = {
4649    hackname    = vxworks_mkdir_macro;
4650    files       = sys/stat.h;
4651    mach        = "*-*-vxworks*";
4652
4653    c_fix       = format;
4654    c_fix_arg   = "%0\n"
4655                "#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n";
4656    c_fix_arg   = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*"
4657                "\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */
4658                "(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */
4659                "\\)[\t ]*;";
4660
4661    test_text   = "extern STATUS mkdir (const char * _qwerty) ;";
4662};
4663
4664
4665/*
4666 *  Fix VxWorks <time.h> to not require including <vxTypes.h>.
4667 */
4668fix = {
4669    hackname  = vxworks_needs_vxtypes;
4670    files     = time.h;
4671    select    = "uint_t([ \t]+_clocks_per_sec)";
4672    c_fix     = format;
4673    c_fix_arg = "unsigned int%1";
4674    test_text = "uint_t\t_clocks_per_sec;";
4675};
4676
4677
4678/*
4679 *  Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
4680 */
4681fix = {
4682    hackname = vxworks_needs_vxworks;
4683    files    = sys/stat.h;
4684    test     = " -r types/vxTypesOld.h";
4685    test     = " -n \"`egrep '#include' $file`\"";
4686    test     = " -n \"`egrep ULONG $file`\"";
4687    select   = "#[ \t]define[ \t]+__INCstath";
4688
4689    sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
4690          "#include <types/vxTypesOld.h>\n";
4691
4692    test_text = "`touch types/vxTypesOld.h`"
4693    "#include </dev/null> /* ULONG */\n"
4694    "# define\t__INCstath <sys/stat.h>";
4695};
4696
4697/*
4698 *  Make it so VxWorks does not include gcc/regs.h accidentally
4699 */
4700fix = {
4701    hackname    = vxworks_regs;
4702    mach        = "*-*-vxworks*";
4703
4704    select      = "#[\t ]*include[\t ]+[<\"]regs.h[>\"]";
4705    c_fix       = format;
4706    c_fix_arg   = "#include <arch/../regs.h>";
4707
4708    test_text   = "#include <regs.h>\n";
4709};
4710
4711
4712/*
4713 *  Another bad dependency in VxWorks 5.2 <time.h>.
4714 */
4715fix = {
4716    hackname = vxworks_time;
4717    files    = time.h;
4718    test     = " -r vxWorks.h";
4719
4720    select    = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
4721    c_fix     = format;
4722
4723    c_fix_arg =
4724    "#ifndef __gcc_VOIDFUNCPTR_defined\n"
4725    "#ifdef __cplusplus\n"
4726    "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
4727    "#else\n"
4728    "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
4729    "#endif\n"
4730    "#define __gcc_VOIDFUNCPTR_defined\n"
4731    "#endif\n"
4732    "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
4733
4734    test_text = "`touch vxWorks.h`"
4735                "#define VOIDFUNCPTR (void(*)())";
4736};
4737
4738/*
4739 *  This hack makes write const-correct on VxWorks
4740 */
4741fix = {
4742    hackname    = vxworks_write_const;
4743    files       = ioLib.h;
4744    mach        = "*-*-vxworks*";
4745
4746    c_fix       = format;
4747    c_fix_arg   = "extern int  write (int, const char*, size_t);";
4748    c_fix_arg   = "extern[\t ]+int[\t ]+write[\t ]*\\("
4749                "[\t ]*int[\t ]*,"
4750                "[\t ]*char[\t ]*\\*[\t ]*,"
4751                "[\t ]*size_t[\t ]*\\)[\t ]*;";
4752
4753    test_text       = "extern int write ( int , char * , size_t ) ;";
4754};
4755
4756/*
4757 *  There are several name conflicts with C++ reserved words in X11 header
4758 *  files.  These are fixed in some versions, so don't do the fixes if
4759 *  we find __cplusplus in the file.  These were found on the RS/6000.
4760 */
4761fix = {
4762    hackname  = x11_class;
4763    files     = X11/ShellP.h;
4764    bypass    = __cplusplus;
4765    select    = "^([ \t]*char \\*)class;(.*)";
4766    c_fix     = format;
4767    c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
4768                "#else\n%1class;%2\n#endif";
4769    test_text =
4770    "struct {\n"
4771    "   char *class;\n"
4772    "} mumble;\n";
4773};
4774
4775
4776/*
4777 *  class in Xm/BaseClassI.h
4778 */
4779fix = {
4780    hackname = x11_class_usage;
4781    files    = Xm/BaseClassI.h;
4782    bypass   = "__cplusplus";
4783
4784    select    = " class\\)";
4785    c_fix     = format;
4786    c_fix_arg = " c_class)";
4787
4788    test_text = "extern mumble (int  class);\n";
4789};
4790
4791
4792/*
4793 *  new in Xm/Traversal.h
4794 */
4795fix = {
4796    hackname = x11_new;
4797    files    = Xm/Traversal.h;
4798    bypass   = __cplusplus;
4799
4800    sed      = "/Widget\told, new;/i\\\n"
4801                   "#ifdef __cplusplus\\\n"
4802                   "\\\tWidget\told, c_new;\\\n"
4803                   "#else\n";
4804
4805    sed      = "/Widget\told, new;/a\\\n"
4806                   "#endif\n";
4807
4808    sed      = "s/Widget new,/Widget c_new,/g";
4809    test_text =
4810    "struct wedge {\n"
4811    "   Widget\told, new;\n"
4812    "};\nextern Wedged( Widget new, Widget old );";
4813};
4814
4815
4816/*
4817 *  Incorrect sprintf declaration in X11/Xmu.h
4818 */
4819fix = {
4820    hackname = x11_sprintf;
4821    files    = X11/Xmu.h;
4822    files    = X11/Xmu/Xmu.h;
4823    select   = "^extern char \\*\tsprintf\\(\\);$";
4824
4825    c_fix     = format;
4826    c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
4827
4828    test_text = "extern char *\tsprintf();";
4829};
4830
4831/*
4832 *  Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
4833 *  that fails when compiling for SSE-less 32-bit x86.
4834 */
4835fix = {
4836    hackname  = feraiseexcept_nosse_invalid;
4837    mach      = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
4838    files     = bits/fenv.h;
4839    select    = "^([\t ]*)__asm__ __volatile__ \\(\"divss %0, %0 *\" : "
4840		": \"x\" \\(__f\\)\\);$";
4841    bypass    = "\"fdiv .*; fwait\"";
4842
4843    c_fix     = format;
4844    c_fix_arg = <<- _EOText_
4845	# ifdef __SSE_MATH__
4846	%0
4847	# else
4848	%1__asm__ __volatile__ ("fdiv %%%%st, %%%%st(0); fwait"
4849	%1			: "=t" (__f) : "0" (__f));
4850	# endif
4851	_EOText_;
4852
4853    test_text = <<- _EOText_
4854	  __asm__ __volatile__ ("divss %0, %0" : : "x" (__f));
4855	_EOText_;
4856};
4857fix = {
4858    hackname  = feraiseexcept_nosse_divbyzero;
4859    mach      = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
4860    files     = bits/fenv.h;
4861    select    = "^([\t ]*)__asm__ __volatile__ \\(\"divss %1, %0 *\" : "
4862		": \"x\" \\(__f\\), \"x\" \\(__g\\)\\);$";
4863    bypass    = "\"fdivp .*; fwait\"";
4864
4865    c_fix     = format;
4866    c_fix_arg = <<- _EOText_
4867	# ifdef __SSE_MATH__
4868	%0
4869	# else
4870	%1__asm__ __volatile__ ("fdivp %%%%st, %%%%st(1); fwait"
4871	%1			: "=t" (__f) : "0" (__f), "u" (__g) : "st(1)");
4872	# endif
4873	_EOText_;
4874
4875    test_text = <<- _EOText_
4876	  __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g));
4877	_EOText_;
4878};
4879
4880/*EOF*/
4881