This is the mail archive of the gcc-patches@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]

RFA: libiberty: do not unconditionally include stdio.h


Hi Guys,

  I would like to place the following patch up for consideration.  It
  undoes this patch:

Thu Jun  8 09:25:54 2000  Philippe De Muyter  <phdm@macqel.be>

	* cp-demangle.c (stdio.h): File included unconditionaly.
	* dyn-string.c (stdio.h): File included.

  Which was submitted because NULL was not being defined when
  bootstrapping on an m68k-motorola-sysv system.  Instead the new
  patch defines NULL itself (if needed), and also prevents the
  inclusion of any of the standard C header files unless
  STANDALONE_DEMANGLE or CP_DEMANGLE_DEBUG are defined.

  (I was not sure if I could use Mo McKinlay's suggestion of including
  stddef.h, since the whole point of this exercise to avoid the
  inclusion of any C header file at all). 

  The patch is actually intended to fix the following build failure
  when compiling a cross compiler: 

gcc/../libiberty/cp-demangle.c:31:20: stdlib.h: No such file or directory
gcc/../libiberty/cp-demangle.c:34:19: stdio.h: No such file or directory
gcc/../libiberty/cp-demangle.c:37:20: string.h: No such file or directory

  This happens when trying to build libgcc, if G++ is being built, and
  only if a cross compiler is being built.  The files cannot be
  found, because for a cross compiler, the target header files have
  not been installed at the time when libgcc is built.


  Should I apply the patch ?

Cheers
	Nick


2000-07-13  Nick Clifton  <nickc@cygnus.com>

	* cp-demangle.c: Only include C headers if
	STANDALONE_DEMANGLE or CP_DEMANGLE_DEBUG are defined.
	Define NULL if not defined by any of the included files.

	* dyn-string.c: Only include C headers if
	STANDALONE_DEMANGLE or CP_DEMANGLE_DEBUG are defined.
	Define NULL if not defined by any of the included files.

Index: libiberty/cp-demangle.c
===================================================================
RCS file: /cvs/gcc/egcs/libiberty/cp-demangle.c,v
retrieving revision 1.10
diff -p -r1.10 cp-demangle.c
*** cp-demangle.c	2000/06/30 15:25:32	1.10
--- cp-demangle.c	2000/07/13 23:51:23
***************
*** 27,32 ****
--- 27,34 ----
  #include "config.h"
  #endif
  
+ #if defined(CP_DEMANGLE_DEBUG) || defined(STANDALONE_DEMANGLER)
+ 
  #ifdef HAVE_STDLIB_H
  #include <stdlib.h>
  #endif
***************
*** 37,46 ****
--- 39,56 ----
  #include <string.h>
  #endif
  
+ #endif
+ 
  #include "ansidecl.h"
  #include "libiberty.h"
  #include "dyn-string.h"
  #include "demangle.h"
+ 
+ /* If the standard C header files have not been included above, then
+    on some targets we can end up without a definition of NULL.  */
+ #ifndef NULL
+ #define NULL ((void*)0)
+ #endif
  
  /* If CP_DEMANGLE_DEBUG is defined, a trace of the grammar evaluation,
     and other debugging output, will be generated. */

Index: libiberty/dyn-string.c
===================================================================
RCS file: /cvs/gcc/egcs/libiberty/dyn-string.c,v
retrieving revision 1.4
diff -p -r1.4 dyn-string.c
*** dyn-string.c	2000/06/23 03:58:44	1.4
--- dyn-string.c	2000/07/13 23:51:23
*************** Boston, MA 02111-1307, USA.  */
*** 23,28 ****
--- 23,30 ----
  #include "config.h"
  #endif
  
+ #if defined(CP_DEMANGLE_DEBUG) || defined(STANDALONE_DEMANGLER)
+ 
  #include <stdio.h>
  
  #ifdef HAVE_STRING_H
*************** Boston, MA 02111-1307, USA.  */
*** 33,40 ****
--- 35,50 ----
  #include <stdlib.h>
  #endif
  
+ #endif
+ 
  #include "libiberty.h"
  #include "dyn-string.h"
+ 
+ /* If the standard C header files have not been included above, then
+    on some targets we can end up without a definition of NULL.  */
+ #ifndef NULL
+ #define NULL ((void*)0)
+ #endif
  
  /* If this file is being compiled for inclusion in the C++ runtime
     library, as part of the demangler implementation, we don't want to

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