OSDN Git Service

(tablejump_internal4+1): Fix typo in condition.
[pf3gnuchains/gcc-fork.git] / gcc / fixincludes
index 8c7efc0..bdbd2dd 100755 (executable)
@@ -371,6 +371,10 @@ for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do
       -e '/typedef[    ][      ]*[a-z_][       a-z_]*[         ]wchar_t/i\
 #ifndef __WCHAR_TYPE__\
 #define __WCHAR_TYPE__ int\
+#endif\
+#ifndef __cplusplus
+' \
+      -e '/typedef[    ][      ]*[a-z_][       a-z_]*[         ]wchar_t/a\
 #endif
 ' \
       -e 's/typedef[   ][      ]*[a-z_][       a-z_]*[         ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \
@@ -700,6 +704,31 @@ if [ -r ${LIB}/$file ]; then
   fi
 fi
 
+# Check for (...) in C++ code in HP/UX sys/file.h.
+file=sys/file.h
+if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
+  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
+  chmod +w ${LIB}/$file 2>/dev/null
+  chmod a+r ${LIB}/$file 2>/dev/null
+fi
+
+if [ -r ${LIB}/$file ]; then
+  if egrep HPUX_SOURCE ${LIB}/$file > /dev/null; then
+    echo Fixing $file, use of '(...)'
+    sed -e 's/(\.\.\.)/(struct file * ...)/' ${LIB}/$file > ${LIB}/${file}.sed
+    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
+    if cmp $file ${LIB}/$file >/dev/null 2>&1; then
+      rm ${LIB}/$file
+    else
+      # Find any include directives that use "file".
+      for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
+       dir=`echo $file | sed -e s'|/[^/]*$||'`
+       required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
+      done
+    fi
+  fi
+fi
+
 # Check for superfluous `static' (in Ultrix 4.2)
 # On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken.
 file=machine/cpu.h
@@ -878,10 +907,10 @@ if [ -r ${LIB}/$file ]; then
   echo Fixing $file
   sed -e 's/int        abort/void      abort/g' \
   -e 's/int    free/void       free/g' \
-  -e 's/char \*        calloc/void \*  calloc/g' \
-  -e 's/char \*        malloc/void \*  malloc/g' \
-  -e 's/char \*        realloc/void \* realloc/g' \
-  -e 's/int    exit/void       exit/g' \
+  -e 's/char[  ]*\*[   ]*calloc/void \*        calloc/g' \
+  -e 's/char[  ]*\*[   ]*malloc/void \*        malloc/g' \
+  -e 's/char[  ]*\*[   ]*realloc/void \*       realloc/g' \
+  -e 's/int[   ][      ]*exit/void     exit/g' \
   -e '/typedef[        a-zA-Z_]*[      ]size_t[        ]*;/i\
 #ifndef _GCC_SIZE_T\
 #define _GCC_SIZE_T
@@ -903,6 +932,7 @@ if [ -r ${LIB}/$file ]; then
 fi
 
 # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
+# Also fix return type of {m,re}alloc in <malloc.h> on sysV68
 file=malloc.h
 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
   cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
@@ -914,6 +944,8 @@ if [ -r ${LIB}/$file ]; then
   echo Fixing $file
   sed -e 's/typedef[   ]char \*        malloc_t/typedef void \*        malloc_t/g' \
   -e 's/int[   ][      ]*free/void     free/g' \
+  -e 's/char\([        ]*\*[   ]*malloc\)/void\1/g' \
+  -e 's/char\([        ]*\*[   ]*realloc\)/void\1/g' \
   ${LIB}/$file > ${LIB}/${file}.sed
   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
@@ -1068,6 +1100,18 @@ if [ -r ${LIB}/$file ]; then
   fi
 fi
 
+# There is a similar problem with the VxWorks drv/netif/if_med.h file.
+file=drv/netif/if_med.h
+if [ -r ${LIB}/$file ]; then
+  if egrep 'Wind River' ${LIB}/$file > /dev/null; then
+    echo Fixing $file, overeager sed script
+    rm ${LIB}/$file
+    sed -e 's|//.*$||g' $file > ${LIB}/$file
+    chmod +w ${LIB}/$file 2>/dev/null
+    chmod a+r ${LIB}/$file 2>/dev/null
+  fi
+fi
+
 # Some IRIX header files contains the string "//"
 for file in elf_abi.h elf.h; do
   if [ -r ${LIB}/$file ]; then
@@ -1157,8 +1201,9 @@ fi
 # declaration on Sun OS 4.x.  We must only fix this on Sun OS 4.x, because
 # many other systems have similar text but correct versions of the file.
 # To ensure only Sun's is fixed, we grep for a likely unique string.
+# Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
 file=memory.h
-if [ -r $file ] && egrep '/\*  @\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2   \*/' $file > /dev/null; then
+if [ -r $file ] && egrep '/\*  @\(#\)(head/memory.h    50.1     |memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2       )\*/' $file > /dev/null; then
   if [ ! -r ${LIB}/$file ]; then
     cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
     chmod +w ${LIB}/$file 2>/dev/null
@@ -1190,6 +1235,31 @@ EOF
   fi
 fi
 
+# Fix return type of fread and fwrite on sysV68
+file=stdio.h
+if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
+  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
+  chmod +w ${LIB}/$file 2>/dev/null
+  chmod a+r ${LIB}/$file 2>/dev/null
+fi
+
+if [ -r ${LIB}/$file ]; then
+  echo Fixing $file, fread and fwrite return type
+  sed -e 's/^\(extern int      fclose(), fflush()\), \(fread(), fwrite()\)\(.*\)$/extern unsigned int  \2;\
+\1\3/' \
+    ${LIB}/$file > ${LIB}/${file}.sed
+  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
+  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
+    rm -f ${LIB}/$file
+  else
+    # Find any include directives that use "file".
+    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
+      dir=`echo $file | sed -e s'|/[^/]*$||'`
+      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
+    done
+  fi
+fi
+
 # parameters not const on DECstation Ultrix V4.0 and OSF/1.
 file=stdio.h
 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
@@ -1476,6 +1546,33 @@ if [ -r ${LIB}/$file ]; then
   fi
 fi
 
+# sys/wait.h on AIX 3.2.5 puts the declaration of wait3 before the definition
+# of struct rusage, so the prototype (added by fixproto) causes havoc.
+file=sys/wait.h
+if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
+  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
+  chmod +w ${LIB}/$file 2>/dev/null
+fi
+
+if [ -r ${LIB}/$file ] \
+  && grep 'bos325,' ${LIB}/$file >/dev/null; then
+  echo Fixing $file, wait3 declaration
+  sed -e '/^extern pid_t wait3();$/i\
+struct rusage;
+'\
+    ${LIB}/$file > ${LIB}/${file}.sed
+  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
+  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
+    rm -f ${LIB}/$file
+  else
+    # Find any include directives that use "file".
+    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
+      dir=`echo $file | sed -e s'|/[^/]*$||'`
+      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
+    done
+  fi
+fi
+
 # NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
 # Note that version 3 of the NeXT system has wait.h in a different directory,
 # so that this code won't do anything.  But wait.h in version 3 has a
@@ -1570,7 +1667,7 @@ fi
 if [ -r ${LIB}/$file ]; then
   echo Fixing $file, non-const arg
   sed -e 's@atof(\([   ]*char[         ]*\*[^)]*\))@atof(const \1)@' \
-      -e 's@inline int abs(int [a-z][a-z]*) {.*}@@' \
+      -e 's@inline int abs(int [a-z][a-z]*) {.*}@extern "C" int abs(int);@' \
       -e 's@inline double abs(double [a-z][a-z]*) {.*}@@' \
       -e 's@inline int sqr(int [a-z][a-z]*) {.*}@@' \
       -e 's@inline double sqr(double [a-z][a-z]*) {.*}@@' \
@@ -1587,6 +1684,35 @@ if [ -r ${LIB}/$file ]; then
   fi
 fi
 
+# fix bogus recursive stdlib.h in NEWS-OS 4.0C
+file=stdlib.h
+if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
+  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
+  chmod +w ${LIB}/$file 2>/dev/null
+  chmod a+r ${LIB}/$file 2>/dev/null
+fi
+
+if [ -r ${LIB}/$file ]; then
+  echo Fixing $file, recursive inclusion
+  sed -e '/^#include <stdlib.h>/i\
+#if 0
+' \
+      -e '/^#include <stdlib.h>/a\
+#endif
+' \
+    ${LIB}/$file > ${LIB}/${file}.sed
+  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
+  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
+    rm -f ${LIB}/$file
+  else
+    # Find any include directives that use "file".
+    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
+      dir=`echo $file | sed -e s'|/[^/]*$||'`
+      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
+    done
+  fi
+fi
+
 # Avoid nested comments on Ultrix 4.3.
 file=rpc/svc.h
 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
@@ -1657,6 +1783,40 @@ if [ -r ${LIB}/$file ]; then
   fi
 fi
 
+# rpc/types.h on OSF1/2.0 is not C++ ready, even though NO_IMPLICIT_EXTERN_C
+# is defined for the alpha.  The problem is the declaration of malloc.
+file=rpc/types.h
+if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
+  mkdir ${LIB}/rpc 2>/dev/null
+  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
+  chmod +w ${LIB}/$file 2>/dev/null
+  chmod a+r ${LIB}/$file 2>/dev/null
+fi
+if [ -r ${LIB}/$file ]; then
+  if egrep '"C"' ${LIB}/$file >/dev/null 2>&1; then
+    true
+  else
+    echo Fixing $file
+    echo '#ifdef __cplusplus
+extern "C" {
+#endif' > ${LIB}/${file}.sed
+    cat ${LIB}/${file} >> ${LIB}/${file}.sed
+    echo '#ifdef __cplusplus
+}
+#endif' >> ${LIB}/${file}.sed 
+    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
+    if cmp $file ${LIB}/$file >/dev/null 2>&1; then
+      rm -f ${LIB}/$file
+    else
+      # Find any include directives that use "file".
+      for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
+        dir=`echo $file | sed -e s'|/[^/]*$||'`
+        required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
+      done
+    fi
+  fi
+fi
+
 # In limits.h, put #ifndefs around things that are supposed to be defined
 # in float.h to avoid redefinition errors if float.h is included first.
 # On HP/UX this patch does not work, because on HP/UX limits.h uses
@@ -1801,6 +1961,8 @@ if [ -r ${LIB}/$file ]; then
   fi
 fi
 
+# Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
+# in string.h on sysV68
 # Correct the return type for strlen in string.h on Lynx.
 # Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
 # Add missing const for strdup on OSF/1 V3.0.
@@ -1812,10 +1974,16 @@ if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
 fi
 
 if [ -r ${LIB}/$file ]; then
-  echo Fixing $file
+  echo Fixing $file, mem{ccpy,chr,cpy,set} and str{len,spn,cspn} return value
   sed -e 's/extern[    ]*int[  ]*strlen();/extern unsigned int strlen();/' \
       -e 's/extern[    ]*int[  ]*ffs[  ]*(long);/extern int ffs(int);/' \
       -e 's/strdup(char \*s1);/strdup(const char *s1);/' \
+      -e '/^extern char$/N' \
+      -e 's/^extern char\(\n   \*memccpy(),\)$/extern void\1/'\
+      -e '/^   strncmp(),$/N'\
+      -e 's/^\(        strncmp()\),\n\(        strlen(),\)$/\1;\
+extern unsigned int\
+\2/'\
     ${LIB}/$file > ${LIB}/${file}.sed
   rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
@@ -1916,9 +2084,9 @@ for files in curses.h; do
 #ifndef __cplusplus'\
        -e '/^#[        ]*define[       ][      ]*bool[         ][      ]*char[         ]*$/a\
 #endif'\
-       -e '/^typedef[  ][      ]*char[         ][      ]*bool[         ]*;[    ]*$/i\
+       -e '/^typedef[  ][      ]*char[         ][      ]*bool[         ]*;/i\
 #ifndef __cplusplus'\
-       -e '/^typedef[  ][      ]*char[         ][      ]*bool[         ]*;[    ]*$/a\
+       -e '/^typedef[  ][      ]*char[         ][      ]*bool[         ]*;/a\
 #endif'\
        ${LIB}/$file > ${LIB}/${file}.sed
     rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
@@ -1984,6 +2152,33 @@ for file in stdio.h stdlib.h; do
   fi
 done
 
+# Fix __page_size* declarations in pthread.h AIX 4.1.[34].
+# The original ones fail if uninitialized externs are not common.
+# This is the default for all ANSI standard C++ compilers.
+for file in pthread.h; do
+  if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
+    cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
+    chmod +w ${LIB}/$file 2>/dev/null
+    chmod a+r ${LIB}/$file 2>/dev/null
+  fi
+
+  if [ -r ${LIB}/$file ]; then
+    echo Fixing $file, __page_size* declarations
+    sed -e 's/^int __page_size/extern int __page_size/' \
+      ${LIB}/$file > ${LIB}/${file}.sed
+    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
+    if cmp $file ${LIB}/$file >/dev/null 2>&1; then
+      rm -f ${LIB}/$file
+    else
+      # Find any include directives that use "file".
+      for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
+        dir=`echo $file | sed -e s'|/[^/]*$||'`
+        required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
+      done
+    fi
+  fi
+done
+
 # Determine if we're on Interactive Unix 2.2 or later, in which case we
 # need to fix some additional files.  This is the same test for ISC that
 # Autoconf uses.
@@ -2384,6 +2579,102 @@ if [ -r ${LIB}/$file ]; then
   fi
 fi
     
+# Another bad dependency in VxWorks 5.2 <time.h>.
+file=time.h
+if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
+  mkdir ${LIB}/sys 2>/dev/null
+  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
+  chmod +w ${LIB}/$file 2>/dev/null
+  chmod a+r ${LIB}/$file 2>/dev/null
+fi
+
+if [ -r ${LIB}/$file ]; then
+  if egrep VOIDFUNCPTR ${LIB}/$file >/dev/null 2>&1; then
+    if [ -r vxWorks.h ]; then
+      echo Fixing $file
+      sed -e '/VOIDFUNCPTR/i\
+#ifndef __gcc_VOIDFUNCPTR_defined\
+#ifdef __cplusplus\
+typedef void (*__gcc_VOIDFUNCPTR) (...);\
+#else\
+typedef void (*__gcc_VOIDFUNCPTR) ();\
+#endif\
+#define __gcc_VOIDFUNCPTR_defined\
+#endif
+' \
+         -e 's/VOIDFUNCPTR/__gcc_VOIDFUNCPTR/g' \
+       ${LIB}/$file > ${LIB}/${file}.sed
+      rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
+    fi
+  fi
+  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
+    rm -f ${LIB}/$file
+  else
+    # Find any include directives that use "file".
+    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
+      dir=`echo $file | sed -e s'|/[^/]*$||'`
+      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
+    done
+  fi
+fi
+    
+# This file in A/UX 3.0.x/3.1.x contains an __asm directive for c89; gcc
+# doesn't understand it.
+file=sys/param.h
+if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
+  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
+  chmod +w ${LIB}/$file 2>/dev/null
+  chmod a+r ${LIB}/$file 2>/dev/null
+fi
+
+if [ -r ${LIB}/$file ]; then
+  echo "Fixing __asm directive in sys/param.h"
+  sed -e 's|#ifndef NOINLINE|#if !defined(NOINLINE) \&\& !defined(__GNUC__)|' \
+    ${LIB}/$file > ${LIB}/${file}.sed
+  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
+  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
+    rm -f ${LIB}/$file
+  else
+    # Find any include directives that use "file".
+    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
+      dir=`echo $file | sed -e s'|/[^/]*$||'`
+      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
+    done
+  fi
+fi
+
+# signal.h on SunOS defines signal using (), which causes trouble when
+# compiling with g++ -pedantic.
+for file in signal.h sys/signal.h; do
+  if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
+    cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
+    chmod +w ${LIB}/$file 2>/dev/null
+    chmod a+r ${LIB}/$file 2>/dev/null
+  fi
+
+  if [ -r ${LIB}/$file ]; then
+    echo "Checking for bad C++ prototype in $file"
+    sed -e '/^void     (\*signal())();$/i\
+  #ifdef __cplusplus\
+  void (*signal(...))(...);\
+  #else
+  ' \
+       -e '/^void      (\*signal())();$/a\
+  #endif
+  ' \
+      ${LIB}/$file > ${LIB}/${file}.sed
+    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
+    if cmp $file ${LIB}/$file >/dev/null 2>&1; then
+      rm -f ${LIB}/$file
+    else
+      # Find any include directives that use "file".
+      for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
+       dir=`echo $file | sed -e s'|/[^/]*$||'`
+       required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
+      done
+    fi
+  fi
+done
 
 # This loop does not appear to do anything, because it uses file
 # rather than $file when setting target.  It also appears to be