]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Cleanup a few cases where isinf is used to get the signbit to improve the readability...
authorWilco Dijkstra <wdijkstr@arm.com>
Fri, 18 Sep 2015 20:19:48 +0000 (21:19 +0100)
committerWilco Dijkstra <wdijkstr@arm.com>
Fri, 18 Sep 2015 20:19:48 +0000 (21:19 +0100)
2015-09-18  Wilco Dijkstra  <wdijkstr@arm.com>

        * math/w_tgamma.c (__ieee754_gamma_r): Use explicit sign check.
        * math/w_tgammaf.c (__ieee754_gammaf_r): Likewise.
        * math/w_tgammal.c (__ieee754_gammal_r): Likewise.
        * stdio-common/printf_fp.c (___printf_fp):
        Use signbit to get the sign. Use isinf macro to allow inlining.
        * stdio-common/printf_fphex.c (__printf_fphex): Likewise.
        * stdio-common/printf_size.c (__printf_size): Likewise.

ChangeLog
math/w_tgamma.c
math/w_tgammaf.c
math/w_tgammal.c
stdio-common/printf_fp.c
stdio-common/printf_fphex.c
stdio-common/printf_size.c

index 7d2bf7fff81d1d6f43c69f8b54180c8a023f578b..67c837da5ab4a851d5875e749a158c72670e0c93 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2015-09-18  Wilco Dijkstra  <wdijkstr@arm.com>
+
+       * math/w_tgamma.c (__ieee754_gamma_r): Use explicit sign check.
+       * math/w_tgammaf.c (__ieee754_gammaf_r): Likewise.
+       * math/w_tgammal.c (__ieee754_gammal_r): Likewise.
+       * stdio-common/printf_fp.c (___printf_fp):
+       Use signbit to get the sign. Use isinf macro to allow inlining.
+       * stdio-common/printf_fphex.c (__printf_fphex): Likewise.
+       * stdio-common/printf_size.c (__printf_size): Likewise.
+
 2015-09-18  Mike Frysinger  <vapier@gentoo.org>
 
        * timezone/Makefile ($(testdata)/XT%): Call $(make-target-directory).
index 1ca7765e2c38227c2eff2eee86196700db510877..99b60298cabe539b725736c9c8df0c05fea8638d 100644 (file)
@@ -26,7 +26,7 @@ __tgamma(double x)
        double y = __ieee754_gamma_r(x,&local_signgam);
 
        if(__glibc_unlikely (!isfinite (y) || y == 0)
-          && (isfinite (x) || isinf (x) < 0)
+          && (isfinite (x) || (isinf (x) && x < 0.0))
           && _LIB_VERSION != _IEEE_) {
          if (x == 0.0)
            return __kernel_standard(x,x,50); /* tgamma pole */
index 9ed7660d738778a04846477889bbe920635d13b0..dfce894cc8878dc46a9ef59dddd9681fff7a3144 100644 (file)
@@ -24,7 +24,7 @@ __tgammaf(float x)
        float y = __ieee754_gammaf_r(x,&local_signgam);
 
        if(__glibc_unlikely (!isfinite (y) || y == 0)
-          && (isfinite (x) || isinf (x) < 0)
+          && (isfinite (x) || (isinf (x) && x < 0.0))
           && _LIB_VERSION != _IEEE_) {
          if (x == (float)0.0)
            /* tgammaf pole */
index b3a9e4a01587f56000a709e12ae8a1375b9e5a1d..50de8cf90675c0e109f80e80e1651cc05bd69278 100644 (file)
@@ -29,7 +29,7 @@ __tgammal(long double x)
        long double y = __ieee754_gammal_r(x,&local_signgam);
 
        if(__glibc_unlikely (!isfinite (y) || y == 0)
-          && (isfinite (x) || isinf (x) < 0)
+          && (isfinite (x) || (isinf (x) && x < 0.0))
           && _LIB_VERSION != _IEEE_) {
          if(x==0.0)
            return __kernel_standard_l(x,x,250); /* tgamma pole */
index 3023b201835be839ebf5774b32b591efa65668da..11f3145b3aa7c1690c819682c2040afaaa29251d 100644 (file)
@@ -332,7 +332,6 @@ ___printf_fp (FILE *fp,
       fpnum.ldbl = *(const long double *) args[0];
 
       /* Check for special values: not a number or infinity.  */
-      int res;
       if (isnan (fpnum.ldbl))
        {
          is_neg = signbit (fpnum.ldbl);
@@ -347,9 +346,9 @@ ___printf_fp (FILE *fp,
                wspecial = L"nan";
              }
        }
-      else if ((res = __isinfl (fpnum.ldbl)))
+      else if (isinf (fpnum.ldbl))
        {
-         is_neg = res < 0;
+         is_neg = signbit (fpnum.ldbl);
          if (isupper (info->spec))
            {
              special = "INF";
@@ -377,11 +376,9 @@ ___printf_fp (FILE *fp,
       fpnum.dbl = *(const double *) args[0];
 
       /* Check for special values: not a number or infinity.  */
-      int res;
       if (isnan (fpnum.dbl))
        {
-         union ieee754_double u = { .d = fpnum.dbl };
-         is_neg = u.ieee.negative != 0;
+         is_neg = signbit (fpnum.dbl);
          if (isupper (info->spec))
            {
              special = "NAN";
@@ -393,9 +390,9 @@ ___printf_fp (FILE *fp,
              wspecial = L"nan";
            }
        }
-      else if ((res = __isinf (fpnum.dbl)))
+      else if (isinf (fpnum.dbl))
        {
-         is_neg = res < 0;
+         is_neg = signbit (fpnum.dbl);
          if (isupper (info->spec))
            {
              special = "INF";
index 6c3b5e97230f530a670387209a4c7fd5608ec48c..0627beaacfb6ac7976c68c33f1b333370a48c6cd 100644 (file)
@@ -180,7 +180,7 @@ __printf_fphex (FILE *fp,
        }
       else
        {
-         if (__isinfl (fpnum.ldbl))
+         if (isinf (fpnum.ldbl))
            {
              if (isupper (info->spec))
                {
@@ -204,7 +204,6 @@ __printf_fphex (FILE *fp,
       /* Check for special values: not a number or infinity.  */
       if (isnan (fpnum.dbl.d))
        {
-         negative = fpnum.dbl.ieee.negative != 0;
          if (isupper (info->spec))
            {
              special = "NAN";
@@ -218,8 +217,7 @@ __printf_fphex (FILE *fp,
        }
       else
        {
-         int res = __isinf (fpnum.dbl.d);
-         if (res)
+         if (isinf (fpnum.dbl.d))
            {
              if (isupper (info->spec))
                {
@@ -231,11 +229,9 @@ __printf_fphex (FILE *fp,
                  special = "inf";
                  wspecial = L"inf";
                }
-             negative = res < 0;
            }
-         else
-           negative = signbit (fpnum.dbl.d);
        }
+      negative = signbit (fpnum.dbl.d);
     }
 
   if (special)
index 7dcd58e0d8e36d4d849b70f886cbbfb619d5e5cd..216f1707d6ea3cbb976e56f214888e4f77e81be0 100644 (file)
@@ -108,7 +108,7 @@ __printf_size (FILE *fp, const struct printf_info *info,
   fpnum;
   const void *ptr = &fpnum;
 
-  int fpnum_sign = 0;
+  int is_neg = 0;
 
   /* "NaN" or "Inf" for the special cases.  */
   const char *special = NULL;
@@ -117,7 +117,6 @@ __printf_size (FILE *fp, const struct printf_info *info,
   struct printf_info fp_info;
   int done = 0;
   int wide = info->wide;
-  int res;
 
   /* Fetch the argument value. */
 #ifndef __NO_LONG_DOUBLE_MATH
@@ -130,11 +129,11 @@ __printf_size (FILE *fp, const struct printf_info *info,
        {
          special = "nan";
          wspecial = L"nan";
-         // fpnum_sign = 0;    Already zero
+         // is_neg = 0;        Already zero
        }
-      else if ((res = __isinfl (fpnum.ldbl)))
+      else if (isinf (fpnum.ldbl))
        {
-         fpnum_sign = res;
+         is_neg = signbit (fpnum.ldbl);
          special = "inf";
          wspecial = L"inf";
        }
@@ -155,11 +154,11 @@ __printf_size (FILE *fp, const struct printf_info *info,
        {
          special = "nan";
          wspecial = L"nan";
-         // fpnum_sign = 0;    Already zero
+         // is_neg = 0;        Already zero
        }
-      else if ((res = __isinf (fpnum.dbl.d)))
+      else if (isinf (fpnum.dbl.d))
        {
-         fpnum_sign = res;
+         is_neg = signbit (fpnum.dbl.d);
          special = "inf";
          wspecial = L"inf";
        }
@@ -175,14 +174,14 @@ __printf_size (FILE *fp, const struct printf_info *info,
     {
       int width = info->prec > info->width ? info->prec : info->width;
 
-      if (fpnum_sign < 0 || info->showsign || info->space)
+      if (is_neg || info->showsign || info->space)
        --width;
       width -= 3;
 
       if (!info->left && width > 0)
        PADN (' ', width);
 
-      if (fpnum_sign < 0)
+      if (is_neg)
        outchar ('-');
       else if (info->showsign)
        outchar ('+');