Patch: New file, tsystem.h

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Tue Feb 1 09:48:00 GMT 2000


This patch adds a new file, tsystem.h, to consolidate handling system
includes and definitions for target files.

The headers which are included are wrapped by inhibit_libc.

The headers we get are either those known to be available everywhere
(based on the fact that we include them unconditionally in system.h,)
or those provided by gcc somehow, or those known to be available
because some target macro is defined (e.g. USG or POSIX.)

Okay to install?

		--Kaveh



2000-02-01  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* tsystem.h: New file.

	* Makefile.in (libgcc2.a, stmp-multilib, crtbegin.o, crtend.o,
	s-crtS): Depend on tsystem.h.

	* crtstuff.c: Include tsystem.h.
	* frame.c: Likewise.
	* libgcc2.c: Likewise.

diff -rup orig/egcs-CVS20000131/gcc/tsystem.h egcs-CVS20000131/gcc/tsystem.h
--- orig/egcs-CVS20000131/gcc/tsystem.h	Tue Feb  1 06:23:59 2000
+++ egcs-CVS20000131/gcc/tsystem.h	Tue Feb  1 06:19:13 2000
@@ -0,0 +1,86 @@
+/* Get common system includes and various definitions and declarations
+   based on target macros.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+#ifndef __GCC_TSYSTEM_H__
+#define __GCC_TSYSTEM_H__
+
+/* GCC supplies this header. */
+#include <stddef.h>
+
+#ifdef inhibit_libc
+
+#ifndef malloc
+extern void *malloc (size_t);
+#endif
+
+#ifndef free
+extern void free (void *);
+#endif
+
+#ifndef atexit
+extern int atexit (void (*)(void));
+#endif
+
+#else /* ! inhibit_libc */
+/* We disable this when inhibit_libc, so that gcc can still be built without
+   needing header files first.  */
+/* ??? This is not a good solution, since prototypes may be required in
+   some cases for correct code.  */
+
+/* GCC supplies this header. */
+#include <stdarg.h>
+
+/* All systems have this header. */
+#include <stdio.h>
+
+/* All systems have this header. */
+#include <sys/types.h>
+
+/* All systems have this header. */
+#include <errno.h>
+
+#ifndef errno
+extern int errno;
+#endif
+
+#if defined(POSIX) || defined(USG)
+#include <string.h>
+#endif
+
+/* GCC (fixproto) guarantees these system headers exist. */
+#include <stdlib.h>
+#include <unistd.h>
+
+/* GCC supplies this header. */
+#include <limits.h>
+
+#if defined(POSIX) || defined(USG)
+#include <time.h>
+#endif
+
+#endif /* inhibit_libc */
+
+/* Define a generic NULL if one hasn't already been defined.  */
+#ifndef NULL
+#define NULL 0
+#endif
+
+#endif /* __GCC_TSYSTEM_H__ */
diff -rup orig/egcs-CVS20000131/gcc/Makefile.in egcs-CVS20000131/gcc/Makefile.in
--- orig/egcs-CVS20000131/gcc/Makefile.in	Sat Jan 29 18:08:53 2000
+++ egcs-CVS20000131/gcc/Makefile.in	Tue Feb  1 06:22:06 2000
@@ -1054,7 +1054,8 @@ libgcc2.ready: $(GCC_PASSES) $(LIBGCC2_D
 
 LIB2ADD = $(srcdir)/frame.c $(LIB2FUNCS_EXTRA) $(LANG_LIB2FUNCS)
 libgcc2.a: libgcc2.c libgcc2.ready $(CONFIG_H) $(FPBIT) $(DPBIT) $(LIB2ADD) \
-   $(MACHMODE_H) longlong.h frame.h gbl-ctors.h config.status stmp-int-hdrs
+   $(MACHMODE_H) longlong.h frame.h gbl-ctors.h config.status stmp-int-hdrs \
+   tsystem.h
 # Actually build it in tmplibgcc2.a, then rename at end,
 # so that libgcc2.a itself remains nonexistent if compilation is aborted.
 	-rm -f tmplibgcc2.a
@@ -1186,7 +1187,7 @@ s-mlib: $(srcdir)/genmultilib Makefile
 
 # Build multiple copies of libgcc.a, one for each target switch.
 stmp-multilib: $(LIBGCC1) libgcc2.c libgcc2.ready $(CONFIG_H) \
-   frame.h \
+   frame.h tsystem.h \
    $(LIB2ADD) $(MACHMODE_H) longlong.h gbl-ctors.h config.status
 	for i in `$(GCC_FOR_TARGET) --print-multi-lib`; do \
 	  dir=`echo $$i | sed -e 's/;.*$$//'`; \
@@ -1272,14 +1273,14 @@ stmp-multilib-sub:
 # linked using GCC on systems using COFF or ELF, for the sake of C++
 # constructors.
 $(T)crtbegin.o: crtstuff.c $(GCC_PASSES) $(CONFIG_H) \
-  defaults.h frame.h gbl-ctors.h stmp-int-hdrs
+  defaults.h frame.h gbl-ctors.h stmp-int-hdrs tsystem.h
 	$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \
 	  -finhibit-size-directive -fno-inline-functions \
 	  -fno-exceptions $(CRTSTUFF_T_CFLAGS) @inhibit_libc@ \
 	  -c $(srcdir)/crtstuff.c -DCRT_BEGIN -o $(T)crtbegin$(objext)
 
 $(T)crtend.o: crtstuff.c $(GCC_PASSES) $(CONFIG_H) \
-  defaults.h frame.h gbl-ctors.h stmp-int-hdrs
+  defaults.h frame.h gbl-ctors.h stmp-int-hdrs tsystem.h
 	$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \
 	  -finhibit-size-directive -fno-inline-functions \
 	  -fno-exceptions $(CRTSTUFF_T_CFLAGS) @inhibit_libc@ \
@@ -1290,7 +1291,7 @@ $(T)crtend.o: crtstuff.c $(GCC_PASSES) $
 crtbeginS.o crtendS.o: s-crtS ; @true
 
 s-crtS: crtstuff.c $(GCC_PASSES) $(CONFIG_H) \
-  defaults.h frame.h gbl-ctors.h stmp-int-hdrs
+  defaults.h frame.h gbl-ctors.h stmp-int-hdrs tsystem.h
 	$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(CRTSTUFF_T_CFLAGS_S) \
 	  -DCRT_BEGIN -DCRTSTUFFS_O -finhibit-size-directive \
 	  -fno-inline-functions -fno-exceptions @inhibit_libc@ -g0 \
diff -rup orig/egcs-CVS20000131/gcc/crtstuff.c egcs-CVS20000131/gcc/crtstuff.c
--- orig/egcs-CVS20000131/gcc/crtstuff.c	Wed Dec 29 16:18:59 1999
+++ egcs-CVS20000131/gcc/crtstuff.c	Tue Feb  1 06:19:13 2000
@@ -1,6 +1,6 @@
 /* Specialized bits of code needed to support construction and
    destruction of file-scope objects in C++ code.
-   Copyright (C) 1991, 1994-1999 Free Software Foundation, Inc.
+   Copyright (C) 1991, 1994-1999, 2000 Free Software Foundation, Inc.
    Contributed by Ron Guilmette (rfg@monkeys.com).
 
 This file is part of GNU CC.
@@ -52,23 +52,9 @@ Boston, MA 02111-1307, USA.  */
    do not apply.  */
 
 #include "tm.h"
-
-/* We disable this when inhibit_libc, so that gcc can still be built without
-   needing header files first.  */
-/* ??? This is not a good solution, since prototypes may be required in
-   some cases for correct code.  See also libgcc2.c/frame.c.  */
-#ifndef inhibit_libc
-/* fixproto guarantees these system headers exist. */
-#include <stdlib.h>
-#include <unistd.h>
-#else
-# ifndef atexit
-extern int atexit(void (*)(void));
-# endif
-#endif
+#include "tsystem.h"
 
 #include "defaults.h"
-#include <stddef.h>
 #include "frame.h"
 
 /* We do not want to add the weak attribute to the declarations of these
diff -rup orig/egcs-CVS20000131/gcc/frame.c egcs-CVS20000131/gcc/frame.c
--- orig/egcs-CVS20000131/gcc/frame.c	Wed Dec 29 16:18:59 1999
+++ egcs-CVS20000131/gcc/frame.c	Tue Feb  1 06:19:13 2000
@@ -1,6 +1,6 @@
 /* Subroutines needed for unwinding stack frames for exception handling.  */
 /* Compile this one with gcc.  */
-/* Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
    Contributed by Jason Merrill <jason@cygnus.com>.
 
 This file is part of GNU CC.
@@ -32,31 +32,12 @@ Boston, MA 02111-1307, USA.  */
    do not apply.  */
 
 #include "tconfig.h"
-
-/* We disable this when inhibit_libc, so that gcc can still be built without
-   needing header files first.  */
-/* ??? This is not a good solution, since prototypes may be required in
-   some cases for correct code.  See also libgcc2.c/crtstuff.c.  */
-#ifndef inhibit_libc
-/* fixproto guarantees these system headers exist. */
-#include <stdlib.h>
-#include <unistd.h>
-
-#else
-#include <stddef.h>
-#ifndef malloc
-extern void *malloc (size_t);
-#endif
-#ifndef free
-extern void free (void *);
-#endif
-#endif
+#include "tsystem.h"
 
 #include "defaults.h"
 
 #ifdef DWARF2_UNWIND_INFO
 #include "dwarf2.h"
-#include <stddef.h>
 #include "frame.h"
 #include "gthr.h"
 
diff -rup orig/egcs-CVS20000131/gcc/libgcc2.c egcs-CVS20000131/gcc/libgcc2.c
--- orig/egcs-CVS20000131/gcc/libgcc2.c	Thu Jan 27 10:44:47 2000
+++ egcs-CVS20000131/gcc/libgcc2.c	Tue Feb  1 06:19:13 2000
@@ -32,36 +32,10 @@ Boston, MA 02111-1307, USA.  */
    do not apply.  */
 
 #include "tconfig.h"
-
-/* We disable this when inhibit_libc, so that gcc can still be built without
-   needing header files first.  */
-/* ??? This is not a good solution, since prototypes may be required in
-   some cases for correct code.  See also frame.c/crtstuff.c.  */
-#ifndef inhibit_libc
-/* fixproto guarantees these system headers exist. */
-#include <stdlib.h>
-#include <unistd.h>
-
-#else
-#ifndef L_trampoline
-#include <stddef.h>
-#ifndef malloc
-extern void *malloc (size_t);
-#endif
-#ifndef free
-extern void free (void *);
-#endif
-#ifndef atexit
-extern int atexit(void (*)(void));
-#endif
-#endif
-#endif
+#include "tsystem.h"
 
 #include "machmode.h"
 #include "defaults.h" 
-#ifndef L_trampoline
-#include <stddef.h>
-#endif
 
 /* Don't use `fancy_abort' here even if config.h says to use it.  */
 #ifdef abort


More information about the Gcc-patches mailing list