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]
Other format: [Raw text]

[decNumber] avoid calls to printf in libgcc


The decNumber functions have debugging code that calls printf.  Most of
these are protected by DECCHECK or DECTRACE, but there are a couple of
calls to printf that are not protected.  This patch prevents a normal
build of the decNumber code from adding references to printf to libgcc.

Bootstrapped and regression tested on powerpc64-linux with -m32/-m64,
with manual check that libgcc has no undefined references to printf.
OK for mainline?

On the 4.4 and 4.3 release branches only the change to decCommon.c
is needed.  Is that part of the patch OK for those branches?

2009-08-12  Janis Johnson  <janis187@us.ibm.com>

	PR c/41046
	* decContext.c (decContextTestEndian): Call printf only if DECCHECK.
	* decCommon.c ( decFloatShow): Define function only for DECCHECK
	or DECTRACE.

Index: libdecnumber/decContext.c
===================================================================
--- libdecnumber/decContext.c	(revision 150501)
+++ libdecnumber/decContext.c	(working copy)
@@ -31,7 +31,9 @@ see the files COPYING3 and COPYING.RUNTI
 /* ------------------------------------------------------------------ */
 
 #include <string.h>	      /* for strcmp */
+#ifdef DECCHECK
 #include <stdio.h>	      /* for printf if DECCHECK */
+#endif
 #include "dconfig.h"	      /* for GCC definitions */
 #include "decContext.h"       /* context and base types */
 #include "decNumberLocal.h"   /* decNumber local types, etc. */
@@ -395,8 +397,10 @@ Int decContextTestEndian(Flag quiet) {
     if (!quiet) {
       if (LITEND) adj="little";
 	     else adj="big";
+#if DECCHECK
       printf("Warning: DECLITEND is set to %d, but this computer appears to be %s-endian\n",
 	     DECLITEND, adj);
+#endif
       }
     res=(Int)LITEND-dle;
     }
Index: libdecnumber/decCommon.c
===================================================================
--- libdecnumber/decCommon.c	(revision 150501)
+++ libdecnumber/decCommon.c	(working copy)
@@ -1157,6 +1157,7 @@ uInt decFloatRadix(const decFloat *df) {
   return 10;
   } /* decFloatRadix */
 
+#if (DECCHECK || DECTRACE)
 /* ------------------------------------------------------------------ */
 /* decFloatShow -- printf a decFloat in hexadecimal and decimal       */
 /*   df  is the decFloat to show				      */
@@ -1183,6 +1184,7 @@ void decFloatShow(const decFloat *df, co
   printf(">%s> %s [big-endian]	%s\n", tag, hexbuf, buff);
   return;
   } /* decFloatShow */
+#endif
 
 /* ------------------------------------------------------------------ */
 /* decFloatToBCD -- get sign, exponent, and BCD8 from a decFloat      */



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