]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - fixincludes/inclhack.def
fix PR89864
[thirdparty/gcc.git] / fixincludes / inclhack.def
index fd12062e16561f6f8d3911079f52eb8a0f16174a..d8ce89ac8c4475fdfc2bfd855e182d3cbabe51a1 100644 (file)
@@ -377,11 +377,15 @@ fix = {
     mach        = "*-*-vxworks*";
         
     replace     = <<- _EndOfHeader_
-       #ifndef _ASSERT_H
+       #ifdef _ASSERT_H
+       #undef _ASSERT_H
+       #undef assert
+       #endif
+
        #define _ASSERT_H
 
-       #ifdef assert
-       #undef assert
+       #ifdef __cplusplus
+       extern "C" {
        #endif
 
        #if defined(__STDC__) || defined(__cplusplus)
@@ -399,11 +403,13 @@ fix = {
 
        #define assert(test) ((void) \
                ((test) ? ((void)0) : \
-               __assert("Assertion failed: " ASSERT_STRINGIFY(test) ", file " \
+               __assert("Assertion failed: " #test ", file " \
                __FILE__ ", line " ASSERT_STRINGIFY(__LINE__) "\n")))
 
        #endif
 
+       #ifdef __cplusplus
+       }
        #endif
        _EndOfHeader_;
 };
@@ -420,124 +426,18 @@ fix = {
     replace     = <<- _EndOfHeader_
        #ifndef _REGS_H
        #define _REGS_H
+       /* regs.h depends on CPU_FAMILY being properly defined, which
+          is done by vxCpu.h.  */
+       #include <types/vxCpu.h>
+       /* regs.h includes a CPU_FAMILY-specific header that requires
+          vxTypesOld.h to already have been included.  Those headers
+          contain proper _ASMLANGUAGE guards around their typedefs,
+          but vxTypesOld.h itself does not. So we avoid including
+          vxTypesOld.h from assembly.  */
+       #ifndef _ASMLANGUAGE
        #include <types/vxTypesOld.h>
-       #include_next <arch/../regs.h>
        #endif
-       _EndOfHeader_;
-};
-
-/*
- * Make VxWorks stdint.h a bit more compliant - add typedefs
- */
-fix = {
-    hackname    = AAB_vxworks_stdint;
-    files       = stdint.h;
-    mach        = "*-*-vxworks*";
-        
-    replace     = <<- _EndOfHeader_
-       #ifndef _STDINT_H
-       #define _STDINT_H
-       /* get int*_t, uint*_t */
-       #include <types/vxTypes.h>
-       
-       /* get legacy vxworks types for compatibility */
-       #include <types/vxTypesOld.h>
-       
-       typedef long intptr_t;
-       typedef unsigned long uintptr_t;
-       
-       typedef int64_t intmax_t;
-       typedef uint64_t uintmax_t;
-       
-       typedef int8_t int_least8_t;
-       typedef int16_t int_least16_t;
-       typedef int32_t int_least32_t;
-       typedef int64_t int_least64_t;
-       
-       typedef uint8_t uint_least8_t;
-       typedef uint16_t uint_least16_t;
-       typedef uint32_t uint_least32_t;
-       typedef uint64_t uint_least64_t;
-       
-       typedef int8_t int_fast8_t;
-       typedef int int_fast16_t;
-       typedef int32_t int_fast32_t;
-       typedef int64_t int_fast64_t;
-       
-       typedef uint8_t uint_fast8_t;
-       typedef unsigned int uint_fast16_t;
-       typedef uint32_t uint_fast32_t;
-       typedef uint64_t uint_fast64_t;
-       
-       /* Ranges */
-       #define UINT8_MAX (~(uint8_t)0)
-       #define UINT8_MIN 0
-       #define UINT16_MAX (~(uint16_t)0)
-       #define UINT16_MIN 0
-       #define UINT32_MAX (~(uint32_t)0)
-       #define UINT32_MIN 0
-       #define UINT64_MAX (~(uint64_t)0)
-       #define UINT64_MIN 0
-       
-       #define UINTPTR_MAX (~(uintptr_t)0)
-       #define UINTPTR_MIN 0
-       
-       /* Need to do int_fast16_t as well, as type
-          size may be architecture dependent */
-       #define UINT_FAST16_MAX (~(uint_fast16_t)0)
-       #define UINT_FAST16_MAX 0
-       
-       #define INT8_MAX (UINT8_MAX>>1)
-       #define INT8_MIN (INT8_MAX+1)
-       #define INT16_MAX (UINT16_MAX>>1)
-       #define INT16_MIN (INT16_MAX+1)
-       #define INT32_MAX (UINT32_MAX>>1)
-       #define INT32_MIN (INT32_MAX+1)
-       #define INT64_MAX (UINT64_MAX>>1)
-       #define INT64_MIN (INT64_MAX+1)
-       
-       #define INTPTR_MAX (UINTPTR_MAX>>1)
-       #define INTPTR_MIN (INTPTR_MAX+1)       
-       
-       #define INT_FAST16_MAX (UINT_FAST16_MAX>>1)
-       #define INT_FAST16_MIN (INT_FAST16_MAX+1)
-       
-       /* now define equiv. constants */
-       #define UINT_FAST8_MAX UINT8_MAX
-       #define UINT_FAST8_MIN UINT_FAST8_MIN
-       #define INT_FAST8_MAX INT8_MAX
-       #define INT_FAST8_MIN INT8_MIN
-       #define UINT_FAST32_MAX UINT32_MAX
-       #define UINT_FAST32_MIN UINT32_MIN
-       #define INT_FAST32_MAX INT32_MAX
-       #define INT_FAST32_MIN INT32_MIN
-       #define UINT_FAST64_MAX UINT64_MAX
-       #define UINT_FAST64_MIN UINT64_MIN
-       #define INT_FAST64_MAX INT64_MAX
-       #define INT_FAST64_MIN INT64_MIN
-       
-       #define UINT_LEAST8_MAX UINT8_MAX
-       #define UINT_LEAST8_MIN UINT8_MIN
-       #define INT_LEAST8_MAX INT8_MAX
-       #define INT_LEAST8_MIN INT8_MIN
-       #define UINT_LEAST16_MAX UINT16_MAX
-       #define UINT_LEAST16_MIN UINT16_MIN
-       #define INT_LEAST16_MAX INT16_MAX
-       #define INT_LEAST16_MIN INT16_MIN
-       #define UINT_LEAST32_MAX UINT32_MAX
-       #define UINT_LEAST32_MIN UINT32_MIN
-       #define INT_LEAST32_MAX INT32_MAX
-       #define INT_LEAST32_MIN INT32_MIN
-       #define UINT_LEAST64_MAX UINT64_MAX
-       #define UINT_LEAST64_MIN UINT64_MIN
-       #define INT_LEAST64_MAX INT64_MAX
-       #define INT_LEAST64_MIN INT64_MIN
-       
-       #define UINTMAX_MAX UINT64_MAX
-       #define UINTMAX_MIN UINT64_MIN
-       #define INTMAX_MAX INT64_MAX
-       #define INTMAX_MIN INT64_MIN
-       
+       #include_next <arch/../regs.h>
        #endif
        _EndOfHeader_;
 };
@@ -954,6 +854,26 @@ fix = {
     test_text = "#define valloc __linux_valloc";
 };
 
+fix = {
+    hackname  = aix_stdlib_vec_malloc;
+    mach      = "*-*-aix*";
+    files     = stdlib.h;
+    select    = "#define[ \t]+malloc[ \t]+vec_malloc";
+    c_fix     = format;
+    c_fix_arg = "extern void *malloc(size_t) __asm__(\"vec_malloc\");";
+    test_text = "#define malloc vec_malloc";
+};
+
+fix = {
+    hackname  = aix_stdlib_vec_calloc;
+    mach      = "*-*-aix*";
+    files     = stdlib.h;
+    select    = "#define[ \t]+calloc[ \t]+vec_calloc";
+    c_fix     = format;
+    c_fix_arg = "extern void *calloc(size_t, size_t) __asm__(\"vec_calloc\");";
+    test_text = "#define calloc vec_calloc";
+};
+
 /*
  * stdlib.h on AIX 4.3 declares strtof() with a non-const first argument.
  */
@@ -1013,6 +933,20 @@ fix = {
     test_text = "typedef volatile int sig_atomic_t;";
 };
 
+/*
+ *  AIX unistd.h defines a static function with an empty parameter list.
+ */
+fix = {
+    hackname  = aix_unistd;
+    mach      = "*-*-aix*";
+    files     = unistd.h;
+
+    select    = "[ \t]+static[ \t]+int[ \t]+getdtablesize\\(\\)";
+    c_fix     = format;
+    c_fix_arg = "\tstatic int\t\tgetdtablesize(void)";
+    test_text = "      static int              getdtablesize()";
+};
+
 /*
  *  Fix __assert declaration in assert.h on Alpha OSF/1.
  */
@@ -1688,6 +1622,25 @@ fix = {
                "#define UINTMAX_C(v) (v ## ULL)";
 };
 
+/*  The SDK included with XCode 10.2 has the file <sys/ucred.h> that uses the
+    C11 _Atomic keyword (exposing it to C++ code).  The work-around here follows
+    the header in declaring the entity volatile when _Atomic is not available.
+*/
+fix = {
+    hackname  = darwin_ucred__Atomic;
+    mach      = "*-*-darwin*";
+    files     = sys/ucred.h;
+    select    = "_Atomic";
+    c_fix     = wrap;
+    c_fix_arg = "#if (__STDC_VERSION__ < 201112L) || defined(__cplusplus)\n"
+               "# define _Atomic volatile\n"
+               "#endif\n";
+    c_fix_arg = "#if (__STDC_VERSION__ < 201112L) || defined(__cplusplus)\n"
+               "# undef _Atomic\n"
+               "#endif\n";
+    test_text = "_Atomic";
+};
+
 /*
  *  Fix <c_asm.h> on Digital UNIX V4.0:
  *  It contains a prototype for a DEC C internal asm() function,
@@ -2366,16 +2319,34 @@ fix = {
 };
 
 /*
- *  Fix C99 constant in __POINTER_SET define.
+ *  The definitions for PTHREAD_MUTEX_INITIALIZER and similar initializers
+ *  in pthread.h need to be constant expressions to be standard complient.
+ *  As a result, we need to remove the void * casts in the initializers
+ *  (see hpux11_pthread_const) and to change the __(M|C|RW)POINTER defines
+ *  to use the long type.
+ */
+fix = {
+    hackname  = hpux11_pthread_pointer;
+    mach      = "*-hp-hpux11.[0-3]*";
+    files     = sys/pthread.h;
+    select    = "(void[ \t]*\\*)(m|c|rw)(_ptr)";
+
+    c_fix     = format;
+    c_fix_arg = "long\t%2%3";
+    test_text = "#define __MPOINTER\t\tvoid\t *m_ptr";
+};
+
+/*
+ *  Remove void pointer cast and fix C99 constant in __POINTER_SET defines.
  */
 fix = {
     hackname  = hpux11_pthread_const;
     mach      = "*-hp-hpux11.[0-3]*";
     files     = sys/pthread.h;
-    select    = "^#define[ \t]*__POINTER_SET[ \t]*\\(\\(void \\*\\) 1LL\\)";
+    select    = "^(#define[ \t]+__POINTER_SET[ \t0,]*)(.*\\))";
 
     c_fix     = format;
-    c_fix_arg = "#define __POINTER_SET\t\t((void *) 1L)";
+    c_fix_arg = "%11";
     test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
 };
 
@@ -4974,7 +4945,7 @@ fix = {
 
     c_fix       = format;
     c_fix_arg   = "%0\n"
-        "#define ioctl(fd, func, arg) (ioctl)(fd, func, (int)(arg))\n";
+        "#define ioctl(fd, func, arg) ioctl(fd, func, (int)(arg))\n";
     c_fix_arg   = "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);";
         
     test_text   = "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;";
@@ -5088,6 +5059,22 @@ fix = {
     test_text       = "extern int write ( int , char * , size_t ) ;";
 };
 
+/*
+ *  This hack ensures the include_next in the fixed unistd.h actually
+ *  finds the system's unistd.h and not the fixed unistd.h again.
+ */
+fix = {
+    hackname    = vxworks_iolib_include_unistd;
+    files       = ioLib.h;
+    mach        = "*-*-vxworks*";
+    select      = "#include \"unistd.h\"";
+
+    c_fix       = format;
+    c_fix_arg   = "#include <unistd.h>";
+
+    test_text       = "#include \"unistd.h\"";
+};
+
 /*
  *  There are several name conflicts with C++ reserved words in X11 header
  *  files.  These are fixed in some versions, so don't do the fixes if