[decNumber] avoid calls to printf in libgcc

Janis Johnson janis187@us.ibm.com
Thu Aug 13 00:03:00 GMT 2009


On Wed, 2009-08-12 at 19:47 +0200, Richard Guenther wrote:
> On Wed, Aug 12, 2009 at 7:43 PM, Janis Johnson<janis187@us.ibm.com> wrote:
> > 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?
> 
> The changes to the branches are ok.  If I can approve the rest it's ok - I don't
> remember if dec*.c is middle-end or not.
> 
> Thanks,
> Richard.

The decNumber files are maintained by Ben Elliston, who is currently on
vacation.  I'm tempted to call this an obvious fix.

> > 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      */
> >
> >
> >



More information about the Gcc-patches mailing list