This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch for `Shouldn't fixincludes remove assert.h instead of trying to fix it?'


On Thu, 19 March 1998, 09:38:00, manfred@s-direktnet.de wrote:

    On Wed, 18 March 1998, 15:16:15, wilson@cygnus.com wrote:
    
        What happens if a file in /usr/include includes "assert.h" ?  What is
        something in /usr/include/sys includes "../assert.h"?  We don't want
        it to include the possibly broken /usr/include/assert.h.  We might have to
        have an assert.h file in the fixinclude directory just to avoid this problem.
        
        It doesn't necessarily have to be a fixed copy of the /usr/include/assert.h 
        file though.  It could be perhaps be gcc's assert.h file instead.  Changing
        where we install assert.h would require fixing some header file search 
        directory problems though.  For instance, TOOL_INCLUDE_DIR comes before
        GCC_INCLUDE_DIR when native but after cross, which means such a change may
        have undesirable side-effects that will need to be dealt with.
        
    Why not simply install it in both directories?

How about this (it includes my stdlib.h fix necessary on
m68k-motorola-sysv)?

Thu Mar 19 11:34:07 1998  Manfred Hollstein  <manfred@s-direktnet.de>

	* fixincludes (assert.h): Don't even try to fix a system's
	probably broken assert.h - we provide our own.
	(stdlib.h): Create missing stdlib.h on m68k-motorola-sysv.
	* Makefile.in (stmp-fixinc): Copy our own assert.h into the
	fixed include directory.

diff -rup -x CVS -x RCS -x *.o -x *.info* -x *.html* -x *.elc -x *.dvi -x *.orig -x *~ -x version.el egcs-980317.orig/gcc/Makefile.in egcs-980317/gcc/Makefile.in
--- egcs-980317.orig/gcc/Makefile.in	Fri Feb 20 14:32:30 1998
+++ egcs-980317/gcc/Makefile.in	Fri Feb 20 14:32:30 1998
@@ -1925,6 +1925,9 @@ stmp-fixinc: $(FIXINCLUDES) gsyslimits.h
 	  cp $(srcdir)/gsyslimits.h include/syslimits.h; \
 	fi
 	chmod a+r include/syslimits.h
+	rm -f include/assert.h
+	cp $(srcdir)/assert.h include/assert.h
+	chmod a+r include/assert.h
 	touch stmp-fixinc
 
 # Files related to the fixproto script.
diff -rup -x CVS -x RCS -x *.o -x *.info* -x *.html* -x *.elc -x *.dvi -x *.orig -x *~ -x version.el egcs-980317.orig/gcc/fixincludes egcs-980317/gcc/fixincludes
--- egcs-980317.orig/gcc/fixincludes	Tue Jan 27 22:16:28 1998
+++ egcs-980317/gcc/fixincludes	Tue Mar 17 13:30:29 1998
@@ -354,6 +354,27 @@ done
 
 cd ${INPUT}
 
+# stdlib.h is missing on m68k-motorola-sysv. fix-header later adds one, but
+# that is missing definitions for at least size_t.
+file=stdlib.h
+if [ $target_canonical = m68k-motorola-sysv ]; then
+  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
+  else
+    echo Creating missing stdlib.h
+    cat > ${LIB}/$file << EOF
+#ifndef stdlib_h
+# define stdlib_h
+
+# include <stddef.h>	/* Make sure we get all necessary type definitions.  */
+
+#endif /* stdlib_h */
+EOF
+  fi
+fi
+
 # Install the proper definition of the three standard types in header files
 # that they come from.
 for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do
@@ -2371,81 +2392,6 @@ struct exception;
   fi
 fi
 
-# assert.h and sys/mman.h on HP/UX are not C++ ready, even though
-# NO_IMPLICIT_EXTERN_C is defined on HP/UX.
-for file in assert.h sys/mman.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
-    if egrep '"C"' ${LIB}/$file >/dev/null 2>&1 \
-       || egrep '__BEGIN_DECLS' ${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
-    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
-done
-
-# check for broken assert.h that needs stdio.h or stdlib.h
-file=assert.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 grep 'stderr' ${LIB}/$file >/dev/null 2>/dev/null; then
-    if grep 'include.*stdio.h' ${LIB}/$file >/dev/null 2>/dev/null; then
-      true
-    else
-      echo "Fixing $file (needs stdio.h)"
-      echo '#include <stdio.h>' >>${LIB}/$file
-    fi
-  fi
-  if grep 'exit *(' ${LIB}/$file >/dev/null 2>/dev/null || 
-     grep 'abort *(' ${LIB}/$file >/dev/null 2>/dev/null; then
-    if grep 'include.*stdlib.h' ${LIB}/$file >/dev/null 2>/dev/null; then
-      true
-    else
-      echo "Fixing $file (needs stdlib.h)"
-      echo '#ifdef __cplusplus
-#include <stdlib.h>
-#endif' >>${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 return value of sbrk in unistd.h on Alpha OSF/1 V2.0
 file=unistd.h
 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
@@ -2999,6 +2945,12 @@ if [ \! -z "$file_to_fix" ]; then
   rm -f /tmp/$base
 fi
 
+# As gcc provides its own assert.h don't even try to fix the system's one.
+file=assert.h
+if [ -r ${LIB}/$file ]; then
+  echo "Removing $file"
+  rm -f $file
+fi
 
 # This loop does not appear to do anything, because it uses file
 # rather than $file when setting target.  It also appears to be


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]