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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/C/acosh.c
          +++ new/usr/src/lib/libm/common/C/acosh.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 __acosh = acosh
  31   32  
  32      -/* INDENT OFF */
       33 +
  33   34  /*
  34   35   * acosh(x)
  35   36   * Method :
  36   37   *      Based on
  37   38   *              acosh(x) = log [ x + sqrt(x*x-1) ]
  38   39   *      we have
  39   40   *              acosh(x) := log(x)+ln2, if x is large; else
  40   41   *              acosh(x) := log(2x-1/(sqrt(x*x-1)+x)) if x > 2; else
  41   42   *              acosh(x) := log1p(t+sqrt(2.0*t+t*t)); where t = x-1.
  42   43   *
  43   44   * Special cases:
  44   45   *      acosh(x) is NaN with signal if x < 1.
  45   46   *      acosh(NaN) is NaN without signal.
  46   47   */
  47      -/* INDENT ON */
  48   48  
  49      -#include "libm_protos.h"        /* _SVID_libm_error */
       49 +#include "libm_protos.h"                /* _SVID_libm_error */
  50   50  #include "libm_macros.h"
  51   51  #include <math.h>
  52   52  
  53      -static const double
  54      -        one = 1.0,
       53 +static const double one = 1.0,
  55   54          ln2 = 6.93147180559945286227e-01;       /* 3FE62E42, FEFA39EF */
  56   55  
  57   56  double
  58      -acosh(double x) {
       57 +acosh(double x)
       58 +{
  59   59          double t;
  60   60          int hx;
  61   61  
  62      -        hx = ((int *) &x)[HIWORD];
  63      -        if (hx < 0x3ff00000) {  /* x < 1 */
       62 +        hx = ((int *)&x)[HIWORD];
       63 +
       64 +        if (hx < 0x3ff00000) {          /* x < 1 */
  64   65                  if (isnan(x))
  65   66  #if defined(FPADD_TRAPS_INCOMPLETE_ON_NAN)
  66   67                          return (hx >= 0xfff80000 ? x : (x - x) / (x - x));
  67      -                        /* assumes sparc-like QNaN */
       68 +
       69 +                /* assumes sparc-like QNaN */
  68   70  #else
  69      -                        return (x - x) / (x - x);
       71 +                        return ((x - x) / (x - x));
  70   72  #endif
  71   73                  else
  72   74                          return (_SVID_libm_err(x, x, 29));
  73   75          } else if (hx >= 0x41b00000) {
  74   76                  /* x > 2**28 */
  75   77                  if (hx >= 0x7ff00000) { /* x is inf of NaN */
  76   78  #if defined(FPADD_TRAPS_INCOMPLETE_ON_NAN)
  77   79                          return (hx >= 0x7ff80000 ? x : x + x);
  78   80                          /* assumes sparc-like QNaN */
  79   81  #else
  80   82                          return (x + x);
  81   83  #endif
  82      -                } else  /* acosh(huge)=log(2x) */
       84 +                } else { /* acosh(huge)=log(2x) */
  83   85                          return (log(x) + ln2);
  84      -        } else if (((hx - 0x3ff00000) | ((int *) &x)[LOWORD]) == 0) {
  85      -                return (0.0);   /* acosh(1) = 0 */
       86 +                }
       87 +        } else if (((hx - 0x3ff00000) | ((int *)&x)[LOWORD]) == 0) {
       88 +                return (0.0);           /* acosh(1) = 0 */
  86   89          } else if (hx > 0x40000000) {
  87   90                  /* 2**28 > x > 2 */
  88   91                  t = x * x;
  89   92                  return (log(2.0 * x - one / (x + sqrt(t - one))));
  90   93          } else {
  91   94                  /* 1 < x < 2 */
  92   95                  t = x - one;
  93   96                  return (log1p(t + sqrt(2.0 * t + t * t)));
  94   97          }
  95   98  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX