[patch] Protect generated .h files from multiple inclusion, include tm.h in hooks.h, and FIX BOOTSTRAP

Nathanael Nerode neroden@twcny.rr.com
Thu Jun 19 01:50:00 GMT 2003


This is a revised version of 
http://gcc.gnu.org/ml/gcc-patches/2003-06/msg02146.html.
This version protects *all* generated headers from multiple inclusion.

Tested on i686-pc-linux-gnu.
(Could get into problems if the use of 'sed' turns out to be unportable
in some stupid way, but I doubt that.)

(incidentally, the URL for my bootstrap breakage report was incorrect
in my previous patch: the correct reference was 
http://gcc.gnu.org/ml/gcc/2003-06/msg01593.html)

	* mkconfig.sh: Protect generated headers from multiple inclusion.
	* hooks.h: Include tm.h.

Index: mkconfig.sh
===================================================================
RCS file: /cvs/gcc/gcc/gcc/mkconfig.sh,v
retrieving revision 1.12
diff -u -r1.12 mkconfig.sh
--- mkconfig.sh	16 Dec 2002 18:19:44 -0000	1.12
+++ mkconfig.sh	19 Jun 2003 01:14:34 -0000
@@ -33,6 +33,14 @@
 output=$1
 rm -f ${output}T
 
+# This converts a file name into header guard macro format.
+hg_sed_expr='y/abcdefghijklmnopqrstuvwxyz./ABCDEFGHIJKLMNOPQRSTUVWXYZ_/'
+header_guard=GCC_`echo ${output} | sed -e ${hg_sed_expr}`
+
+# Add multiple inclusion protection guard, part one.
+echo "#ifndef ${header_guard}" >> ${output}T
+echo "#define ${header_guard}" >> ${output}T
+
 # Define TARGET_CPU_DEFAULT if the system wants one.
 # This substitutes for lots of *.h files.
 if [ "$TARGET_CPU_DEFAULT" != "" ]; then
@@ -84,6 +92,9 @@
 EOF
     ;;
 esac
+
+# Add multiple inclusion protection guard, part two.
+echo "#endif /* ${header_guard} */" >> ${output}T
 
 # Avoid changing the actual file if possible.
 if [ -f $output ] && cmp ${output}T $output >/dev/null 2>&1; then
Index: hooks.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/hooks.h,v
retrieving revision 1.16
diff -u -r1.16 hooks.h
--- hooks.h	18 Jun 2003 19:43:49 -0000	1.16
+++ hooks.h	19 Jun 2003 01:14:34 -0000
@@ -22,6 +22,10 @@
 #ifndef GCC_HOOKS_H
 #define GCC_HOOKS_H
 
+/* We need the definition of enum reg_class (which is in tm.h)
+   for hook_reg_class_void_no_regs. */
+#include "tm.h"
+
 bool hook_bool_void_false PARAMS ((void));
 enum reg_class hook_reg_class_void_no_regs (void);
 bool hook_bool_bool_false (bool);

-- 
Nathanael Nerode  <neroden at gcc.gnu.org>
Don't use the GNU FDL for free documentation.  See
<http://home.twcny.rr.com/nerode/neroden/fdl.html>



More information about the Gcc-patches mailing list