--- gcc/fixincludes 2018/04/24 18:18:28 1.1.1.7 +++ gcc/fixincludes 2018/04/24 18:24:47 1.1.1.8 @@ -289,7 +289,7 @@ while [ $# != 0 ]; do /#define[ ]*[ ]CTRL/ s/'\''\([cgx]\)'\''/\1/g /#define[ ]*[ ]_CTRL/ s/'\''\([cgx]\)'\''/\1/g /#define.BSD43_CTRL/ s/'\''\([cgx]\)'\''/\1/g - /#[el]*if/{ + /#[ ]*[el]*if/{ s/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g s/ bsd4\([0-9]\) / __bsd4\1__ /g @@ -305,16 +305,18 @@ while [ $# != 0 ]; do s/ ns32000 / __ns32000__ /g s/ pdp11 / __pdp11__ /g s/ pyr / __pyr__ /g + s/ sel / __sel__ /g s/ sony_news / __sony_news__ /g s/ sparc / __sparc__ /g s/ sun\([a-z0-9]*\) / __sun\1__ /g + s/ tahoe / __tahoe__ /g s/ tower\([_0-9]*\) / __tower\1__ /g s/ u370 / __u370__ /g s/ u3b\([0-9]*\) / __u3b\1__ /g s/ unix / __unix__ /g s/ vax / __vax__ /g s/ _*MIPSE\([LB]\) / __MIPSE\1__ /g - s/ _*R\([34]\)000 / __R\1000__ /g + s/ _*\([Rr][34]\)000 / __\1000__ /g s/ _*SYSTYPE_\([A-Z0-9]*\) / __SYSTYPE_\1__ /g s/ \([a-zA-Z0-9_][a-zA-Z0-9_]*\) /\1/g @@ -369,6 +371,10 @@ for file in sys/types.h stdlib.h sys/std -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/' \ @@ -698,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 @@ -876,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 @@ -901,6 +932,7 @@ if [ -r ${LIB}/$file ]; then fi # Fix return type of free and {c,m,re}alloc in on SunOS 4.1. +# Also fix return type of {m,re}alloc in 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" @@ -912,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 @@ -1066,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 @@ -1525,6 +1571,7 @@ if [ -r ${LIB}/$file ]; then # Don't claim to have defined va_list. sed -e 's@ va_list @ __gnuc_va_list @' \ -e 's@ va_list)@ __gnuc_va_list)@' \ + -e 's@ _BSD_VA_LIST_));@ __gnuc_va_list));@' \ -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \ -e 's@ va_list@ __va_list__@' \ -e 's@\*va_list@*__va_list__@' \ @@ -1555,7 +1602,7 @@ if [ -r $file ] && [ ! -r ${LIB}/$file ] fi fi -# parameter to atof not const on DECstation Ultrix V4.0. +# parameter to atof not const on DECstation Ultrix V4.0 and NEWS-OS 4.2R. # also get rid of bogus inline definitions in HP-UX 8.0 file=math.h if [ -r $file ] && [ ! -r ${LIB}/$file ]; then @@ -1566,8 +1613,8 @@ fi if [ -r ${LIB}/$file ]; then echo Fixing $file, non-const arg - sed -e 's@atof( char \*__nptr );@atof( const char *__nptr );@' \ - -e 's@inline int abs(int [a-z][a-z]*) {.*}@@' \ + sed -e 's@atof(\([ ]*char[ ]*\*[^)]*\))@atof(const \1)@' \ + -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]*) {.*}@@' \ @@ -1584,6 +1631,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 /i\ +#if 0 +' \ + -e '/^#include /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 @@ -1798,6 +1874,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. @@ -1809,10 +1887,40 @@ if [ -r $file ] && [ ! -r ${LIB}/$file ] 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 + 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 + +# Correct the return type for strlen in strings.h in SunOS 4. +file=strings.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 + sed -e 's/int[ ]*strlen();/__SIZE_TYPE__ strlen();/' \ ${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 @@ -1850,6 +1958,30 @@ if [ -r ${LIB}/$file ]; then fi fi +# Fix `typedef struct term;' on hppa1.1-hp-hpux9. +file=curses.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 + sed -e 's/^[ ]*typedef[ ][ ]*\(struct[ ][ ]*term[ ]*;[ ]*\)$/\1/' \ + ${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 + # For C++, avoid any typedef or macro definition of bool, and use the # built in type instead. for files in curses.h; do @@ -1865,9 +1997,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 @@ -2096,7 +2228,9 @@ if [ -r ${LIB}/$file ]; then true else echo "Fixing $file (needs stdio.h)" - echo '#include ' >>${LIB}/$file + echo '#ifdef __cplusplus +#include +#endif' >>${LIB}/$file fi fi if grep 'exit *(' ${LIB}/$file >/dev/null 2>/dev/null || @@ -2105,7 +2239,9 @@ if [ -r ${LIB}/$file ]; then true else echo "Fixing $file (needs stdlib.h)" - echo '#include ' >>${LIB}/$file + echo '#ifdef __cplusplus +#include +#endif' >>${LIB}/$file fi fi if cmp $file ${LIB}/$file >/dev/null 2>&1; then @@ -2199,6 +2335,137 @@ if [ -r ${LIB}/$file ]; then fi fi +# Fix definitions of macros used by va-i960.h in VxWorks header file. +file=arch/i960/archI960.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 + sed -e 's/__vsiz/__vxvsiz/' -e 's/__vali/__vxvali/' \ + -e s'/__vpad/__vxvpad/' -e 's/__alignof__/__vxalignof__/' \ + ${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 + +# Make VxWorks header which is almost gcc ready fully gcc ready. +file=types/vxTypesBase.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 + sed -e 's/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/#if 1/' \ + -e '/[ ]size_t/i\ +#ifndef _GCC_SIZE_T\ +#define _GCC_SIZE_T +' \ + -e '/[ ]size_t/a\ +#endif +' \ + -e '/[ ]ptrdiff_t/i\ +#ifndef _GCC_PTRDIFF_T\ +#define _GCC_PTRDIFF_T +' \ + -e '/[ ]ptrdiff_t/a\ +#endif +' \ + -e '/[ ]wchar_t/i\ +#ifndef _GCC_WCHAR_T\ +#define _GCC_WCHAR_T +' \ + -e '/[ ]wchar_t/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 + +# Fix VxWorks to not require including . +file=sys/stat.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 '#include' ${LIB}/$file >/dev/null 2>&1; then + : + else + if egrep 'ULONG' ${LIB}/$file >/dev/null 2>&1 \ + && [ -r types/vxTypesOld.h ]; then + echo Fixing $file + sed -e '/#define[ ][ ]*__INCstath/a\ +#include +' \ + ${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 + +# Fix VxWorks to not require including . +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 'uint_t[ ][ ]*_clocks_per_sec' ${LIB}/$file >/dev/null 2>&1; then + echo Fixing $file + sed -e 's/uint_t/unsigned int/' ${LIB}/$file > ${LIB}/${file}.sed + rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file + 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 loop does not appear to do anything, because it uses file # rather than $file when setting target. It also appears to be # unnecessary, since the main loop processes symbolic links.