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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/R/scalbnf.c
          +++ new/usr/src/lib/libm/common/R/scalbnf.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  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   23   * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  24   24   */
       25 +
  25   26  /*
  26   27   * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  27   28   * Use is subject to license terms.
  28   29   */
  29   30  
  30   31  #pragma weak __scalbnf = scalbnf
  31   32  
  32   33  #include "libm.h"
  33      -#include <float.h>              /* FLT_MAX, FLT_MIN */
  34      -#include <stdlib.h>             /* abs */
       34 +#include <float.h>                      /* FLT_MAX, FLT_MIN */
       35 +#include <stdlib.h>                     /* abs */
  35   36  
  36   37  static const float twom25f = 2.98023223876953125e-8F;
       38 +
  37   39  #if defined(__x86)
  38   40  static const float two23f = 8388608.0F;
  39   41  #else
  40   42  /*
  41   43   * v: a non-zero subnormal |x|; returns [-22, 0]
  42   44   */
  43   45  static int
  44      -ilogbf_biased(unsigned v) {
       46 +ilogbf_biased(unsigned v)
       47 +{
  45   48          int r = -22;
  46   49  
  47   50          if (v & 0xffff0000)
  48   51                  r += 16, v >>= 16;
       52 +
  49   53          if (v & 0xff00)
  50   54                  r += 8, v >>= 8;
       55 +
  51   56          if (v & 0xf0)
  52   57                  r += 4, v >>= 4;
       58 +
  53   59          v <<= 1;
  54   60          return (r + ((0xffffaa50 >> v) & 0x3));
  55   61  }
  56      -#endif  /* defined(__x86) */
       62 +#endif /* defined(__x86) */
  57   63  
  58   64  float
  59      -scalbnf(float x, int n) {
  60      -        int *px = (int *) &x, ix, k;
       65 +scalbnf(float x, int n)
       66 +{
       67 +        int *px = (int *)&x, ix, k;
  61   68  
  62   69          ix = *px & ~0x80000000;
  63   70          k = ix >> 23;
       71 +
  64   72          if (k == 0xff)
  65   73  #if defined(FPADD_TRAPS_INCOMPLETE_ON_NAN)
  66   74                  return (ix > 0x7f800000 ? x * x : x);
  67   75  #else
  68   76                  return (x + x);
  69   77  #endif
       78 +
  70   79          if (ix == 0 || n == 0)
  71   80                  return (x);
       81 +
  72   82          if (k == 0) {
  73   83  #if defined(__x86)
  74   84                  x *= two23f;
  75   85                  k = ((*px & ~0x80000000) >> 23) - 23;
  76   86  #else
  77   87                  k = ilogbf_biased(ix);
  78   88                  *px = (*px & 0x80000000) | (ix << (-k + 1));
  79   89  #endif
  80   90          }
  81      -        if ((unsigned) abs(n) >= 131072)        /* cast to unsigned for -2^31 */
       91 +
       92 +        if ((unsigned)abs(n) >= 131072) /* cast to unsigned for -2^31 */
  82   93                  n >>= 1;                /* avoid subsequent integer overflow */
       94 +
  83   95          k += n;
       96 +
  84   97          if (k > 0xfe)
  85   98                  return (FLT_MAX * copysignf(FLT_MAX, x));
       99 +
  86  100          if (k <= -25)
  87  101                  return (FLT_MIN * copysignf(FLT_MIN, x));
      102 +
  88  103          if (k > 0) {
  89  104                  *px = (*px & ~0x7f800000) | (k << 23);
  90  105                  return (x);
  91  106          }
      107 +
  92  108          k += 25;
  93  109          *px = (*px & ~0x7f800000) | (k << 23);
  94  110          return (x * twom25f);
  95  111  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX