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

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