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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/C/ilogb.c
          +++ new/usr/src/lib/libm/common/C/ilogb.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 __ilogb = ilogb
  31   32  
  32   33  #include "libm.h"
  33      -#include "xpg6.h"       /* __xpg6 */
       34 +#include "xpg6.h"                       /* __xpg6 */
  34   35  
  35   36  #if defined(__x86)
  36   37  static const double two52 = 4503599627370496.0;
  37   38  #else
  38   39  /*
  39   40   * v: high part of a non-zero subnormal |x|; w: low part of |x|
  40   41   */
  41   42  static int
  42      -ilogb_subnormal(unsigned v, unsigned w) {
       43 +ilogb_subnormal(unsigned v, unsigned w)
       44 +{
  43   45          int r = -1022 - 52;
  44   46  
  45   47          if (v)
  46   48                  r += 32;
  47   49          else
  48   50                  v = w;
       51 +
  49   52          if (v & 0xffff0000)
  50   53                  r += 16, v >>= 16;
       54 +
  51   55          if (v & 0xff00)
  52   56                  r += 8, v >>= 8;
       57 +
  53   58          if (v & 0xf0)
  54   59                  r += 4, v >>= 4;
       60 +
  55   61          v <<= 1;
  56   62          return (r + ((0xffffaa50 >> v) & 0x3));
  57   63  }
  58      -#endif  /* defined(__x86) */
       64 +#endif /* defined(__x86) */
  59   65  
  60   66  static int
  61      -raise_invalid(int v) {  /* SUSv3 requires ilogb(0,+/-Inf,NaN) raise invalid */
       67 +raise_invalid(int v)    /* SUSv3 requires ilogb(0,+/-Inf,NaN) raise invalid */
       68 +{
  62   69  #ifndef lint
  63   70          if ((__xpg6 & _C99SUSv3_ilogb_0InfNaN_raises_invalid) != 0) {
  64   71                  static const double zero = 0.0;
  65   72                  volatile double dummy __unused;
  66   73  
  67   74                  dummy = zero / zero;
  68   75          }
  69   76  #endif
  70   77          return (v);
  71   78  }
  72   79  
  73   80  int
  74      -ilogb(double x) {
  75      -        int *px = (int *) &x, k = px[HIWORD] & ~0x80000000;
       81 +ilogb(double x)
       82 +{
       83 +        int *px = (int *)&x, k = px[HIWORD] & ~0x80000000;
  76   84  
  77   85          if (k < 0x00100000) {
  78      -                if ((px[LOWORD] | k) == 0)
       86 +                if ((px[LOWORD] | k) == 0) {
  79   87                          return (raise_invalid(0x80000001));
  80      -                else {
       88 +                } else {
  81   89  #if defined(__x86)
  82   90                          x *= two52;
  83   91                          return (((px[HIWORD] & 0x7ff00000) >> 20) - 1075);
  84   92  #else
  85   93                          return (ilogb_subnormal(k, px[LOWORD]));
  86   94  #endif
  87   95                  }
  88      -        } else if (k < 0x7ff00000)
       96 +        } else if (k < 0x7ff00000) {
  89   97                  return ((k >> 20) - 1023);
  90      -        else
       98 +        } else {
  91   99                  return (raise_invalid(0x7fffffff));
      100 +        }
  92  101  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX