Print this page
11210 libm should be cstyle(1ONBLD) clean
*** 20,37 ****
*/
/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma weak __tanh = tanh
! /* INDENT OFF */
/*
* TANH(X)
* RETURN THE HYPERBOLIC TANGENT OF X
* code based on 4.3bsd
* Modified by K.C. Ng for sun 4.0, Jan 31, 1987
--- 20,38 ----
*/
/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*/
+
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma weak __tanh = tanh
!
/*
* TANH(X)
* RETURN THE HYPERBOLIC TANGENT OF X
* code based on 4.3bsd
* Modified by K.C. Ng for sun 4.0, Jan 31, 1987
*** 57,101 ****
#include "libm.h"
#include "libm_protos.h"
#include <math.h>
! static const double
! one = 1.0,
! two = 2.0,
! small = 1.0e-10,
! big = 1.0e10;
! /* INDENT ON */
double
tanh(double x)
{
double t, y, z;
int signx;
volatile double dummy __unused;
if (isnan(x))
return (x * x); /* + -> * for Cheetah */
signx = signbit(x);
t = fabs(x);
z = one;
if (t <= 22.0) {
! if (t > one)
z = one - two / (expm1(t + t) + two);
! else if (t > small) {
y = expm1(-t - t);
z = -y / (y + two);
} else {
/* raise the INEXACT flag for non-zero t */
dummy = t + big;
#ifdef lint
dummy = dummy;
#endif
return (x);
}
! } else if (!finite(t))
return (copysign(1.0, x));
! else
return ((signx != 0) ? -z + small * small : z - small * small);
return ((signx != 0) ? -z : z);
}
--- 58,101 ----
#include "libm.h"
#include "libm_protos.h"
#include <math.h>
! static const double one = 1.0, two = 2.0, small = 1.0e-10, big = 1.0e10;
!
double
tanh(double x)
{
double t, y, z;
int signx;
volatile double dummy __unused;
if (isnan(x))
return (x * x); /* + -> * for Cheetah */
+
signx = signbit(x);
t = fabs(x);
z = one;
+
if (t <= 22.0) {
! if (t > one) {
z = one - two / (expm1(t + t) + two);
! } else if (t > small) {
y = expm1(-t - t);
z = -y / (y + two);
} else {
/* raise the INEXACT flag for non-zero t */
dummy = t + big;
#ifdef lint
dummy = dummy;
#endif
return (x);
}
! } else if (!finite(t)) {
return (copysign(1.0, x));
! } else {
return ((signx != 0) ? -z + small * small : z - small * small);
+ }
return ((signx != 0) ? -z : z);
}