OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [fixincludes/] [inclhack.def] - Blame information for rev 763

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.