comparison fixincludes/inclhack.def @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents f6334be47118
children 84e7813d76e9
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
9 9
10 blocksort output=inclhack.sorted \ 10 blocksort output=inclhack.sorted \
11 pattern='^/\*$' \ 11 pattern='^/\*$' \
12 trailer='^/\*EOF\*[/]' \ 12 trailer='^/\*EOF\*[/]' \
13 input=inclhack.def \ 13 input=inclhack.def \
14 key='hackname[ ]*=[ ]*(.*);' 14 key=$'hackname[ \t]*=[ \t]*(.*);'
15 15
16 Set up a debug test so we can make the templates emit special 16 Set up a debug test so we can make the templates emit special
17 code while debugging these fixes: */ 17 code while debugging these fixes: */
18 18
19 #ifdef DEBUG 19 #ifdef DEBUG
62 #endif 62 #endif
63 63
64 _EOArg_; 64 _EOArg_;
65 }; 65 };
66 66
67 /* On AIX when _LARGE_FILES is defined fcntl.h defines open to
68 * open64 and creat to creat64. This fixes fcntl.h to
69 * undef those defines and use __asm__ to alias the symbols if
70 * building with g++ and -D_LARGE_FILES
71 */
72 fix = {
73 hackname = AAB_aix_fcntl;
74 files = fcntl.h;
75 select = "define open[ \t]open64";
76 mach = "*-*-aix*";
77 test-text = ''; /* no way to test */
78
79 c_fix = wrap;
80
81 c_fix_arg = "";
82
83 c_fix_arg = <<- _EOArg_
84
85 #if defined __GNUG__ && defined _LARGE_FILES && defined __cplusplus
86 #define __need__aix_fcntl_h_fix
87 #ifdef __need__aix_fcntl_h_fix
88 #undef open
89 #undef creat
90 #undef openat
91 /* Alias the symbols using asm */
92 extern "C" {
93 extern int open(const char *, int, ...) __asm__("open64");
94 extern int creat(const char *, mode_t) __asm__("creat64");
95 #if (_XOPEN_SOURCE >= 700)
96 extern int openat(int, const char *, int, ...) __asm__("open64at");
97 #endif
98 }
99 #endif
100 #endif
101
102 _EOArg_;
103 };
67 104
68 /* 105 /*
69 * On Mac OS 10.3.9, the 'long double' functions are available in 106 * On Mac OS 10.3.9, the 'long double' functions are available in
70 * libSystem, but are not prototyped in math.h. 107 * libSystem, but are not prototyped in math.h.
71 */ 108 */
155 # endif 192 # endif
156 #endif /* __MATH__ */ 193 #endif /* __MATH__ */
157 _EndOfHeader_; 194 _EndOfHeader_;
158 }; 195 };
159 196
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 /* 197 /*
180 * This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n) 198 * This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n)
181 */ 199 */
182 fix = { 200 fix = {
183 hackname = AAB_fd_zero_asm_posix_types_h; 201 hackname = AAB_fd_zero_asm_posix_types_h;
215 #define _POSIX_TYPES_H_WRAPPER 233 #define _POSIX_TYPES_H_WRAPPER
216 #endif /* _POSIX_TYPES_H_WRAPPER */ 234 #endif /* _POSIX_TYPES_H_WRAPPER */
217 _EndOfHeader_; 235 _EndOfHeader_;
218 }; 236 };
219 237
220
221 /* 238 /*
222 * This fixes __FD_ZERO bug for glibc-1.x 239 * This fixes __FD_ZERO bug for glibc-1.x
223 */ 240 */
224 fix = { 241 fix = {
225 hackname = AAB_fd_zero_gnu_types_h; 242 hackname = AAB_fd_zero_gnu_types_h;
252 269
253 #define _TYPES_H_WRAPPER 270 #define _TYPES_H_WRAPPER
254 #endif /* _TYPES_H_WRAPPER */ 271 #endif /* _TYPES_H_WRAPPER */
255 _EndOfHeader_; 272 _EndOfHeader_;
256 }; 273 };
257
258 274
259 /* 275 /*
260 * This fixes __FD_ZERO bug for glibc-2.0.x 276 * This fixes __FD_ZERO bug for glibc-2.0.x
261 */ 277 */
262 fix = { 278 fix = {
295 #define _SELECTBITS_H_WRAPPER 311 #define _SELECTBITS_H_WRAPPER
296 #endif /* _SELECTBITS_H_WRAPPER */ 312 #endif /* _SELECTBITS_H_WRAPPER */
297 _EndOfHeader_; 313 _EndOfHeader_;
298 }; 314 };
299 315
300
301 /* 316 /*
302 * Solaris <sys/varargs.h> is a DDK (aka kernel-land) header providing 317 * Solaris <sys/varargs.h> is a DDK (aka kernel-land) header providing
303 * the same interface as <stdarg.h>. No idea why they couldn't have just 318 * the same interface as <stdarg.h>. No idea why they couldn't have just
304 * used the standard header. 319 * used the standard header.
305 */ 320 */
313 #else 328 #else
314 #include <varargs.h> 329 #include <varargs.h>
315 #endif 330 #endif
316 _EndOfHeader_; 331 _EndOfHeader_;
317 }; 332 };
318
319 333
320 /* 334 /*
321 * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin 335 * 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 336 * 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. 337 * many other systems have similar text but correct versions of the file.
352 366
353 #endif /* __memory_h__ */ 367 #endif /* __memory_h__ */
354 _EndOfHeader_; 368 _EndOfHeader_;
355 }; 369 };
356 370
371 /*
372 * Fix assert.h on VxWorks:
373 */
374 fix = {
375 hackname = AAB_vxworks_assert;
376 files = assert.h;
377 mach = "*-*-vxworks*";
378
379 replace = <<- _EndOfHeader_
380 #ifndef _ASSERT_H
381 #define _ASSERT_H
382
383 #ifdef assert
384 #undef assert
385 #endif
386
387 #if defined(__STDC__) || defined(__cplusplus)
388 extern void __assert (const char*);
389 #else
390 extern void __assert ();
391 #endif
392
393 #ifdef NDEBUG
394 #define assert(ign) ((void)0)
395 #else
396
397 #define ASSERT_STRINGIFY(str) ASSERT_STRINGIFY_HELPER(str)
398 #define ASSERT_STRINGIFY_HELPER(str) #str
399
400 #define assert(test) ((void) \
401 ((test) ? ((void)0) : \
402 __assert("Assertion failed: " ASSERT_STRINGIFY(test) ", file " \
403 __FILE__ ", line " ASSERT_STRINGIFY(__LINE__) "\n")))
404
405 #endif
406
407 #endif
408 _EndOfHeader_;
409 };
410
411 /*
412 * Add needed include to regs.h (NOT the gcc header) on VxWorks
413 */
414
415 fix = {
416 hackname = AAB_vxworks_regs_vxtypes;
417 files = regs.h;
418 mach = "*-*-vxworks*";
419
420 replace = <<- _EndOfHeader_
421 #ifndef _REGS_H
422 #define _REGS_H
423 #include <types/vxTypesOld.h>
424 #include_next <arch/../regs.h>
425 #endif
426 _EndOfHeader_;
427 };
428
429 /*
430 * This hack makes makes unistd.h more POSIX-compliant on VxWorks
431 */
432 fix = {
433 hackname = AAB_vxworks_unistd;
434 files = unistd.h;
435 mach = "*-*-vxworks*";
436
437 replace = <<- _EndOfHeader_
438 #ifndef _UNISTD_H
439 #define _UNISTD_H
440 #include_next <unistd.h>
441 #include <ioLib.h>
442 #ifndef STDIN_FILENO
443 #define STDIN_FILENO 0
444 #endif
445 #ifndef STDOUT_FILENO
446 #define STDOUT_FILENO 1
447 #endif
448 #ifndef STDERR_FILENO
449 #define STDERR_FILENO 2
450 #endif
451 #endif /* _UNISTD_H */
452 _EndOfHeader_;
453 };
454
455 /*
456 * assert.h on AIX 7 redefines static_assert as _Static_assert without
457 * protecting C++.
458 */
459 fix = {
460 hackname = aix_assert;
461 mach = "*-*-aix*";
462 files = assert.h;
463 select = "#define[ \t]static_assert[ \t]_Static_assert";
464 c_fix = format;
465 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
466 test_text = "#define static_assert _Static_assert";
467 };
357 468
358 /* 469 /*
359 * complex.h on AIX 5 and AIX 6 define _Complex_I and I in terms of __I, 470 * 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. 471 * which only is provided by AIX xlc C99.
361 */ 472 */
367 c_fix = format; 478 c_fix = format;
368 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)"; 479 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
369 test_text = "#define _Complex_I __I\n"; 480 test_text = "#define _Complex_I __I\n";
370 }; 481 };
371 482
483 /*
484 * On AIX some headers are not properly guarded by 'extern "C"'.
485 */
486 fix = {
487 hackname = aix_externc;
488 mach = "*-*-aix*";
489 files = ctype.h;
490 files = fcntl.h;
491 files = langinfo.h;
492 files = ldfcn.h;
493 files = sys/localedef.h;
494 files = sys/times.h;
495 bypass = "extern \"C\"";
496 c_fix = wrap;
497 c_fix_arg = "#ifdef __cplusplus\n"
498 "extern \"C\" {\n"
499 "#endif\n";
500 c_fix_arg = "#ifdef __cplusplus\n"
501 "}\n"
502 "#endif\n";
503 test_text = "extern int __n_pthreads;\n";
504 };
505
506 /*
507 * On AIX sys/socket.h assumes C++.
508 */
509 fix = {
510 hackname = aix_externcpp1;
511 mach = "*-*-aix*";
512 files = "sys/socket.h";
513 select = "#ifdef __cplusplus";
514 c_fix = format;
515 c_fix_arg = "#ifdef __cplusplus\n"
516 "extern \"C++\" {";
517 test_text = "#ifdef __cplusplus";
518
519 };
520
521 fix = {
522 hackname = aix_externcpp2;
523 mach = "*-*-aix*";
524 files = "sys/socket.h";
525 select = "#else /\\* __cplusplus \\*/";
526 c_fix = format;
527 c_fix_arg = "} /* extern \"C++\" */\n"
528 "#else /* __cplusplus */";
529 test_text = "#else /* __cplusplus */";
530
531 };
532
533 /*
534 * malloc.h on AIX6 uses XLC++ specific builtin syntax
535 */
536 fix = {
537 hackname = aix_malloc;
538 mach = "*-*-aix*";
539 files = "malloc.h";
540 select = "#ifdef __cplusplus";
541 c_fix = format;
542 c_fix_arg = "#if (defined(__cplusplus) && defined(__IBMCPP__))";
543 test_text = "#ifdef __cplusplus";
544 };
545
546 /*
547 * net/if_arp.h defines a variable fc_softc instead of adding a
548 * typedef for the struct on AIX 5.2, 5.3, 6.1 and 7.1
549 */
550 fix = {
551 hackname = aix_net_if_arp;
552 mach = "*-*-aix*";
553 files = "net/if_arp.h";
554 select = "^struct fc_softc \\{";
555 c_fix = format;
556 c_fix_arg = "typedef struct _fc_softc {";
557 test_text = "struct fc_softc {\n int a;\n};";
558 };
559
560 /*
561 * Fix AIX definition of NULL for G++.
562 */
563 fix = {
564 hackname = aix_null;
565 mach = "*-*-aix*";
566 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
567 time.h, unistd.h, wchar.h, sys/dir.h, sys/param.h, sys/types.h;
568 bypass = __null;
569 select = "#define[ \t]+NULL[ \t]+\\(*0L*\\)*";
570 c_fix = format;
571 c_fix_arg = <<- _EOFix_
572 #ifndef NULL
573 #ifdef __cplusplus
574 #ifdef __GNUG__
575 #define NULL __null
576 #else /* ! __GNUG__ */
577 #define NULL 0L
578 #endif /* __GNUG__ */
579 #else /* ! __cplusplus */
580 #define NULL ((void *)0)
581 #endif /* __cplusplus */
582 #endif /* !NULL */
583 _EOFix_;
584 test_text = "# define\tNULL \t(0L) /* typed NULL */";
585 };
586
587 /*
588 * pthread.h on AIX defines PTHREAD_ONCE_INIT, PTHREAD_MUTEX_INITIALIZER,
589 * PTHREAD_COND_INITIALIZER and PTHREAD_RWLOCK_INITIALIZER without enough
590 * braces.
591 */
592 fix = {
593 hackname = aix_once_init_1;
594 mach = "*-*-aix*";
595 files = "pthread.h";
596 select = "#define[ \t]PTHREAD_ONCE_INIT \\\\\n"
597 "\\{ \\\\\n";
598 c_fix = format;
599 c_fix_arg = "#define PTHREAD_ONCE_INIT \\\n"
600 "{{ \\\n";
601 test_text = "#define PTHREAD_ONCE_INIT \\\\\n"
602 "{ \\\\\n";
603 };
604
605 fix = {
606 hackname = aix_once_init_2;
607 mach = "*-*-aix*";
608 files = "pthread.h";
609 select = "[ \t]0 \\\\\n"
610 "\\}\n";
611 c_fix = format;
612 c_fix_arg = " 0 \\\n"
613 "}}\n";
614 test_text = " 0 \\\\\n"
615 "}\n";
616 };
617
618 fix = {
619 hackname = aix_mutex_initializer_1;
620 mach = "*-*-aix*";
621 files = "pthread.h";
622 select = "#define[ \t]PTHREAD_MUTEX_INITIALIZER \\\\\n"
623 "\\{ \\\\\n";
624 c_fix = format;
625 c_fix_arg = "#define PTHREAD_MUTEX_INITIALIZER \\\n"
626 "{{ \\\n";
627 test_text = "#define PTHREAD_MUTEX_INITIALIZER \\\\\n"
628 "{ \\\\\n";
629 };
630
631 fix = {
632 hackname = aix_cond_initializer_1;
633 mach = "*-*-aix*";
634 files = "pthread.h";
635 select = "#define[ \t]PTHREAD_COND_INITIALIZER \\\\\n"
636 "\\{ \\\\\n";
637 c_fix = format;
638 c_fix_arg = "#define PTHREAD_COND_INITIALIZER \\\n"
639 "{{ \\\n";
640 test_text = "#define PTHREAD_COND_INITIALIZER \\\\\n"
641 "{ \\\\\n";
642 };
643
644 fix = {
645 hackname = aix_rwlock_initializer_1;
646 mach = "*-*-aix*";
647 files = "pthread.h";
648 select = "#define[ \t]PTHREAD_RWLOCK_INITIALIZER \\\\\n"
649 "\\{ \\\\\n";
650 c_fix = format;
651 c_fix_arg = "#define PTHREAD_RWLOCK_INITIALIZER \\\n"
652 "{{ \\\n";
653 test_text = "#define PTHREAD_RWLOCK_INITIALIZER \\\\\n"
654 "{ \\\\\n";
655 };
372 656
373 /* 657 /*
374 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace 658 * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
375 * which violates a requirement of ISO C. 659 * which violates a requirement of ISO C.
376 */ 660 */
377 fix = { 661 fix = {
378 hackname = aix_pthread; 662 hackname = aix_pthread;
379 files = "pthread.h"; 663 files = "pthread.h";
380 select = "(#define [A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])"; 664 select = "(#define[\t ][A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
381 c_fix = format; 665 c_fix = format;
382 c_fix_arg = "%1 %2"; 666 c_fix_arg = "%1 %2";
383 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n" 667 test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
384 "{...init stuff...}"; 668 "{...init stuff...}";
385 }; 669 };
386
387 670
388 /* 671 /*
389 * AIX stdint.h fixes. 672 * AIX stdint.h fixes.
390 */ 673 */
391 fix = { 674 fix = {
399 "#define UINT16_MAX (65535)"; 682 "#define UINT16_MAX (65535)";
400 test_text = "#define UINT8_MAX (255U)\n" 683 test_text = "#define UINT8_MAX (255U)\n"
401 "#define UINT16_MAX (65535U)"; 684 "#define UINT16_MAX (65535U)";
402 }; 685 };
403 686
404 687 /*
688 * aix_stdint_2
689 */
405 fix = { 690 fix = {
406 hackname = aix_stdint_2; 691 hackname = aix_stdint_2;
407 mach = "*-*-aix*"; 692 mach = "*-*-aix*";
408 files = stdint-aix.h, stdint.h; 693 files = stdint-aix.h, stdint.h;
409 select = "#define[ \t]INTPTR_MIN[ \t]INT64_MIN\n" 694 select = "#define[ \t]INTPTR_MIN[ \t]INT64_MIN\n"
428 "#define INTPTR_MIN INT32_MIN\n" 713 "#define INTPTR_MIN INT32_MIN\n"
429 "#define INTPTR_MAX INT32_MAX\n" 714 "#define INTPTR_MAX INT32_MAX\n"
430 "#define UINTPTR_MAX UINT32_MAX"; 715 "#define UINTPTR_MAX UINT32_MAX";
431 }; 716 };
432 717
433 718 /*
719 * aix_stdint_3
720 */
434 fix = { 721 fix = {
435 hackname = aix_stdint_3; 722 hackname = aix_stdint_3;
436 mach = "*-*-aix*"; 723 mach = "*-*-aix*";
437 files = stdint-aix.h, stdint.h; 724 files = stdint-aix.h, stdint.h;
438 select = "#define[ \t]PTRDIFF_MIN[ \t]INT64_MIN\n" 725 select = "#define[ \t]PTRDIFF_MIN[ \t]INT64_MIN\n"
451 "#else\n" 738 "#else\n"
452 "#define PTRDIFF_MIN INT32_MIN\n" 739 "#define PTRDIFF_MIN INT32_MIN\n"
453 "#define PTRDIFF_MAX INT32_MAX"; 740 "#define PTRDIFF_MAX INT32_MAX";
454 }; 741 };
455 742
456 743 /*
744 * aix_stdint_4
745 */
457 fix = { 746 fix = {
458 hackname = aix_stdint_4; 747 hackname = aix_stdint_4;
459 mach = "*-*-aix*"; 748 mach = "*-*-aix*";
460 files = stdint-aix.h, stdint.h; 749 files = stdint-aix.h, stdint.h;
461 select = "#define[ \t]SIZE_MAX[ \t]UINT64_MAX\n" 750 select = "#define[ \t]SIZE_MAX[ \t]UINT64_MAX\n"
468 test_text = "#define SIZE_MAX UINT64_MAX\n" 757 test_text = "#define SIZE_MAX UINT64_MAX\n"
469 "#else\n" 758 "#else\n"
470 "#define SIZE_MAX UINT32_MAX"; 759 "#define SIZE_MAX UINT32_MAX";
471 }; 760 };
472 761
473 762 /*
763 * aix_stdint_5
764 */
474 fix = { 765 fix = {
475 hackname = aix_stdint_5; 766 hackname = aix_stdint_5;
476 mach = "*-*-aix*"; 767 mach = "*-*-aix*";
477 files = stdint-aix.h, stdint.h; 768 files = stdint-aix.h, stdint.h;
478 select = "#define[ \t]UINT8_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)\n" 769 select = "#define[ \t]UINT8_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)\n"
482 "#define UINT16_C(c) c"; 773 "#define UINT16_C(c) c";
483 test_text = "#define UINT8_C(c) __CONCAT__(c,U)\n" 774 test_text = "#define UINT8_C(c) __CONCAT__(c,U)\n"
484 "#define UINT16_C(c) __CONCAT__(c,U)"; 775 "#define UINT16_C(c) __CONCAT__(c,U)";
485 }; 776 };
486 777
778 /*
779 * stdio.h on AIX defines ferror, clearerr and feof as C++ inline, which
780 produces wrong code with G++.
781 */
782 fix = {
783 hackname = aix_stdio_inline;
784 mach = "*-*-aix*";
785 files = stdio.h;
786 select = "#ifdef __cplusplus\\\n"
787 "}\\\n\\\n"
788 "#ifdef ferror\\\n";
789 c_fix = format;
790 c_fix_arg = "#ifdef __cplusplus\n"
791 "}\n"
792 "#endif\n\n"
793 "#if (defined(__cplusplus) && defined(__IBMCPP__))\n"
794 "#ifdef ferror\n";
795 test_text = "#ifdef __cplusplus\n}\n\n#ifdef ferror";
796 };
797
798 /*
799 * stdlib.h on AIX uses #define on malloc and friends.
800 */
801 fix = {
802 hackname = aix_stdlib_malloc;
803 mach = "*-*-aix*";
804 files = stdlib.h;
805 select = "#define[ \t]+malloc[ \t]+__linux_malloc";
806 c_fix = format;
807 c_fix_arg = "extern void *malloc(size_t) __asm__(\"__linux_malloc\");";
808 test_text = "#define malloc __linux_malloc";
809 };
810
811 fix = {
812 hackname = aix_stdlib_realloc;
813 mach = "*-*-aix*";
814 files = stdlib.h;
815 select = "#define[ \t]+realloc[ \t]+__linux_realloc";
816 c_fix = format;
817 c_fix_arg = "extern void *realloc(void *, size_t) __asm__(\"__linux_realloc\");";
818 test_text = "#define realloc __linux_realloc";
819 };
820
821 fix = {
822 hackname = aix_stdlib_calloc;
823 mach = "*-*-aix*";
824 files = stdlib.h;
825 select = "#define[ \t]+calloc[ \t]+__linux_calloc";
826 c_fix = format;
827 c_fix_arg = "extern void *calloc(size_t, size_t) __asm__(\"__linux_calloc\");";
828 test_text = "#define calloc __linux_calloc";
829 };
830
831 fix = {
832 hackname = aix_stdlib_valloc;
833 mach = "*-*-aix*";
834 files = stdlib.h;
835 select = "#define[ \t]+valloc[ \t]+__linux_valloc";
836 c_fix = format;
837 c_fix_arg = "extern void *valloc(size_t) __asm__(\"__linux_valloc\");";
838 test_text = "#define valloc __linux_valloc";
839 };
840
841 /*
842 * stdlib.h on AIX 4.3 declares strtof() with a non-const first argument.
843 */
844 fix = {
845 hackname = aix_strtof_const;
846 mach = "*-*-aix*";
847 files = stdlib.h;
848 select = "((extern[ \t]+)?float[ \t]+strtof)\\(char \\*, char \\*\\*\\);";
849 c_fix = format;
850 c_fix_arg = "%1(const char *, char **);";
851 test_text = "extern float strtof(char *, char **);";
852 };
487 853
488 /* 854 /*
489 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline 855 * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
490 * in an otherwise harmless (and #ifed out) macro definition 856 * in an otherwise harmless (and #ifed out) macro definition
491 */ 857 */
492 fix = { 858 fix = {
493 hackname = aix_sysmachine; 859 hackname = aix_sysmachine;
860 mach = "*-*-aix*";
494 files = sys/machine.h; 861 files = sys/machine.h;
495 select = "\\\\ +\n"; 862 select = "\\\\ +\n";
496 c_fix = format; 863 c_fix = format;
497 c_fix_arg = "\\\n"; 864 c_fix_arg = "\\\n";
498 test_text = "#define FOO \\\n" 865 test_text = "#define FOO \\\n"
499 " bar \\ \n baz \\ \n bat"; 866 " bar \\ \n baz \\ \n bat";
500 }; 867 };
501 868
502
503 /* 869 /*
504 * sys/wait.h on AIX 5.2 defines macros that have both signed and 870 * sys/wait.h on AIX 5.2 defines macros that have both signed and
505 * unsigned types in conditional expressions. 871 * unsigned types in conditional expressions.
506 */ 872 */
507 fix = { 873 fix = {
508 hackname = aix_syswait_2; 874 hackname = aix_syswait_2;
875 mach = "*-*-aix*";
509 files = sys/wait.h; 876 files = sys/wait.h;
510 select = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)'; 877 select = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)';
511 c_fix = format; 878 c_fix = format;
512 c_fix_arg = "? (int)%1"; 879 c_fix_arg = "? (int)%1";
513 test_text = "#define WSTOPSIG(__x) (int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)"; 880 test_text = "#define WSTOPSIG(__x) "
514 }; 881 "(int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
515 882 };
516 883
517 /* 884 /*
518 * sys/signal.h on some versions of AIX uses volatile in the typedef of 885 * sys/signal.h on some versions of AIX uses volatile in the typedef of
519 * sig_atomic_t, which causes gcc to generate a warning about duplicate 886 * sig_atomic_t, which causes gcc to generate a warning about duplicate
520 * volatile when a sig_atomic_t variable is declared volatile, as 887 * volatile when a sig_atomic_t variable is declared volatile, as
521 * required by ANSI C. 888 * required by ANSI C.
522 */ 889 */
523 fix = { 890 fix = {
524 hackname = aix_volatile; 891 hackname = aix_volatile;
892 mach = "*-*-aix*";
525 files = sys/signal.h; 893 files = sys/signal.h;
526 select = "typedef volatile int sig_atomic_t"; 894 select = "typedef volatile int sig_atomic_t";
527 c_fix = format; 895 c_fix = format;
528 c_fix_arg = "typedef int sig_atomic_t"; 896 c_fix_arg = "typedef int sig_atomic_t";
529 test_text = "typedef volatile int sig_atomic_t;"; 897 test_text = "typedef volatile int sig_atomic_t;";
530 }; 898 };
531
532 899
533 /* 900 /*
534 * Fix __assert declaration in assert.h on Alpha OSF/1. 901 * Fix __assert declaration in assert.h on Alpha OSF/1.
535 */ 902 */
536 fix = { 903 fix = {
540 c_fix = format; 907 c_fix = format;
541 c_fix_arg = "__assert(const char *, const char *, int)"; 908 c_fix_arg = "__assert(const char *, const char *, int)";
542 test_text = 'extern void __assert(char *, char *, int);'; 909 test_text = 'extern void __assert(char *, char *, int);';
543 }; 910 };
544 911
545
546 /*
547 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V4/5 headers.
548 */
549 fix = {
550 hackname = alpha___extern_prefix;
551 select = "(.*)(defined\\(__DECC\\)|def[ \t]*__DECC)[ \t]*\n"
552 "(#[ \t]*pragma[ \t]*extern_prefix.*)";
553
554 mach = "alpha*-dec-osf*";
555 c_fix = format;
556 c_fix_arg = "%1 (defined(__DECC) || defined(__PRAGMA_EXTERN_PREFIX))\n%3";
557
558 test_text = "#ifdef __DECC\n"
559 "#pragma extern_prefix \"_P\"\n"
560 "# if defined(__DECC)\n"
561 "# pragma extern_prefix \"_E\"\n"
562 "# if !defined(_LIBC_POLLUTION_H_) && defined(__DECC)\n"
563 "# pragma extern_prefix \"\"";
564 };
565
566
567 /*
568 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V4/5 <standards.h>.
569 */
570 fix = {
571 hackname = alpha___extern_prefix_standards;
572 files = standards.h;
573 select = ".*!defined\\(_LIBC_POLLUTION_H_\\) && !defined\\(__DECC\\)";
574
575 mach = "alpha*-dec-osf*";
576 c_fix = format;
577 c_fix_arg = "%0 && !defined(__PRAGMA_EXTERN_PREFIX)";
578
579 test_text = "#if (_ISO_C_SOURCE>=19990L) "
580 "&& !defined(_LIBC_POLLUTION_H_) && !defined(__DECC)";
581 };
582
583
584 /*
585 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V5 <sys/mount.h> and
586 * <sys/stat.h>. The tests for __DECC are special in various ways, so
587 * alpha__extern_prefix cannot be used.
588 */
589 fix = {
590 hackname = alpha___extern_prefix_sys_stat;
591 files = sys/stat.h;
592 files = sys/mount.h;
593 select = "#[ \t]*if[ \t]*defined\\(__DECC\\)";
594
595 mach = "alpha*-dec-osf5*";
596 c_fix = format;
597 c_fix_arg = "%0 || defined(__PRAGMA_EXTERN_PREFIX)";
598
599 test_text = "# if defined(__DECC)";
600 };
601
602
603 /* 912 /*
604 * Fix assert macro in assert.h on Alpha OSF/1. 913 * Fix assert macro in assert.h on Alpha OSF/1.
605 * The superfluous int cast breaks C++. 914 * The superfluous int cast breaks C++.
606 */ 915 */
607 fix = { 916 fix = {
611 c_fix = format; 920 c_fix = format;
612 c_fix_arg = "%1(EX)"; 921 c_fix_arg = "%1(EX)";
613 test_text = '#define assert(EX) (((int) (EX)) ? (void)0 ' 922 test_text = '#define assert(EX) (((int) (EX)) ? (void)0 '
614 ': __assert(#EX, __FILE__, __LINE__))'; 923 ': __assert(#EX, __FILE__, __LINE__))';
615 }; 924 };
616
617
618 /*
619 * Fix #defines under Alpha OSF/1:
620 * The following files contain '#pragma extern_prefix "_FOO"' followed by
621 * a '#define something(x,y,z) _FOOsomething(x,y,z)'. The intent of these
622 * statements is to reduce namespace pollution. While these macros work
623 * properly in most cases, they don't allow you to take a pointer to the
624 * "something" being modified. To get around this limitation, change these
625 * statements to be of the form '#define something _FOOsomething'.
626 *
627 * sed ain't egrep, lesson 2463: sed can use self-referential
628 * regular expressions. In the substitute expression below,
629 * "\\1" and "\\2" refer to subexpressions found earlier in the
630 * same match. So, we continue to use sed. "extern_prefix" will
631 * be a rare match anyway...
632 */
633 fix = {
634 hackname = alpha_bad_lval;
635
636 select = "^[ \t]*#[ \t]*pragma[ \t]+extern_prefix";
637 mach = "alpha*-dec-osf*";
638
639 sed =
640 "s/^[ \t]*#[ \t]*define[ \t][ \t]*\\([^(]*\\)\\(([^)]*)\\)[ \t]*"
641 "\\(_.*\\)\\1\\2[ \t]*$/#define \\1 \\3\\1/";
642
643 test_text = '#pragma extern_prefix "_FOO"'"\n"
644 "#define something(x,y,z) _FOOsomething(x,y,z)\n"
645 "#define mumble _FOOmumble";
646 };
647
648 925
649 /* 926 /*
650 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX. 927 * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
651 */ 928 */
652 fix = { 929 fix = {
657 c_fix = format; 934 c_fix = format;
658 c_fix_arg = "getopt(int, char *const[], const char *)"; 935 c_fix_arg = "getopt(int, char *const[], const char *)";
659 test_text = 'extern int getopt(int, char *[], char *);'; 936 test_text = 'extern int getopt(int, char *[], char *);';
660 }; 937 };
661 938
662
663 /* 939 /*
664 * Fix missing semicolon on Alpha OSF/4 in <net/if.h> 940 * Fix missing semicolon on Alpha OSF/4 in <net/if.h>
665 */ 941 */
666 fix = { 942 fix = {
667 hackname = alpha_if_semicolon; 943 hackname = alpha_if_semicolon;
670 c_fix = format; 946 c_fix = format;
671 c_fix_arg = "struct sockaddr vmif_paddr;\t/*"; 947 c_fix_arg = "struct sockaddr vmif_paddr;\t/*";
672 test_text = ' struct sockaddr vmif_paddr /* protocol address */'; 948 test_text = ' struct sockaddr vmif_paddr /* protocol address */';
673 }; 949 };
674 950
675
676 /* 951 /*
677 * Remove erroneous parentheses in sym.h on Alpha OSF/1. 952 * Remove erroneous parentheses in sym.h on Alpha OSF/1.
678 */ 953 */
679 fix = { 954 fix = {
680 hackname = alpha_parens; 955 hackname = alpha_parens;
683 c_fix = format; 958 c_fix = format;
684 c_fix_arg = "#ifndef __mips64"; 959 c_fix_arg = "#ifndef __mips64";
685 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif"; 960 test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
686 }; 961 };
687 962
688
689 /*
690 * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX <pthread.h>.
691 */
692 fix = {
693 hackname = alpha_pthread;
694 files = pthread.h;
695 select = "((#[ \t]*if)([ \t]*defined[ \t]*\\(_PTHREAD_ENV_DECC\\)"
696 "|def _PTHREAD_ENV_DECC)(.*))\n"
697 "(#[ \t]*define _PTHREAD_USE_PTDNAM_)";
698
699 mach = "alpha*-dec-osf*";
700 c_fix = format;
701 c_fix_arg = "%2 defined (_PTHREAD_ENV_DECC)%4 "
702 "|| defined (__PRAGMA_EXTERN_PREFIX)\n%5";
703
704 test_text = "# if defined (_PTHREAD_ENV_DECC) "
705 "|| defined (_PTHREAD_ENV_EPCC)\n"
706 "# define _PTHREAD_USE_PTDNAM_\n"
707 "# endif\n"
708 "# ifdef _PTHREAD_ENV_DECC\n"
709 "# define _PTHREAD_USE_PTDNAM_\n"
710 "# endif";
711 };
712
713
714 /*
715 * Recognize GCC in Tru64 UNIX V5.1B <pthread.h>.
716 */
717 fix = {
718 hackname = alpha_pthread_gcc;
719 files = pthread.h;
720 select = "#else\n# error <pthread.h>: unrecognized compiler.";
721
722 mach = "alpha*-dec-osf*";
723 c_fix = format;
724 c_fix_arg = "#elif defined (__GNUC__)\n"
725 "# define _PTHREAD_ENV_GCC\n"
726 "%0";
727
728 test_text = "# define _PTHREAD_ENV_INTELC\n"
729 "#else\n"
730 "# error <pthread.h>: unrecognized compiler.\n"
731 "#endif";
732 };
733
734
735 /*
736 * Compaq Tru64 v5.1 defines all of its PTHREAD_*_INITIALIZER macros
737 * incorrectly, specifying less fields in the initializers than are
738 * defined in the corresponding structure types. Use of these macros
739 * in user code results in spurious warnings.
740 */
741 fix = {
742 hackname = alpha_pthread_init;
743 files = pthread.h;
744 select = ' \* @\(#\).RCSfile: pthread\.h,v \$'
745 ' .Revision: 1\.1\.33\.21 \$ \(DEC\)'
746 ' .Date: 2000/08/15 15:30:13 \$';
747 mach = "alpha*-dec-osf*";
748 sed = "s@MVALID\\(.*\\)A}@MVALID\\1A, 0, 0, 0, 0, 0, 0 }@\n"
749 "s@MVALID\\(.*\\)_}@MVALID\\1_, 0, 0, 0, 0 }@\n"
750 "s@CVALID\\(.*\\)A}@CVALID\\1A, 0, 0, 0, 0 }@\n"
751 "s@CVALID\\(.*\\)_}@CVALID\\1_, 0, 0 }@\n"
752 "s@WVALID\\(.*\\)A}@WVALID\\1A, 0, 0, 0, 0, 0, 0, 0, 0, 0 }@\n"
753 "s@WVALID\\(.*\\)_}@WVALID\\1_, 0, 0, 0, 0, 0, 0, 0 }@\n";
754 test_text = <<- _EOText_
755 /*
756 * @(#)_RCSfile: pthread.h,v $ _Revision: 1.1.33.21 $ (DEC) _Date: 2000/08/15 15:30:13 $
757 */
758 #ifndef _PTHREAD_NOMETER_STATIC
759 # define PTHREAD_MUTEX_INITIALIZER \
760 {_PTHREAD_MSTATE_CONFIG, _PTHREAD_MVALID | _PTHREAD_MVF_STA}
761 # define PTHREAD_COND_INITIALIZER \
762 {_PTHREAD_CSTATE_SLOW, _PTHREAD_CVALID | _PTHREAD_CVF_STA}
763 # define PTHREAD_MUTEX_INITWITHNAME_NP(_n_,_a_) \
764 {_PTHREAD_MSTATE_CONFIG, _PTHREAD_MVALID | _PTHREAD_MVF_STA, _n_, _a_}
765 # define PTHREAD_COND_INITWITHNAME_NP(_n_,_a_) \
766 {_PTHREAD_CSTATE_SLOW, _PTHREAD_CVALID | _PTHREAD_CVF_STA, _n_, _a_}
767 #else
768 # define PTHREAD_MUTEX_INITIALIZER {0, _PTHREAD_MVALID | _PTHREAD_MVF_STA}
769 # define PTHREAD_MUTEX_INITWITHNAME_NP(_n_,_a_) \
770 {0, _PTHREAD_MVALID | _PTHREAD_MVF_STA, _n_, _a_}
771 # define PTHREAD_COND_INITWITHNAME_NP(_n_,_a_) \
772 {0, _PTHREAD_CVALID | _PTHREAD_CVF_STA, _n_, _a_}
773 #endif
774
775 #define PTHREAD_RWLOCK_INITIALIZER {_PTHREAD_RWVALID | _PTHREAD_RWVF_STA}
776 #define PTHREAD_RWLOCK_INITWITHNAME_NP(_n_,_a_) \
777 {_PTHREAD_RWVALID | _PTHREAD_RWVF_STA, _n_, _a_}
778 _EOText_;
779 };
780
781
782 /* 963 /*
783 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0 964 * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
784 * And OpenBSD. 965 * And OpenBSD.
785 */ 966 */
786 fix = { 967 fix = {
789 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\("; 970 select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
790 c_fix = format; 971 c_fix = format;
791 c_fix_arg = "void *sbrk("; 972 c_fix_arg = "void *sbrk(";
792 test_text = "extern char* sbrk(ptrdiff_t increment);"; 973 test_text = "extern char* sbrk(ptrdiff_t increment);";
793 }; 974 };
794
795 975
796 /* 976 /*
797 * For C++, avoid any typedef or macro definition of bool, 977 * For C++, avoid any typedef or macro definition of bool,
798 * and use the built in type instead. 978 * and use the built in type instead.
799 * HP/UX 10.20 also has it in curses_colr/curses.h. 979 * HP/UX 10.20 also has it in curses_colr/curses.h.
813 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*"; 993 c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
814 994
815 test_text = "# define bool\t char \n"; 995 test_text = "# define bool\t char \n";
816 }; 996 };
817 997
818 998 /*
999 * avoid_bool_type
1000 */
819 fix = { 1001 fix = {
820 hackname = avoid_bool_type; 1002 hackname = avoid_bool_type;
821 files = curses.h; 1003 files = curses.h;
822 files = curses_colr/curses.h; 1004 files = curses_colr/curses.h;
823 files = term.h; 1005 files = term.h;
829 c_fix = format; 1011 c_fix = format;
830 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif"; 1012 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
831 1013
832 test_text = "typedef unsigned int\tbool \t; /* bool\n type */"; 1014 test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
833 }; 1015 };
834
835 1016
836 /* 1017 /*
837 * For C++, avoid any typedef definition of wchar_t, 1018 * For C++, avoid any typedef definition of wchar_t,
838 * and use the built in type instead. 1019 * and use the built in type instead.
839 * Don't do this for headers that are smart enough to do the right 1020 * Don't do this for headers that are smart enough to do the right
854 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif"; 1035 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
855 1036
856 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */"; 1037 test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
857 }; 1038 };
858 1039
859
860 /* 1040 /*
861 * Fix `typedef struct term;' on hppa1.1-hp-hpux9. 1041 * Fix `typedef struct term;' on hppa1.1-hp-hpux9.
862 */ 1042 */
863 fix = { 1043 fix = {
864 hackname = bad_struct_term; 1044 hackname = bad_struct_term;
868 c_fix_arg = "struct term;"; 1048 c_fix_arg = "struct term;";
869 1049
870 test_text = 'typedef struct term;'; 1050 test_text = 'typedef struct term;';
871 }; 1051 };
872 1052
873
874 /* 1053 /*
875 * Fix one other error in this file: 1054 * Fix one other error in this file:
876 * a mismatched quote not inside a C comment. 1055 * a mismatched quote not inside a C comment.
877 */ 1056 */
878 fix = { 1057 fix = {
882 c_fix = format; 1061 c_fix = format;
883 c_fix_arg = "does not"; 1062 c_fix_arg = "does not";
884 1063
885 test_text = "/* doesn't have matched single quotes */"; 1064 test_text = "/* doesn't have matched single quotes */";
886 }; 1065 };
887
888 1066
889 /* 1067 /*
890 * check for broken assert.h that needs stdio.h 1068 * check for broken assert.h that needs stdio.h
891 */ 1069 */
892 fix = { 1070 fix = {
896 bypass = "include.*stdio\\.h"; 1074 bypass = "include.*stdio\\.h";
897 c_fix = wrap; 1075 c_fix = wrap;
898 c_fix_arg = "#include <stdio.h>\n"; 1076 c_fix_arg = "#include <stdio.h>\n";
899 test_text = "extern FILE* stderr;"; 1077 test_text = "extern FILE* stderr;";
900 }; 1078 };
901
902 1079
903 /* 1080 /*
904 * check for broken assert.h that needs stdlib.h 1081 * check for broken assert.h that needs stdlib.h
905 */ 1082 */
906 fix = { 1083 fix = {
913 "#include <stdlib.h>\n" 1090 "#include <stdlib.h>\n"
914 "#endif\n"; 1091 "#endif\n";
915 test_text = "extern void exit ( int );"; 1092 test_text = "extern void exit ( int );";
916 }; 1093 };
917 1094
918
919 /* 1095 /*
920 * Remove `extern double cabs' declarations from math.h. 1096 * Remove `extern double cabs' declarations from math.h.
921 * This conflicts with C99. Discovered on AIX. 1097 * This conflicts with C99. Discovered on AIX.
922 * IRIX 5 and IRIX 6 before 6.5.18 (where C99 support was introduced)
923 * declares cabs() to take a struct __cabs_s argument.
924 * SunOS4 has its cabs() declaration followed by a comment which
925 * terminates on the following line.
926 * Darwin hides its broken cabs in architecture-specific subdirs. 1098 * Darwin hides its broken cabs in architecture-specific subdirs.
927 */ 1099 */
928 fix = { 1100 fix = {
929 hackname = broken_cabs; 1101 hackname = broken_cabs;
930 files = math.h, "architecture/*/math.h"; 1102 files = math.h, "architecture/*/math.h";
936 test_text = "#ifdef __STDC__\n" 1108 test_text = "#ifdef __STDC__\n"
937 "extern double cabs(struct dbl_hypot);\n" 1109 "extern double cabs(struct dbl_hypot);\n"
938 "#else\n" 1110 "#else\n"
939 "extern double cabs();\n" 1111 "extern double cabs();\n"
940 "#endif\n" 1112 "#endif\n"
941 "extern double cabs ( _Complex z );\n" 1113 "extern double cabs ( _Complex z );";
942 "extern double cabs(); /* This is a comment\n" 1114 };
943 " and it ends here. */\n"
944 "extern double cabs(struct __cabs_s);\n"
945 "extern long double cabsl( struct __cabsl_s );";
946 };
947
948 1115
949 /* 1116 /*
950 * Fixup Darwin's broken check for __builtin_nanf. 1117 * Fixup Darwin's broken check for __builtin_nanf.
951 */ 1118 */
952 fix = { 1119 fix = {
957 * of a test file to play with. It would be a nuisance to have a directory 1124 * of a test file to play with. It would be a nuisance to have a directory
958 * with the name "*". 1125 * with the name "*".
959 */ 1126 */
960 files = "architecture/ppc/math.h"; 1127 files = "architecture/ppc/math.h";
961 files = "architecture/*/math.h"; 1128 files = "architecture/*/math.h";
962 select = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)"; 1129 select = '#if defined\(__APPLE_CC__\) && \(__APPLE_CC__ >= 1345\)';
963 bypass = "powl"; 1130 bypass = "powl";
964 c_fix = format; 1131 c_fix = format;
965 c_fix_arg = "#if 1"; 1132 c_fix_arg = "#if 1";
966 test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)"; 1133 test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
967 }; 1134 };
968
969 1135
970 /* 1136 /*
971 * Various systems derived from BSD4.4 contain a macro definition 1137 * Various systems derived from BSD4.4 contain a macro definition
972 * for vfscanf that interacts badly with requirements of builtin-attrs.def. 1138 * for vfscanf that interacts badly with requirements of builtin-attrs.def.
973 * Known to be fixed in FreeBSD 5 system headers. 1139 * Known to be fixed in FreeBSD 5 system headers.
983 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n" 1149 '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
984 'int vfscanf(FILE *, const char *, __builtin_va_list) ' 1150 'int vfscanf(FILE *, const char *, __builtin_va_list) '
985 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");'; 1151 '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
986 test_text = '#define vfscanf __svfscanf'; 1152 test_text = '#define vfscanf __svfscanf';
987 }; 1153 };
988
989 1154
990 /* 1155 /*
991 * Fix various macros used to define ioctl numbers. 1156 * Fix various macros used to define ioctl numbers.
992 * The traditional syntax was: 1157 * The traditional syntax was:
993 * 1158 *
1016 */ 1181 */
1017 test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n"; 1182 test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
1018 test_text = "#define _CTRL(c) ('c'&037)"; 1183 test_text = "#define _CTRL(c) ('c'&037)";
1019 }; 1184 };
1020 1185
1186 /*
1187 * Fix various macros used to define ioctl numbers.
1188 */
1021 fix = { 1189 fix = {
1022 hackname = ctrl_quotes_use; 1190 hackname = ctrl_quotes_use;
1023 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']"; 1191 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
1024 c_fix = char_macro_use; 1192 c_fix = char_macro_use;
1025 c_fix_arg = "CTRL"; 1193 c_fix_arg = "CTRL";
1026 test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)"; 1194 test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
1027 }; 1195 };
1028
1029 1196
1030 /* 1197 /*
1031 * sys/mman.h on HP/UX is not C++ ready, 1198 * sys/mman.h on HP/UX is not C++ ready,
1032 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX. 1199 * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
1033 * 1200 *
1052 "}\n" 1219 "}\n"
1053 "#endif\n"; 1220 "#endif\n";
1054 test_text = "extern void* malloc( size_t );"; 1221 test_text = "extern void* malloc( size_t );";
1055 }; 1222 };
1056 1223
1224 /*
1225 * macOS 10.12 <AvailabilityInternal.h> uses __attribute__((availability))
1226 * unconditionally.
1227 */
1228 fix = {
1229 hackname = darwin_availabilityinternal;
1230 mach = "*-*-darwin*";
1231 files = AvailabilityInternal.h;
1232 select = "#define[ \t]+(__API_[ADU]\\([^)]*\\)).*";
1233 c_fix = format;
1234 c_fix_arg = <<- _EOFix_
1235 #if defined(__has_attribute)
1236 #if __has_attribute(availability)
1237 %0
1238 #else
1239 #define %1
1240 #endif
1241 #else
1242 #define %1
1243 #endif
1244 _EOFix_;
1245
1246 test_text = "#define __API_A(x) __attribute__((availability(__API_AVAILABLE_PLATFORM_##x)))\n"
1247 "#define __API_D(msg,x) __attribute__((availability(__API_DEPRECATED_PLATFORM_##x,message=msg)))";
1248 };
1249
1250 /*
1251 * For the AAB_darwin7_9_long_double_funcs fix to be useful,
1252 * you have to not use "" includes.
1253 */
1254 fix = {
1255 hackname = darwin_9_long_double_funcs_2;
1256 mach = "*-*-darwin7.9*";
1257 files = math.h;
1258 select = '#include[ \t]+\"';
1259 c_fix = format;
1260 c_fix_arg = "%1<%2.h>";
1261
1262 c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
1263
1264 test_text = '#include "architecture/ppc/math.h"';
1265 };
1057 1266
1058 /* 1267 /*
1059 * On darwin8 and earlier, mach-o/swap.h isn't properly guarded 1268 * On darwin8 and earlier, mach-o/swap.h isn't properly guarded
1060 * by 'extern "C"'. On darwin7 some mach/ headers aren't properly guarded. 1269 * by 'extern "C"'. On darwin7 some mach/ headers aren't properly guarded.
1061 */ 1270 */
1078 "}\n" 1287 "}\n"
1079 "#endif\n"; 1288 "#endif\n";
1080 test_text = "extern void swap_fat_header();\n"; 1289 test_text = "extern void swap_fat_header();\n";
1081 }; 1290 };
1082 1291
1083
1084 /* 1292 /*
1085 * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of 1293 * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of
1086 * bad __GNUC__ tests. 1294 * bad __GNUC__ tests.
1087 */ 1295 */
1088
1089 fix = { 1296 fix = {
1090 hackname = darwin_gcc4_breakage; 1297 hackname = darwin_gcc4_breakage;
1091 mach = "*-*-darwin*"; 1298 mach = "*-*-darwin*";
1092 files = AvailabilityMacros.h; 1299 files = AvailabilityMacros.h;
1093 select = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)"; 1300 select = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
1095 c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))"; 1302 c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
1096 test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && " 1303 test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
1097 "(__GNUC_MINOR__ >= 1)\n"; 1304 "(__GNUC_MINOR__ >= 1)\n";
1098 }; 1305 };
1099 1306
1307 /*
1308 * Before Mac OS X 10.8 <i386/setjmp.h> doesn't mark longjump noreturn.
1309 */
1310 fix = {
1311 hackname = darwin_longjmp_noreturn;
1312 mach = "*-*-darwin*";
1313 files = "i386/setjmp.h";
1314 bypass = "__dead2";
1315 select = "(.*longjmp\\(.*jmp_buf.*[^)]+\\));";
1316 c_fix = format;
1317 c_fix_arg = "%1 __attribute__ ((__noreturn__));";
1318
1319 test_text = "void siglongjmp(sigjmp_buf, int);";
1320 };
1321
1322 /*
1323 * Mac OS X 10.11 <os/trace.h> uses attribute on function definition.
1324 */
1325 fix = {
1326 hackname = darwin_os_trace_1;
1327 mach = "*-*-darwin*";
1328 files = os/trace.h;
1329 select = "^(_os_trace_verify_printf.*) (__attribute__.*)";
1330 c_fix = format;
1331 c_fix_arg = "%1";
1332 test_text = "_os_trace_verify_printf(const char *msg, ...) __attribute__((format(printf, 1, 2)))";
1333 };
1334
1335 /*
1336 * Mac OS X 10.1[012] <os/trace.h> os_trace_payload_t typedef uses Blocks
1337 * extension without guard.
1338 */
1339 fix = {
1340 hackname = darwin_os_trace_2;
1341 mach = "*-*-darwin*";
1342 files = os/trace.h;
1343 select = "typedef.*\\^os_trace_payload_t.*";
1344 c_fix = format;
1345 c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1346 test_text = "typedef void (^os_trace_payload_t)(xpc_object_t xdict);";
1347 };
1348
1349 /*
1350 * In Mac OS X 10.1[012] <os/trace.h>, need to guard users of
1351 * os_trace_payload_t typedef, too.
1352 */
1353 fix = {
1354 hackname = darwin_os_trace_3;
1355 mach = "*-*-darwin*";
1356 files = os/trace.h;
1357 select = <<- _EOSelect_
1358 __(API|OSX)_.*
1359 OS_EXPORT.*
1360 .*
1361 _os_trace.*os_trace_payload_t payload);
1362 _EOSelect_;
1363 c_fix = format;
1364 c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1365 test_text = <<- _EOText_
1366 __API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(8.0))
1367 OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
1368 void
1369 _os_trace_with_buffer(void *dso, const char *message, uint8_t type, const void *buffer, size_t buffer_size, os_trace_payload_t payload);
1370
1371 __OSX_AVAILABLE_STARTING(__MAC_10_12, __IPHONE_10_0)
1372 OS_EXPORT OS_NOTHROW
1373 void
1374 _os_trace_internal(void *dso, uint8_t type, const char *format, const uint8_t *buf, size_t buf_size, os_trace_payload_t payload);
1375 _EOText_;
1376 };
1100 1377
1101 /* 1378 /*
1102 * __private_extern__ doesn't exist in FSF GCC. Even if it did, 1379 * __private_extern__ doesn't exist in FSF GCC. Even if it did,
1103 * why would you ever put it in a system header file? 1380 * why would you ever put it in a system header file?
1104 */ 1381 */
1113 test_text = "__private_extern__ int _dyld_func_lookup(\n" 1390 test_text = "__private_extern__ int _dyld_func_lookup(\n"
1114 "const char *dyld_func_name,\n" 1391 "const char *dyld_func_name,\n"
1115 "unsigned long *address);\n"; 1392 "unsigned long *address);\n";
1116 }; 1393 };
1117 1394
1118
1119 /* 1395 /*
1120 * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to 1396 * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
1121 * unsigned constants. 1397 * unsigned constants.
1122 */ 1398 */
1123 fix = { 1399 fix = {
1129 select = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n" 1405 select = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n"
1130 "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)"; 1406 "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)";
1131 test_text = "#define UINT8_C(v) (v ## U)\n" 1407 test_text = "#define UINT8_C(v) (v ## U)\n"
1132 "#define UINT16_C(v) (v ## U)"; 1408 "#define UINT16_C(v) (v ## U)";
1133 }; 1409 };
1134
1135 1410
1136 /* 1411 /*
1137 * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX 1412 * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
1138 * with wrong types. 1413 * with wrong types.
1139 */ 1414 */
1163 "#define INTPTR_MIN INT32_MIN\n" 1438 "#define INTPTR_MIN INT32_MIN\n"
1164 "#define INTPTR_MAX INT32_MAX\n" 1439 "#define INTPTR_MAX INT32_MAX\n"
1165 "#endif"; 1440 "#endif";
1166 }; 1441 };
1167 1442
1168
1169 /* 1443 /*
1170 * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type. 1444 * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
1171 */ 1445 */
1172 fix = { 1446 fix = {
1173 hackname = darwin_stdint_3; 1447 hackname = darwin_stdint_3;
1189 "#else\n" 1463 "#else\n"
1190 "#define UINTPTR_MAX UINT32_MAX\n" 1464 "#define UINTPTR_MAX UINT32_MAX\n"
1191 "#endif"; 1465 "#endif";
1192 }; 1466 };
1193 1467
1194
1195 /* 1468 /*
1196 * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type. 1469 * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
1197 */ 1470 */
1198 fix = { 1471 fix = {
1199 hackname = darwin_stdint_4; 1472 hackname = darwin_stdint_4;
1214 "#define SIZE_MAX UINT64_MAX\n" 1487 "#define SIZE_MAX UINT64_MAX\n"
1215 "#else\n" 1488 "#else\n"
1216 "#define SIZE_MAX UINT32_MAX\n" 1489 "#define SIZE_MAX UINT32_MAX\n"
1217 "#endif"; 1490 "#endif";
1218 }; 1491 };
1219
1220 1492
1221 /* 1493 /*
1222 * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX} 1494 * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX}
1223 * with a wrong type. 1495 * with a wrong type.
1224 */ 1496 */
1243 test_text = "#define INTMAX_MIN INT64_MIN\n" 1515 test_text = "#define INTMAX_MIN INT64_MIN\n"
1244 "#define INTMAX_MAX INT64_MAX\n" 1516 "#define INTMAX_MAX INT64_MAX\n"
1245 "\n" 1517 "\n"
1246 "#define UINTMAX_MAX UINT64_MAX"; 1518 "#define UINTMAX_MAX UINT64_MAX";
1247 }; 1519 };
1248
1249 1520
1250 /* 1521 /*
1251 * Darwin headers have a stdint.h that defines {U,}INTMAX_C 1522 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1252 * with a wrong type. 1523 * with a wrong type.
1253 */ 1524 */
1277 "#define PTRDIFF_MIN INT32_MIN\n" 1548 "#define PTRDIFF_MIN INT32_MIN\n"
1278 "#define PTRDIFF_MAX INT32_MAX\n" 1549 "#define PTRDIFF_MAX INT32_MAX\n"
1279 "#endif"; 1550 "#endif";
1280 }; 1551 };
1281 1552
1282
1283 /* 1553 /*
1284 * Darwin headers have a stdint.h that defines {U,}INTMAX_C 1554 * Darwin headers have a stdint.h that defines {U,}INTMAX_C
1285 * with a wrong type. 1555 * with a wrong type.
1286 */ 1556 */
1287 fix = { 1557 fix = {
1300 "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)"; 1570 "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)";
1301 test_text = "#define INTMAX_C(v) (v ## LL)\n" 1571 test_text = "#define INTMAX_C(v) (v ## LL)\n"
1302 "#define UINTMAX_C(v) (v ## ULL)"; 1572 "#define UINTMAX_C(v) (v ## ULL)";
1303 }; 1573 };
1304 1574
1305
1306 /* 1575 /*
1307 * Fix <c_asm.h> on Digital UNIX V4.0: 1576 * Fix <c_asm.h> on Digital UNIX V4.0:
1308 * It contains a prototype for a DEC C internal asm() function, 1577 * It contains a prototype for a DEC C internal asm() function,
1309 * clashing with gcc's asm keyword. So protect this with __DECC. 1578 * clashing with gcc's asm keyword. So protect this with __DECC.
1310 */ 1579 */
1318 "float fasm {\n" 1587 "float fasm {\n"
1319 " ... asm stuff ...\n" 1588 " ... asm stuff ...\n"
1320 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/"; 1589 "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
1321 }; 1590 };
1322 1591
1323
1324 /* 1592 /*
1325 * Fix typo in <wchar.h> on DJGPP 2.03. 1593 * Fix typo in <wchar.h> on DJGPP 2.03.
1326 */ 1594 */
1327 fix = { 1595 fix = {
1328 hackname = djgpp_wchar_h; 1596 hackname = djgpp_wchar_h;
1334 c_fix_arg = "#include <stddef.h>"; 1602 c_fix_arg = "#include <stddef.h>";
1335 test_text = "#include <stddef.h>\n" 1603 test_text = "#include <stddef.h>\n"
1336 "extern __DJ_wint_t x;\n"; 1604 "extern __DJ_wint_t x;\n";
1337 }; 1605 };
1338 1606
1339
1340 /* 1607 /*
1341 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef. 1608 * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
1342 */ 1609 */
1343 fix = { 1610 fix = {
1344 hackname = ecd_cursor; 1611 hackname = ecd_cursor;
1349 c_fix_arg = 'ecd_cursor'; 1616 c_fix_arg = 'ecd_cursor';
1350 1617
1351 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */"; 1618 test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
1352 }; 1619 };
1353 1620
1621 /*
1622 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1623 * that fails when compiling for SSE-less 32-bit x86.
1624 */
1625 fix = {
1626 hackname = feraiseexcept_nosse_divbyzero;
1627 mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
1628 files = bits/fenv.h, '*/bits/fenv.h';
1629 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %1, %0 *\" : "
1630 ": \"x\" \\(__f\\), \"x\" \\(__g\\)\\);$";
1631 bypass = "\"fdivp .*; fwait\"";
1632
1633 c_fix = format;
1634 c_fix_arg = <<- _EOText_
1635 # ifdef __SSE_MATH__
1636 %0
1637 # else
1638 %1__asm__ __volatile__ ("fdivp %%%%st, %%%%st(1); fwait"
1639 %1 : "=t" (__f) : "0" (__f), "u" (__g) : "st(1)");
1640 # endif
1641 _EOText_;
1642
1643 test_text = <<- _EOText_
1644 __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g));
1645 _EOText_;
1646 };
1647
1648 /*
1649 * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
1650 * that fails when compiling for SSE-less 32-bit x86.
1651 */
1652 fix = {
1653 hackname = feraiseexcept_nosse_invalid;
1654 mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
1655 files = bits/fenv.h, '*/bits/fenv.h';
1656 select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %0, %0 *\" : "
1657 ": \"x\" \\(__f\\)\\);$";
1658 bypass = "\"fdiv .*; fwait\"";
1659
1660 c_fix = format;
1661 c_fix_arg = <<- _EOText_
1662 # ifdef __SSE_MATH__
1663 %0
1664 # else
1665 %1__asm__ __volatile__ ("fdiv %%%%st, %%%%st(0); fwait"
1666 %1 : "=t" (__f) : "0" (__f));
1667 # endif
1668 _EOText_;
1669
1670 test_text = <<- _EOText_
1671 __asm__ __volatile__ ("divss %0, %0" : : "x" (__f));
1672 _EOText_;
1673 };
1354 1674
1355 /* 1675 /*
1356 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume 1676 * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
1357 * neither the existence of GCC 3 nor its exact feature set yet break 1677 * neither the existence of GCC 3 nor its exact feature set yet break
1358 * (by design?) when __GNUC__ is set beyond 2. 1678 * (by design?) when __GNUC__ is set beyond 2.
1366 c_fix = format; 1686 c_fix = format;
1367 c_fix_arg = '%0 || __GNUC__ >= 3'; 1687 c_fix_arg = '%0 || __GNUC__ >= 3';
1368 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7'; 1688 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
1369 }; 1689 };
1370 1690
1371
1372 /* 1691 /*
1373 * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume 1692 * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
1374 * neither the existence of GCC 4 nor its exact feature set yet break 1693 * neither the existence of GCC 4 nor its exact feature set yet break
1375 * (by design?) when __GNUC__ is set beyond 3. 1694 * (by design?) when __GNUC__ is set beyond 3.
1376 */ 1695 */
1381 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$'; 1700 select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$';
1382 c_fix = format; 1701 c_fix = format;
1383 c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3'; 1702 c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3';
1384 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3'; 1703 test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
1385 }; 1704 };
1386
1387 1705
1388 /* 1706 /*
1389 * Some versions of glibc don't expect the C99 inline semantics. 1707 * Some versions of glibc don't expect the C99 inline semantics.
1390 */ 1708 */
1391 fix = { 1709 fix = {
1400 # define __USE_EXTERN_INLINES 1 1718 # define __USE_EXTERN_INLINES 1
1401 #endif 1719 #endif
1402 EOT; 1720 EOT;
1403 }; 1721 };
1404 1722
1405
1406 /* 1723 /*
1407 * Similar, but a version that didn't have __NO_INLINE__ 1724 * Similar, but a version that didn't have __NO_INLINE__
1408 */ 1725 */
1409 fix = { 1726 fix = {
1410 hackname = glibc_c99_inline_1a; 1727 hackname = glibc_c99_inline_1a;
1417 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ 1734 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
1418 # define __USE_EXTERN_INLINES 1 1735 # define __USE_EXTERN_INLINES 1
1419 #endif 1736 #endif
1420 EOT; 1737 EOT;
1421 }; 1738 };
1422
1423 1739
1424 /* 1740 /*
1425 * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately 1741 * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately
1426 * there are many glibc headers which do not respect __USE_EXTERN_INLINES. 1742 * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
1427 * The remaining glibc_c99_inline_* fixes deal with some of those headers. 1743 * The remaining glibc_c99_inline_* fixes deal with some of those headers.
1454 __NTH (fstat64 (int __fd, struct stat64 *__statbuf)) 1770 __NTH (fstat64 (int __fd, struct stat64 *__statbuf))
1455 {} 1771 {}
1456 EOT; 1772 EOT;
1457 }; 1773 };
1458 1774
1459 1775 /*
1776 * glibc_c99_inline_3
1777 */
1460 fix = { 1778 fix = {
1461 hackname = glibc_c99_inline_3; 1779 hackname = glibc_c99_inline_3;
1462 files = bits/string2.h, '*/bits/string2.h'; 1780 files = bits/string2.h, '*/bits/string2.h';
1463 select = "extern __inline"; 1781 select = "extern __inline";
1464 bypass = "__extern_inline|__GNU_STDC_INLINE__"; 1782 bypass = "__extern_inline|__GNU_STDC_INLINE__";
1472 # define __STRING_INLINE extern __inline 1790 # define __STRING_INLINE extern __inline
1473 # endif 1791 # endif
1474 EOT; 1792 EOT;
1475 }; 1793 };
1476 1794
1477 1795 /*
1796 * glibc_c99_inline_4
1797 */
1478 fix = { 1798 fix = {
1479 hackname = glibc_c99_inline_4; 1799 hackname = glibc_c99_inline_4;
1480 files = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h'; 1800 files = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h',
1801 pthread.h, '*/pthread.h';
1481 bypass = "__extern_inline|__gnu_inline__"; 1802 bypass = "__extern_inline|__gnu_inline__";
1482 select = "(^| )extern __inline"; 1803 select = "(^| )extern __inline";
1483 c_fix = format; 1804 c_fix = format;
1484 c_fix_arg = "%0 __attribute__ ((__gnu_inline__))"; 1805 c_fix_arg = "%0 __attribute__ ((__gnu_inline__))";
1485 test_text = <<-EOT 1806 test_text = <<-EOT
1486 __extension__ extern __inline unsigned int 1807 __extension__ extern __inline unsigned int
1487 extern __inline unsigned int 1808 extern __inline unsigned int
1488 EOT; 1809 EOT;
1489 }; 1810 };
1490
1491 1811
1492 /* glibc-2.3.5 defines pthread mutex initializers incorrectly, 1812 /* glibc-2.3.5 defines pthread mutex initializers incorrectly,
1493 * so we replace them with versions that correspond to the 1813 * so we replace them with versions that correspond to the
1494 * definition. 1814 * definition.
1495 */ 1815 */
1560 # endif 1880 # endif
1561 #define PTHREAD_COND_INITIALIZER { { 0, } } 1881 #define PTHREAD_COND_INITIALIZER { { 0, } }
1562 _EOText_; 1882 _EOText_;
1563 }; 1883 };
1564 1884
1565
1566 /* glibc versions before 2.5 have a version of stdint.h that defines 1885 /* glibc versions before 2.5 have a version of stdint.h that defines
1567 UINT8_C and UINT16_C to produce unsigned constants, as do uClibc 1886 UINT8_C and UINT16_C to produce unsigned constants, as do uClibc
1568 versions with stdint.h based on those glibc versions. */ 1887 versions with stdint.h based on those glibc versions. */
1569 fix = { 1888 fix = {
1570 hackname = glibc_stdint; 1889 hackname = glibc_stdint;
1571 files = stdint.h; 1890 files = stdint.h;
1572 select = "GNU C Library"; 1891 select = "GNU C Library";
1573 c_fix = format; 1892 c_fix = format;
1574 c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc"; 1893 c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
1575 c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U"; 1894 c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
1576 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"; 1895 test_text = "/* This file is part of the GNU C Library. */\n"
1577 }; 1896 "# define UINT8_C(c)\tc ## U\n"
1578 1897 "# define UINT16_C(c)\tc ## U";
1898 };
1579 1899
1580 /* Some versions of glibc have a version of bits/string2.h that 1900 /* Some versions of glibc have a version of bits/string2.h that
1581 produces "value computed is not used" warnings from strncpy; fix 1901 produces "value computed is not used" warnings from strncpy; fix
1582 this definition by using __builtin_strncpy instead as in newer 1902 this definition by using __builtin_strncpy instead as in newer
1583 versions. */ 1903 versions. */
1584 fix = { 1904 fix = {
1585 hackname = glibc_strncpy; 1905 hackname = glibc_strncpy;
1586 files = bits/string2.h; 1906 files = bits/string2.h, '*/bits/string2.h';
1587 bypass = "__builtin_strncpy"; 1907 bypass = "__builtin_strncpy";
1588 c_fix = format; 1908 c_fix = format;
1589 c_fix_arg = "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)"; 1909 c_fix_arg = "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
1590 c_fix_arg = "# define strncpy([^\n]*\\\\\n)*[^\n]*"; 1910 c_fix_arg = "# define strncpy([^\n]*\\\\\n)*[^\n]*";
1591 test_text = <<-EOT 1911 test_text = <<-EOT
1606 hackname = glibc_tgmath; 1926 hackname = glibc_tgmath;
1607 files = tgmath.h; 1927 files = tgmath.h;
1608 select = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)'; 1928 select = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
1609 bypass = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type"; 1929 bypass = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
1610 c_fix = format; 1930 c_fix = format;
1611 c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || (__builtin_classify_type ((type) 0) == 9 && __builtin_classify_type (__real__ ((type) 0)) == 8))"; 1931 c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || "
1932 "(__builtin_classify_type ((type) 0) == 9 && "
1933 "__builtin_classify_type (__real__ ((type) 0)) == 8))";
1612 test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))"; 1934 test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
1613 }; 1935 };
1614 1936
1615 /* 1937 /*
1616 * Fix these files to use the types we think they should for 1938 * Fix these files to use the types we think they should for
1638 test_text = "typedef long int ptrdiff_t; /* long int */\n" 1960 test_text = "typedef long int ptrdiff_t; /* long int */\n"
1639 "typedef uint_t size_t; /* uint_t */\n" 1961 "typedef uint_t size_t; /* uint_t */\n"
1640 "typedef ushort_t wchar_t; /* ushort_t */"; 1962 "typedef ushort_t wchar_t; /* ushort_t */";
1641 }; 1963 };
1642 1964
1643
1644 /* 1965 /*
1645 * Fix HP & Sony's use of "../machine/xxx.h" 1966 * Fix HP & Sony's use of "../machine/xxx.h"
1646 * to refer to: <machine/xxx.h> 1967 * to refer to: <machine/xxx.h>
1647 */ 1968 */
1648 fix = { 1969 fix = {
1658 '([a-z]+)\.h"'; 1979 '([a-z]+)\.h"';
1659 1980
1660 test_text = ' # include "../machine/mumble.h"'; 1981 test_text = ' # include "../machine/mumble.h"';
1661 }; 1982 };
1662 1983
1663
1664 /* 1984 /*
1665 * Check for (...) in C++ code in HP/UX sys/file.h. 1985 * Check for (...) in C++ code in HP/UX sys/file.h.
1666 */ 1986 */
1667 fix = { 1987 fix = {
1668 hackname = hp_sysfile; 1988 hackname = hp_sysfile;
1673 c_fix_arg = "(struct file *, ...)"; 1993 c_fix_arg = "(struct file *, ...)";
1674 c_fix_arg = '\(\.\.\.\)'; 1994 c_fix_arg = '\(\.\.\.\)';
1675 1995
1676 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */"; 1996 test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
1677 }; 1997 };
1678
1679 1998
1680 /* 1999 /*
1681 * Un-Hide a series of five FP defines from post-1999 compliance GCC: 2000 * Un-Hide a series of five FP defines from post-1999 compliance GCC:
1682 * FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN 2001 * FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN
1683 */ 2002 */
1707 "# define FP_ZERO 1\n" 2026 "# define FP_ZERO 1\n"
1708 "# define FP_INFINITE 2\n" 2027 "# define FP_INFINITE 2\n"
1709 "# define FP_SUBNORMAL 3\n" 2028 "# define FP_SUBNORMAL 3\n"
1710 "# define FP_NAN 4\n"; 2029 "# define FP_NAN 4\n";
1711 }; 2030 };
1712
1713 2031
1714 /* 2032 /*
1715 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11 2033 * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
1716 * math.h to prevent clash with define in c_std/bits/std_cmath.h. 2034 * math.h to prevent clash with define in c_std/bits/std_cmath.h.
1717 */ 2035 */
1756 " inline double pow(double d,int expon) {\n" 2074 " inline double pow(double d,int expon) {\n"
1757 " return pow(d, (double)expon);\n" 2075 " return pow(d, (double)expon);\n"
1758 " }\n"; 2076 " }\n";
1759 }; 2077 };
1760 2078
1761
1762 /* 2079 /*
1763 * Fix hpux 10.X missing ctype declarations 1 2080 * Fix hpux 10.X missing ctype declarations 1
1764 */ 2081 */
1765 fix = { 2082 fix = {
1766 hackname = hpux10_ctype_declarations1; 2083 hackname = hpux10_ctype_declarations1;
1777 "#endif /* _PROTOTYPES */\n\n" 2094 "#endif /* _PROTOTYPES */\n\n"
1778 "%0\n"; 2095 "%0\n";
1779 2096
1780 test_text = "# define _toupper(__c) __toupper(__c)\n"; 2097 test_text = "# define _toupper(__c) __toupper(__c)\n";
1781 }; 2098 };
1782
1783 2099
1784 /* 2100 /*
1785 * Fix hpux 10.X missing ctype declarations 2 2101 * Fix hpux 10.X missing ctype declarations 2
1786 */ 2102 */
1787 fix = { 2103 fix = {
1819 2135
1820 test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n" 2136 test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
1821 " extern unsigned int *__SB_masks;\n"; 2137 " extern unsigned int *__SB_masks;\n";
1822 }; 2138 };
1823 2139
1824
1825 /* 2140 /*
1826 * Fix hpux 10.X missing stdio declarations 2141 * Fix hpux 10.X missing stdio declarations
1827 */ 2142 */
1828 fix = { 2143 fix = {
1829 hackname = hpux10_stdio_declarations; 2144 hackname = hpux10_stdio_declarations;
1841 "# endif /* __STDC__) || __cplusplus */\n"; 2156 "# endif /* __STDC__) || __cplusplus */\n";
1842 2157
1843 test_text = "# define _iob __iob\n"; 2158 test_text = "# define _iob __iob\n";
1844 }; 2159 };
1845 2160
2161 /*
2162 * The HP-UX stddef.h is replaced by gcc's. It doesn't include sys/stdsyms.h.
2163 * As a result, we need to include sys/stdsyms.h in alloca.h.
2164 */
2165 fix = {
2166 hackname = hppa_hpux11_alloca;
2167 mach = "hppa*-*-hpux11*";
2168 files = alloca.h;
2169 select = "#ifndef _STDDEF_INCLUDED";
2170 c_fix = format;
2171 c_fix_arg = "#ifndef _SYS_STDSYMS_INCLUDED\n"
2172 "# include <sys/stdsyms.h>\n"
2173 "#endif /* _SYS_STDSYMS_INCLUDED */\n\n"
2174 "%0";
2175
2176 test_text = "#ifndef _STDDEF_INCLUDED";
2177 };
1846 2178
1847 /* 2179 /*
1848 * Make sure hpux defines abs in header. 2180 * Make sure hpux defines abs in header.
1849 */ 2181 */
1850 fix = { 2182 fix = {
1851 hackname = hpux11_abs; 2183 hackname = hpux11_abs;
1852 mach = "ia64-hp-hpux11*"; 2184 mach = "*-hp-hpux11*";
1853 files = stdlib.h; 2185 files = stdlib.h;
1854 select = "ifndef _MATH_INCLUDED"; 2186 select = "ifndef _MATH_INCLUDED";
1855 c_fix = format; 2187 c_fix = format;
1856 c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)"; 2188 c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
1857 test_text = "#ifndef _MATH_INCLUDED"; 2189 test_text = "#ifndef _MATH_INCLUDED";
1858 }; 2190 };
1859 2191
2192 /*
2193 * Fix hpux11 __LWP_RWLOCK_VALID define
2194 */
2195 fix = {
2196 hackname = hpux11_lwp_rwlock_valid;
2197 mach = "*-hp-hpux11*";
2198 files = sys/pthread.h;
2199 select = "#define __LWP_RWLOCK_VALID[ \t]*0x8c91";
2200 c_fix = format;
2201 c_fix_arg = "#define __LWP_RWLOCK_VALID -29551";
2202 test_text = "#define __LWP_RWLOCK_VALID 0x8c91";
2203 };
2204
2205 /*
2206 * hpux sendfile()
2207 */
2208 fix = {
2209 hackname = hpux11_extern_sendfile;
2210 mach = "*-hp-hpux11.[12]*";
2211 files = sys/socket.h;
2212 select = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
2213 c_fix = format;
2214 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2215 test_text = " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n"
2216 " const struct iovec *, int));\n";
2217 };
2218
2219 /*
2220 * hpux sendpath()
2221 */
2222 fix = {
2223 hackname = hpux11_extern_sendpath;
2224 mach = "*-hp-hpux11.[12]*";
2225 files = sys/socket.h;
2226 select = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
2227 c_fix = format;
2228 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2229 test_text = " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n"
2230 " const struct iovec *, int));\n";
2231 };
1860 2232
1861 /* 2233 /*
1862 * Keep HP-UX 11 from stomping on C++ math namespace 2234 * Keep HP-UX 11 from stomping on C++ math namespace
1863 * with defines for fabsf. 2235 * with defines for fabsf.
1864 */ 2236 */
1865 fix = { 2237 fix = {
1866 hackname = hpux11_fabsf; 2238 hackname = hpux11_fabsf;
2239 mach = "*-hp-hpux11*";
1867 files = math.h; 2240 files = math.h;
1868 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*"; 2241 select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
1869 bypass = "__cplusplus";
1870 2242
1871 c_fix = format; 2243 c_fix = format;
1872 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif"; 2244 c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
1873 2245
1874 test_text = 2246 test_text =
1875 "#ifdef _PA_RISC\n" 2247 "#ifdef _PA_RISC\n"
1876 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n" 2248 "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
1877 "#endif"; 2249 "#endif";
1878 }; 2250 };
1879 2251
1880 2252 /*
1881 /* 2253 * The definitions for PTHREAD_MUTEX_INITIALIZER and similar initializers
1882 * Fix C99 constant in __POINTER_SET define. 2254 * in pthread.h need to be constant expressions to be standard complient.
2255 * As a result, we need to remove the void * casts in the initializers
2256 * (see hpux11_pthread_const) and to change the __(M|C|RW)POINTER defines
2257 * to use the long type.
2258 */
2259 fix = {
2260 hackname = hpux11_pthread_pointer;
2261 mach = "*-hp-hpux11.[0-3]*";
2262 files = sys/pthread.h;
2263 select = "(void[ \t]*\\*)(m|c|rw)(_ptr)";
2264
2265 c_fix = format;
2266 c_fix_arg = "long\t%2%3";
2267 test_text = "#define __MPOINTER\t\tvoid\t *m_ptr";
2268 };
2269
2270 /*
2271 * Remove void pointer cast and fix C99 constant in __POINTER_SET defines.
1883 */ 2272 */
1884 fix = { 2273 fix = {
1885 hackname = hpux11_pthread_const; 2274 hackname = hpux11_pthread_const;
1886 mach = "*-hp-hpux11.[0-3]*"; 2275 mach = "*-hp-hpux11.[0-3]*";
1887 files = sys/pthread.h; 2276 files = sys/pthread.h;
1888 select = "^#define[ \t]*__POINTER_SET[ \t]*\\(\\(void \\*\\) 1LL\\)"; 2277 select = "^(#define[ \t]+__POINTER_SET[ \t0,]*)(.*\\))";
1889 2278
1890 c_fix = format; 2279 c_fix = format;
1891 c_fix_arg = "#define __POINTER_SET\t\t((void *) 1L)"; 2280 c_fix_arg = "%11";
1892 test_text = "#define __POINTER_SET\t\t((void *) 1LL)"; 2281 test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
1893 }; 2282 };
1894
1895 2283
1896 /* 2284 /*
1897 * Prevent HP-UX 11 from defining __size_t and preventing size_t from 2285 * Prevent HP-UX 11 from defining __size_t and preventing size_t from
1898 * being defined by having it define _hpux_size_t instead. 2286 * being defined by having it define _hpux_size_t instead.
1899 */ 2287 */
1907 2295
1908 test_text = 2296 test_text =
1909 "#define __size_t size_t\n" 2297 "#define __size_t size_t\n"
1910 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n"; 2298 " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
1911 }; 2299 };
1912
1913 2300
1914 /* 2301 /*
1915 * Fix hpux 11.00 broken snprintf declaration 2302 * Fix hpux 11.00 broken snprintf declaration
1916 * (third argument is char *, needs to be const char * to prevent 2303 * (third argument is char *, needs to be const char * to prevent
1917 * spurious warnings with -Wwrite-strings or in C++). 2304 * spurious warnings with -Wwrite-strings or in C++).
1942 2329
1943 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,' 2330 test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
1944 ' __va__list);'; 2331 ' __va__list);';
1945 }; 2332 };
1946 2333
2334 /*
2335 * Fix missing const in hpux vsscanf declaration
2336 */
2337 fix = {
2338 hackname = hpux_vsscanf;
2339 mach = "*-*-hpux*";
2340 files = stdio.h;
2341 select = '(extern int vsscanf\()char';
2342 c_fix = format;
2343 c_fix_arg = "%1const char";
2344
2345 test_text = 'extern int vsscanf(char *, const char *, __va_list);';
2346 };
1947 2347
1948 /* 2348 /*
1949 * get rid of bogus inline definitions in HP-UX 8.0 2349 * get rid of bogus inline definitions in HP-UX 8.0
1950 */ 2350 */
1951 fix = { 2351 fix = {
1960 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@"; 2360 sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
1961 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n" 2361 test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
1962 "inline double sqr(double v) { return v**0.5; }"; 2362 "inline double sqr(double v) { return v**0.5; }";
1963 }; 2363 };
1964 2364
2365 /*
2366 * hpux intptr
2367 */
2368 fix = {
2369 hackname = hpux_c99_intptr;
2370 mach = "*-hp-hpux11.3*";
2371 files = stdint-hpux11.h, stdint.h;
2372 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*"
2373 "INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
2374 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*"
2375 "INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2376 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*"
2377 "INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
2378 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*"
2379 "INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
2380 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*"
2381 "UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
2382 sed = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*"
2383 "UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
2384 test_text = "#define PTRDIFF_MAX INT32_MAX\n"
2385 "#define PTRDIFF_MIN INT32_MIN\n"
2386 "#define INTPTR_MAX INT32_MAX\n"
2387 "#define INTPTR_MIN INT32_MIN\n"
2388 "#define UINTPTR_MAX UINT32_MAX\n"
2389 "#define SIZE_MAX UINT32_MAX\n";
2390 };
2391
2392 /*
2393 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2394 */
2395 fix = {
2396 hackname = hpux_c99_inttypes;
2397 mach = "*-hp-hpux11.[23]*";
2398 files = inttypes.h;
2399 files = stdint-hpux11.h, stdint.h;
2400 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2401 "__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
2402 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2403 "__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
2404 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*"
2405 "__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
2406 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@"
2407 "#define UINT32_C(__c) __CONCAT__(__c,u)@";
2408 test_text = "#define UINT8_C(__c) __CONCAT_U__(__c)\n"
2409 "#define UINT16_C(__c) __CONCAT_U__(__c)\n"
2410 "#define INT32_C(__c) __CONCAT__(__c,l)\n"
2411 "#define UINT32_C(__c) __CONCAT__(__c,ul)\n";
2412 };
2413
2414 /*
2415 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2416 */
2417 fix = {
2418 hackname = hpux_c99_inttypes2;
2419 mach = "*-hp-hpux11.2*";
2420 files = stdint-hpux11.h, stdint.h;
2421 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*"
2422 "((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
2423 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
2424 "((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
2425 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*"
2426 "((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
2427 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
2428 "((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
2429 test_text = "# define INT8_C(__c) ((signed char)(__c))\n"
2430 "# define UINT8_C(__c) ((unsigned char)(__c))\n"
2431 "# define INT16_C(__c) ((short)(__c))\n"
2432 "# define UINT16_C(__c) ((unsigned short)(__c))\n";
2433 };
1965 2434
1966 /* 2435 /*
1967 * Fix hpux broken ctype macros 2436 * Fix hpux broken ctype macros
1968 */ 2437 */
1969 fix = { 2438 fix = {
1976 2445
1977 test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n" 2446 test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
1978 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n"; 2447 "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
1979 }; 2448 };
1980 2449
2450 /*
2451 * hpux errno()
2452 */
2453 fix = {
2454 hackname = hpux_extern_errno;
2455 mach = "*-hp-hpux10.*";
2456 mach = "*-hp-hpux11.[0-2]*";
2457 files = errno.h;
2458 select = "^[ \t]*extern int errno;$";
2459 c_fix = format;
2460 c_fix_arg = "#ifdef __cplusplus\n"
2461 "extern \"C\" {\n"
2462 "#endif\n"
2463 "%0\n"
2464 "#ifdef __cplusplus\n"
2465 "}\n"
2466 "#endif";
2467 test_text = " extern int errno;\n";
2468 };
1981 2469
1982 /* 2470 /*
1983 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc. 2471 * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
1984 */ 2472 */
1985 fix = { 2473 fix = {
2004 "#define htons(x) (x)\n" 2492 "#define htons(x) (x)\n"
2005 "#endif\n" 2493 "#endif\n"
2006 "#endif /* ! _XOPEN_SOURCE_EXTENDED */"; 2494 "#endif /* ! _XOPEN_SOURCE_EXTENDED */";
2007 }; 2495 };
2008 2496
2497 /*
2498 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2499 */
2500 fix = {
2501 hackname = hpux_imaginary_i;
2502 mach = "ia64-hp-hpux11.*";
2503 files = complex.h;
2504 select = "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*";
2505 c_fix = format;
2506 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
2507 test_text = "#define _Complex_I (0.f+_Imaginary_I)\n";
2508 };
2509
2510 /*
2511 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2512 */
2513 fix = {
2514 hackname = hpux_inttype_int8_t;
2515 mach = "*-hp-hpux1[01].*";
2516 files = sys/_inttypes.h;
2517 select = "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*";
2518 c_fix = format;
2519 c_fix_arg = "typedef signed char int%18_t;";
2520 test_text = "typedef char int_least8_t;\n"
2521 "typedef char int8_t;\n";
2522 };
2009 2523
2010 /* 2524 /*
2011 * HP-UX long_double 2525 * HP-UX long_double
2012 */ 2526 */
2013 fix = { 2527 fix = {
2027 " } long_double;\n" 2541 " } long_double;\n"
2028 "# endif /* _LONG_DOUBLE */\n" 2542 "# endif /* _LONG_DOUBLE */\n"
2029 "extern long_double strtold(const char *, char **);\n"; 2543 "extern long_double strtold(const char *, char **);\n";
2030 }; 2544 };
2031 2545
2032 /* 2546 /*
2033 * We cannot use the above rule on 11.31 because it removes the strtold 2547 * We cannot use the above rule on 11.31 because it removes the strtold
2034 * definition. ia64 is OK with no hack, PA needs some help. 2548 * definition. ia64 is OK with no hack, PA needs some help.
2035 */ 2549 */
2036 fix = { 2550 fix = {
2037 hackname = hpux_long_double_2; 2551 hackname = hpux_long_double_2;
2038 mach = "hppa*-*-hpux11.3*"; 2552 mach = "hppa*-*-hpux11.3*";
2039 files = stdlib.h; 2553 files = stdlib.h;
2040 select = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| defined\\(_PROTOTYPES\\) \\|\\| defined\\(_LONG_DOUBLE_STRUCT\\)"; 2554 select = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| "
2555 "defined\\(_PROTOTYPES\\) \\|\\| "
2556 "defined\\(_LONG_DOUBLE_STRUCT\\)";
2041 c_fix = format; 2557 c_fix = format;
2042 c_fix_arg = "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)"; 2558 c_fix_arg = "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
2043 2559
2044 test_text = "# if !defined(__ia64) || !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)\n"; 2560 test_text = "# if !defined(__ia64) || "
2045 }; 2561 "!defined(_PROTOTYPES) || "
2046 2562 "defined(_LONG_DOUBLE_STRUCT)\n";
2047 /* 2563 };
2048 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
2049 */
2050 fix = {
2051 hackname = hpux_systime;
2052 files = sys/time.h;
2053 select = "^extern struct sigevent;";
2054
2055 c_fix = format;
2056 c_fix_arg = "struct sigevent;";
2057
2058 test_text = 'extern struct sigevent;';
2059 };
2060
2061
2062 /*
2063 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
2064 * type and mpinfou is only defined when _KERNEL is set.
2065 */
2066 fix = {
2067 hackname = hpux_spu_info;
2068 mach = "*-hp-hpux*";
2069 /*
2070 * It is tempting to omit the first "files" entry. Do not.
2071 * The testing machinery will take the first "files" entry as the name
2072 * of a test file to play with. It would be a nuisance to have a directory
2073 * with the name "*".
2074 */
2075 files = "ia64/sys/getppdp.h";
2076 files = "*/sys/getppdp.h";
2077 select = "^.*extern.*spu_info.*";
2078
2079 c_fix = format;
2080 c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
2081
2082 test_text = "extern union mpinfou spu_info[];";
2083 };
2084
2085 fix = {
2086 hackname = hpux11_extern_sendfile;
2087 mach = "*-hp-hpux11.[12]*";
2088 files = sys/socket.h;
2089 select = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
2090 c_fix = format;
2091 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2092 test_text = " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n const struct iovec *, int));\n";
2093 };
2094
2095 fix = {
2096 hackname = hpux11_extern_sendpath;
2097 mach = "*-hp-hpux11.[12]*";
2098 files = sys/socket.h;
2099 select = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
2100 c_fix = format;
2101 c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
2102 test_text = " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n const struct iovec *, int));\n";
2103 };
2104
2105 fix = {
2106 hackname = hpux_extern_errno;
2107 mach = "*-hp-hpux10.*";
2108 mach = "*-hp-hpux11.[0-2]*";
2109 files = errno.h;
2110 select = "^[ \t]*extern int errno;$";
2111 c_fix = format;
2112 c_fix_arg = "#ifdef __cplusplus\nextern \"C\" {\n#endif\n%0\n#ifdef __cplusplus\n}\n#endif";
2113 test_text = " extern int errno;\n";
2114 };
2115
2116 2564
2117 /* 2565 /*
2118 * Add missing braces to pthread initializer defines. 2566 * Add missing braces to pthread initializer defines.
2119 */ 2567 */
2120 fix = { 2568 fix = {
2154 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n" 2602 "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
2155 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n" 2603 "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
2156 "}\n"; 2604 "}\n";
2157 }; 2605 };
2158 2606
2159 fix = { 2607 /*
2160 hackname = hpux_c99_intptr; 2608 * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
2161 mach = "*-hp-hpux11.3*"; 2609 * type and mpinfou is only defined when _KERNEL is set.
2162 files = stdint-hpux11.h, stdint.h; 2610 */
2163 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@"; 2611 fix = {
2164 sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@"; 2612 hackname = hpux_spu_info;
2165 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@"; 2613 mach = "*-hp-hpux*";
2166 sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@"; 2614 /*
2167 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@"; 2615 * It is tempting to omit the first "files" entry. Do not.
2168 sed = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@"; 2616 * The testing machinery will take the first "files" entry as the name
2169 test_text = "#define PTRDIFF_MAX INT32_MAX\n" 2617 * of a test file to play with. It would be a nuisance to have a directory
2170 "#define PTRDIFF_MIN INT32_MIN\n" 2618 * with the name "*".
2171 "#define INTPTR_MAX INT32_MAX\n" 2619 */
2172 "#define INTPTR_MIN INT32_MIN\n" 2620 files = "ia64/sys/getppdp.h";
2173 "#define UINTPTR_MAX UINT32_MAX\n" 2621 files = "*/sys/getppdp.h";
2174 "#define SIZE_MAX UINT32_MAX\n"; 2622 select = "^.*extern.*spu_info.*";
2623
2624 c_fix = format;
2625 c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
2626
2627 test_text = "extern union mpinfou spu_info[];";
2175 }; 2628 };
2176 2629
2177 /* 2630 /*
2178 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31. 2631 * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
2179 */ 2632 */
2180
2181 fix = {
2182 hackname = hpux_c99_inttypes;
2183 mach = "*-hp-hpux11.[23]*";
2184 files = inttypes.h;
2185 files = stdint-hpux11.h, stdint.h;
2186 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
2187 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
2188 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
2189 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@#define UINT32_C(__c) __CONCAT__(__c,u)@";
2190 test_text = "#define UINT8_C(__c) __CONCAT_U__(__c)\n"
2191 "#define UINT16_C(__c) __CONCAT_U__(__c)\n"
2192 "#define INT32_C(__c) __CONCAT__(__c,l)\n"
2193 "#define UINT32_C(__c) __CONCAT__(__c,ul)\n";
2194 };
2195
2196 fix = {
2197 hackname = hpux_c99_inttypes2;
2198 mach = "*-hp-hpux11.2*";
2199 files = stdint-hpux11.h, stdint.h;
2200 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
2201 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
2202 sed = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
2203 sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
2204 test_text = "# define INT8_C(__c) ((signed char)(__c))\n"
2205 "# define UINT8_C(__c) ((unsigned char)(__c))\n"
2206 "# define INT16_C(__c) ((short)(__c))\n"
2207 "# define UINT16_C(__c) ((unsigned short)(__c))\n";
2208 };
2209
2210 fix = { 2633 fix = {
2211 hackname = hpux_stdint_least_fast; 2634 hackname = hpux_stdint_least_fast;
2212 mach = "*-hp-hpux11.2*"; 2635 mach = "*-hp-hpux11.2*";
2213 files = stdint-hpux11.h, stdint.h; 2636 files = stdint-hpux11.h, stdint.h;
2214 select = 2637 select =
2215 "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX"; 2638 "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX";
2216 c_fix = format; 2639 c_fix = format;
2217 c-fix-arg = "# define UINT_%164_MAX __UINT64_MAX__"; 2640 c-fix-arg = "# define UINT_%164_MAX __UINT64_MAX__";
2218 test-text = "# define UINT_FAST64_MAX ULLONG_MAX\n" 2641 test-text = "# define UINT_FAST64_MAX ULLONG_MAX\n"
2219 "# define UINT_LEAST64_MAX ULLONG_MAX\n"; 2642 "# define UINT_LEAST64_MAX ULLONG_MAX\n";
2220 _EOFix_; 2643 };
2221 }; 2644
2222 2645 /*
2223 fix = { 2646 * Add noreturn attribute to longjmp declarations in hpux <setjmp.h>
2224 hackname = hpux_inttype_int8_t; 2647 */
2225 mach = "*-hp-hpux1[01].*"; 2648 fix = {
2226 files = sys/_inttypes.h; 2649 hackname = hpux_longjmp;
2227 select = "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*"; 2650 mach = "*-hp-hpux*";
2228 c_fix = format; 2651 files = setjmp.h;
2229 c_fix_arg = "typedef signed char int%18_t;"; 2652 select = "^[ \t]*extern[ \t]+void[ \t]+.*longjmp[ \t]*\(__\\(\\(.*int\\)\\)|\\(.*int\\)|\\(\\)\)";
2230 test_text = "typedef char int_least8_t;\n" 2653
2231 "typedef char int8_t;\n"; 2654 c_fix = format;
2232 }; 2655 c_fix_arg = "%0 __attribute__ ((__noreturn__))";
2233 2656
2234 fix = { 2657 test_text = 'extern void longjmp __((jmp_buf, int));';
2235 hackname = hpux_imaginary_i; 2658 };
2236 mach = "ia64-hp-hpux11.*"; 2659
2237 files = complex.h; 2660 /*
2238 select = "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*"; 2661 * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
2239 c_fix = format; 2662 */
2240 c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)"; 2663 fix = {
2241 test_text = "#define _Complex_I (0.f+_Imaginary_I)\n"; 2664 hackname = hpux_systime;
2665 files = sys/time.h;
2666 select = "^extern struct sigevent;";
2667
2668 c_fix = format;
2669 c_fix_arg = "struct sigevent;";
2670
2671 test_text = 'extern struct sigevent;';
2242 }; 2672 };
2243 2673
2244 /* 2674 /*
2245 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant 2675 * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
2246 */ 2676 */
2247 fix = { 2677 fix = {
2248 hackname = huge_val_hex; 2678 hackname = huge_val_hex;
2249 files = bits/huge_val.h; 2679 files = bits/huge_val.h, '*/bits/huge_val.h';
2250 select = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*"; 2680 select = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
2251 bypass = "__builtin_huge_val"; 2681 bypass = "__builtin_huge_val";
2252 2682
2253 c_fix = format; 2683 c_fix = format;
2254 c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n"; 2684 c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n";
2255 2685
2256 test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)"; 2686 test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
2257 }; 2687 };
2258 2688
2259
2260 /* 2689 /*
2261 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant 2690 * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
2262 */ 2691 */
2263 fix = { 2692 fix = {
2264 hackname = huge_valf_hex; 2693 hackname = huge_valf_hex;
2265 files = bits/huge_val.h; 2694 files = bits/huge_val.h, '*/bits/huge_val.h';
2266 select = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*"; 2695 select = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
2267 bypass = "__builtin_huge_valf"; 2696 bypass = "__builtin_huge_valf";
2268 2697
2269 c_fix = format; 2698 c_fix = format;
2270 c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n"; 2699 c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n";
2271 2700
2272 test_text = "# define HUGE_VALF (__extension__ 0x1.0p255f)"; 2701 test_text = "# define HUGE_VALF (__extension__ 0x1.0p255f)";
2273 }; 2702 };
2274 2703
2275
2276 /* 2704 /*
2277 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant 2705 * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
2278 */ 2706 */
2279 fix = { 2707 fix = {
2280 hackname = huge_vall_hex; 2708 hackname = huge_vall_hex;
2281 files = bits/huge_val.h; 2709 files = bits/huge_val.h, '*/bits/huge_val.h';
2282 select = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*"; 2710 select = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
2283 bypass = "__builtin_huge_vall"; 2711 bypass = "__builtin_huge_vall";
2284 2712
2285 c_fix = format; 2713 c_fix = format;
2286 c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n"; 2714 c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n";
2287 2715
2288 test_text = "# define HUGE_VALL (__extension__ 0x1.0p32767L)"; 2716 test_text = "# define HUGE_VALL (__extension__ 0x1.0p32767L)";
2289 }; 2717 };
2290
2291 2718
2292 /* 2719 /*
2293 * Fix return type of abort and free 2720 * Fix return type of abort and free
2294 */ 2721 */
2295 fix = { 2722 fix = {
2303 2730
2304 test_text = "extern int abort(int);\n" 2731 test_text = "extern int abort(int);\n"
2305 "extern int free(void*);\n" 2732 "extern int free(void*);\n"
2306 "extern int exit(void*);"; 2733 "extern int exit(void*);";
2307 }; 2734 };
2308
2309 2735
2310 /* 2736 /*
2311 * Fix various macros used to define ioctl numbers. 2737 * Fix various macros used to define ioctl numbers.
2312 * The traditional syntax was: 2738 * The traditional syntax was:
2313 * 2739 *
2335 "#define _IO(x,y) ('x'<<8|y)"; 2761 "#define _IO(x,y) ('x'<<8|y)";
2336 test_text = 2762 test_text =
2337 "#define XX_IO(x) ('x'<<8|256)"; 2763 "#define XX_IO(x) ('x'<<8|256)";
2338 }; 2764 };
2339 2765
2766 /*
2767 * Fix the usage of the ioctl macro numbers.
2768 */
2340 fix = { 2769 fix = {
2341 hackname = io_quotes_use; 2770 hackname = io_quotes_use;
2342 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*" 2771 select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
2343 "\\( *[^,']"; 2772 "\\( *[^,']";
2344 c_fix = char_macro_use; 2773 c_fix = char_macro_use;
2345 c_fix_arg = "IO"; 2774 c_fix_arg = "IO";
2346 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n" 2775 test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
2347 "#define TIOCFOO \\\\\n" 2776 "#define TIOCFOO \\\\\n"
2348 "BSD43__IOWR(T, 1) /* Some are multi-line */"; 2777 "BSD43__IOWR(T, 1) /* Some are multi-line */";
2349 }; 2778 };
2350
2351 2779
2352 /* 2780 /*
2353 * Check for missing ';' in struct 2781 * Check for missing ';' in struct
2354 */ 2782 */
2355 fix = { 2783 fix = {
2363 " int x;\n" 2791 " int x;\n"
2364 " }\n" 2792 " }\n"
2365 "}; /* mumbled struct */\n"; 2793 "}; /* mumbled struct */\n";
2366 }; 2794 };
2367 2795
2368
2369 /*
2370 * IRIX 6.5.1[89] <internal/sgimacros.h> unconditionally defines
2371 * __restrict as restrict iff __c99. This is wrong for C++, which
2372 * needs many C99 features, but only supports __restrict.
2373 */
2374 fix = {
2375 hackname = irix___restrict;
2376 files = internal/sgimacros.h;
2377 select = "(#ifdef __c99\n)(#[ \t]*define __restrict restrict)";
2378
2379 mach = "mips-sgi-irix6.5";
2380 c_fix = format;
2381 c_fix_arg = "%1"
2382 "# ifndef __cplusplus\n%2\n# endif";
2383
2384 test_text = "#ifdef __c99\n# define __restrict restrict";
2385 };
2386
2387 /*
2388 * IRIX 6.5.22 <internal/math_core.h> uses the SGI c99 __generic() intrinsic
2389 * to define the fpclasify, isfinite, isinf, isnan, isnormal and signbit
2390 * functions.
2391 *
2392 * This was probably introduced around IRIX 6.5.18
2393 */
2394 fix = {
2395 hackname = irix___generic1;
2396 files = internal/math_core.h;
2397 mach = "mips-sgi-irix6.5";
2398 select = "#define ([a-z]+)\\(x\\) *__generic.*";
2399
2400 c_fix = format;
2401 c_fix_arg = "extern int %1(double);\n"
2402 "extern int %1f(float);\n"
2403 "extern int %1l(long double);\n"
2404 "#define %1(x) (sizeof(x) == sizeof(double) ? _%1(x) \\\n"
2405 " : sizeof(x) == sizeof(float) ? _%1f(x) \\\n"
2406 " : _%1l(x))\n";
2407
2408 test_text =
2409 "#define isnan(x) __generic(x,,, _isnan, _isnanf, _isnanl,,,)(x)\n";
2410 };
2411
2412
2413 /* Likewise <internal/math_core.h> on IRIX 6.5.19 and later uses the SGI
2414 compiler's __generic intrinsic to define isgreater, isgreaterequal,
2415 isless, islessequal, islessgreater and isunordered functions. */
2416 fix = {
2417 hackname = irix___generic2;
2418 files = internal/math_core.h;
2419 mach = "mips-sgi-irix6.5";
2420 select = "#define ([a-z]+)\\(x,y\\) *__generic.*";
2421
2422 c_fix = format;
2423 c_fix_arg = "#define %1(x,y) \\\n"
2424 " ((sizeof(x)<=4 && sizeof(y)<=4) ? _%1f(x,y) \\\n"
2425 " : (sizeof(x)<=8 && sizeof(y)<=8) ? _%1(x,y) \\\n"
2426 " : _%1l(x,y))\n";
2427
2428 test_text =
2429 "#define isless(x,y) __generic(x,y,, _isless, _islessf, _islessl,,,)(x,y)";
2430 };
2431
2432
2433 /*
2434 * IRIX 5.2's <sys/asm.h> contains an asm comment with a contraction
2435 * that causes the assembly preprocessor to complain about an
2436 * unterminated character constant.
2437 */
2438 fix = {
2439 hackname = irix_asm_apostrophe;
2440 files = sys/asm.h;
2441
2442 select = "^[ \t]*#.*[Ww]e're";
2443 c_fix = format;
2444 c_fix_arg = "%1 are";
2445 c_fix_arg = "^([ \t]*#.*[Ww]e)'re";
2446 test_text = "\t# and we're on vacation";
2447 };
2448
2449
2450 /*
2451 * IRIX 6.5 complex.h defines _Complex_I and _Imaginary_I in terms of __I__,
2452 * which is a MIPSpro compiler builtin. Remove _Imaginary_I and imaginary
2453 * definitions which are not supported by GCC.
2454 */
2455 fix = {
2456 hackname = irix_complex;
2457 mach = "mips-sgi-irix6.5";
2458 files = complex.h;
2459 select = "#define[ \t]_Complex_I[ \t]\\(\\(float[ \t]_Complex\\)[ \t]\\(__I__\\)\\)";
2460 sed = "s/#define[ \t]_Complex_I[ \t]((float[ \t]_Complex)[ \t](__I__))/"
2461 "#define _Complex_I (__extension__ 1.0iF)/";
2462 sed = "/#define[ \t]imaginary[ \t]_Imaginary/d";
2463 sed = "/#define[ \t]_Imaginary_I/d";
2464 sed = "s/#define[ \t]I[ \t]_Imaginary_I/#define I _Complex_I/";
2465 test_text = "#define _Complex_I ((float _Complex) (__I__))\n"
2466 "#define imaginary _Imaginary\n"
2467 "// #define _Imaginary_I ((float _Imaginary) 1)\n"
2468 "#define _Imaginary_I __I__\n"
2469 "#define I _Imaginary_I";
2470 };
2471
2472
2473 /* 2796 /*
2474 * Non-traditional "const" declaration in Irix's limits.h. 2797 * Non-traditional "const" declaration in Irix's limits.h.
2475 */ 2798 */
2476 fix = { 2799 fix = {
2477 hackname = irix_limits_const; 2800 hackname = irix_limits_const;
2480 c_fix = format; 2803 c_fix = format;
2481 c_fix_arg = "extern __const "; 2804 c_fix_arg = "extern __const ";
2482 test_text = "extern const char limit; /* test limits */"; 2805 test_text = "extern const char limit; /* test limits */";
2483 }; 2806 };
2484 2807
2485 2808 /*
2486 /* 2809 * IRIX 5.x's stdio.h declares some functions that take a va_list as
2487 * IRIX 6.5 PTHREAD_*_INITIALIZER need an additional level of braces in
2488 * <pthread.h>.
2489 */
2490 fix = {
2491 hackname = irix_pthread_init;
2492 files = pthread.h;
2493 select = "^(#define[ \t]+PTHREAD_.*_INITIALIZER[ \t]+)(\\{ 0 \\})";
2494
2495 mach = "mips-sgi-irix6.5";
2496 c_fix = format;
2497 c_fix_arg = "%1{ %2 }";
2498 test_text = "#define PTHREAD_MUTEX_INITIALIZER { 0 }\n"
2499 "#define PTHREAD_COND_INITIALIZER { 0 }\n"
2500 "#define PTHREAD_RWLOCK_INITIALIZER { 0 }";
2501 };
2502
2503
2504 /*
2505 * IRIX 6.5.1[78] <sys/socket.h> has a broken definition of socklen_t.
2506 * Various socket function prototypes use different types instead,
2507 * depending on the API in use (BSD, XPG4/5), but the socklen_t
2508 * definition doesn't reflect this (SGI Bug Id 864477, fixed in
2509 * IRIX 6.5.19).
2510 */
2511 fix = {
2512 hackname = irix_socklen_t;
2513 files = sys/socket.h;
2514 select = "(#define _SOCKLEN_T\n)(typedef u_int32_t socklen_t;)";
2515
2516 mach = "mips-sgi-irix6.5";
2517 c_fix = format;
2518 c_fix_arg = "%1"
2519 "#if _NO_XOPEN4 && _NO_XOPEN5\n"
2520 "typedef int socklen_t;\n"
2521 "#else\n"
2522 "%2\n"
2523 "#endif /* _NO_XOPEN4 && _NO_XOPEN5 */";
2524
2525 test_text = "#define _SOCKLEN_T\ntypedef u_int32_t socklen_t;";
2526 };
2527
2528 /*
2529 * IRIX 6.5 <stdint.h> only works with ISO C99 and errors out
2530 * otherwise.
2531 */
2532 fix = {
2533 hackname = irix_stdint_c99_mode;
2534 files = stdint.h;
2535 select = "(#ifndef __c99\n)(#error This header file is to be used only for c99 mode compilations)";
2536
2537 mach = "mips-sgi-irix6.5";
2538 c_fix = format;
2539 c_fix_arg = "#if 0\n"
2540 "%2";
2541 test_text =
2542 "#ifndef __c99\n#error This header file is to be used only for c99 mode compilations\n#else";
2543 };
2544
2545
2546 /*
2547 * IRIX 6.5 <stdint.h> has some *_MIN/MAX constants whose types don't
2548 * match the corresponding types, as required by ISO C99.
2549 */
2550 fix = {
2551 hackname = irix_stdint_c99_types;
2552 files = stdint-irix65.h, stdint.h;
2553 mach = "mips-sgi-irix6.5";
2554 sed = "s@^#define INT64_MIN.*(-0x7fffffffffffffff - 1)$@"
2555 "#define INT64_MIN (-0x7fffffffffffffffLL - 1)@";
2556 sed = "s@^#define INT64_MAX.*0x7fffffffffffffff$@"
2557 "#define INT64_MAX 0x7fffffffffffffffLL@";
2558 sed = "s@^#define UINT32_MAX.*0xffffffff$@"
2559 "#define UINT32_MAX 0xffffffffU@";
2560 sed = "s@^#define UINT64_MAX.*0xffffffffffffffff$@"
2561 "#define UINT64_MAX 0xffffffffffffffffULL@";
2562 sed = "s@^#define INTPTR_MIN.*INT32_MIN$@"
2563 "#define INTPTR_MIN (-0x7fffffffL - 1)@";
2564 sed = "s@^#define INTPTR_MAX.*INT32_MAX$@"
2565 "#define INTPTR_MAX 0x7fffffffL@";
2566 sed = "s@^#define UINTPTR_MAX.*UINT32_MAX$@"
2567 "#define UINTPTR_MAX 0xffffffffUL@";
2568 sed = "s@^#define INTPTR_MIN.*INT64_MIN@"
2569 "#define INTPTR_MIN (-0x7fffffffffffffffL - 1)@";
2570 sed = "s@^#define INTPTR_MAX.*INT64_MAX$@"
2571 "#define INTPTR_MAX 0x7fffffffffffffffL@";
2572 sed = "s@^#define UINTPTR_MAX.*UINT64_MAX$@"
2573 "#define UINTPTR_MAX 0xffffffffffffffffUL@";
2574 sed = "s@^#define PTRDIFF_MIN.*INT64_MIN$@"
2575 "#define PTRDIFF_MIN (-0x7fffffffffffffffL - 1)@";
2576 sed = "s@^#define PTRDIFF_MAX.*INT64_MAX$@"
2577 "#define PTRDIFF_MAX 0x7fffffffffffffffL@";
2578 sed = "s@^#define SIZE_MAX.*UINT64_MAX$@"
2579 "#define SIZE_MAX 0xffffffffffffffffUL@";
2580 test_text = "#define INT64_MIN (-0x7fffffffffffffff - 1)\n"
2581 "#define INT64_MAX 0x7fffffffffffffff\n"
2582 "#define UINT32_MAX 0xffffffff\n"
2583 "#define UINT64_MAX 0xffffffffffffffff\n"
2584 "#define INTPTR_MIN INT32_MIN\n"
2585 "#define INTPTR_MAX INT32_MAX\n"
2586 "#define UINTPTR_MAX UINT32_MAX\n"
2587 "#define INTPTR_MIN INT64_MIN\n"
2588 "#define INTPTR_MAX INT64_MAX\n"
2589 "#define UINTPTR_MAX UINT64_MAX\n"
2590 "#define PTRDIFF_MIN INT64_MIN\n"
2591 "#define PTRDIFF_MAX INT64_MAX\n"
2592 "#define SIZE_MAX UINT64_MAX";
2593 };
2594
2595
2596 /*
2597 * IRIX 6.5 <stdint.h> uses casts in some macros which cannot thus be used
2598 * in preprocessor tests, although ISO C99 requires this.
2599 */
2600 fix = {
2601 hackname = irix_stdint_c99_macros;
2602 files = stdint-irix65.h, stdint.h;
2603 mach = "mips-sgi-irix6.5";
2604 sed = "s@^#define INT8_C(x).*int.*_t.*$@#define INT8_C(x) (x)@";
2605 sed = "s@^#define INT16_C(x).*int.*_t.*$@#define INT16_C(x) (x)@";
2606 sed = "s@^#define INT32_C(x).*int.*_t.*$@#define INT32_C(x) (x)@";
2607 sed = "s@^#define INT64_C(x).*int.*_t.*$@#define INT64_C(x) (x ## LL)@";
2608 sed = "s@^#define UINT8_C(x).*int.*_t.*$@#define UINT8_C(x) (x)@";
2609 sed = "s@^#define UINT16_C(x).*int.*_t.*$@#define UINT16_C(x) (x)@";
2610 sed = "s@^#define UINT32_C(x).*int.*_t.*$@#define UINT32_C(x) (x ## U)@";
2611 sed = "s@^#define UINT64_C(x).*int.*_t.*$@#define UINT64_C(x) (x ## ULL)@";
2612 sed = "s@^#define INTMAX_C(x).*int.*_t.*$@#define INTMAX_C(x) (x ## LL)@";
2613 sed = "s@^#define UINTMAX_C(x).*int.*_t.*$@#define UINTMAX_C(x) (x ## ULL)@";
2614 test_text = "#define INT8_C(x) (int_least8_t)(x)\n"
2615 "#define INT16_C(x) (int_least16_t)(x)\n"
2616 "#define INT32_C(x) (int_least32_t)(x)\n"
2617 "#define INT64_C(x) (int_least64_t)(x)\n"
2618 "#define UINT8_C(x) (uint_least8_t)(x)\n"
2619 "#define UINT16_C(x) (uint_least16_t)(x)\n"
2620 "#define UINT32_C(x) (uint_least32_t)(x)\n"
2621 "#define UINT64_C(x) (uint_least64_t)(x)\n"
2622 "#define INTMAX_C(x) (intmax_t)(x)\n"
2623 "#define UINTMAX_C(x) (uintmax_t)(x)";
2624 };
2625
2626
2627 /*
2628 * IRIX 5.x's stdio.h and IRIX 6.5's internal/stdio_core.h declare
2629 * some functions that take a va_list as
2630 * taking char *. However, GCC uses void * for va_list, so 2810 * taking char *. However, GCC uses void * for va_list, so
2631 * calling vfprintf with a va_list fails in C++. */ 2811 * calling vfprintf with a va_list fails in C++. */
2632 fix = { 2812 fix = {
2633 hackname = irix_stdio_va_list; 2813 hackname = irix_stdio_va_list;
2634 files = stdio.h; 2814 files = stdio.h;
2635 files = internal/stdio_core.h;
2636 2815
2637 select = '/\* va_list \*/ char \*'; 2816 select = '/\* va_list \*/ char \*';
2638 c_fix = format; 2817 c_fix = format;
2639 c_fix_arg = "__gnuc_va_list"; 2818 c_fix_arg = "__gnuc_va_list";
2640 test_text = 2819 test_text =
2641 "extern int printf( const char *, /* va_list */ char * );"; 2820 "extern int printf( const char *, /* va_list */ char * );";
2642 }; 2821 };
2643
2644
2645 /*
2646 * IRIX 6.5.19 <internal/wchar_core.h> provides the XPG4 variant of
2647 * wcsftime by default. ISO C99 requires the XPG5 variant instead.
2648 */
2649 fix = {
2650 hackname = irix_wcsftime;
2651 files = internal/wchar_core.h;
2652 select = "#if _NO_XOPEN5\n(extern size_t[ \t]+wcsftime.*const char \*.*)";
2653
2654 mach = "mips-sgi-irix6.5";
2655 c_fix = format;
2656 c_fix_arg = "#if _NO_XOPEN5 && !defined(__c99)\n%1";
2657
2658 test_text = "#if _NO_XOPEN5\n"
2659 "extern size_t wcsftime(wchar_t *, "
2660 "__SGI_LIBC_NAMESPACE_QUALIFIER size_t, const char *, "
2661 "const struct tm *);";
2662 };
2663
2664 2822
2665 /* 2823 /*
2666 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3 2824 * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
2667 * use / * * / to concatenate tokens. 2825 * use / * * / to concatenate tokens.
2668 */ 2826 */
2684 c_fix = format; 2842 c_fix = format;
2685 c_fix_arg = '##'; 2843 c_fix_arg = '##';
2686 test_text = "#define __CONCAT__(a,b) a/**/b"; 2844 test_text = "#define __CONCAT__(a,b) a/**/b";
2687 }; 2845 };
2688 2846
2689 2847 /*
2690 /* The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines 2848 * The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
2691 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time 2849 * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
2692 * constant on recent versions of g++. 2850 * constant on recent versions of g++.
2693 */ 2851 */
2694 fix = { 2852 fix = {
2695 hackname = linux_ia64_ucontext; 2853 hackname = linux_ia64_ucontext;
2701 c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)"; 2859 c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
2702 test_text = "# define _SC_GR0_OFFSET\t\\\\\n" 2860 test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
2703 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n"; 2861 "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
2704 }; 2862 };
2705 2863
2706
2707 /* 2864 /*
2708 * Remove header file warning from sys/time.h. Autoconf's 2865 * Remove header file warning from sys/time.h. Autoconf's
2709 * AC_HEADER_TIME recommends to include both sys/time.h and time.h 2866 * AC_HEADER_TIME recommends to include both sys/time.h and time.h
2710 * which causes warning on LynxOS. Remove the warning. 2867 * which causes warning on LynxOS. Remove the warning.
2711 */ 2868 */
2715 select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>"; 2872 select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
2716 c_fix = format; 2873 c_fix = format;
2717 c_fix_arg = ""; 2874 c_fix_arg = "";
2718 test_text = "#warning Using <time.h> instead of <sys/time.h>"; 2875 test_text = "#warning Using <time.h> instead of <sys/time.h>";
2719 }; 2876 };
2720
2721 2877
2722 /* 2878 /*
2723 * Add missing declaration for putenv. 2879 * Add missing declaration for putenv.
2724 */ 2880 */
2725 fix = { 2881 fix = {
2733 "extern int putenv _AP((char *));"; 2889 "extern int putenv _AP((char *));";
2734 c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);"; 2890 c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
2735 test_text = "extern char *getenv _AP((const char *));"; 2891 test_text = "extern char *getenv _AP((const char *));";
2736 }; 2892 };
2737 2893
2738
2739 /* 2894 /*
2740 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_. 2895 * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
2741 * 2896 *
2742 * On NetBSD, machine is a symbolic link to an architecture specific 2897 * On NetBSD, machine is a symbolic link to an architecture specific
2743 * directory name, so we can't match a specific file name here. 2898 * directory name, so we can't match a specific file name here.
2752 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*"; 2907 c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
2753 2908
2754 test_text = " # define _BSD_VA_LIST_\tchar**"; 2909 test_text = " # define _BSD_VA_LIST_\tchar**";
2755 }; 2910 };
2756 2911
2757
2758 /* 2912 /*
2759 * Fix non-ansi machine name defines 2913 * Fix non-ansi machine name defines
2760 */ 2914 */
2761 fix = { 2915 fix = {
2762 hackname = machine_name; 2916 hackname = machine_name;
2765 2919
2766 test_text = "/* MACH_DIFF: */\n" 2920 test_text = "/* MACH_DIFF: */\n"
2767 "#if defined( i386 ) || defined( sparc ) || defined( vax )" 2921 "#if defined( i386 ) || defined( sparc ) || defined( vax )"
2768 "\n/* no uniform test, so be careful :-) */"; 2922 "\n/* no uniform test, so be careful :-) */";
2769 }; 2923 };
2770
2771 2924
2772 /* 2925 /*
2773 * Some math.h files define struct exception (it's in the System V 2926 * Some math.h files define struct exception (it's in the System V
2774 * Interface Definition), which conflicts with the class exception defined 2927 * Interface Definition), which conflicts with the class exception defined
2775 * in the C++ file std/stdexcept.h. We redefine it to __math_exception. 2928 * in the C++ file std/stdexcept.h. We redefine it to __math_exception.
2779 fix = { 2932 fix = {
2780 hackname = math_exception; 2933 hackname = math_exception;
2781 files = math.h; 2934 files = math.h;
2782 select = "struct exception"; 2935 select = "struct exception";
2783 /* 2936 /*
2784 * This should be bypassed on __cplusplus, but some supposedly C++ C++ 2937 * This should be bypassed on __cplusplus, but some supposedly C++
2785 * aware headers, such as Solaris 8 and 9, don't wrap their struct 2938 * aware headers, such as Solaris 8 and 9, don't wrap their struct
2786 * exception either. So currently we bypass only for glibc, based on a 2939 * exception either. So currently we bypass only for glibc, based on a
2787 * comment in the fixed glibc header. Ick. 2940 * comment in the fixed glibc header. Ick.
2788 */ 2941 */
2789 bypass = 'We have a problem when using C\+\+|for C\+\+, ' 2942 bypass = 'We have a problem when using C\+\+|for C\+\+, '
2790 '_[a-z0-9A-Z_]+_exception; for C, exception'; 2943 '_[a-z0-9A-Z_]+_exception; for C, exception';
2944 /* The Solaris 10 headers already get this right. */
2945 mach = '*-*-solaris2.1[0-9]*';
2946 not_machine = true;
2791 c_fix = wrap; 2947 c_fix = wrap;
2792 2948
2793 c_fix_arg = "#ifdef __cplusplus\n" 2949 c_fix_arg = "#ifdef __cplusplus\n"
2794 "#define exception __math_exception\n" 2950 "#define exception __math_exception\n"
2795 "#endif\n"; 2951 "#endif\n";
2798 "#undef exception\n" 2954 "#undef exception\n"
2799 "#endif\n"; 2955 "#endif\n";
2800 2956
2801 test_text = "typedef struct exception t_math_exception;"; 2957 test_text = "typedef struct exception t_math_exception;";
2802 }; 2958 };
2803
2804 2959
2805 /* 2960 /*
2806 * This looks pretty broken to me. ``dbl_max_def'' will contain 2961 * This looks pretty broken to me. ``dbl_max_def'' will contain
2807 * "define DBL_MAX " at the start, when what we really want is just 2962 * "define DBL_MAX " at the start, when what we really want is just
2808 * the value portion. Can't figure out how to write a test case 2963 * the value portion. Can't figure out how to write a test case
2837 test_text = 2992 test_text =
2838 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n" 2993 "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
2839 "#define HUGE_VAL DBL_MAX"; 2994 "#define HUGE_VAL DBL_MAX";
2840 }; 2995 };
2841 2996
2842
2843 /* 2997 /*
2844 * nested comment 2998 * nested comment
2845 */ 2999 */
2846 fix = { 3000 fix = {
2847 hackname = nested_auth_des; 3001 hackname = nested_auth_des;
2849 select = '(/\*.*rpc/auth_des\.h>.*)/\*'; 3003 select = '(/\*.*rpc/auth_des\.h>.*)/\*';
2850 c_fix = format; 3004 c_fix = format;
2851 c_fix_arg = "%1*/ /*"; 3005 c_fix_arg = "%1*/ /*";
2852 test_text = "/*#include <rpc/auth_des.h> /* skip this */"; 3006 test_text = "/*#include <rpc/auth_des.h> /* skip this */";
2853 }; 3007 };
2854
2855 3008
2856 /* 3009 /*
2857 * Some versions of NetBSD don't expect the C99 inline semantics. 3010 * Some versions of NetBSD don't expect the C99 inline semantics.
2858 */ 3011 */
2859 fix = { 3012 fix = {
2870 "__inline int"; 3023 "__inline int";
2871 3024
2872 test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}"; 3025 test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
2873 }; 3026 };
2874 3027
2875 3028 /*
3029 * netbsd_c99_inline_2
3030 */
2876 fix = { 3031 fix = {
2877 hackname = netbsd_c99_inline_2; 3032 hackname = netbsd_c99_inline_2;
2878 mach = "*-*-netbsd*"; 3033 mach = "*-*-netbsd*";
2879 files = signal.h; 3034 files = signal.h;
2880 select = "#define _SIGINLINE extern __inline"; 3035 select = "#define _SIGINLINE extern __inline";
2889 _EOArg_; 3044 _EOArg_;
2890 3045
2891 test_text = "#define _SIGINLINE extern __inline"; 3046 test_text = "#define _SIGINLINE extern __inline";
2892 }; 3047 };
2893 3048
2894
2895 /* 3049 /*
2896 * NetBSD has a semicolon after the ending '}' for some extern "C". 3050 * NetBSD has a semicolon after the ending '}' for some extern "C".
2897 */ 3051 */
2898 fix = { 3052 fix = {
2899 hackname = netbsd_extra_semicolon; 3053 hackname = netbsd_extra_semicolon;
2905 c_fix_arg = "#define __END_DECLS }"; 3059 c_fix_arg = "#define __END_DECLS }";
2906 3060
2907 test_text = "#define __END_DECLS };"; 3061 test_text = "#define __END_DECLS };";
2908 }; 3062 };
2909 3063
2910 3064 /*
2911 /* newlib's stdint.h has several failures to conform to C99. The fix 3065 * newlib's stdint.h has several failures to conform to C99. The fix
2912 for these removed a comment that can be matched to identify unfixed 3066 * for these removed a comment that can be matched to identify unfixed
2913 versions. */ 3067 * versions.
3068 */
2914 fix = { 3069 fix = {
2915 hackname = newlib_stdint_1; 3070 hackname = newlib_stdint_1;
2916 files = stdint-newlib.h, stdint.h; 3071 files = stdint-newlib.h, stdint.h;
2917 select = "@todo - Add support for wint_t types"; 3072 select = "@todo - Add support for wint_t types";
2918 sed = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@"; 3073 sed = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
2919 sed = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@"; 3074 sed = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
2920 sed = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@"; 3075 sed = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
2921 sed = "s@#define INT_LEAST32_MIN.*@#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@"; 3076 sed = "s@#define INT_LEAST32_MIN.*@"
2922 sed = "s@#define INT_LEAST32_MAX.*@#define INT_LEAST32_MAX __INT_LEAST32_MAX__@"; 3077 "#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
2923 sed = "s@#define UINT_LEAST32_MAX.*@#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@"; 3078 sed = "s@#define INT_LEAST32_MAX.*@"
2924 sed = 's@#define INT_FAST\([0-9]*\)_MIN.*@#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@'; 3079 "#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
2925 sed = 's@#define INT_FAST\([0-9]*\)_MAX.*@#define INT_FAST\1_MAX __INT_FAST\1_MAX__@'; 3080 sed = "s@#define UINT_LEAST32_MAX.*@"
2926 sed = 's@#define UINT_FAST\([0-9]*\)_MAX.*@#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@'; 3081 "#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
3082 sed = 's@#define INT_FAST\([0-9]*\)_MIN.*@'
3083 '#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@';
3084 sed = 's@#define INT_FAST\([0-9]*\)_MAX.*@'
3085 '#define INT_FAST\1_MAX __INT_FAST\1_MAX__@';
3086 sed = 's@#define UINT_FAST\([0-9]*\)_MAX.*@'
3087 '#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@';
2927 sed = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@"; 3088 sed = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
2928 sed = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@"; 3089 sed = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
2929 sed = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@"; 3090 sed = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
2930 sed = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@"; 3091 sed = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@";
2931 sed = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@"; 3092 sed = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@";
2944 "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n" 3105 "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n"
2945 "#define UINT8_C(x) x##U\n" 3106 "#define UINT8_C(x) x##U\n"
2946 "#define UINT16_C(x) x##U"; 3107 "#define UINT16_C(x) x##U";
2947 }; 3108 };
2948 3109
2949 3110 /*
3111 * newlib_stdint_2
3112 */
2950 fix = { 3113 fix = {
2951 hackname = newlib_stdint_2; 3114 hackname = newlib_stdint_2;
2952 files = stdint-newlib.h, stdint.h; 3115 files = stdint-newlib.h, stdint.h;
2953 select = "@todo - Add support for wint_t types"; 3116 select = "@todo - Add support for wint_t types";
2954 c_fix = format; 3117 c_fix = format;
2963 c_fix_arg = '/\*\* Macros for minimum-width integer constant expressions \*/'; 3126 c_fix_arg = '/\*\* Macros for minimum-width integer constant expressions \*/';
2964 test_text = "/* @todo - Add support for wint_t types. */\n" 3127 test_text = "/* @todo - Add support for wint_t types. */\n"
2965 "/** Macros for minimum-width integer constant expressions */"; 3128 "/** Macros for minimum-width integer constant expressions */";
2966 }; 3129 };
2967 3130
2968
2969 /* 3131 /*
2970 * NeXT 3.2 adds const prefix to some math functions. 3132 * NeXT 3.2 adds const prefix to some math functions.
2971 * These conflict with the built-in functions. 3133 * These conflict with the built-in functions.
2972 */ 3134 */
2973 fix = { 3135 fix = {
2980 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\("; 3142 c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
2981 3143
2982 test_text = "extern\tdouble\t__const__\tmumble();"; 3144 test_text = "extern\tdouble\t__const__\tmumble();";
2983 }; 3145 };
2984 3146
2985
2986 /* 3147 /*
2987 * NeXT 3.2 uses the word "template" as a parameter for some 3148 * NeXT 3.2 uses the word "template" as a parameter for some
2988 * functions. GCC reports an invalid use of a reserved key word 3149 * functions. GCC reports an invalid use of a reserved key word
2989 * with the built-in functions. 3150 * with the built-in functions.
2990 */ 3151 */
2997 c_fix_arg = "(%1)"; 3158 c_fix_arg = "(%1)";
2998 c_fix_arg = "\\(([^)]*)[ \t]template\\)"; 3159 c_fix_arg = "\\(([^)]*)[ \t]template\\)";
2999 test_text = "extern mumble( char * template); /* fix */"; 3160 test_text = "extern mumble( char * template); /* fix */";
3000 }; 3161 };
3001 3162
3002
3003 /* 3163 /*
3004 * NeXT 3.2 includes the keyword volatile in the abort() and exit() 3164 * NeXT 3.2 includes the keyword volatile in the abort() and exit()
3005 * function prototypes. That conflicts with the built-in functions. 3165 * function prototypes. That conflicts with the built-in functions.
3006 */ 3166 */
3007 fix = { 3167 fix = {
3013 c_fix_arg = "extern void %1("; 3173 c_fix_arg = "extern void %1(";
3014 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\("; 3174 c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
3015 3175
3016 test_text = "extern\tvolatile\tvoid\tabort();"; 3176 test_text = "extern\tvolatile\tvoid\tabort();";
3017 }; 3177 };
3018
3019 3178
3020 /* 3179 /*
3021 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1. 3180 * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
3022 * Note that version 3 of the NeXT system has wait.h in a different directory, 3181 * Note that version 3 of the NeXT system has wait.h in a different directory,
3023 * so that this code won't do anything. But wait.h in version 3 has a 3182 * so that this code won't do anything. But wait.h in version 3 has a
3030 select = 'wait\(union wait'; 3189 select = 'wait\(union wait';
3031 c_fix = format; 3190 c_fix = format;
3032 c_fix_arg = "wait(void"; 3191 c_fix_arg = "wait(void";
3033 test_text = "extern pid_d wait(union wait*);"; 3192 test_text = "extern pid_d wait(union wait*);";
3034 }; 3193 };
3035
3036 3194
3037 /* 3195 /*
3038 * a missing semi-colon at the end of the nodeent structure definition. 3196 * a missing semi-colon at the end of the nodeent structure definition.
3039 */ 3197 */
3040 fix = { 3198 fix = {
3164 "typedef __regmatch_t\tregmatch_t;"; 3322 "typedef __regmatch_t\tregmatch_t;";
3165 3323
3166 test_text = "#include <reg_types.h>"; 3324 test_text = "#include <reg_types.h>";
3167 }; 3325 };
3168 3326
3169
3170 /* 3327 /*
3171 * On broken glibc-2.3.3 systems an array of incomplete structures is 3328 * On broken glibc-2.3.3 systems an array of incomplete structures is
3172 * passed to __sigsetjmp. Fix that to take a pointer instead. 3329 * passed to __sigsetjmp. Fix that to take a pointer instead.
3173 */ 3330 */
3174 fix = { 3331 fix = {
3175 hackname = pthread_incomplete_struct_argument; 3332 hackname = pthread_incomplete_struct_argument;
3176 files = pthread.h; 3333 files = pthread.h;
3177 select = "struct __jmp_buf_tag"; 3334 select = "struct __jmp_buf_tag";
3178 c_fix = format; 3335 c_fix = format;
3179 c_fix_arg = "%1 *%2%3"; 3336 c_fix_arg = "%1 *%2%3";
3180 c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) (__env)\\[1\\](.*)$"; 3337 c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) "
3181 test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask);"; 3338 "(__env)\\[1\\](.*)$";
3339 test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], "
3340 "int __savemask);";
3182 }; 3341 };
3183 3342
3184 /* 3343 /*
3185 * Fix return type of fread and fwrite on sysV68 3344 * Fix return type of fread and fwrite on sysV68
3186 */ 3345 */
3193 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)"; 3352 c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
3194 3353
3195 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();"; 3354 test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
3196 }; 3355 };
3197 3356
3198
3199 /* 3357 /*
3200 * Fix casts as lvalues in glibc's <rpc/xdr.h>. 3358 * Fix casts as lvalues in glibc's <rpc/xdr.h>.
3201 */ 3359 */
3202 fix = { 3360 fix = {
3203 hackname = rpc_xdr_lvalue_cast_a; 3361 hackname = rpc_xdr_lvalue_cast_a;
3207 c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))"; 3365 c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
3208 test_text = "#define IXDR_GET_LONG(buf) \\\\\n" 3366 test_text = "#define IXDR_GET_LONG(buf) \\\\\n"
3209 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))"; 3367 "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
3210 }; 3368 };
3211 3369
3212 3370 /*
3371 * rpc_xdr_lvalue_cast_b
3372 */
3213 fix = { 3373 fix = {
3214 hackname = rpc_xdr_lvalue_cast_b; 3374 hackname = rpc_xdr_lvalue_cast_b;
3215 files = rpc/xdr.h; 3375 files = rpc/xdr.h;
3216 select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*"; 3376 select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
3217 c_fix = format; 3377 c_fix = format;
3218 c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))"; 3378 c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
3219 test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n" 3379 test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n"
3220 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))"; 3380 "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
3221 }; 3381 };
3222 3382
3223
3224 /* 3383 /*
3225 * function class(double x) conflicts with C++ keyword on rs/6000 3384 * function class(double x) conflicts with C++ keyword on rs/6000
3226 */ 3385 */
3227 fix = { 3386 fix = {
3228 hackname = rs6000_double; 3387 hackname = rs6000_double;
3234 c_fix_arg = '^.*[^a-zA-Z_]class\(.*'; 3393 c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
3235 3394
3236 test_text = "extern int class();"; 3395 test_text = "extern int class();";
3237 }; 3396 };
3238 3397
3239
3240 /* 3398 /*
3241 * Wrong fchmod prototype on RS/6000. 3399 * Wrong fchmod prototype on RS/6000.
3242 */ 3400 */
3243 fix = { 3401 fix = {
3244 hackname = rs6000_fchmod; 3402 hackname = rs6000_fchmod;
3247 c_fix = format; 3405 c_fix = format;
3248 c_fix_arg = "fchmod(int"; 3406 c_fix_arg = "fchmod(int";
3249 test_text = "extern int fchmod(char *, mode_t);"; 3407 test_text = "extern int fchmod(char *, mode_t);";
3250 }; 3408 };
3251 3409
3252
3253 /* 3410 /*
3254 * parameters conflict with C++ new on rs/6000 3411 * parameters conflict with C++ new on rs/6000
3255 */ 3412 */
3256 fix = { 3413 fix = {
3257 hackname = rs6000_param; 3414 hackname = rs6000_param;
3262 c_fix = format; 3419 c_fix = format;
3263 c_fix_arg = 'rename(const char *_old, const char *_new)'; 3420 c_fix_arg = 'rename(const char *_old, const char *_new)';
3264 3421
3265 test_text = 'extern int rename(const char *old, const char *new);'; 3422 test_text = 'extern int rename(const char *old, const char *new);';
3266 }; 3423 };
3267
3268 3424
3269 /* 3425 /*
3270 * Solaris 10+ <sys/feature_tests.h> defines _RESTRICT_KYWD as restrict 3426 * Solaris 10+ <sys/feature_tests.h> defines _RESTRICT_KYWD as restrict
3271 * for C99. This is wrong for C++, which needs many C99 features, but 3427 * for C99. This is wrong for C++, which needs many C99 features, but
3272 * only supports __restrict. 3428 * only supports __restrict.
3279 c_fix = format; 3435 c_fix = format;
3280 c_fix_arg = "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n" 3436 c_fix_arg = "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n"
3281 "#else\n%0\n#endif"; 3437 "#else\n%0\n#endif";
3282 test_text = "#define _RESTRICT_KYWD restrict"; 3438 test_text = "#define _RESTRICT_KYWD restrict";
3283 }; 3439 };
3284
3285 3440
3286 /* 3441 /*
3287 * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of 3442 * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of
3288 * themselves, which are Sun Studio compiler intrinsics. Remove _Imaginary_I 3443 * themselves, which are Sun Studio compiler intrinsics. Remove _Imaginary_I
3289 * and imaginary definitions which are not supported by GCC. 3444 * and imaginary definitions which are not supported by GCC.
3304 "#define imaginary _Imaginary\n" 3459 "#define imaginary _Imaginary\n"
3305 "#undef I\n" 3460 "#undef I\n"
3306 "#define I _Imaginary_I"; 3461 "#define I _Imaginary_I";
3307 }; 3462 };
3308 3463
3309
3310 /* 3464 /*
3311 * Solaris 10+ <complex.h> is wrapped in #ifndef __cplusplus. Wrap in 3465 * Solaris 10+ <complex.h> is wrapped in #ifndef __cplusplus. Wrap in
3312 * extern "C" instead so libstdc++ can use it. 3466 * extern "C" instead so libstdc++ can use it.
3313 */ 3467 */
3314 fix = { 3468 fix = {
3315 hackname = solaris_complex_cxx; 3469 hackname = solaris_complex_cxx;
3316 mach = "*-*-solaris2.*"; 3470 mach = "*-*-solaris2.*";
3317 files = complex.h; 3471 files = complex.h;
3318 sed = "/#if[ \t]*!defined(__cplusplus)/c" 3472 sed = "/#if[ \t]*!defined(__cplusplus)/c\\\n"
3319 "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif"; 3473 "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
3320 sed = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c" 3474 sed = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n"
3321 "#ifdef\t__cplusplus\\\n}\\\n#endif"; 3475 "#ifdef\t__cplusplus\\\n}\\\n#endif";
3322 test_text = "#if !defined(__cplusplus)\n" 3476 test_text = "#if !defined(__cplusplus)\n"
3323 "#endif /* !defined(__cplusplus) */"; 3477 "#endif /* !defined(__cplusplus) */";
3324 }; 3478 };
3325 3479
3326 3480 /*
3327 /* 3481 * g++ rejects functions declared with both C and C++ linkage.
3328 * Solaris 8 PTHREAD_COND_INITIALIZER lacks the __pthread_cond_magic field. 3482 */
3329 * COND_MAGIC is only defined in <synch.h> and pollutes the namespace, so 3483 fix = {
3330 * use the value literally instead. 3484 hackname = solaris_cxx_linkage;
3331 */ 3485 mach = '*-*-solaris2*';
3332 fix = { 3486 files = "iso/stdlib_iso.h";
3333 hackname = solaris_cond_init; 3487 select = "(#if __cplusplus >= 199711L)\n"
3334 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; 3488 "(extern \"C\\+\\+\" \\{\n)"
3335 files = pthread.h; 3489 "(.*(bsearch|qsort).*)";
3336 mach = '*-*-solaris2.8'; 3490 c_fix = format;
3337 c_fix = format; 3491 c_fix_arg = "%1 && !__GNUG__\n%2%3";
3338 c_fix_arg = "%1, 0x4356%2"; 3492
3339 c_fix_arg = "^(#define[ \t]+PTHREAD_COND_INITIALIZER[ \t]+"
3340 "\\{.*0)(\\},[ \t]*0\\}.*)$";
3341 test_text = 3493 test_text =
3342 '#pragma ident "@(#)pthread.h 1.29 01/07/07 SMI"'"\n" 3494 "#if __cplusplus >= 199711L\n"
3343 '#define PTHREAD_COND_INITIALIZER {{{0}, 0}, 0} /* = DEFAULTCV */'; 3495 "extern \"C++\" {\n"
3344 }; 3496 " void *bsearch(const void *, const void *, size_t, size_t,";
3345 3497 };
3498
3499 /*
3500 * Solaris <iso/stdio_iso.h> doesn't declare getc for C++ with
3501 * _STRICT_STDC, but uses it.
3502 */
3503 fix = {
3504 hackname = solaris_getc_strict_stdc;
3505 mach = "*-*-solaris2*";
3506 files = "iso/stdio_iso.h";
3507 select = "(.*&& )!defined\\(_STRICT_STDC\\)(.*)";
3508 c_fix = format;
3509 c_fix_arg = "%1(!defined(_STRICT_STDC) || (__cplusplus >= 199711L))%2";
3510
3511 test_text =
3512 "#if !defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)";
3513 };
3514
3515 /*
3516 * Solaris <iso/stdio_iso.h> should deprecate gets before C11.
3517 */
3518 fix = {
3519 hackname = solaris_gets_c11;
3520 mach = "*-*-solaris2*";
3521 files = "iso/stdio_iso.h";
3522 select = "(extern char[ \t]*\\*gets\\(char \\*\\));";
3523
3524 c_fix = format;
3525 c_fix_arg = "#if __STDC_VERSION__ < 201112L && __cplusplus < 201402L\n"
3526 "%1 __attribute__((__deprecated__));\n"
3527 "#endif";
3528
3529 test_text = "extern char *gets(char *);";
3530 };
3531
3532 /*
3533 * Solaris <iso/stdio_iso.h> shouldn't declare gets for C++14.
3534 */
3535 fix = {
3536 hackname = solaris_gets_cxx14;
3537 mach = "*-*-solaris2*";
3538 files = "iso/stdio_iso.h";
3539 select = <<- _EOSelect_
3540 (#if __STDC_VERSION__ < 201112L)
3541 (extern char \*gets\(char \*\) __ATTR_DEPRECATED;)
3542 _EOSelect_;
3543 c_fix = format;
3544 c_fix_arg = "%1 && __cplusplus < 201402L\n%2";
3545
3546 test_text = <<- _EOText_
3547 #if __STDC_VERSION__ < 201112L
3548 extern char *gets(char *) __ATTR_DEPRECATED;
3549 _EOText_;
3550 };
3551
3552 /*
3553 * Sun Solaris 2 has a version of sys/int_const.h that defines
3554 * UINT8_C and UINT16_C to unsigned constants.
3555 */
3556 fix = {
3557 hackname = solaris_int_const;
3558 files = sys/int_const.h;
3559 mach = '*-*-solaris2*';
3560 c_fix = format;
3561 c_fix_arg = "#define\tUINT8_C(c)\t(c)\n"
3562 "%1\n"
3563 "#define\tUINT16_C(c)\t(c)";
3564 select = "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n"
3565 "(/\*.*\*/)\n"
3566 "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*";
3567 test_text =
3568 "#define UINT8_C(c) __CONCAT__(c,u)\n"
3569 "/* CSTYLED */\n"
3570 "#define UINT16_C(c) __CONCAT__(c,u)";
3571 };
3572
3573 /*
3574 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3575 * UINT8_MAX and UINT16_MAX to unsigned constants.
3576 */
3577 fix = {
3578 hackname = solaris_int_limits_1;
3579 files = sys/int_limits.h;
3580 mach = '*-*-solaris2*';
3581 c_fix = format;
3582 c_fix_arg = "#define\tUINT8_MAX\t(255)\n"
3583 "#define\tUINT16_MAX\t(65535)";
3584 select = "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n"
3585 "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
3586 test_text =
3587 "#define UINT8_MAX (255U)\n"
3588 "#define UINT16_MAX (65535U)";
3589 };
3590
3591 /*
3592 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3593 * INT_FAST16 limits to wrong values for sys/int_types.h.
3594 */
3595 fix = {
3596 hackname = solaris_int_limits_2;
3597 files = sys/int_limits.h;
3598 mach = '*-*-solaris2*';
3599 c_fix = format;
3600 c_fix_arg = "#define\t%1_FAST16_%2 %132_%2";
3601 select = "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
3602 test_text =
3603 "#define INT_FAST16_MAX INT16_MAX\n"
3604 "#define UINT_FAST16_MAX UINT16_MAX\n"
3605 "#define INT_FAST16_MIN INT16_MIN";
3606 };
3607
3608 /*
3609 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3610 * SIZE_MAX as unsigned long.
3611 */
3612 fix = {
3613 hackname = solaris_int_limits_3;
3614 files = sys/int_limits.h;
3615 mach = '*-*-solaris2*';
3616 c_fix = format;
3617 c_fix_arg = "#define\tSIZE_MAX\t4294967295U";
3618 select = "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL";
3619 test_text =
3620 "#define SIZE_MAX 4294967295UL";
3621 };
3346 3622
3347 /* 3623 /*
3348 * Sun Solaris 10 defines several C99 math macros in terms of 3624 * Sun Solaris 10 defines several C99 math macros in terms of
3349 * builtins specific to the Studio compiler, in particular not 3625 * builtins specific to the Studio compiler, in particular not
3350 * compatible with the GNU compiler. 3626 * compatible with the GNU compiler.
3365 "#define HUGE_VALF __builtin_huge_valf\n" 3641 "#define HUGE_VALF __builtin_huge_valf\n"
3366 "#undef HUGE_VALL\n" 3642 "#undef HUGE_VALL\n"
3367 "#define HUGE_VALL __builtin_huge_vall"; 3643 "#define HUGE_VALL __builtin_huge_vall";
3368 }; 3644 };
3369 3645
3646 /*
3647 * On Solaris 11, if you do isinf(NaN) you'll get a floating point
3648 * exception. Provide an alternative using GCC's builtin.
3649 */
3650 fix = {
3651 hackname = solaris_math_10;
3652 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3653 files = iso/math_c99.h;
3654 c_fix = format;
3655 c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)";
3656 c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
3657 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);"
3658 "[ \t]*\\\\\n"
3659 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3660 "INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
3661 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
3662 "\\(-INFINITY\\);[ \t]*\\}\\)";
3663 test_text =
3664 '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n"
3665 "#undef isinf\n"
3666 "#define isinf(x) __extension__( \\\\\n"
3667 " { __typeof(x) __x_i = (x); \\\\\n"
3668 " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
3669 " __x_i == (__typeof(__x_i)) (-INFINITY); })";
3670 };
3671
3672 /*
3673 * Solaris math INFINITY
3674 */
3370 fix = { 3675 fix = {
3371 hackname = solaris_math_2; 3676 hackname = solaris_math_2;
3372 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; 3677 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3373 bypass = "__GNUC__"; 3678 bypass = "__GNUC__";
3374 files = iso/math_c99.h; 3679 files = iso/math_c99.h;
3379 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n" 3684 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3380 "#undef INFINITY\n" 3685 "#undef INFINITY\n"
3381 "#define INFINITY __builtin_infinity"; 3686 "#define INFINITY __builtin_infinity";
3382 }; 3687 };
3383 3688
3689 /*
3690 * Solaris math NAN
3691 */
3384 fix = { 3692 fix = {
3385 hackname = solaris_math_3; 3693 hackname = solaris_math_3;
3386 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; 3694 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3387 bypass = "__GNUC__"; 3695 bypass = "__GNUC__";
3388 files = iso/math_c99.h; 3696 files = iso/math_c99.h;
3393 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n" 3701 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3394 "#undef NAN\n" 3702 "#undef NAN\n"
3395 "#define NAN __builtin_nan"; 3703 "#define NAN __builtin_nan";
3396 }; 3704 };
3397 3705
3706 /*
3707 * Solaris math fpclassify
3708 */
3398 fix = { 3709 fix = {
3399 hackname = solaris_math_4; 3710 hackname = solaris_math_4;
3400 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; 3711 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3401 bypass = "__GNUC__"; 3712 bypass = "__GNUC__";
3402 files = iso/math_c99.h; 3713 files = iso/math_c99.h;
3403 c_fix = format; 3714 c_fix = format;
3404 c_fix_arg = "#define\tfpclassify(x) \\\n" 3715 c_fix_arg = "#define\tfpclassify(x) \\\n"
3405 " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, (x))"; 3716 " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, "
3717 "FP_SUBNORMAL, FP_ZERO, (x))";
3406 c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)"; 3718 c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
3407 test_text = 3719 test_text =
3408 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n" 3720 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3409 "#undef fpclassify\n" 3721 "#undef fpclassify\n"
3410 "#define fpclassify(x) __builtin_fpclassify(x)"; 3722 "#define fpclassify(x) __builtin_fpclassify(x)";
3411 }; 3723 };
3412 3724
3725 /*
3726 * Solaris math signbit
3727 */
3413 fix = { 3728 fix = {
3414 hackname = solaris_math_8; 3729 hackname = solaris_math_8;
3415 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI"; 3730 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI";
3416 bypass = "__GNUC__"; 3731 bypass = "__GNUC__";
3417 files = iso/math_c99.h; 3732 files = iso/math_c99.h;
3427 #undef signbit 3742 #undef signbit
3428 #define signbit(x) __builtin_signbit(x) 3743 #define signbit(x) __builtin_signbit(x)
3429 _EOText_; 3744 _EOText_;
3430 }; 3745 };
3431 3746
3747 /*
3748 * Solaris math comparison macros
3749 */
3432 fix = { 3750 fix = {
3433 hackname = solaris_math_9; 3751 hackname = solaris_math_9;
3434 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; 3752 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3435 bypass = "__GNUC__"; 3753 bypass = "__GNUC__";
3436 files = iso/math_c99.h; 3754 files = iso/math_c99.h;
3437 c_fix = format; 3755 c_fix = format;
3438 c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)"; 3756 c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)";
3439 c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) __builtin_[a-z]+\\(y\\)\\)"; 3757 c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) "
3758 "__builtin_[a-z]+\\(y\\)\\)";
3440 test_text = 3759 test_text =
3441 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n" 3760 '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
3442 "#undef isgreater\n" 3761 "#undef isgreater\n"
3443 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n" 3762 "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n"
3444 "#undef isgreaterequal\n" 3763 "#undef isgreaterequal\n"
3452 "#undef isunordered\n" 3771 "#undef isunordered\n"
3453 "#define isunordered(x, y) ((x) __builtin_isunordered(y))"; 3772 "#define isunordered(x, y) ((x) __builtin_isunordered(y))";
3454 }; 3773 };
3455 3774
3456 /* 3775 /*
3457 * On Solaris 11, if you do isinf(NaN) you'll get a floating point 3776 * Newer Solaris 10/11 GCC signbit implementations cause strict-aliasing
3458 * exception. Provide an alternative using GCC's builtin. 3777 * warnings.
3459 */ 3778 */
3460 3779 fix = {
3461 fix = { 3780 hackname = solaris_math_11;
3462 hackname = solaris_math_10; 3781 select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ ";
3463 select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; 3782 files = iso/math_c99.h;
3464 files = iso/math_c99.h; 3783 c_fix = format;
3465 c_fix = format; 3784 c_fix_arg = << _EOArg_
3466 c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)"; 3785 #undef signbit
3467 c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n" 3786 #define signbit(x) (sizeof(x) == sizeof(float) \
3468 "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);[ \t]*\\\\\n" 3787 ? __builtin_signbitf(x) \
3469 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*INFINITY[ \t]*\\|\\|[ \t]*\\\\\n" 3788 : sizeof(x) == sizeof(long double) \
3470 "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*\\(-INFINITY\\);[ \t]*\\}\\)"; 3789 ? __builtin_signbitl(x) \
3471 test_text = 3790 : __builtin_signbit(x))
3472 '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n" 3791 _EOArg_;
3473 "#undef isinf\n" 3792 c_fix_arg = << _EOArg_
3474 "#define isinf(x) __extension__( \\\\\n" 3793 ^#undef[ ]+signbit
3475 " { __typeof(x) __x_i = (x); \\\\\n" 3794 #if defined\(__sparc\)
3476 " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n" 3795 #define[ ]+signbit\(x\)[ ]+__extension__\( \\
3477 " __x_i == (__typeof(__x_i)) (-INFINITY); })"; 3796 [ ]+\{[ ]*__typeof\(x\)[ ]*__x_s[ ]*=[ ]*\(x\);[ ]*\\
3478 }; 3797 [ ]+\(int\)[ ]*\(\*\(unsigned[ ]*\*\)[ ]*\&__x_s[ ]*>>[ ]*31\);[ ]*\}\)
3479 3798 #elif defined\(__i386\) \|\| defined\(__amd64\)
3480 /* 3799 #define[ ]+signbit\(x\)[ ]+__extension__\( \\
3481 * Sun Solaris defines PTHREAD_MUTEX_INITIALIZER with a trailing 3800 [ ]+\{ __typeof\(x\) __x_s = \(x\); \\
3482 * "0" for the last field of the pthread_mutex_t structure, which is 3801 [ ]+\(sizeof \(__x_s\) == sizeof \(float\) \? \\
3483 * of type upad64_t, which itself is typedef'd to int64_t, but with 3802 [ ]+\(int\) \(\*\(unsigned \*\) \&__x_s >> 31\) : \\
3484 * __STDC__ defined (e.g. by -ansi) it is a union. So change the 3803 [ ]+sizeof \(__x_s\) == sizeof \(double\) \? \\
3485 * initializer to "{0}" instead 3804 [ ]+\(int\) \(\(\(unsigned \*\) \&__x_s\)\[1\] >> 31\) : \\
3486 */ 3805 [ ]+\(int\) \(\(\(unsigned short \*\) \&__x_s\)\[4\] >> 15\)\); \}\)
3487 fix = { 3806 #endif
3488 hackname = solaris_mutex_init_2; 3807 _EOArg_;
3808 test_text = << _EOText_
3809 /* @(#)math_c99.h 1.14 13/03/27 */
3810 #undef signbit
3811 #if defined(__sparc)
3812 #define signbit(x) __extension__( \\
3813 { __typeof(x) __x_s = (x); \\
3814 (int) (*(unsigned *) &__x_s >> 31); })
3815 #elif defined(__i386) || defined(__amd64)
3816 #define signbit(x) __extension__( \\
3817 { __typeof(x) __x_s = (x); \\
3818 (sizeof (__x_s) == sizeof (float) ? \\
3819 (int) (*(unsigned *) &__x_s >> 31) : \\
3820 sizeof (__x_s) == sizeof (double) ? \\
3821 (int) (((unsigned *) &__x_s)[1] >> 31) : \\
3822 (int) (((unsigned short *) &__x_s)[4] >> 15)); })
3823 #endif
3824 _EOText_;
3825 };
3826
3827 /*
3828 * Some versions of Solaris 10+ <math.h> #undef libstdc++-internal macros.
3829 */
3830 fix = {
3831 hackname = solaris_math_12;
3832 files = math.h;
3833 mach = '*-*-solaris2*';
3834 select = '#undef.*_GLIBCXX_USE_C99_MATH';
3835 sed = "/#undef[ \t]*_GLIBCXX_USE_C99_MATH/d";
3836 test_text = << _EOText_
3837 #if __cplusplus >= 201103L
3838 #undef _GLIBCXX_USE_C99_MATH
3839 #undef _GLIBCXX_USE_C99_MATH_TR1
3840 #endif
3841 _EOText_;
3842 };
3843
3844 /*
3845 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
3846 * structure. As such, it need two levels of brackets, but only
3847 * contains one. Wrap the macro definition in an extra layer.
3848 */
3849 fix = {
3850 hackname = solaris_once_init_1;
3489 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; 3851 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3490 files = pthread.h; 3852 files = pthread.h;
3491 /* 3853 mach = '*-*-solaris*';
3492 * On Solaris 10, this fix is unnecessary because upad64_t is
3493 * always defined correctly regardless of the definition of the
3494 * __STDC__ macro. The first "mach" pattern matches up to
3495 * solaris9. The second "mach" pattern will not match any two (or
3496 * more) digit solaris version, but it will match e.g. 2.5.1.
3497 */
3498 mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*';
3499 c_fix = format; 3854 c_fix = format;
3500 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n" 3855 c_fix_arg = "%1{%2}%3";
3501 "%0\n" 3856 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
3502 "#else\n"
3503 "%1, {0}}%4\n"
3504 "#endif";
3505 c_fix_arg = "(^#define[ \t]+PTHREAD_(MUTEX|COND)_INITIALIZER[ \t]+"
3506 "(|/\*.*\*/[ \t]*\\\\\n[ \t]*)\\{.*)"
3507 ",[ \t]*0\\}" "(|[ \t].*)$";
3508 test_text = 3857 test_text =
3509 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n" 3858 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n"
3510 "#define PTHREAD_MUTEX_INITIALIZER\t{{{0},0}, {{{0}}}, 0}\n" 3859 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
3511 "#define PTHREAD_COND_INITIALIZER\t{{{0}, 0}, 0}\t/* DEFAULTCV */\n" 3860 };
3512 "#define PTHREAD_MUTEX_INITIALIZER /* = DEFAULTMUTEX */ \\\\\n" 3861
3513 " {{0, 0, 0, DEFAULT_TYPE, _MUTEX_MAGIC}, {{{0}}}, 0}\n" 3862 /*
3514 "#define PTHREAD_COND_INITIALIZER /* = DEFAULTCV */ \\\\\n" 3863 * Solaris 10+ <spawn.h> uses char *const argv[_RESTRICT_KYWD] in the
3515 " {{{0, 0, 0, 0}, DEFAULT_TYPE, _COND_MAGIC}, 0}"; 3864 * posix_spawn declarations, which doesn't work with C++.
3516 }; 3865 */
3517 3866 fix = {
3867 hackname = solaris_posix_spawn_restrict;
3868 files = spawn.h;
3869 mach = '*-*-solaris2*';
3870 c_fix = format;
3871 c_fix_arg = "%1*_RESTRICT_KYWD %2%3";
3872 select = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)";
3873 test_text =
3874 "char *const argv[_RESTRICT_KYWD],\n"
3875 "char *const envp[_RESTRICT_KYWD]);";
3876 };
3877
3878 /*
3879 * The pow overloads with int were removed in C++ 2011 DR 550.
3880 */
3881 fix = {
3882 hackname = solaris_pow_int_overload;
3883 mach = '*-*-solaris2*';
3884 files = "iso/math_iso.h";
3885 select = "^[ \t]*inline [a-z ]* pow\\([^()]*, int [^()]*\\)"
3886 " *\\{[^{}]*\n[^{}]*\\}";
3887 c_fix = format;
3888 c_fix_arg = "#if __cplusplus < 201103L\n%0\n#endif";
3889
3890 test_text =
3891 " inline long double pow(long double __X, int __Y) { return\n"
3892 " __powl(__X, (long double) (__Y)); }";
3893 };
3518 3894
3519 /* 3895 /*
3520 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some 3896 * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
3521 * fields of the pthread_rwlock_t structure, which are of type 3897 * fields of the pthread_rwlock_t structure, which are of type
3522 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__ 3898 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3540 test_text = 3916 test_text =
3541 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n" 3917 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3542 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}"; 3918 "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
3543 }; 3919 };
3544 3920
3545 3921 /*
3546 /* 3922 * Before Solaris 10, <stdio.h> lacks declarations of std::__filbuf and
3547 * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a 3923 * std::__flsbuf, but <iso/stdio_iso.h> uses them.
3548 * structure. As such, it need two levels of brackets, but only 3924 */
3549 * contains one. Wrap the macro definition in an extra layer. 3925 fix = {
3550 */ 3926 hackname = solaris_std___filbuf;
3551 fix = { 3927 files = stdio.h;
3552 hackname = solaris_once_init_1;
3553 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3554 files = pthread.h;
3555 mach = '*-*-solaris*';
3556 c_fix = format;
3557 c_fix_arg = "%1{%2}%3";
3558 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
3559 test_text =
3560 '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n"
3561 "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
3562 };
3563
3564
3565 /*
3566 * Sun Solaris defines PTHREAD_ONCE_INIT with a "0" for some
3567 * fields of the pthread_once_t structure, which are of type
3568 * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
3569 * defined (e.g. by -ansi) it is a union. So change the initializer
3570 * to "{0}" instead. This test relies on solaris_once_init_1.
3571 */
3572 fix = {
3573 hackname = solaris_once_init_2;
3574 select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
3575 files = pthread.h;
3576 /*
3577 * On Solaris 10, this fix is unnecessary because upad64_t is
3578 * always defined correctly regardless of the definition of the
3579 * __STDC__ macro. The first "mach" pattern matches up to
3580 * solaris9. The second "mach" pattern will not match any two (or
3581 * more) digit solaris version, but it will match e.g. 2.5.1.
3582 */
3583 mach = '*-*-solaris2.[0-9]', '*-*-solaris2.[0-9][!0-9]*';
3584 c_fix = format;
3585 c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3586 "%0\n"
3587 "#else\n"
3588 "%1{0}, {0}, {0}, {%3}%4\n"
3589 "#endif";
3590 c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{\\{)"
3591 "(0, 0, 0, )(PTHREAD_[A-Z_]+)(\\}\\})[ \t]*$";
3592 test_text =
3593 '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
3594 "#define PTHREAD_ONCE_INIT\t{{0, 0, 0, PTHREAD_ONCE_NOTDONE}}\n";
3595 };
3596
3597
3598 /*
3599 * Sun Solaris 2 has a version of sys/int_const.h that defines
3600 * UINT8_C and UINT16_C to unsigned constants.
3601 */
3602 fix = {
3603 hackname = solaris_int_const;
3604 files = sys/int_const.h;
3605 mach = '*-*-solaris2*'; 3928 mach = '*-*-solaris2*';
3606 c_fix = format; 3929 bypass = "using std::__filbuf";
3607 c_fix_arg = "#define\tUINT8_C(c)\t(c)\n" 3930 select = "(using std::perror;\n)(#endif)";
3608 "%1\n" 3931 c_fix = format;
3609 "#define\tUINT16_C(c)\t(c)"; 3932 c_fix_arg = "%1#ifndef _LP64\n"
3610 select = "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n" 3933 "using std::__filbuf;\n"
3611 "(/\*.*\*/)\n" 3934 "using std::__flsbuf;\n"
3612 "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*"; 3935 "#endif\n%2";
3613 test_text = 3936
3614 "#define UINT8_C(c) __CONCAT__(c,u)\n" 3937 test_text = "using std::perror;\n"
3615 "/* CSTYLED */\n" 3938 "#endif";
3616 "#define UINT16_C(c) __CONCAT__(c,u)"; 3939 };
3617 }; 3940
3618 3941 /*
3619 3942 * Solaris <stdio.h> shouldn't use std::gets for C++14.
3620 /* 3943 */
3621 * Sun Solaris 2 has a version of sys/int_limits.h that defines 3944 fix = {
3622 * UINT8_MAX and UINT16_MAX to unsigned constants. 3945 hackname = solaris_std_gets_cxx14;
3623 */ 3946 mach = "*-*-solaris2*";
3624 fix = { 3947 files = "stdio.h";
3625 hackname = solaris_int_limits_1; 3948 select = "using std::gets;";
3626 files = sys/int_limits.h; 3949
3627 mach = '*-*-solaris2*'; 3950 c_fix = format;
3628 c_fix = format; 3951 c_fix_arg = "#if __cplusplus < 201402L\n%0\n#endif";
3629 c_fix_arg = "#define\tUINT8_MAX\t(255)\n" 3952
3630 "#define\tUINT16_MAX\t(65535)"; 3953 test_text = "using std::gets;";
3631 select = "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n" 3954 };
3632 "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
3633 test_text =
3634 "#define UINT8_MAX (255U)\n"
3635 "#define UINT16_MAX (65535U)";
3636 };
3637
3638
3639 /*
3640 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3641 * INT_FAST16 limits to wrong values for sys/int_types.h.
3642 */
3643 fix = {
3644 hackname = solaris_int_limits_2;
3645 files = sys/int_limits.h;
3646 mach = '*-*-solaris2*';
3647 c_fix = format;
3648 c_fix_arg = "#define\t%1_FAST16_%2 %132_%2";
3649 select = "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
3650 test_text =
3651 "#define INT_FAST16_MAX INT16_MAX\n"
3652 "#define UINT_FAST16_MAX UINT16_MAX\n"
3653 "#define INT_FAST16_MIN INT16_MIN";
3654 };
3655
3656
3657 /*
3658 * Sun Solaris 2 has a version of sys/int_limits.h that defines
3659 * SIZE_MAX as unsigned long.
3660 */
3661 fix = {
3662 hackname = solaris_int_limits_3;
3663 files = sys/int_limits.h;
3664 mach = '*-*-solaris2*';
3665 c_fix = format;
3666 c_fix_arg = "#define\tSIZE_MAX\t4294967295U";
3667 select = "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL";
3668 test_text =
3669 "#define SIZE_MAX 4294967295UL";
3670 };
3671
3672
3673 /*
3674 * Sun Solaris up to 9 has a version of sys/int_types.h that forbids use
3675 * of Standard C99 64-bit types in 32-bit mode.
3676 */
3677 fix = {
3678 hackname = solaris_int_types;
3679 select = "__STDC__ - 0 == 0";
3680 bypass = "_LONGLONG_TYPE";
3681 files = sys/int_types.h;
3682 c_fix = format;
3683 c_fix_arg =
3684 "(defined(_STDC_C99) || !defined(_STRICT_STDC) || defined(__GNUC__))";
3685 test_text =
3686 "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
3687 "typedef long long int64_t;\n"
3688 "#endif\n\n"
3689 "#if defined(_LP64) || (__STDC__ - 0 == 0 && !defined(_NO_LONGLONG))\n"
3690 "typedef int64_t intmax_t;\n"
3691 "#endif";
3692 };
3693
3694 3955
3695 /* 3956 /*
3696 * Sun Solaris 8 has what appears to be some gross workaround for 3957 * Sun Solaris 8 has what appears to be some gross workaround for
3697 * some old version of their c++ compiler. G++ doesn't want it 3958 * some old version of their c++ compiler. G++ doesn't want it
3698 * either, but doesn't want to be tied to SunPRO version numbers. 3959 * either, but doesn't want to be tied to SunPRO version numbers.
3708 sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/'; 3969 sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
3709 3970
3710 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)"; 3971 test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
3711 }; 3972 };
3712 3973
3713 3974 /*
3714 /* 3975 * Solaris <stdlib.h> shouldn't use _Noreturn, breaks with C++.
3715 * On Solaris 8 and 9, __va_list needs to become a typedef for 3976 */
3716 * __builtin_va_list to make -Wmissing-format-attribute work. 3977 fix = {
3717 */ 3978 hackname = solaris_stdlib_noreturn;
3718 fix = { 3979 mach = "*-*-solaris2*";
3719 hackname = solaris_sys_va_list; 3980 files = "iso/stdlib_c99.h";
3720 files = sys/va_list.h; 3981 select = "(extern) _Noreturn (void quick_exit\\(int\\));";
3721 mach = '*-*-solaris2.[89]'; 3982
3722 select = "#if.*__STDC__.*\n" 3983 c_fix = format;
3723 "typedef void \\*__va_list;\n" 3984 c_fix_arg = "%1 %2 __attribute__((__noreturn__));";
3724 "#else\n" 3985
3725 "typedef char \\*__va_list;\n" 3986 test_text = "extern _Noreturn void quick_exit(int);";
3726 "#endif"; 3987 };
3727
3728 c_fix = format;
3729 c_fix_arg = "#ifdef __GNUC__\n"
3730 "typedef __builtin_va_list __va_list;\n"
3731 "#else\n"
3732 "%0\n"
3733 "#endif";
3734 test_text = "#if defined(__STDC__) && !defined(__ia64)\n"
3735 "typedef void *__va_list;\n"
3736 "#else\n"
3737 "typedef char *__va_list;\n"
3738 "#endif";
3739 };
3740
3741 3988
3742 /* 3989 /*
3743 * a missing semi-colon at the end of the statsswtch structure definition. 3990 * a missing semi-colon at the end of the statsswtch structure definition.
3744 */ 3991 */
3745 fix = { 3992 fix = {
3748 select = "boottime$"; 3995 select = "boottime$";
3749 c_fix = format; 3996 c_fix = format;
3750 c_fix_arg = "boottime;"; 3997 c_fix_arg = "boottime;";
3751 test_text = "struct statswtch {\n int boottime\n};"; 3998 test_text = "struct statswtch {\n int boottime\n};";
3752 }; 3999 };
3753
3754 4000
3755 /* 4001 /*
3756 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list. 4002 * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
3757 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's 4003 * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
3758 * OK too. 4004 * OK too.
3773 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n"; 4019 c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
3774 4020
3775 test_text = ""; 4021 test_text = "";
3776 }; 4022 };
3777 4023
3778
3779 /* 4024 /*
3780 * Don't use or define the name va_list in stdio.h. This is for 4025 * Don't use or define the name va_list in stdio.h. This is for
3781 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence 4026 * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence
3782 * of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to 4027 * of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to
3783 * indicate that the header knows what it's doing -- under SUSv2, 4028 * indicate that the header knows what it's doing -- under SUSv2,
3784 * stdio.h is required to define va_list, and we shouldn't break 4029 * stdio.h is required to define va_list, and we shouldn't break
3785 * that. On IRIX 6.5, internal/wchar_core.h used to get its 4030 * that.
3786 * definition of va_list from stdio.h. Since this doesn't happen any
3787 * longer, use __gnuc_va_list there, too.
3788 */ 4031 */
3789 fix = { 4032 fix = {
3790 hackname = stdio_va_list; 4033 hackname = stdio_va_list;
3791 files = stdio.h; 4034 files = stdio.h;
3792 files = internal/stdio_core.h;
3793 files = internal/wchar_core.h;
3794 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list'; 4035 bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
3795 /* 4036 /*
3796 * On Solaris 10, the definition in 4037 * On Solaris 10, the definition in
3797 * <stdio.h> is guarded appropriately by the _XPG4 feature macro; 4038 * <stdio.h> is guarded appropriately by the _XPG4 feature macro;
3798 * there is therefore no need for this fix there. 4039 * there is therefore no need for this fix there.
3825 "s@VA_LIST@DUMMY_VA_LIST@\n" 4066 "s@VA_LIST@DUMMY_VA_LIST@\n"
3826 "s@_Va_LIST@_VA_LIST@"; 4067 "s@_Va_LIST@_VA_LIST@";
3827 test_text = "extern void mumble( va_list);"; 4068 test_text = "extern void mumble( va_list);";
3828 }; 4069 };
3829 4070
3830
3831 /* 4071 /*
3832 * Fix headers that use va_list from stdio.h to use the updated 4072 * Fix headers that use va_list from stdio.h to use the updated
3833 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is 4073 * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is
3834 * dealt with elsewhere. The presence of __gnuc_va_list, 4074 * dealt with elsewhere. The presence of __gnuc_va_list,
3835 * __DJ_va_list, or _G_va_list is taken to indicate that the header 4075 * __DJ_va_list, or _G_va_list is taken to indicate that the header
3875 "s@VA_LIST@DUMMY_VA_LIST@\n" 4115 "s@VA_LIST@DUMMY_VA_LIST@\n"
3876 "s@_Va_LIST@_VA_LIST@"; 4116 "s@_Va_LIST@_VA_LIST@";
3877 test_text = "extern void mumble( va_list);"; 4117 test_text = "extern void mumble( va_list);";
3878 }; 4118 };
3879 4119
3880
3881 /* 4120 /*
3882 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0" 4121 * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
3883 * is "!defined( __STRICT_ANSI__ )" 4122 * is "!defined( __STRICT_ANSI__ )"
3884 */ 4123 */
3885 fix = { 4124 fix = {
3938 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n" 4177 "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
3939 "|| __STDC__ - 0 == 0 ) /* not std C */\n" 4178 "|| __STDC__ - 0 == 0 ) /* not std C */\n"
3940 "int foo;\n#endif"; 4179 "int foo;\n#endif";
3941 }; 4180 };
3942 4181
3943
3944 /* 4182 /*
3945 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1" 4183 * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
3946 * is "defined( __STRICT_ANSI__ )" 4184 * is "defined( __STRICT_ANSI__ )"
3947 */ 4185 */
3948 fix = { 4186 fix = {
3958 c_fix_arg = "%1 defined(__STRICT_ANSI__)"; 4196 c_fix_arg = "%1 defined(__STRICT_ANSI__)";
3959 4197
3960 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif"; 4198 test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
3961 }; 4199 };
3962 4200
3963
3964 /* 4201 /*
3965 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s 4202 * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
3966 * in prototype without previous definition. 4203 * in prototype without previous definition.
3967 */ 4204 */
3968 fix = { 4205 fix = {
3971 select = '^.*xdrstdio_create.*struct __file_s'; 4208 select = '^.*xdrstdio_create.*struct __file_s';
3972 c_fix = format; 4209 c_fix = format;
3973 c_fix_arg = "struct __file_s;\n%0"; 4210 c_fix_arg = "struct __file_s;\n%0";
3974 test_text = "extern void xdrstdio_create( struct __file_s* );"; 4211 test_text = "extern void xdrstdio_create( struct __file_s* );";
3975 }; 4212 };
3976
3977 4213
3978 /* 4214 /*
3979 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr 4215 * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
3980 * in prototype without previous definition. 4216 * in prototype without previous definition.
3981 * 4217 *
3990 bypass = "struct sockaddr;\n"; 4226 bypass = "struct sockaddr;\n";
3991 c_fix = format; 4227 c_fix = format;
3992 c_fix_arg = "struct sockaddr;\n%0"; 4228 c_fix_arg = "struct sockaddr;\n%0";
3993 test_text = "extern AUTH* authdes_create( struct sockaddr* );"; 4229 test_text = "extern AUTH* authdes_create( struct sockaddr* );";
3994 }; 4230 };
3995
3996 4231
3997 /* 4232 /*
3998 * Apply fix this to all OSs since this problem seems to effect 4233 * Apply fix this to all OSs since this problem seems to effect
3999 * more than just SunOS. 4234 * more than just SunOS.
4000 */ 4235 */
4019 "struct auth_t {\n" 4254 "struct auth_t {\n"
4020 " int (*name)(); /* C++ bad */\n" 4255 " int (*name)(); /* C++ bad */\n"
4021 "};"; 4256 "};";
4022 }; 4257 };
4023 4258
4024
4025 /* 4259 /*
4026 * Fix bogus #ifdef on SunOS 4.1. 4260 * Fix bogus #ifdef on SunOS 4.1.
4027 */ 4261 */
4028 fix = { 4262 fix = {
4029 hackname = sun_bogus_ifdef; 4263 hackname = sun_bogus_ifdef;
4034 c_fix_arg = "#if%1"; 4268 c_fix_arg = "#if%1";
4035 4269
4036 test_text = "#ifdef __i386__ || __vax__ || __sun4c__"; 4270 test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
4037 }; 4271 };
4038 4272
4039
4040 /* 4273 /*
4041 * Fix the CAT macro in SunOS memvar.h. 4274 * Fix the CAT macro in SunOS memvar.h.
4042 */ 4275 */
4043 fix = { 4276 fix = {
4044 hackname = sun_catmacro; 4277 hackname = sun_catmacro;
4052 "#else\n%0\n#endif"; 4285 "#else\n%0\n#endif";
4053 4286
4054 test_text = 4287 test_text =
4055 "#define CAT(a,b)\ta/**/b"; 4288 "#define CAT(a,b)\ta/**/b";
4056 }; 4289 };
4057
4058 4290
4059 /* 4291 /*
4060 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1. 4292 * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
4061 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68 4293 * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
4062 */ 4294 */
4077 "char*\tmalloc();\n" 4309 "char*\tmalloc();\n"
4078 "char*\tcalloc();\n" 4310 "char*\tcalloc();\n"
4079 "char*\trealloc();"; 4311 "char*\trealloc();";
4080 }; 4312 };
4081 4313
4082
4083 /* 4314 /*
4084 * Check for yet more missing ';' in struct (in SunOS 4.0.x) 4315 * Check for yet more missing ';' in struct (in SunOS 4.0.x)
4085 */ 4316 */
4086 fix = { 4317 fix = {
4087 hackname = sun_rusers_semi; 4318 hackname = sun_rusers_semi;
4089 select = "_cnt$"; 4320 select = "_cnt$";
4090 sed = "/^struct/,/^};/s/_cnt$/_cnt;/"; 4321 sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
4091 test_text = "struct mumble\n int _cnt\n};"; 4322 test_text = "struct mumble\n int _cnt\n};";
4092 }; 4323 };
4093 4324
4094
4095 /* 4325 /*
4096 * signal.h on SunOS defines signal using (), 4326 * signal.h on SunOS defines signal using (),
4097 * which causes trouble when compiling with g++ -pedantic. 4327 * which causes trouble when compiling with g++ -pedantic.
4098 */ 4328 */
4099 fix = { 4329 fix = {
4109 "#else\n%0\n#endif"; 4339 "#else\n%0\n#endif";
4110 4340
4111 test_text = "void\t(*signal())();"; 4341 test_text = "void\t(*signal())();";
4112 }; 4342 };
4113 4343
4114
4115 /* 4344 /*
4116 * Correct the return type for strlen in strings.h in SunOS 4. 4345 * Correct the return type for strlen in strings.h in SunOS 4.
4117 */ 4346 */
4118 fix = { 4347 fix = {
4119 hackname = sunos_strlen; 4348 hackname = sunos_strlen;
4122 c_fix = format; 4351 c_fix = format;
4123 c_fix_arg = "__SIZE_TYPE__ strlen();%1"; 4352 c_fix_arg = "__SIZE_TYPE__ strlen();%1";
4124 test_text = " int\tstrlen(); /* string length */"; 4353 test_text = " int\tstrlen(); /* string length */";
4125 }; 4354 };
4126 4355
4356 /*
4357 * Linux kernel's vt.h breaks C++
4358 */
4359 fix = {
4360 hackname = suse_linux_vt_cxx;
4361 files = linux/vt.h;
4362
4363 select = "^[ \t]*unsigned int new;";
4364 c_fix = format;
4365 c_fix_arg = "unsigned int newev;";
4366
4367 test_text = " unsigned int new; /* New console (if changing) */";
4368 };
4127 4369
4128 /* 4370 /*
4129 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h> 4371 * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
4130 * that is visible to any ANSI compiler using this include. Simply 4372 * that is visible to any ANSI compiler using this include. Simply
4131 * delete the lines that #define some string functions to internal forms. 4373 * delete the lines that #define some string functions to internal forms.
4136 select = '#define.*__std_hdr_'; 4378 select = '#define.*__std_hdr_';
4137 sed = '/#define.*__std_hdr_/d'; 4379 sed = '/#define.*__std_hdr_/d';
4138 test_text = "#define strlen __std_hdr_strlen\n"; 4380 test_text = "#define strlen __std_hdr_strlen\n";
4139 }; 4381 };
4140 4382
4141
4142 /* 4383 /*
4143 * Fix broken decl of getcwd present on some svr4 systems. 4384 * Fix broken decl of getcwd present on some svr4 systems.
4144 */ 4385 */
4145 fix = { 4386 fix = {
4146 hackname = svr4_getcwd; 4387 hackname = svr4_getcwd;
4153 c_fix_arg = "getcwd(char *, size_t)"; 4394 c_fix_arg = "getcwd(char *, size_t)";
4154 4395
4155 test_text = "extern char* getcwd(char *, int);"; 4396 test_text = "extern char* getcwd(char *, int);";
4156 }; 4397 };
4157 4398
4158
4159 /* 4399 /*
4160 * Fix broken decl of profil present on some svr4 systems. 4400 * Fix broken decl of profil present on some svr4 systems.
4161 */ 4401 */
4162 fix = { 4402 fix = {
4163 hackname = svr4_profil; 4403 hackname = svr4_profil;
4164 files = stdlib.h; 4404 files = stdlib.h;
4165 files = unistd.h; 4405 files = unistd.h;
4166 4406
4167 select = 4407 select =
4168 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)'; 4408 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
4169 /* The fix is wrong on IRIX 5/6 and creates a conflict with another
4170 prototype in <sys/profil.h>. */
4171 bypass = 'Silicon Graphics';
4172 c_fix = format; 4409 c_fix = format;
4173 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)'; 4410 c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
4174 4411
4175 test_text = 4412 test_text =
4176 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);'; 4413 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
4177 }; 4414 };
4178
4179 4415
4180 /* 4416 /*
4181 * Correct types for signal handler constants like SIG_DFL; they might be 4417 * Correct types for signal handler constants like SIG_DFL; they might be
4182 * void (*) (), and should be void (*) (int). C++ doesn't like the 4418 * void (*) (), and should be void (*) (int). C++ doesn't like the
4183 * old style. 4419 * old style.
4189 c_fix = format; 4425 c_fix = format;
4190 c_fix_arg = "void (*)(int)"; 4426 c_fix_arg = "void (*)(int)";
4191 test_text = "#define SIG_DFL (void(*)())0\n" 4427 test_text = "#define SIG_DFL (void(*)())0\n"
4192 "#define SIG_IGN (void (*)())0\n"; 4428 "#define SIG_IGN (void (*)())0\n";
4193 }; 4429 };
4194
4195 4430
4196 /* 4431 /*
4197 * Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local 4432 * Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local
4198 * function 'getrnge' in <regexp.h> before they declare it. For these 4433 * function 'getrnge' in <regexp.h> before they declare it. For these
4199 * systems add a 'static int' declaration of 'getrnge' into <regexp.h> 4434 * systems add a 'static int' declaration of 'getrnge' into <regexp.h>
4219 "/* stuff which calls getrnge() */\n" 4454 "/* stuff which calls getrnge() */\n"
4220 "static getrnge()\n" 4455 "static getrnge()\n"
4221 "{}"; 4456 "{}";
4222 }; 4457 };
4223 4458
4224
4225 /* 4459 /*
4226 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn} 4460 * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
4227 * in string.h on sysV68 4461 * in string.h on sysV68
4228 * Correct the return type for strlen in string.h on Lynx. 4462 * Correct the return type for strlen in string.h on Lynx.
4229 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0. 4463 * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
4267 4501
4268 "extern int\n" 4502 "extern int\n"
4269 "\tstrlen(), strspn();"; 4503 "\tstrlen(), strspn();";
4270 }; 4504 };
4271 4505
4272
4273 /* 4506 /*
4274 * Fix return type of calloc, malloc, realloc, bsearch and exit 4507 * Fix return type of calloc, malloc, realloc, bsearch and exit
4275 */ 4508 */
4276 fix = { 4509 fix = {
4277 hackname = sysz_stdlib_for_sun; 4510 hackname = sysz_stdlib_for_sun;
4287 "extern char*\tmalloc(size_t);\n" 4520 "extern char*\tmalloc(size_t);\n"
4288 "extern char*\trealloc(void*,size_t);\n" 4521 "extern char*\trealloc(void*,size_t);\n"
4289 "extern char*\tbsearch(void*,size_t,size_t);\n"; 4522 "extern char*\tbsearch(void*,size_t,size_t);\n";
4290 }; 4523 };
4291 4524
4292
4293 /* 4525 /*
4294 * __thread is now a keyword. 4526 * __thread is now a keyword.
4295 */ 4527 */
4296 fix = { 4528 fix = {
4297 hackname = thread_keyword; 4529 hackname = thread_keyword;
4298 files = "pthread.h"; 4530 files = "pthread.h";
4299 files = "bits/sigthread.h"; 4531 files = bits/sigthread.h, '*/bits/sigthread.h';
4300 select = "([* ])__thread([,)])"; 4532 select = "([* ])__thread([,)])";
4301 c_fix = format; 4533 c_fix = format;
4302 c_fix_arg = "%1__thr%2"; 4534 c_fix_arg = "%1__thr%2";
4303 4535
4304 test_text = 4536 test_text =
4318 4550
4319 c_fix = format; 4551 c_fix = format;
4320 c_fix_arg = " __cplusplus"; 4552 c_fix_arg = " __cplusplus";
4321 test_text = "#ifdef _cplusplus\nint bogus;\n#endif"; 4553 test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
4322 }; 4554 };
4323
4324 4555
4325 /* 4556 /*
4326 * parameters not const on DECstation Ultrix V4.0 and OSF/1. 4557 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4327 */ 4558 */
4328 fix = { 4559 fix = {
4341 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n" 4572 "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
4342 "extern int fscanf( FILE *__stream, char *__format, ...);\n" 4573 "extern int fscanf( FILE *__stream, char *__format, ...);\n"
4343 "extern int scanf( char *__format, ...);\n"; 4574 "extern int scanf( char *__format, ...);\n";
4344 }; 4575 };
4345 4576
4346
4347 /* 4577 /*
4348 * parameters not const on DECstation Ultrix V4.0 and OSF/1. 4578 * parameters not const on DECstation Ultrix V4.0 and OSF/1.
4349 */ 4579 */
4350 fix = { 4580 fix = {
4351 hackname = ultrix_const2; 4581 hackname = ultrix_const2;
4363 "extern int sscanf( char *__s, char *__format, ...);\n" 4593 "extern int sscanf( char *__s, char *__format, ...);\n"
4364 "extern FILE *popen(char *, char *);\n" 4594 "extern FILE *popen(char *, char *);\n"
4365 "extern char *tempnam(char*,char*);\n"; 4595 "extern char *tempnam(char*,char*);\n";
4366 }; 4596 };
4367 4597
4368
4369 /* 4598 /*
4370 * Fix definitions of macros used by va-i960.h in VxWorks header file. 4599 * Fix definitions of macros used by va-i960.h in VxWorks header file.
4371 */ 4600 */
4372 fix = { 4601 fix = {
4373 hackname = va_i960_macro; 4602 hackname = va_i960_macro;
4382 "extern int __vali vali;\n" 4611 "extern int __vali vali;\n"
4383 "extern int __vpad vpad;\n" 4612 "extern int __vpad vpad;\n"
4384 "#define __alignof__(x) ..."; 4613 "#define __alignof__(x) ...";
4385 }; 4614 };
4386 4615
4616 /*
4617 * On VMS, add missing braces around sigset_t constants.
4618 */
4619 fix = {
4620 hackname = vms_add_missing_braces;
4621 select = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)";
4622 mach = "*-*-*vms*";
4623 files = "rtldef/signal.h";
4624 c_fix = format;
4625
4626 c_fix_arg = '%1 {%2} ';
4627
4628 test_text = "static const __sigset_t _SIG_EMPTY_SET = "
4629 "{0x00000000, 0x00000000},\n"
4630 " _SIG_FULL_SET = {0xFFFFFFFF, 0xFFFFFFFF};\n";
4631 };
4632
4633 /*
4634 * On VMS, some DEC-C builtins are directly used.
4635 */
4636 fix = {
4637 hackname = vms_decc_builtin;
4638 select = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)";
4639 mach = "*-*-*vms*";
4640 files = rtldef/string.h, rtldef/time.h, rtldef/strings.h,
4641 rtldef/socket.h;
4642 sed = "s@__MEMSET@memset@";
4643 sed = "s@__MEMMOVE@memmove@";
4644 sed = "s@__MEMCPY@memcpy@";
4645 sed = "s@__STRLEN@strlen@";
4646 sed = "s@__STRCPY@strcpy@";
4647
4648 test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n";
4649 };
4650
4651 /*
4652 * Define __CAN_USE_EXTERN_PREFIX on vms.
4653 */
4654 fix = {
4655 hackname = vms_define_can_use_extern_prefix;
4656 files = "rtldef/decc$types.h";
4657 select = "#[ \t]*else\n"
4658 "#[ \t]*if defined\\(__DECCXX\\)\n"
4659 "#[ \t]*define __CAN_USE_EXTERN_PREFIX 1\n";
4660 mach = "*-*-*vms*";
4661 c_fix = format;
4662
4663 c_fix_arg = "%0"
4664 "# elif defined (__GNUC__)\n"
4665 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n";
4666
4667 test_text = "# else\n"
4668 "# if defined(__DECCXX)\n"
4669 "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n"
4670 "# endif\n"
4671 "# endif\n";
4672 };
4673
4674 /*
4675 * On VMS, disable the use of dec-c string builtins
4676 */
4677 fix = {
4678 hackname = vms_disable_decc_string_builtins;
4679 select = "#if !defined\\(__VAX\\)\n";
4680 mach = "*-*-*vms*";
4681 files = "rtldef/string.h";
4682 c_fix = format;
4683
4684 c_fix_arg = "#if !defined(__VAX) && !defined(__GNUC__)\n";
4685
4686 test_text = "#if !defined(__VAX)\n";
4687 };
4688
4689 /*
4690 * On VMS, fix incompatible redeclaration of hostalias.
4691 */
4692 fix = {
4693 hackname = vms_do_not_redeclare_hostalias;
4694 select = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n"
4695 "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)";
4696 mach = "*-*-*vms*";
4697 files = "rtldef/resolv.h";
4698 c_fix = format;
4699
4700 c_fix_arg = "%1\n"
4701 "/* %2 */";
4702
4703 test_text = "void fp_nquery (const u_char *, int, FILE *);\n"
4704 "__char_ptr32 hostalias (const char *);\n";
4705 };
4706
4707 /*
4708 * On VMS, forward declare structure before referencing them in prototypes.
4709 */
4710 fix = {
4711 hackname = vms_forward_declare_struct;
4712 select = "(/\\* forward decls for C\\+\\+ \\*/\n)"
4713 "#ifdef __cplusplus\n";
4714 mach = "*-*-*vms*";
4715 files = rtldef/if.h;
4716 c_fix = format;
4717
4718 c_fix_arg = "%1"
4719 "#if defined (__cplusplus) || defined (__GNUC__)\n";
4720
4721 test_text = "/* forward decls for C++ */\n"
4722 "#ifdef __cplusplus\n"
4723 "struct foo;\n"
4724 "#endif\n";
4725 };
4726
4727 /*
4728 * On VMS, do not declare getopt and al if pointers are 64 bit.
4729 */
4730 fix = {
4731 hackname = vms_no_64bit_getopt;
4732 select = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)"
4733 "|(char \\*optarg))([ \t]*\\(.*\\))?;\n";
4734 mach = "*-*-*vms*";
4735 files = rtldef/stdio.h, rtldef/unistd.h;
4736 c_fix = format;
4737
4738 c_fix_arg = <<- _EOArg_
4739 #if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only. */
4740 %0#endif
4741
4742 _EOArg_;
4743
4744 test_text = "int getopt (int, char * const [], const char *);";
4745 };
4746
4747 /*
4748 * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions
4749 * which is not yet fully supported by gcc.
4750 */
4751 fix = {
4752 hackname = vms_use_fast_setjmp;
4753 select = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)";
4754 mach = "*-*-*vms*";
4755 files = rtldef/setjmp.h;
4756 c_fix = format;
4757
4758 c_fix_arg = "%0 defined (__GNUC__) ||";
4759
4760 test_text = "# if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)";
4761 };
4762
4763 /*
4764 * On VMS, use pragma extern_model instead of VAX-C keywords.
4765 */
4766 fix = {
4767 hackname = vms_use_pragma_extern_model;
4768 select = "#if defined\\(__DECC\\) \\|\\| defined\\(__DECCXX\\)\n"
4769 "# pragma extern_model __save\n";
4770 mach = "*-*-*vms*";
4771 c_fix = format;
4772
4773 c_fix_arg = "#if defined(__DECC) || defined(__DECCXX) || defined(__GNUC__)\n"
4774 "# pragma extern_model __save\n";
4775
4776 test_text = "#if defined(__DECC) || defined(__DECCXX)\n"
4777 "# pragma extern_model __save\n"
4778 "# pragma extern_model strict_refdef\n"
4779 " extern struct x zz$yy;\n"
4780 "# pragma extern_model __restore\n"
4781 "#endif\n";
4782 };
4783
4784 /*
4785 * On VMS, change <resource.h> to <sys/resource.h> to avoid a
4786 * conflict while building gcc. Likewise for <builtins.h>
4787 */
4788 fix = {
4789 hackname = vms_use_quoted_include;
4790 select = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>";
4791 mach = "*-*-*vms*";
4792 files = rtldef/wait.h, starlet_c/pthread.h;
4793 c_fix = format;
4794
4795 c_fix_arg = '%1<sys/%2.h>';
4796
4797 test_text = "# include <resource.h>";
4798 };
4387 4799
4388 /* 4800 /*
4389 * AIX and Interix headers define NULL to be cast to a void pointer, 4801 * AIX and Interix headers define NULL to be cast to a void pointer,
4390 * which is illegal in ANSI C++. 4802 * which is illegal in ANSI C++.
4391 */ 4803 */
4392 fix = { 4804 fix = {
4393 hackname = void_null; 4805 hackname = void_null;
4394 files = curses.h; 4806 files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
4395 files = dbm.h; 4807 time.h, unistd.h, sys/dir.h, sys/param.h, sys/types.h;
4396 files = locale.h;
4397 files = stdio.h;
4398 files = stdlib.h;
4399 files = string.h;
4400 files = time.h;
4401 files = unistd.h;
4402 files = sys/dir.h;
4403 files = sys/param.h;
4404 files = sys/types.h;
4405 /* avoid changing C++ friendly NULL */ 4808 /* avoid changing C++ friendly NULL */
4406 bypass = __cplusplus; 4809 bypass = __cplusplus;
4810 bypass = __null;
4407 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)"; 4811 select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
4408 c_fix = format; 4812 c_fix = format;
4409 c_fix_arg = "#define NULL 0"; 4813 c_fix_arg = <<- _EOFix_
4814 #ifndef NULL
4815 #ifdef __cplusplus
4816 #ifdef __GNUG__
4817 #define NULL __null
4818 #else /* ! __GNUG__ */
4819 #define NULL 0L
4820 #endif /* __GNUG__ */
4821 #else /* ! __cplusplus */
4822 #define NULL ((void *)0)
4823 #endif /* __cplusplus */
4824 #endif /* !NULL */
4825 _EOFix_;
4410 test_text = "# define\tNULL \t((void *)0) /* typed NULL */"; 4826 test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
4411 }; 4827 };
4412
4413 4828
4414 /* 4829 /*
4415 * Make VxWorks header which is almost gcc ready fully gcc ready. 4830 * Make VxWorks header which is almost gcc ready fully gcc ready.
4416 */ 4831 */
4417 fix = { 4832 fix = {
4449 "typedef long ptrdiff_t;\n" 4864 "typedef long ptrdiff_t;\n"
4450 "typedef unsigned short wchar_t;\n" 4865 "typedef unsigned short wchar_t;\n"
4451 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n"; 4866 "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
4452 }; 4867 };
4453 4868
4869 /*
4870 * Wrap VxWorks ioctl to keep everything pretty
4871 */
4872 fix = {
4873 hackname = vxworks_ioctl_macro;
4874 files = ioLib.h;
4875 mach = "*-*-vxworks*";
4876
4877 c_fix = format;
4878 c_fix_arg = "%0\n"
4879 "#define ioctl(fd, func, arg) (ioctl)(fd, func, (int)(arg))\n";
4880 c_fix_arg = "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);";
4881
4882 test_text = "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;";
4883 };
4884
4885 /*
4886 * Wrap VxWorks mkdir to be posix compliant
4887 */
4888 fix = {
4889 hackname = vxworks_mkdir_macro;
4890 files = sys/stat.h;
4891 mach = "*-*-vxworks*";
4892
4893 c_fix = format;
4894 c_fix_arg = "%0\n"
4895 "#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n";
4896 c_fix_arg = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*"
4897 "\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */
4898 "(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */
4899 "\\)[\t ]*;";
4900
4901 test_text = "extern STATUS mkdir (const char * _qwerty) ;";
4902 };
4454 4903
4455 /* 4904 /*
4456 * Fix VxWorks <time.h> to not require including <vxTypes.h>. 4905 * Fix VxWorks <time.h> to not require including <vxTypes.h>.
4457 */ 4906 */
4458 fix = { 4907 fix = {
4461 select = "uint_t([ \t]+_clocks_per_sec)"; 4910 select = "uint_t([ \t]+_clocks_per_sec)";
4462 c_fix = format; 4911 c_fix = format;
4463 c_fix_arg = "unsigned int%1"; 4912 c_fix_arg = "unsigned int%1";
4464 test_text = "uint_t\t_clocks_per_sec;"; 4913 test_text = "uint_t\t_clocks_per_sec;";
4465 }; 4914 };
4466
4467 4915
4468 /* 4916 /*
4469 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>. 4917 * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
4470 */ 4918 */
4471 fix = { 4919 fix = {
4482 test_text = "`touch types/vxTypesOld.h`" 4930 test_text = "`touch types/vxTypesOld.h`"
4483 "#include </dev/null> /* ULONG */\n" 4931 "#include </dev/null> /* ULONG */\n"
4484 "# define\t__INCstath <sys/stat.h>"; 4932 "# define\t__INCstath <sys/stat.h>";
4485 }; 4933 };
4486 4934
4935 /*
4936 * Make it so VxWorks does not include gcc/regs.h accidentally
4937 */
4938 fix = {
4939 hackname = vxworks_regs;
4940 mach = "*-*-vxworks*";
4941
4942 select = "#[\t ]*include[\t ]+[<\"]regs.h[>\"]";
4943 c_fix = format;
4944 c_fix_arg = "#include <arch/../regs.h>";
4945
4946 test_text = "#include <regs.h>\n";
4947 };
4487 4948
4488 /* 4949 /*
4489 * Another bad dependency in VxWorks 5.2 <time.h>. 4950 * Another bad dependency in VxWorks 5.2 <time.h>.
4490 */ 4951 */
4491 fix = { 4952 fix = {
4509 4970
4510 test_text = "`touch vxWorks.h`" 4971 test_text = "`touch vxWorks.h`"
4511 "#define VOIDFUNCPTR (void(*)())"; 4972 "#define VOIDFUNCPTR (void(*)())";
4512 }; 4973 };
4513 4974
4975 /*
4976 * This hack makes write const-correct on VxWorks
4977 */
4978 fix = {
4979 hackname = vxworks_write_const;
4980 files = ioLib.h;
4981 mach = "*-*-vxworks*";
4982
4983 c_fix = format;
4984 c_fix_arg = "extern int write (int, const char*, size_t);";
4985 c_fix_arg = "extern[\t ]+int[\t ]+write[\t ]*\\("
4986 "[\t ]*int[\t ]*,"
4987 "[\t ]*char[\t ]*\\*[\t ]*,"
4988 "[\t ]*size_t[\t ]*\\)[\t ]*;";
4989
4990 test_text = "extern int write ( int , char * , size_t ) ;";
4991 };
4514 4992
4515 /* 4993 /*
4516 * There are several name conflicts with C++ reserved words in X11 header 4994 * There are several name conflicts with C++ reserved words in X11 header
4517 * files. These are fixed in some versions, so don't do the fixes if 4995 * files. These are fixed in some versions, so don't do the fixes if
4518 * we find __cplusplus in the file. These were found on the RS/6000. 4996 * we find __cplusplus in the file. These were found on the RS/6000.
4529 "struct {\n" 5007 "struct {\n"
4530 " char *class;\n" 5008 " char *class;\n"
4531 "} mumble;\n"; 5009 "} mumble;\n";
4532 }; 5010 };
4533 5011
4534
4535 /* 5012 /*
4536 * class in Xm/BaseClassI.h 5013 * class in Xm/BaseClassI.h
4537 */ 5014 */
4538 fix = { 5015 fix = {
4539 hackname = x11_class_usage; 5016 hackname = x11_class_usage;
4544 c_fix = format; 5021 c_fix = format;
4545 c_fix_arg = " c_class)"; 5022 c_fix_arg = " c_class)";
4546 5023
4547 test_text = "extern mumble (int class);\n"; 5024 test_text = "extern mumble (int class);\n";
4548 }; 5025 };
4549
4550 5026
4551 /* 5027 /*
4552 * new in Xm/Traversal.h 5028 * new in Xm/Traversal.h
4553 */ 5029 */
4554 fix = { 5030 fix = {
4569 "struct wedge {\n" 5045 "struct wedge {\n"
4570 " Widget\told, new;\n" 5046 " Widget\told, new;\n"
4571 "};\nextern Wedged( Widget new, Widget old );"; 5047 "};\nextern Wedged( Widget new, Widget old );";
4572 }; 5048 };
4573 5049
4574
4575 /* 5050 /*
4576 * Incorrect sprintf declaration in X11/Xmu.h 5051 * Incorrect sprintf declaration in X11/Xmu.h
4577 */ 5052 */
4578 fix = { 5053 fix = {
4579 hackname = x11_sprintf; 5054 hackname = x11_sprintf;
4584 c_fix = format; 5059 c_fix = format;
4585 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */"; 5060 c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
4586 5061
4587 test_text = "extern char *\tsprintf();"; 5062 test_text = "extern char *\tsprintf();";
4588 }; 5063 };
4589
4590 /*EOF*/ 5064 /*EOF*/