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]

Re: RFA: libiberty: do not unconditionally include stdio.h


Hi Guys,

: 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.

Oops - a little further checkign revealed that I should only disable
the inclusion of the header files when building lIBGCC2, and that
rather than using (void*) I should use (PTR).  So here is a revised
patch:

Cheers
	Nick

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/14 00:37:06
***************
*** 27,32 ****
--- 27,34 ----
  #include "config.h"
  #endif
  
+ #if !defined IN_LIBGCC2 || 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 ((PTR)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/14 00:37:06
*************** Boston, MA 02111-1307, USA.  */
*** 23,28 ****
--- 23,30 ----
  #include "config.h"
  #endif
  
+ #if !defined IN_LIBGCC2 || 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 ((PTR)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]