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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/Q/ilogbl.c
          +++ new/usr/src/lib/libm/common/Q/ilogbl.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 __ilogbl = ilogbl
  31   32  
  32   33  #include "libm.h"
  33      -#include "xpg6.h"       /* __xpg6 */
       34 +#include "xpg6.h"                               /* __xpg6 */
  34   35  
  35   36  #if defined(__sparc)
  36      -#define ISNORMALL(k, x) (k != 0x7fff)                   /* assuming k != 0 */
       37 +#define ISNORMALL(k, x)         (k != 0x7fff)   /* assuming k != 0 */
  37   38  #define X86PDNRM(k, x)
  38      -#define XSCALE_OFFSET   0x406f                          /* 0x3fff + 112 */
       39 +#define XSCALE_OFFSET           0x406f          /* 0x3fff + 112 */
       40 +
  39   41  static const long double xscale = 5192296858534827628530496329220096.0L;
  40      -                                                                /* 2^112 */
       42 +
       43 +/* 2^112 */
  41   44  #elif defined(__x86)
  42   45  /*
  43   46   * if pseudo-denormal, replace by the equivalent normal
  44   47   */
  45      -#define X86PDNRM(k, x)  if (k == 0 && (((int *) &x)[1] & 0x80000000) != 0) \
  46      -                                ((int *) &x)[2] |= k = 1
  47      -#if defined(HANDLE_UNSUPPORTED)                         /* assuming k != 0 */
  48      -#define ISNORMALL(k, x) (k != 0x7fff && (((int *) &x)[1] & 0x80000000) != 0)
       48 +#define X86PDNRM(k, x)  \
       49 +        if (k == 0 && (((int *)&x)[1] & 0x80000000) !=  0) \
       50 +                ((int *)&x)[2] |= k = 1
       51 +#if defined(HANDLE_UNSUPPORTED)         /* assuming k != 0 */
       52 +#define ISNORMALL(k, x) (k != 0x7fff && (((int *)&x)[1] & 0x80000000) != \
       53 +        0)
  49   54  #else
  50      -#define ISNORMALL(k, x) (k != 0x7fff)
       55 +#define ISNORMALL(k, x)         (k != 0x7fff)
  51   56  #endif
  52   57  #define XSCALE_OFFSET   0x403e                          /* 0x3fff + 63 */
  53   58  static const long double xscale = 9223372036854775808.0L;       /* 2^63 */
  54   59  #endif
  55   60  
  56   61  static int
  57      -raise_invalid(int v) {  /* SUSv3 requires ilogbl(0,+/-Inf,NaN) raise invalid */
       62 +raise_invalid(int v)   /* SUSv3 requires ilogbl(0,+/-Inf,NaN) raise invalid */
       63 +{
  58   64  #ifndef lint
  59   65          if ((__xpg6 & _C99SUSv3_ilogb_0InfNaN_raises_invalid) != 0) {
  60   66                  static const double zero = 0.0;
  61   67                  volatile double dummy;
  62   68  
  63   69                  dummy = zero / zero;
  64   70          }
  65   71  #endif
  66   72          return (v);
  67   73  }
  68   74  
  69   75  int
  70      -ilogbl(long double x) {
       76 +ilogbl(long double x)
       77 +{
  71   78          int k = XBIASED_EXP(x);
  72   79  
  73   80          X86PDNRM(k, x);
       81 +
  74   82          if (k == 0) {
  75      -                if (ISZEROL(x))
       83 +                if (ISZEROL(x)) {
  76   84                          return (raise_invalid(0x80000001));
  77      -                else {
  78      -                        x *= xscale;            /* scale up by 2^112 or 2^63 */
       85 +                } else {
       86 +                        x *= xscale;    /* scale up by 2^112 or 2^63 */
  79   87                          return (XBIASED_EXP(x) - XSCALE_OFFSET);
  80   88                  }
  81      -        } else if (ISNORMALL(k, x))
       89 +        } else if (ISNORMALL(k, x)) {
  82   90                  return (k - 0x3fff);
  83      -        else
       91 +        } else {
  84   92                  return (raise_invalid(0x7fffffff));
       93 +        }
  85   94  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX