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