inclhack.def (alpha___extern_prefix): Renamed to ...
[gcc.git] / gcc / fixinc / inclhack.def
index 374b860a9ed124e706136352445c914133c34bd1..68fbaf5151a9ee8ca92bbf7b12865a404f60304c 100644 (file)
@@ -221,8 +221,9 @@ fix = {
 
 
 /*
- *  Completely replace <sys/byteorder.h>; with a file that implements gcc's
- *  optimized byteswapping.
+ *  Completely replace <sys/byteorder.h> with a file that implements gcc's
+ *  optimized byteswapping.  (The original probably implemented some
+ *  incompatible optimized byteswapping.)
  */
 fix = {
     hackname = AAB_svr4_replace_byteorder;
@@ -233,6 +234,7 @@ fix = {
     mach     = "i[34567]86-*-solaris2.[0-4]";
     mach     = "powerpcle-*-solaris2.[0-4]";
     mach     = "sparc-*-solaris2.[0-4]";
+    mach     = "i[34567]86-sequent-ptx*";
     files    = sys/byteorder.h;
     replace  = <<-  _EndOfHeader_
        #ifndef _SYS_BYTEORDER_H
@@ -521,11 +523,50 @@ fix = {
 
 
 /*
- *  Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V5 <sys/stat.h>.
+ *  Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V4/5 headers.
  */
 fix = {
     hackname  = alpha___extern_prefix;
+    select    = "(.*)(defined\\(__DECC\\)|def[ \t]*__DECC)[ \t]*\n(#[ \t]*pragma[ \t]*extern_prefix.*)";
+
+    mach      = "alpha*-dec-osf*";
+    c_fix     = format;
+    c_fix_arg = "%1 (defined(__DECC) || defined(__PRAGMA_EXTERN_PREFIX))\n%3";
+
+    test_text = "#ifdef  __DECC\n"
+               "#pragma extern_prefix \"_P\"\n"
+               "#   if defined(__DECC)\n"
+               "#     pragma extern_prefix \"_E\"\n"
+               "# if !defined(_LIBC_POLLUTION_H_) && defined(__DECC)\n"
+               "#  pragma extern_prefix \"\"";
+};
+
+
+/*
+ *  Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V4/5 <standards.h>.
+ */
+fix = {
+    hackname  = alpha___extern_prefix_standards;
+    files     = standards.h;
+    select    = ".*!defined\\(_LIBC_POLLUTION_H_\\) && !defined\\(__DECC\\)";
+
+    mach      = "alpha*-dec-osf*";
+    c_fix     = format;
+    c_fix_arg = "%0 && !defined(__PRAGMA_EXTERN_PREFIX)";
+
+    test_text = "#if (_ISO_C_SOURCE>=19990L) && !defined(_LIBC_POLLUTION_H_) && !defined(__DECC)";
+};
+
+
+/*
+ *  Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V5 <sys/mount.h> and
+ *  <sys/stat.h>.  The tests for __DECC are special in various ways, so
+ *  alpha__extern_prefix cannot be used.
+ */
+fix = {
+    hackname  = alpha___extern_prefix_sys_stat;
     files     = sys/stat.h;
+    files     = sys/mount.h;
     select    = "#[ \t]*if[ \t]*defined\\(__DECC\\)";
 
     mach      = "alpha*-dec-osf5*";
@@ -583,19 +624,43 @@ fix = {
 fix = {
     hackname  = alpha_pthread;
     files     = pthread.h;
-    select    = "(#[ \t]*if defined \\(_PTHREAD_ENV_DECC\\) || defined \\(_PTHREAD_ENV_EPCC\\))\n"
+    select    = "((#[ \t]*if)([ \t]*defined[ \t]*\\(_PTHREAD_ENV_DECC\\)|def _PTHREAD_ENV_DECC)(.*))\n"
                "(#[ \t]*define _PTHREAD_USE_PTDNAM_)";
 
     mach      = "alpha*-dec-osf*";
     c_fix     = format;
-    c_fix_arg = "%1 || defined (__PRAGMA_EXTERN_PREFIX)\n%2";
+    c_fix_arg = "%2 defined (_PTHREAD_ENV_DECC)%4 || defined (__PRAGMA_EXTERN_PREFIX)\n%5";
 
     test_text = "#  if defined (_PTHREAD_ENV_DECC) || defined (_PTHREAD_ENV_EPCC)\n"
+               "#   define _PTHREAD_USE_PTDNAM_\n"
+               "#  endif\n"
+               "#  ifdef _PTHREAD_ENV_DECC\n"
                "#   define _PTHREAD_USE_PTDNAM_\n"
                "#  endif";
 };
 
 
+/*
+ *  Recognize GCC in Tru64 UNIX V5.1B <pthread.h>.
+ */
+fix = {
+    hackname  = alpha_pthread_gcc;
+    files     = pthread.h;
+    select    = "#else\n# error <pthread.h>: unrecognized compiler.";
+
+    mach      = "alpha*-dec-osf*";
+    c_fix     = format;
+    c_fix_arg = "#elif defined (__GNUC__)\n"
+               "# define _PTHREAD_ENV_GCC\n"
+               "%0";
+
+    test_text = "# define _PTHREAD_ENV_INTELC\n"
+               "#else\n"
+               "# error <pthread.h>: unrecognized compiler.\n"
+               "#endif";
+};
+
+
 /*
  *  Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
  *  And OpenBSD.
@@ -610,6 +675,23 @@ fix = {
 };
 
 
+/*
+ *  Change external names of wcstok/wcsftime via asm instead of macros on
+ *  Tru64 UNIX V4.0.
+ */
+fix = {
+    hackname = alpha_wchar;
+    files    = wchar.h;
+
+    mach     = "alpha*-dec-osf4*";
+    select   = "#define wcstok wcstok_r";
+    sed      = "s@#define wcstok wcstok_r@extern wchar_t *wcstok __((wchar_t *, const wchar_t *, wchar_t **)) __asm__(\"wcstok_r\");@";
+    sed      = "s@#define wcsftime __wcsftime_isoc@extern size_t   wcsftime __((wchar_t *, size_t, const wchar_t *, const struct tm *)) __asm__(\"__wcsftime_isoc\");@";
+    test_text = "#define wcstok wcstok_r\n"
+               "#define wcsftime __wcsftime_isoc";
+};
+
+
 /*
  *  For C++, avoid any typedef or macro definition of bool,
  *  and use the built in type instead.
@@ -694,20 +776,31 @@ fix = {
 
     select   = "^[ \t]*#[ \t]*pragma[ \t]+extern_prefix";
 
-    files    = libgen.h;
     files    = dirent.h;
     files    = ftw.h;
     files    = grp.h;
+    files    = libgen.h;
     files    = ndbm.h;
     files    = pthread.h;
     files    = pwd.h;
     files    = signal.h;
     files    = standards.h;
+    files    = stdio.h;
     files    = stdlib.h;
     files    = string.h;
     files    = stropts.h;
+    files    = sys/mount.h;
+    files    = sys/resource.h;
+    files    = sys/signal.h;
+    files    = sys/socket.h;
+    files    = sys/stat.h;
+    files    = sys/stropts.h;
+    files    = sys/uio.h;
     files    = time.h;
     files    = unistd.h;
+    files    = utmp.h;
+    files    = utmpx.h;
+    files    = wchar.h;
 
     sed      =
         "s/^[ \t]*#[ \t]*define[ \t][ \t]*\\([^(]*\\)\\(([^)]*)\\)[ \t]*"
@@ -895,6 +988,24 @@ fix = {
 };
 
 
+/*
+ *  __private_extern__ doesn't exist in FSF GCC.  Even if it did,
+ *  why would you ever put it in a system header file?
+ */
+fix = {
+  hackname  = darwin_private_extern;
+  mach      = "*-*-darwin*";
+  files     = mach-o/dyld.h;
+  select    = "__private_extern__ [a-z_]+ _dyld_";
+  c_fix     = format;
+  c_fix_arg = "extern";
+  c_fix_arg = "__private_extern__";
+  test_text = "__private_extern__ int _dyld_func_lookup(\n"
+             "const char *dyld_func_name,\n"
+             "unsigned long *address);\n";
+};
+
+
 /*
  *  Fix <c_asm.h> on Digital UNIX V4.0:
  *  It contains a prototype for a DEC C internal asm() function,
@@ -1187,6 +1298,25 @@ fix = {
 };
 
 
+/*
+ *  Fix hpux 11.00 broken snprintf declaration
+ *  (third argument is char *, needs to be const char * to prevent
+ *  spurious warnings with -Wwrite-strings or in C++).
+ */
+fix = {
+    hackname = hpux11_snprintf;
+    files    = stdio.h;
+    select   = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
+                                    ' *(char *\*, *\.\.\.\);)';
+    c_fix     = format;
+    c_fix_arg = '%1 const %3';
+
+    test_text = "extern int snprintf(char *, size_t, char *, ...);\n"
+                "extern int snprintf(char *, __size_t, char *, ...);\n"
+                "extern int snprintf(char *, _hpux_size_t, char *, ...);";
+};
+
+
 /*
  * In inttypes.h on HPUX 11, the use of __CONCAT__ in the definition
  * of UINT32_C has undefined behavior according to ISO/ANSI:
@@ -1478,9 +1608,9 @@ fix = {
     files     = stdio.h;
     files     = internal/stdio_core.h;
 
-    select = '(printf\(.*), /\* va_list \*/ char \*';
+    select = '/\* va_list \*/ char \*';
     c_fix  = format;
-    c_fix_arg = "%1, __gnuc_va_list";
+    c_fix_arg = "__gnuc_va_list";
     test_text =
     "extern int printf( const char *, /* va_list */ char * );";
 };
@@ -1649,6 +1779,21 @@ fix = {
 };
 
 
+/*
+ * Apparently some SVR4 systems typedef longlong_t to long ?
+ */
+#ifdef SVR4
+fix = {
+    hackname  = longlong_t;
+    select    = "typedef[ \t]+(unsigned[ \t]+)?long[ \t]+(u_)?longlong_t";
+    c_fix     = format;
+    c_fix_arg = "typedef %1long long %2longlong_t";
+    test_text = "typedef long longlong_t\n"
+                "typedef unsigned long u_longlong_t";
+};
+#endif
+
+
 /*
  *  Delete the '#define void int' line from curses.h on Lynx
  */
@@ -1939,6 +2084,31 @@ fix = {
 };
 
 
+/*
+ *  obstack.h used casts as lvalues.
+ *
+ *  We need to change postincrements of casted pointers (which are
+ *  then dereferenced and assigned into) of the form
+ *
+ *    *((TYPE*)PTRVAR)++ = (VALUE)
+ *
+ *  into expressions like
+ *
+ *    ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
+ *
+ *  which is correct for the cases used in obstack.h since PTRVAR is
+ *  of type char * and the value of the expression is not used.
+ */
+fix = {
+    hackname  = obstack_lvalue_cast;
+    files     = obstack.h;
+    select    = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
+    c_fix     = format;
+    c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
+    test_text = "*((void **) (h)->next_free)++ = (aptr)";
+};
+
+
 /*
  *  sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
  *  defining regex.h related types.  This causes libg++ build and usage
@@ -1998,6 +2168,30 @@ fix = {
 };
 
 
+/*
+ * On DYNIX/ptx, sys/mc_param.h has an embedded asm for the cpuid instruction
+ * on the P5. This is not used by anything else so we ifdef it out.
+ * Current GCC doesn't seem to complain about the asm, though.
+ */
+#ifdef PTX
+fix = {
+    hackname  = ptx_sys_mc_param_h;
+    files     = sys/mc_param.h;
+    sed       = "/__asm/,/}/{"
+                  "/__asm/i\\\n"
+                  "#if !defined (__GNUC__) && !defined (__GNUG__)\n"
+                  "/}/a\\\n"
+                  "#endif\n"
+                "}";
+    test_text = "__asm\n"
+                "int _CPUID()\n"
+                "{\n"
+                "   non-GNU assembly here\n"
+                "}";
+};
+#endif
+
+
 /*
  *  Fix return type of fread and fwrite on sysV68
  */
@@ -2295,7 +2489,8 @@ fix = {
 fix = {
     hackname  = solaris_widec;
     files     = widec.h;
-    mach      = '*-*-solaris2.[0-5]*';
+    mach      = '*-*-solaris2.[0-5]';
+    mach      = '*-*-solaris2.[0-5].*';
     bypass    = "include.*wchar\\.h";
     select    = "#include <euc.h>";
     c_fix     = format;
@@ -2362,9 +2557,7 @@ fix = {
      * instead of va_list.
      * Don't claim to have defined va_list.
      */
-    sed = "s@ va_list @ __gnuc_va_list @\n"
-          "s@ va_list)@ __gnuc_va_list)@\n"
-         "s@va_list _ap;@__gnuc_va_list _ap;@\n"
+    sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
          "s@(va_list)&@(__gnuc_va_list)\\&@\n"
           "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
           "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
@@ -2803,7 +2996,6 @@ fix = {
      * in any case. -- Nathanael */
     mach     = '*-*-sysv4*';
     mach     = 'i?86-sequent-ptx*';
-    mach     = 'i?86-sequent-sysv3*';
     files    = fs/rfs/rf_cache.h;
     files    = sys/erec.h;
     files    = sys/err.h;
@@ -2889,6 +3081,34 @@ fix = {
 #endif
 
 
+/*
+ * Some SVR4 systems supposedly use these non-ANSI preprocessor directives.
+ */
+#ifdef SVR4
+fix = {
+    hackname  = svr4_preproc_lint_on;
+    select    = '#lint\(on\)';
+    c_fix     = format;
+    c_fix_arg = 'defined(lint)';
+    test_text = "#if #lint(on)";
+};
+fix = {
+    hackname  = svr4_preproc_lint_off;
+    select    = '#lint\(off\)';
+    c_fix     = format;
+    c_fix_arg = '!defined(lint)';
+    test_text = "#if #lint(off)";
+};
+fix = {
+    hackname  = svr4_preproc_machine;
+    select    = '#(machine|system|cpu)\(([^)]*)\)';
+    c_fix     = format;
+    c_fix_arg = 'defined(__%1__)';
+    test_text = "#if #machine(i386) || #system(vax) || #cpu(sparc)";
+};
+#endif
+
+
 /*
  *   Fix broken decl of profil present on some svr4 systems.
  */
@@ -2975,6 +3195,22 @@ fix = {
 };
 #endif
 
+
+/*
+ * Correct types for signal handler constants like SIG_DFL; they might be
+ * void (*) (), and should be void (*) (int).  C++ doesn't like the
+ * old style.
+ */
+fix = {
+    hackname = svr4_sighandler_type;
+    files = sys/signal.h;
+    select = 'void *\(\*\)\(\)';
+    c_fix = format;
+    c_fix_arg = "void (*)(int)";
+    test_text = "#define SIG_DFL (void(*)())0\n"
+                "#define SIG_IGN (void (*)())0\n";
+};
+
 /*
  *  Put storage class at start of decl, to avoid warning.
  */
@@ -3332,6 +3568,8 @@ fix = {
 /*
  *  Fix multiple defines for NULL.  Sometimes, we stumble into \r\n
  *  terminated lines, so accommodate these.  Test both ways.
+ *  Don't bother to reproduce the \r\n termination, as GCC has to
+ *  recognize \n termination anyway.
  */
 fix = {
     hackname  = undefine_null;
@@ -3339,10 +3577,11 @@ fix = {
     bypass    = "#[ \t]*(ifn|un)def[ \t]+NULL($|[ \t\r])";
 
     c_fix     = format;
-    c_fix_arg = "#ifndef NULL%2\n#define NULL%1%2\n#endif%2\n";
-    c_fix_arg = "^#[ \t]*define[ \t]*[ \t]NULL([^\r\n]+)([\r]*)\n";
+    c_fix_arg = "#ifndef NULL\n#define NULL%1\n#endif\n";
+    c_fix_arg = "^#[ \t]*define[ \t]+NULL([^\r\n]+)[\r]*\n";
 
-    test_text = "#define NULL 0UL\r\n#define NULL\t((void*)0)\n";
+    test_text = "#define NULL 0UL\r\n"
+                "#define NULL\t((void*)0)\n";
 };
 
 /*