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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/C/nextafter.c
          +++ new/usr/src/lib/libm/common/C/nextafter.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  #pragma weak __nextafter = nextafter
  30   32  #pragma weak _nextafter = nextafter
  31   33  
  32   34  #include "libm.h"
  33      -#include <float.h>              /* DBL_MIN */
       35 +#include <float.h>                      /* DBL_MIN */
  34   36  
  35   37  double
  36      -nextafter(double x, double y) {
  37      -        int             hx, hy, k;
  38      -        double          ans;
  39      -        unsigned        lx;
       38 +nextafter(double x, double y)
       39 +{
       40 +        int hx, hy, k;
       41 +        double ans;
       42 +        unsigned lx;
  40   43          volatile double dummy __unused;
  41   44  
  42   45          hx = ((int *)&x)[HIWORD];
  43   46          lx = ((int *)&x)[LOWORD];
  44   47          hy = ((int *)&y)[HIWORD];
  45   48          k = (hx & ~0x80000000) | lx;
  46   49  
  47   50          if (x == y)
  48   51                  return (y);             /* C99 requirement */
       52 +
  49   53          if (x != x || y != y)
  50   54                  return (x * y);
       55 +
  51   56          if (k == 0) {                   /* x = 0 */
  52   57                  k = hy & 0x80000000;
  53   58                  ((int *)&ans)[HIWORD] = k;
  54   59                  ((int *)&ans)[LOWORD] = 1;
  55   60          } else if (hx >= 0) {
  56   61                  if (x > y) {
  57   62                          ((int *)&ans)[LOWORD] = lx - 1;
  58      -                        k = (lx == 0)? hx - 1 : hx;
       63 +                        k = (lx == 0) ? hx - 1 : hx;
  59   64                          ((int *)&ans)[HIWORD] = k;
  60   65                  } else {
  61   66                          ((int *)&ans)[LOWORD] = lx + 1;
  62      -                        k  = (lx == 0xffffffff)? hx + 1 : hx;
       67 +                        k = (lx == 0xffffffff) ? hx + 1 : hx;
  63   68                          ((int *)&ans)[HIWORD] = k;
  64   69                  }
  65   70          } else {
  66   71                  if (x < y) {
  67   72                          ((int *)&ans)[LOWORD] = lx - 1;
  68      -                        k = (lx == 0)? hx - 1 : hx;
       73 +                        k = (lx == 0) ? hx - 1 : hx;
  69   74                          ((int *)&ans)[HIWORD] = k;
  70   75                  } else {
  71   76                          ((int *)&ans)[LOWORD] = lx + 1;
  72      -                        k  = (lx == 0xffffffff)? hx + 1 : hx;
       77 +                        k = (lx == 0xffffffff) ? hx + 1 : hx;
  73   78                          ((int *)&ans)[HIWORD] = k;
  74   79                  }
  75   80          }
       81 +
  76   82          k = (k >> 20) & 0x7ff;
       83 +
  77   84          if (k == 0x7ff) {
  78   85                  /* overflow */
  79   86                  return (_SVID_libm_err(x, y, 46));
  80   87  #if !defined(__lint)
  81   88          } else if (k == 0) {
  82   89                  /* underflow */
  83   90                  dummy = DBL_MIN * copysign(DBL_MIN, x);
  84   91  #endif
  85   92          }
       93 +
  86   94          return (ans);
  87   95  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX