Print this page
11210 libm should be cstyle(1ONBLD) clean

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/Q/rndintl.c
          +++ new/usr/src/lib/libm/common/Q/rndintl.c
↓ open down ↓ 10 lines elided ↑ open up ↑
  11   11   * and limitations under the License.
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
       21 +
  21   22  /*
  22   23   * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  23   24   */
       25 +
  24   26  /*
  25   27   * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
  26   28   * Use is subject to license terms.
  27   29   */
  28   30  
  29   31  /*
  30   32   * aintl(x)     return x chopped to integral value
  31   33   * anintl(x)    return sign(x)*(|x|+0.5) chopped to integral value
  32   34   * irintl(x)    return rint(x) in integer format
  33   35   * nintl(x)     return anint(x) in integer format
↓ open down ↓ 1 lines elided ↑ open up ↑
  35   37   * NOTE: aintl(x), anintl(x), ceill(x), floorl(x), and rintl(x) return result
  36   38   * with the same sign as x's,  including 0.0.
  37   39   */
  38   40  
  39   41  #include "libm.h"
  40   42  #include "longdouble.h"
  41   43  
  42   44  extern enum fp_direction_type __swapRD(enum fp_direction_type);
  43   45  
  44   46  static const long double qone = 1.0L, qhalf = 0.5L, qmhalf = -0.5L;
  45      -
  46   47  long double
  47      -aintl(long double x) {
       48 +aintl(long double x)
       49 +{
  48   50          long double t, w;
  49   51  
  50   52          if (!finitel(x))
  51   53                  return (x + x);
       54 +
  52   55          w = fabsl(x);
  53   56          t = rintl(w);
       57 +
  54   58          if (t <= w)
  55      -                return (copysignl(t, x));       /* NaN or already aint(|x|) */
  56      -        else    /* |t|>|x| case */
  57      -                return (copysignl(t - qone, x));        /* |t-1|*sign(x) */
       59 +                return (copysignl(t, x)); /* NaN or already aint(|x|) */
       60 +        else                              /* |t|>|x| case */
       61 +                return (copysignl(t - qone, x)); /* |t-1|*sign(x) */
  58   62  }
  59   63  
  60   64  long double
  61      -anintl(long double x) {
       65 +anintl(long double x)
       66 +{
  62   67          long double t, w, z;
  63   68  
  64   69          if (!finitel(x))
  65   70                  return (x + x);
       71 +
  66   72          w = fabsl(x);
  67   73          t = rintl(w);
       74 +
  68   75          if (t == w)
  69   76                  return (copysignl(t, x));
       77 +
  70   78          z = t - w;
       79 +
  71   80          if (z > qhalf)
  72   81                  t = t - qone;
  73   82          else if (z <= qmhalf)
  74   83                  t = t + qone;
       84 +
  75   85          return (copysignl(t, x));
  76   86  }
  77   87  
  78   88  int
  79      -irintl(long double x) {
       89 +irintl(long double x)
       90 +{
  80   91          enum fp_direction_type rd;
  81   92  
  82   93          rd = __swapRD(fp_nearest);
  83      -        (void) __swapRD(rd);    /* restore Rounding Direction */
       94 +        (void) __swapRD(rd);            /* restore Rounding Direction */
       95 +
  84   96          switch (rd) {
  85   97          case fp_nearest:
       98 +
  86   99                  if (x < 2147483647.5L && x >= -2147483648.5L)
  87  100                          return ((int)rintl(x));
      101 +
  88  102                  break;
  89  103          case fp_tozero:
      104 +
  90  105                  if (x < 2147483648.0L && x > -2147483649.0L)
  91  106                          return ((int)rintl(x));
      107 +
  92  108                  break;
  93  109          case fp_positive:
      110 +
  94  111                  if (x <= 2147483647.0L && x > -2147483649.0L)
  95  112                          return ((int)rintl(x));
      113 +
  96  114                  break;
  97  115          case fp_negative:
      116 +
  98  117                  if (x < 2147483648.0L && x >= -2147483648.0L)
  99  118                          return ((int)rintl(x));
      119 +
 100  120                  break;
 101  121          }
      122 +
 102  123          return ((int)copysignl(1.0e100L, x));
 103  124  }
 104  125  
 105  126  int
 106      -nintl(long double x) {
      127 +nintl(long double x)
      128 +{
 107  129          if ((x < 2147483647.5L) && (x > -2147483648.5L))
 108  130                  return ((int)anintl(x));
 109  131          else
 110  132                  return ((int)copysignl(1.0e100L, x));
 111  133  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX