summaryrefslogtreecommitdiff
path: root/native
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2006-03-02 09:33:42 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2006-03-02 09:33:42 +0000
commit9feea8b823c069addfda8b43e0c14c7f46d5be19 (patch)
tree3b919f10a9486ca3469576d063409d5af42b7c1a /native
parent789bb86a1bfe9953bfeb6b5d9b08aaf58fd6e108 (diff)
downloadclasspath-9feea8b823c069addfda8b43e0c14c7f46d5be19.tar.gz
2006-03-02 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Merge of HEAD-->generics-branch for the period between the 0.20 release and the tag generics-merge-20050225.
Diffstat (limited to 'native')
-rw-r--r--native/fdlibm/Makefile.am12
-rw-r--r--native/fdlibm/e_acos.c32
-rw-r--r--native/fdlibm/e_asin.c24
-rw-r--r--native/fdlibm/e_atan2.c48
-rw-r--r--native/fdlibm/e_cosh.c89
-rw-r--r--native/fdlibm/e_exp.c59
-rw-r--r--native/fdlibm/e_fmod.c42
-rw-r--r--native/fdlibm/e_hypot.c115
-rw-r--r--native/fdlibm/e_log.c71
-rw-r--r--native/fdlibm/e_log10.c91
-rw-r--r--native/fdlibm/e_pow.c137
-rw-r--r--native/fdlibm/e_rem_pio2.c96
-rw-r--r--native/fdlibm/e_remainder.c31
-rw-r--r--native/fdlibm/e_scalb.c8
-rw-r--r--native/fdlibm/e_sinh.c82
-rw-r--r--native/fdlibm/e_sqrt.c118
-rw-r--r--native/fdlibm/fdlibm.h281
-rw-r--r--native/fdlibm/k_cos.c38
-rw-r--r--native/fdlibm/k_rem_pio2.c94
-rw-r--r--native/fdlibm/k_sin.c31
-rw-r--r--native/fdlibm/k_tan.c180
-rw-r--r--native/fdlibm/namespace.h4
-rw-r--r--native/fdlibm/s_atan.c73
-rw-r--r--native/fdlibm/s_cbrt.c87
-rw-r--r--native/fdlibm/s_ceil.c28
-rw-r--r--native/fdlibm/s_copysign.c59
-rw-r--r--native/fdlibm/s_cos.c20
-rw-r--r--native/fdlibm/s_expm1.c215
-rw-r--r--native/fdlibm/s_fabs.c52
-rw-r--r--native/fdlibm/s_finite.c12
-rw-r--r--native/fdlibm/s_floor.c81
-rw-r--r--native/fdlibm/s_log1p.c165
-rw-r--r--native/fdlibm/s_rint.c35
-rw-r--r--native/fdlibm/s_scalbn.c73
-rw-r--r--native/fdlibm/s_sin.c70
-rw-r--r--native/fdlibm/s_tan.c58
-rw-r--r--native/fdlibm/s_tanh.c82
-rw-r--r--native/fdlibm/w_acos.c89
-rw-r--r--native/fdlibm/w_asin.c86
-rw-r--r--native/fdlibm/w_atan2.c83
-rw-r--r--native/fdlibm/w_cosh.c38
-rw-r--r--native/fdlibm/w_exp.c104
-rw-r--r--native/fdlibm/w_fmod.c74
-rw-r--r--native/fdlibm/w_hypot.c39
-rw-r--r--native/fdlibm/w_log.c88
-rw-r--r--native/fdlibm/w_log10.c42
-rw-r--r--native/fdlibm/w_pow.c201
-rw-r--r--native/fdlibm/w_remainder.c91
-rw-r--r--native/fdlibm/w_sinh.c38
-rw-r--r--native/fdlibm/w_sqrt.c61
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c26
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c9
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer.c4
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c28
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollbarPeer.c20
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c33
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c45
-rw-r--r--native/jni/java-lang/Makefile.am2
-rw-r--r--native/jni/java-lang/java_lang_VMDouble.c22
-rw-r--r--native/jni/java-lang/java_lang_VMMath.c (renamed from native/jni/java-lang/java_lang_Math.c)100
-rw-r--r--native/jni/java-net/javanet.c2
-rw-r--r--native/jni/java-net/javanet.h1
62 files changed, 2023 insertions, 2096 deletions
diff --git a/native/fdlibm/Makefile.am b/native/fdlibm/Makefile.am
index 545b0f86d..64b3b3936 100644
--- a/native/fdlibm/Makefile.am
+++ b/native/fdlibm/Makefile.am
@@ -5,13 +5,17 @@ libfdlibm_la_SOURCES = \
e_acos.c \
e_asin.c \
e_atan2.c \
+ e_cosh.c \
e_exp.c \
e_fmod.c \
+ e_hypot.c \
e_log.c \
+ e_log10.c \
e_pow.c \
e_remainder.c \
e_rem_pio2.c \
e_scalb.c \
+ e_sinh.c \
e_sqrt.c \
fdlibm.h \
ieeefp.h \
@@ -22,27 +26,35 @@ libfdlibm_la_SOURCES = \
mprec.c \
mprec.h \
s_atan.c \
+ s_cbrt.c \
s_ceil.c \
s_copysign.c \
s_cos.c \
+ s_expm1.c \
s_fabs.c \
sf_fabs.c \
s_finite.c \
s_floor.c \
+ s_log1p.c \
sf_rint.c \
s_rint.c \
s_scalbn.c \
s_sin.c \
s_tan.c \
+ s_tanh.c \
strtod.c \
w_acos.c \
w_asin.c \
w_atan2.c \
+ w_cosh.c \
w_exp.c \
w_fmod.c \
+ w_hypot.c \
w_log.c \
+ w_log10.c \
w_pow.c \
w_remainder.c \
+ w_sinh.c \
w_sqrt.c \
namespace.h
diff --git a/native/fdlibm/e_acos.c b/native/fdlibm/e_acos.c
index ee6b168a1..d7c9ed225 100644
--- a/native/fdlibm/e_acos.c
+++ b/native/fdlibm/e_acos.c
@@ -1,25 +1,25 @@
-/* @(#)e_acos.c 5.1 93/09/24 */
+/* @(#)e_acos.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
/* __ieee754_acos(x)
- * Method :
+ * Method :
* acos(x) = pi/2 - asin(x)
* acos(-x) = pi/2 + asin(x)
* For |x|<=0.5
* acos(x) = pi/2 - (x + x*x^2*R(x^2)) (see asin.c)
* For x>0.5
* acos(x) = pi/2 - (pi/2 - 2asin(sqrt((1-x)/2)))
- * = 2asin(sqrt((1-x)/2))
+ * = 2asin(sqrt((1-x)/2))
* = 2s + 2s*z*R(z) ...z=(1-x)/2, s=sqrt(z)
* = 2f + (2c + 2s*z*R(z))
* where f=hi part of s, and c = (z-f*f)/(s+f) is the correction term
@@ -37,12 +37,10 @@
#include "fdlibm.h"
-#ifndef _DOUBLE_IS_32BITS
-
#ifdef __STDC__
-static const double
+static const double
#else
-static double
+static double
#endif
one= 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
pi = 3.14159265358979311600e+00, /* 0x400921FB, 0x54442D18 */
@@ -67,13 +65,11 @@ qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
#endif
{
double z,p,q,r,w,s,c,df;
- int32_t hx,ix;
- GET_HIGH_WORD(hx,x);
+ int hx,ix;
+ hx = __HI(x);
ix = hx&0x7fffffff;
if(ix>=0x3ff00000) { /* |x| >= 1 */
- uint32_t lx;
- GET_LOW_WORD(lx,x);
- if(((ix-0x3ff00000)|lx)==0) { /* |x|==1 */
+ if(((ix-0x3ff00000)|__LO(x))==0) { /* |x|==1 */
if(hx>0) return 0.0; /* acos(1) = 0 */
else return pi+2.0*pio2_lo; /* acos(-1)= pi */
}
@@ -90,15 +86,15 @@ qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
z = (one+x)*0.5;
p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
- s = __ieee754_sqrt(z);
+ s = sqrt(z);
r = p/q;
w = r*s-pio2_lo;
return pi - 2.0*(s+w);
} else { /* x > 0.5 */
z = (one-x)*0.5;
- s = __ieee754_sqrt(z);
+ s = sqrt(z);
df = s;
- SET_LOW_WORD(df,0);
+ __LO(df) = 0;
c = (z-df*df)/(s+df);
p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
@@ -107,5 +103,3 @@ qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
return 2.0*(df+w);
}
}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/native/fdlibm/e_asin.c b/native/fdlibm/e_asin.c
index 90fc77ffc..6cba5d8c7 100644
--- a/native/fdlibm/e_asin.c
+++ b/native/fdlibm/e_asin.c
@@ -1,10 +1,10 @@
-/* @(#)e_asin.c 5.1 93/09/24 */
+/* @(#)e_asin.c 1.4 96/03/07 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
@@ -18,7 +18,7 @@
* asin(x) = x + x*x^2*R(x^2)
* where
* R(x^2) is a rational approximation of (asin(x)-x)/x^3
- * and its remez error is bounded by
+ * and its Remes error is bounded by
* |(asin(x)-x)/x^3 - R(x^2)| < 2^(-58.75)
*
* For x in [0.5,1]
@@ -44,8 +44,6 @@
#include "fdlibm.h"
-#ifndef _DOUBLE_IS_32BITS
-
#ifdef __STDC__
static const double
#else
@@ -75,14 +73,12 @@ qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
double x;
#endif
{
- double t = 0., w, p, q, c, r, s;
- int32_t hx,ix;
- GET_HIGH_WORD(hx,x);
+ double t,w,p,q,c,r,s;
+ int hx,ix;
+ hx = __HI(x);
ix = hx&0x7fffffff;
if(ix>= 0x3ff00000) { /* |x|>= 1 */
- uint32_t lx;
- GET_LOW_WORD(lx,x);
- if(((ix-0x3ff00000)|lx)==0)
+ if(((ix-0x3ff00000)|__LO(x))==0)
/* asin(1)=+-pi/2 with inexact */
return x*pio2_hi+x*pio2_lo;
return (x-x)/(x-x); /* asin(|x|>1) is NaN */
@@ -101,13 +97,13 @@ qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
t = w*0.5;
p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5)))));
q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4)));
- s = __ieee754_sqrt(t);
+ s = sqrt(t);
if(ix>=0x3FEF3333) { /* if |x| > 0.975 */
w = p/q;
t = pio2_hi-(2.0*(s+s*w)-pio2_lo);
} else {
w = s;
- SET_LOW_WORD(w,0);
+ __LO(w) = 0;
c = (t-w*w)/(s+w);
r = p/q;
p = 2.0*s*r-(pio2_lo-2.0*c);
@@ -116,5 +112,3 @@ qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
}
if(hx>0) return t; else return -t;
}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/native/fdlibm/e_atan2.c b/native/fdlibm/e_atan2.c
index c75448db2..4e731baa3 100644
--- a/native/fdlibm/e_atan2.c
+++ b/native/fdlibm/e_atan2.c
@@ -1,12 +1,12 @@
-/* @(#)e_atan2.c 5.1 93/09/24 */
+/* @(#)e_atan2.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*
@@ -15,7 +15,7 @@
/* __ieee754_atan2(y,x)
* Method :
* 1. Reduce y to positive by atan2(y,x)=-atan2(-y,x).
- * 2. Reduce x to positive by (if x and y are unexceptional):
+ * 2. Reduce x to positive by (if x and y are unexceptional):
* ARG (x+iy) = arctan(y/x) ... if x > 0,
* ARG (x+iy) = pi - arctan[y/(-x)] ... if x < 0,
*
@@ -33,20 +33,18 @@
* ATAN2(+-INF, (anything but,0,NaN, and INF)) is +-pi/2;
*
* Constants:
- * The hexadecimal values are the intended ones for the following
- * constants. The decimal values may be used, provided that the
- * compiler will convert from decimal to binary accurately enough
+ * The hexadecimal values are the intended ones for the following
+ * constants. The decimal values may be used, provided that the
+ * compiler will convert from decimal to binary accurately enough
* to produce the hexadecimal values shown.
*/
#include "fdlibm.h"
-#ifndef _DOUBLE_IS_32BITS
-
#ifdef __STDC__
-static const double
+static const double
#else
-static double
+static double
#endif
tiny = 1.0e-300,
zero = 0.0,
@@ -61,25 +59,25 @@ pi_lo = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */
double __ieee754_atan2(y,x)
double y,x;
#endif
-{
+{
double z;
- int32_t k,m,hx,hy,ix,iy;
- uint32_t lx,ly;
+ int k,m,hx,hy,ix,iy;
+ unsigned lx,ly;
- EXTRACT_WORDS(hx,lx,x);
- ix = hx&0x7fffffff;
- EXTRACT_WORDS(hy,ly,y);
- iy = hy&0x7fffffff;
+ hx = __HI(x); ix = hx&0x7fffffff;
+ lx = __LO(x);
+ hy = __HI(y); iy = hy&0x7fffffff;
+ ly = __LO(y);
if(((ix|((lx|-lx)>>31))>0x7ff00000)||
((iy|((ly|-ly)>>31))>0x7ff00000)) /* x or y is NaN */
return x+y;
- if(((hx-0x3ff00000)|lx)==0) return atan(y); /* x=1.0 */
+ if((hx-0x3ff00000|lx)==0) return atan(y); /* x=1.0 */
m = ((hy>>31)&1)|((hx>>30)&2); /* 2*sign(x)+sign(y) */
/* when y = 0 */
if((iy|ly)==0) {
switch(m) {
- case 0:
+ case 0:
case 1: return y; /* atan(+-0,+anything)=+-0 */
case 2: return pi+tiny;/* atan(+0,-anything) = pi */
case 3: return -pi-tiny;/* atan(-0,-anything) =-pi */
@@ -87,7 +85,7 @@ pi_lo = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */
}
/* when x = 0 */
if((ix|lx)==0) return (hy<0)? -pi_o_2-tiny: pi_o_2+tiny;
-
+
/* when x is INF */
if(ix==0x7ff00000) {
if(iy==0x7ff00000) {
@@ -116,16 +114,10 @@ pi_lo = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */
else z=atan(fabs(y/x)); /* safe to do y/x */
switch (m) {
case 0: return z ; /* atan(+,+) */
- case 1: {
- uint32_t zh;
- GET_HIGH_WORD(zh,z);
- SET_HIGH_WORD(z,zh ^ 0x80000000);
- }
+ case 1: __HI(z) ^= 0x80000000;
return z ; /* atan(-,+) */
case 2: return pi-(z-pi_lo);/* atan(+,-) */
default: /* case 3 */
return (z-pi_lo)-pi;/* atan(-,-) */
}
}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/native/fdlibm/e_cosh.c b/native/fdlibm/e_cosh.c
new file mode 100644
index 000000000..204017d84
--- /dev/null
+++ b/native/fdlibm/e_cosh.c
@@ -0,0 +1,89 @@
+
+/* @(#)e_cosh.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/* __ieee754_cosh(x)
+ * Method :
+ * mathematically cosh(x) if defined to be (exp(x)+exp(-x))/2
+ * 1. Replace x by |x| (cosh(x) = cosh(-x)).
+ * 2.
+ * [ exp(x) - 1 ]^2
+ * 0 <= x <= ln2/2 : cosh(x) := 1 + -------------------
+ * 2*exp(x)
+ *
+ * exp(x) + 1/exp(x)
+ * ln2/2 <= x <= 22 : cosh(x) := -------------------
+ * 2
+ * 22 <= x <= lnovft : cosh(x) := exp(x)/2
+ * lnovft <= x <= ln2ovft: cosh(x) := exp(x/2)/2 * exp(x/2)
+ * ln2ovft < x : cosh(x) := huge*huge (overflow)
+ *
+ * Special cases:
+ * cosh(x) is |x| if x is +INF, -INF, or NaN.
+ * only cosh(0)=1 is exact for finite x.
+ */
+
+#include "fdlibm.h"
+
+#ifdef __STDC__
+static const double one = 1.0, half=0.5, huge = 1.0e300;
+#else
+static double one = 1.0, half=0.5, huge = 1.0e300;
+#endif
+
+#ifdef __STDC__
+ double __ieee754_cosh(double x)
+#else
+ double __ieee754_cosh(x)
+ double x;
+#endif
+{
+ double t,w;
+ int ix;
+ unsigned lx;
+
+ /* High word of |x|. */
+ ix = __HI(x);
+ ix &= 0x7fffffff;
+
+ /* x is INF or NaN */
+ if(ix>=0x7ff00000) return x*x;
+
+ /* |x| in [0,0.5*ln2], return 1+expm1(|x|)^2/(2*exp(|x|)) */
+ if(ix<0x3fd62e43) {
+ t = expm1(fabs(x));
+ w = one+t;
+ if (ix<0x3c800000) return w; /* cosh(tiny) = 1 */
+ return one+(t*t)/(w+w);
+ }
+
+ /* |x| in [0.5*ln2,22], return (exp(|x|)+1/exp(|x|)/2; */
+ if (ix < 0x40360000) {
+ t = __ieee754_exp(fabs(x));
+ return half*t+half/t;
+ }
+
+ /* |x| in [22, log(maxdouble)] return half*exp(|x|) */
+ if (ix < 0x40862E42) return half*__ieee754_exp(fabs(x));
+
+ /* |x| in [log(maxdouble), overflowthresold] */
+ lx = *( (((*(unsigned*)&one)>>29)) + (unsigned*)&x);
+ if (ix<0x408633CE ||
+ (ix==0x408633ce)&&(lx<=(unsigned)0x8fb9f87d)) {
+ w = __ieee754_exp(half*fabs(x));
+ t = half*w;
+ return t*w;
+ }
+
+ /* |x| > overflowthresold, cosh(x) overflow */
+ return huge*huge;
+}
diff --git a/native/fdlibm/e_exp.c b/native/fdlibm/e_exp.c
index ad37f86b0..e2012057f 100644
--- a/native/fdlibm/e_exp.c
+++ b/native/fdlibm/e_exp.c
@@ -1,12 +1,11 @@
-/* @(#)e_exp.c 5.1 93/09/24 */
+/* @(#)e_exp.c 1.6 04/04/22 */
/*
* ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
@@ -19,36 +18,36 @@
* Reduce x to an r so that |r| <= 0.5*ln2 ~ 0.34658.
* Given x, find r and integer k such that
*
- * x = k*ln2 + r, |r| <= 0.5*ln2.
+ * x = k*ln2 + r, |r| <= 0.5*ln2.
*
- * Here r will be represented as r = hi-lo for better
+ * Here r will be represented as r = hi-lo for better
* accuracy.
*
* 2. Approximation of exp(r) by a special rational function on
* the interval [0,0.34658]:
* Write
* R(r**2) = r*(exp(r)+1)/(exp(r)-1) = 2 + r*r/6 - r**4/360 + ...
- * We use a special Reme algorithm on [0,0.34658] to generate
- * a polynomial of degree 5 to approximate R. The maximum error
+ * We use a special Remes algorithm on [0,0.34658] to generate
+ * a polynomial of degree 5 to approximate R. The maximum error
* of this polynomial approximation is bounded by 2**-59. In
* other words,
* R(z) ~ 2.0 + P1*z + P2*z**2 + P3*z**3 + P4*z**4 + P5*z**5
* (where z=r*r, and the values of P1 to P5 are listed below)
* and
* | 5 | -59
- * | 2.0+P1*z+...+P5*z - R(z) | <= 2
+ * | 2.0+P1*z+...+P5*z - R(z) | <= 2
* | |
* The computation of exp(r) thus becomes
* 2*r
* exp(r) = 1 + -------
* R - r
- * r*R1(r)
+ * r*R1(r)
* = 1 + r + ----------- (for better accuracy)
* 2 - R1(r)
* where
* 2 4 10
* R1(r) = r - (P1*r + P2*r + ... + P5*r ).
- *
+ *
* 3. Scale back to obtain exp(x):
* From step 1, we have
* exp(x) = 2^k * exp(r)
@@ -63,21 +62,19 @@
* 1 ulp (unit in the last place).
*
* Misc. info.
- * For IEEE double
+ * For IEEE double
* if x > 7.09782712893383973096e+02 then exp(x) overflow
* if x < -7.45133219101941108420e+02 then exp(x) underflow
*
* Constants:
- * The hexadecimal values are the intended ones for the following
- * constants. The decimal values may be used, provided that the
+ * The hexadecimal values are the intended ones for the following
+ * constants. The decimal values may be used, provided that the
* compiler will convert from decimal to binary accurately enough
* to produce the hexadecimal values shown.
*/
#include "fdlibm.h"
-#ifndef _DOUBLE_IS_32BITS
-
#ifdef __STDC__
static const double
#else
@@ -108,20 +105,18 @@ P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */
double x;
#endif
{
- double y,hi = 0., lo = 0.,c,t;
- int32_t k = 0, xsb;
- uint32_t hx;
+ double y,hi,lo,c,t;
+ int k,xsb;
+ unsigned hx;
- GET_HIGH_WORD(hx,x);
+ hx = __HI(x); /* high word of x */
xsb = (hx>>31)&1; /* sign bit of x */
hx &= 0x7fffffff; /* high word of |x| */
/* filter out non-finite argument */
if(hx >= 0x40862E42) { /* if |x|>=709.78... */
if(hx>=0x7ff00000) {
- uint32_t lx;
- GET_LOW_WORD(lx,x);
- if(((hx&0xfffff)|lx)!=0)
+ if(((hx&0xfffff)|__LO(x))!=0)
return x+x; /* NaN */
else return (xsb==0)? x:0.0; /* exp(+-inf)={inf,0} */
}
@@ -130,17 +125,17 @@ P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */
}
/* argument reduction */
- if(hx > 0x3fd62e42) { /* if |x| > 0.5 ln2 */
+ if(hx > 0x3fd62e42) { /* if |x| > 0.5 ln2 */
if(hx < 0x3FF0A2B2) { /* and |x| < 1.5 ln2 */
hi = x-ln2HI[xsb]; lo=ln2LO[xsb]; k = 1-xsb-xsb;
} else {
- k = invln2*x+halF[xsb];
+ k = (int)(invln2*x+halF[xsb]);
t = k;
hi = x - t*ln2HI[0]; /* t*ln2HI is exact here */
lo = t*ln2LO[0];
}
x = hi - lo;
- }
+ }
else if(hx < 0x3e300000) { /* when |x|<2**-28 */
if(huge+x>one) return one+x;/* trigger inexact */
}
@@ -149,19 +144,13 @@ P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */
/* x is now in primary range */
t = x*x;
c = x - t*(P1+t*(P2+t*(P3+t*(P4+t*P5))));
- if(k==0) return one-((x*c)/(c-2.0)-x);
+ if(k==0) return one-((x*c)/(c-2.0)-x);
else y = one-((lo-(x*c)/(2.0-c))-hi);
if(k >= -1021) {
- uint32_t hy;
- GET_HIGH_WORD(hy,y);
- SET_HIGH_WORD(y,hy+(k<<20)); /* add k to y's exponent */
+ __HI(y) += (k<<20); /* add k to y's exponent */
return y;
} else {
- uint32_t hy;
- GET_HIGH_WORD(hy,y);
- SET_HIGH_WORD(y,hy+((k+1000)<<20)); /* add k to y's exponent */
+ __HI(y) += ((k+1000)<<20);/* add k to y's exponent */
return y*twom1000;
}
}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/native/fdlibm/e_fmod.c b/native/fdlibm/e_fmod.c
index 1cf099076..53bb86081 100644
--- a/native/fdlibm/e_fmod.c
+++ b/native/fdlibm/e_fmod.c
@@ -1,17 +1,17 @@
-/* @(#)e_fmod.c 5.1 93/09/24 */
+/* @(#)e_fmod.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
-/*
+/*
* __ieee754_fmod(x,y)
* Return x mod y in exact arithmetic
* Method: shift and subtract
@@ -19,8 +19,6 @@
#include "fdlibm.h"
-#ifndef _DOUBLE_IS_32BITS
-
#ifdef __STDC__
static const double one = 1.0, Zero[] = {0.0, -0.0,};
#else
@@ -34,11 +32,13 @@ static double one = 1.0, Zero[] = {0.0, -0.0,};
double x,y ;
#endif
{
- int32_t n,hx,hy,hz,ix,iy,sx,i;
- uint32_t lx,ly,lz;
+ int n,hx,hy,hz,ix,iy,sx,i;
+ unsigned lx,ly,lz;
- EXTRACT_WORDS(hx,lx,x);
- EXTRACT_WORDS(hy,ly,y);
+ hx = __HI(x); /* high word of x */
+ lx = __LO(x); /* low word of x */
+ hy = __HI(y); /* high word of y */
+ ly = __LO(y); /* low word of y */
sx = hx&0x80000000; /* sign of x */
hx ^=sx; /* |x| */
hy &= 0x7fffffff; /* |y| */
@@ -49,8 +49,8 @@ static double one = 1.0, Zero[] = {0.0, -0.0,};
return (x*y)/(x*y);
if(hx<=hy) {
if((hx<hy)||(lx<ly)) return x; /* |x|<|y| return x */
- if(lx==ly)
- return Zero[(uint32_t)sx>>31]; /* |x|=|y| return x*0*/
+ if(lx==ly)
+ return Zero[(unsigned)sx>>31]; /* |x|=|y| return x*0*/
}
/* determine ix = ilogb(x) */
@@ -72,7 +72,7 @@ static double one = 1.0, Zero[] = {0.0, -0.0,};
} else iy = (hy>>20)-1023;
/* set up {hx,lx}, {hy,ly} and align y to x */
- if(ix >= -1022)
+ if(ix >= -1022)
hx = 0x00100000|(0x000fffff&hx);
else { /* subnormal x, shift x to normal */
n = -1022-ix;
@@ -84,7 +84,7 @@ static double one = 1.0, Zero[] = {0.0, -0.0,};
lx = 0;
}
}
- if(iy >= -1022)
+ if(iy >= -1022)
hy = 0x00100000|(0x000fffff&hy);
else { /* subnormal y, shift y to normal */
n = -1022-iy;
@@ -104,7 +104,7 @@ static double one = 1.0, Zero[] = {0.0, -0.0,};
if(hz<0){hx = hx+hx+(lx>>31); lx = lx+lx;}
else {
if((hz|lz)==0) /* return sign(x)*0 */
- return Zero[(uint32_t)sx>>31];
+ return Zero[(unsigned)sx>>31];
hx = hz+hz+(lz>>31); lx = lz+lz;
}
}
@@ -113,28 +113,28 @@ static double one = 1.0, Zero[] = {0.0, -0.0,};
/* convert back to floating value and restore the sign */
if((hx|lx)==0) /* return sign(x)*0 */
- return Zero[(uint32_t)sx>>31];
+ return Zero[(unsigned)sx>>31];
while(hx<0x00100000) { /* normalize x */
hx = hx+hx+(lx>>31); lx = lx+lx;
iy -= 1;
}
if(iy>= -1022) { /* normalize output */
hx = ((hx-0x00100000)|((iy+1023)<<20));
- INSERT_WORDS(x,hx|sx,lx);
+ __HI(x) = hx|sx;
+ __LO(x) = lx;
} else { /* subnormal output */
n = -1022 - iy;
if(n<=20) {
- lx = (lx>>n)|((uint32_t)hx<<(32-n));
+ lx = (lx>>n)|((unsigned)hx<<(32-n));
hx >>= n;
} else if (n<=31) {
lx = (hx<<(32-n))|(lx>>n); hx = sx;
} else {
lx = hx>>(n-32); hx = sx;
}
- INSERT_WORDS(x,hx|sx,lx);
+ __HI(x) = hx|sx;
+ __LO(x) = lx;
x *= one; /* create necessary signal */
}
return x; /* exact output */
}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/native/fdlibm/e_hypot.c b/native/fdlibm/e_hypot.c
new file mode 100644
index 000000000..80c1e6db2
--- /dev/null
+++ b/native/fdlibm/e_hypot.c
@@ -0,0 +1,115 @@
+
+/* @(#)e_hypot.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/* __ieee754_hypot(x,y)
+ *
+ * Method :
+ * If (assume round-to-nearest) z=x*x+y*y
+ * has error less than sqrt(2)/2 ulp, than
+ * sqrt(z) has error less than 1 ulp (exercise).
+ *
+ * So, compute sqrt(x*x+y*y) with some care as
+ * follows to get the error below 1 ulp:
+ *
+ * Assume x>y>0;
+ * (if possible, set rounding to round-to-nearest)
+ * 1. if x > 2y use
+ * x1*x1+(y*y+(x2*(x+x1))) for x*x+y*y
+ * where x1 = x with lower 32 bits cleared, x2 = x-x1; else
+ * 2. if x <= 2y use
+ * t1*y1+((x-y)*(x-y)+(t1*y2+t2*y))
+ * where t1 = 2x with lower 32 bits cleared, t2 = 2x-t1,
+ * y1= y with lower 32 bits chopped, y2 = y-y1.
+ *
+ * NOTE: scaling may be necessary if some argument is too
+ * large or too tiny
+ *
+ * Special cases:
+ * hypot(x,y) is INF if x or y is +INF or -INF; else
+ * hypot(x,y) is NAN if x or y is NAN.
+ *
+ * Accuracy:
+ * hypot(x,y) returns sqrt(x^2+y^2) with error less
+ * than 1 ulps (units in the last place)
+ */
+
+#include "fdlibm.h"
+
+#ifdef __STDC__
+ double __ieee754_hypot(double x, double y)
+#else
+ double __ieee754_hypot(x,y)
+ double x, y;
+#endif
+{
+ double a=x,b=y,t1,t2,y1,y2,w;
+ int j,k,ha,hb;
+
+ ha = __HI(x)&0x7fffffff; /* high word of x */
+ hb = __HI(y)&0x7fffffff; /* high word of y */
+ if(hb > ha) {a=y;b=x;j=ha; ha=hb;hb=j;} else {a=x;b=y;}
+ __HI(a) = ha; /* a <- |a| */
+ __HI(b) = hb; /* b <- |b| */
+ if((ha-hb)>0x3c00000) {return a+b;} /* x/y > 2**60 */
+ k=0;
+ if(ha > 0x5f300000) { /* a>2**500 */
+ if(ha >= 0x7ff00000) { /* Inf or NaN */
+ w = a+b; /* for sNaN */
+ if(((ha&0xfffff)|__LO(a))==0) w = a;
+ if(((hb^0x7ff00000)|__LO(b))==0) w = b;
+ return w;
+ }
+ /* scale a and b by 2**-600 */
+ ha -= 0x25800000; hb -= 0x25800000; k += 600;
+ __HI(a) = ha;
+ __HI(b) = hb;
+ }
+ if(hb < 0x20b00000) { /* b < 2**-500 */
+ if(hb <= 0x000fffff) { /* subnormal b or 0 */
+ if((hb|(__LO(b)))==0) return a;
+ t1=0;
+ __HI(t1) = 0x7fd00000; /* t1=2^1022 */
+ b *= t1;
+ a *= t1;
+ k -= 1022;
+ } else { /* scale a and b by 2^600 */
+ ha += 0x25800000; /* a *= 2^600 */
+ hb += 0x25800000; /* b *= 2^600 */
+ k -= 600;
+ __HI(a) = ha;
+ __HI(b) = hb;
+ }
+ }
+ /* medium size a and b */
+ w = a-b;
+ if (w>b) {
+ t1 = 0;
+ __HI(t1) = ha;
+ t2 = a-t1;
+ w = sqrt(t1*t1-(b*(-b)-t2*(a+t1)));
+ } else {
+ a = a+a;
+ y1 = 0;
+ __HI(y1) = hb;
+ y2 = b - y1;
+ t1 = 0;
+ __HI(t1) = ha+0x00100000;
+ t2 = a - t1;
+ w = sqrt(t1*y1-(w*(-w)-(t1*y2+t2*b)));
+ }
+ if(k!=0) {
+ t1 = 1.0;
+ __HI(t1) += (k<<20);
+ return t1*w;
+ } else return w;
+}
diff --git a/native/fdlibm/e_log.c b/native/fdlibm/e_log.c
index 093473e10..1f38843a8 100644
--- a/native/fdlibm/e_log.c
+++ b/native/fdlibm/e_log.c
@@ -1,12 +1,12 @@
-/* @(#)e_log.c 5.1 93/09/24 */
+/* @(#)e_log.c 1.4 96/03/07 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
@@ -14,17 +14,17 @@
/* __ieee754_log(x)
* Return the logrithm of x
*
- * Method :
- * 1. Argument Reduction: find k and f such that
- * x = 2^k * (1+f),
+ * Method :
+ * 1. Argument Reduction: find k and f such that
+ * x = 2^k * (1+f),
* where sqrt(2)/2 < 1+f < sqrt(2) .
*
* 2. Approximation of log(1+f).
* Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s)
* = 2s + 2/3 s**3 + 2/5 s**5 + .....,
* = 2s + s*R
- * We use a special Reme algorithm on [0,0.1716] to generate
- * a polynomial of degree 14 to approximate R The maximum error
+ * We use a special Remes algorithm on [0,0.1716] to generate
+ * a polynomial of degree 14 to approximate R The maximum error
* of this polynomial approximation is bounded by 2**-58.45. In
* other words,
* 2 4 6 8 10 12 14
@@ -32,22 +32,22 @@
* (the values of Lg1 to Lg7 are listed in the program)
* and
* | 2 14 | -58.45
- * | Lg1*s +...+Lg7*s - R(z) | <= 2
+ * | Lg1*s +...+Lg7*s - R(z) | <= 2
* | |
* Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2.
* In order to guarantee error in log below 1ulp, we compute log
* by
* log(1+f) = f - s*(f - R) (if f is not too large)
* log(1+f) = f - (hfsq - s*(hfsq+R)). (better accuracy)
- *
- * 3. Finally, log(x) = k*ln2 + log(1+f).
+ *
+ * 3. Finally, log(x) = k*ln2 + log(1+f).
* = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo)))
- * Here ln2 is split into two floating point number:
+ * Here ln2 is split into two floating point number:
* ln2_hi + ln2_lo,
* where n*ln2_hi is always exact for |n| < 2000.
*
* Special cases:
- * log(x) is NaN with signal if x < 0 (including -INF) ;
+ * log(x) is NaN with signal if x < 0 (including -INF) ;
* log(+INF) is +INF; log(0) is -INF with signal;
* log(NaN) is that NaN with no signal.
*
@@ -56,16 +56,14 @@
* 1 ulp (unit in the last place).
*
* Constants:
- * The hexadecimal values are the intended ones for the following
- * constants. The decimal values may be used, provided that the
- * compiler will convert from decimal to binary accurately enough
+ * The hexadecimal values are the intended ones for the following
+ * constants. The decimal values may be used, provided that the
+ * compiler will convert from decimal to binary accurately enough
* to produce the hexadecimal values shown.
*/
#include "fdlibm.h"
-#ifndef _DOUBLE_IS_32BITS
-
#ifdef __STDC__
static const double
#else
@@ -82,11 +80,7 @@ Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */
Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */
Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
-#ifdef __STDC__
-static const double zero = 0.0;
-#else
static double zero = 0.0;
-#endif
#ifdef __STDC__
double __ieee754_log(double x)
@@ -96,47 +90,42 @@ static double zero = 0.0;
#endif
{
double hfsq,f,s,z,R,w,t1,t2,dk;
- int32_t k,hx,i,j;
- uint32_t lx;
+ int k,hx,i,j;
+ unsigned lx;
- EXTRACT_WORDS(hx,lx,x);
+ hx = __HI(x); /* high word of x */
+ lx = __LO(x); /* low word of x */
k=0;
if (hx < 0x00100000) { /* x < 2**-1022 */
- if (((hx&0x7fffffff)|lx)==0)
+ if (((hx&0x7fffffff)|lx)==0)
return -two54/zero; /* log(+-0)=-inf */
if (hx<0) return (x-x)/zero; /* log(-#) = NaN */
k -= 54; x *= two54; /* subnormal number, scale up x */
- GET_HIGH_WORD(hx,x);
- }
+ hx = __HI(x); /* high word of x */
+ }
if (hx >= 0x7ff00000) return x+x;
k += (hx>>20)-1023;
hx &= 0x000fffff;
i = (hx+0x95f64)&0x100000;
- SET_HIGH_WORD(x,hx|(i^0x3ff00000)); /* normalize x or x/2 */
+ __HI(x) = hx|(i^0x3ff00000); /* normalize x or x/2 */
k += (i>>20);
f = x-1.0;
if((0x000fffff&(2+hx))<3) { /* |f| < 2**-20 */
- if(f==zero) {
- if(k==0)
- return zero;
- else {
- dk=(double)k;
- return dk*ln2_hi+dk*ln2_lo;
- }
- }
+ if(f==zero) if(k==0) return zero; else {dk=(double)k;
+ return dk*ln2_hi+dk*ln2_lo;}
R = f*f*(0.5-0.33333333333333333*f);
if(k==0) return f-R; else {dk=(double)k;
return dk*ln2_hi-((R-dk*ln2_lo)-f);}
}
- s = f/(2.0+f);
+ s = f/(2.0+f);
dk = (double)k;
z = s*s;
i = hx-0x6147a;
w = z*z;
j = 0x6b851-hx;
- t1= w*(Lg2+w*(Lg4+w*Lg6));
- t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7)));
+ t1= w*(Lg2+w*(Lg4+w*Lg6));
+ t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7)));
i |= j;
R = t2+t1;
if(i>0) {
@@ -148,5 +137,3 @@ static double zero = 0.0;
return dk*ln2_hi-((s*(f-R)-dk*ln2_lo)-f);
}
}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/native/fdlibm/e_log10.c b/native/fdlibm/e_log10.c
new file mode 100644
index 000000000..dc7e31244
--- /dev/null
+++ b/native/fdlibm/e_log10.c
@@ -0,0 +1,91 @@
+
+/* @(#)e_log10.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/* __ieee754_log10(x)
+ * Return the base 10 logarithm of x
+ *
+ * Method :
+ * Let log10_2hi = leading 40 bits of log10(2) and
+ * log10_2lo = log10(2) - log10_2hi,
+ * ivln10 = 1/log(10) rounded.
+ * Then
+ * n = ilogb(x),
+ * if(n<0) n = n+1;
+ * x = scalbn(x,-n);
+ * log10(x) := n*log10_2hi + (n*log10_2lo + ivln10*log(x))
+ *
+ * Note 1:
+ * To guarantee log10(10**n)=n, where 10**n is normal, the rounding
+ * mode must set to Round-to-Nearest.
+ * Note 2:
+ * [1/log(10)] rounded to 53 bits has error .198 ulps;
+ * log10 is monotonic at all binary break points.
+ *
+ * Special cases:
+ * log10(x) is NaN with signal if x < 0;
+ * log10(+INF) is +INF with no signal; log10(0) is -INF with signal;
+ * log10(NaN) is that NaN with no signal;
+ * log10(10**N) = N for N=0,1,...,22.
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following constants.
+ * The decimal values may be used, provided that the compiler will convert
+ * from decimal to binary accurately enough to produce the hexadecimal values
+ * shown.
+ */
+
+#include "fdlibm.h"
+
+#ifdef __STDC__
+static const double
+#else
+static double
+#endif
+two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */
+ivln10 = 4.34294481903251816668e-01, /* 0x3FDBCB7B, 0x1526E50E */
+log10_2hi = 3.01029995663611771306e-01, /* 0x3FD34413, 0x509F6000 */
+log10_2lo = 3.69423907715893078616e-13; /* 0x3D59FEF3, 0x11F12B36 */
+
+static double zero = 0.0;
+
+#ifdef __STDC__
+ double __ieee754_log10(double x)
+#else
+ double __ieee754_log10(x)
+ double x;
+#endif
+{
+ double y,z;
+ int i,k,hx;
+ unsigned lx;
+
+ hx = __HI(x); /* high word of x */
+ lx = __LO(x); /* low word of x */
+
+ k=0;
+ if (hx < 0x00100000) { /* x < 2**-1022 */
+ if (((hx&0x7fffffff)|lx)==0)
+ return -two54/zero; /* log(+-0)=-inf */
+ if (hx<0) return (x-x)/zero; /* log(-#) = NaN */
+ k -= 54; x *= two54; /* subnormal number, scale up x */
+ hx = __HI(x); /* high word of x */
+ }
+ if (hx >= 0x7ff00000) return x+x;
+ k += (hx>>20)-1023;
+ i = ((unsigned)k&0x80000000)>>31;
+ hx = (hx&0x000fffff)|((0x3ff-i)<<20);
+ y = (double)(k+i);
+ __HI(x) = hx;
+ z = y*log10_2lo + ivln10*__ieee754_log(x);
+ return z+y*log10_2hi;
+}
diff --git a/native/fdlibm/e_pow.c b/native/fdlibm/e_pow.c
index b21c0e92b..5683bf5fd 100644
--- a/native/fdlibm/e_pow.c
+++ b/native/fdlibm/e_pow.c
@@ -1,12 +1,14 @@
-/* @(#)e_pow.c 5.1 93/09/24 */
+#ifndef lint
+static char sccsid[] = "@(#)e_pow.c 1.5 04/04/22 SMI";
+#endif
+
/*
* ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
@@ -18,7 +20,7 @@
* 1. Compute and return log2(x) in two pieces:
* log2(x) = w1 + w2,
* where w1 has 53-24 = 29 bit trailing zeros.
- * 2. Perform y*log2(x) = n+y' by simulating muti-precision
+ * 2. Perform y*log2(x) = n+y' by simulating muti-precision
* arithmetic, where |y'|<=0.5.
* 3. Return x**y = 2**n*exp(y'*log2)
*
@@ -46,24 +48,22 @@
* Accuracy:
* pow(x,y) returns x**y nearly rounded. In particular
* pow(integer,integer)
- * always returns the correct integer provided it is
+ * always returns the correct integer provided it is
* representable.
*
* Constants :
- * The hexadecimal values are the intended ones for the following
- * constants. The decimal values may be used, provided that the
- * compiler will convert from decimal to binary accurately enough
+ * The hexadecimal values are the intended ones for the following
+ * constants. The decimal values may be used, provided that the
+ * compiler will convert from decimal to binary accurately enough
* to produce the hexadecimal values shown.
*/
#include "fdlibm.h"
-#ifndef _DOUBLE_IS_32BITS
-
#ifdef __STDC__
-static const double
+static const double
#else
-static double
+static double
#endif
bp[] = {1.0, 1.5,},
dp_h[] = { 0.0, 5.84962487220764160156e-01,}, /* 0x3FE2B803, 0x40000000 */
@@ -106,21 +106,22 @@ ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/
{
double z,ax,z_h,z_l,p_h,p_l;
double y1,t1,t2,r,s,t,u,v,w;
- int32_t i,j,k,yisint,n;
- int32_t hx,hy,ix,iy;
- uint32_t lx,ly;
+ int i0,i1,i,j,k,yisint,n;
+ int hx,hy,ix,iy;
+ unsigned lx,ly;
- EXTRACT_WORDS(hx,lx,x);
- EXTRACT_WORDS(hy,ly,y);
+ i0 = ((*(int*)&one)>>29)^1; i1=1-i0;
+ hx = __HI(x); lx = __LO(x);
+ hy = __HI(y); ly = __LO(y);
ix = hx&0x7fffffff; iy = hy&0x7fffffff;
/* y==zero: x**0 = 1 */
- if((iy|ly)==0) return one;
+ if((iy|ly)==0) return one;
/* +-NaN return x+y */
if(ix > 0x7ff00000 || ((ix==0x7ff00000)&&(lx!=0)) ||
- iy > 0x7ff00000 || ((iy==0x7ff00000)&&(ly!=0)))
- return x+y;
+ iy > 0x7ff00000 || ((iy==0x7ff00000)&&(ly!=0)))
+ return x+y;
/* determine if y is an odd int when x < 0
* yisint = 0 ... y is not an integer
@@ -128,22 +129,22 @@ ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/
* yisint = 2 ... y is an even int
*/
yisint = 0;
- if(hx<0) {
+ if(hx<0) {
if(iy>=0x43400000) yisint = 2; /* even integer y */
else if(iy>=0x3ff00000) {
k = (iy>>20)-0x3ff; /* exponent */
if(k>20) {
j = ly>>(52-k);
- if((uint32_t)(j<<(52-k))==ly) yisint = 2-(j&1);
+ if((j<<(52-k))==ly) yisint = 2-(j&1);
} else if(ly==0) {
j = iy>>(20-k);
if((j<<(20-k))==iy) yisint = 2-(j&1);
}
- }
- }
+ }
+ }
/* special value of y */
- if(ly==0) {
+ if(ly==0) {
if (iy==0x7ff00000) { /* y is +-inf */
if(((ix-0x3ff00000)|lx)==0)
return y - y; /* inf**+-1 is NaN */
@@ -151,14 +152,14 @@ ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/
return (hy>=0)? y: zero;
else /* (|x|<1)**-,+inf = inf,0 */
return (hy<0)?-y: zero;
- }
+ }
if(iy==0x3ff00000) { /* y is +-1 */
if(hy<0) return one/x; else return x;
}
if(hy==0x40000000) return x*x; /* y is 2 */
if(hy==0x3fe00000) { /* y is 0.5 */
if(hx>=0) /* x >= +0 */
- return __ieee754_sqrt(x);
+ return sqrt(x);
}
}
@@ -171,19 +172,20 @@ ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/
if(hx<0) {
if(((ix-0x3ff00000)|yisint)==0) {
z = (z-z)/(z-z); /* (-1)**non-int is NaN */
- } else if(yisint==1)
+ } else if(yisint==1)
z = -z; /* (x<0)**odd = -(|x|**odd) */
}
return z;
}
}
+
+ n = (hx>>31)+1;
/* (x<0)**(non-int) is NaN */
- /* GCJ LOCAL: This used to be
- if((((hx>>31)+1)|yisint)==0) return (x-x)/(x-x);
- but ANSI C says a right shift of a signed negative quantity is
- implementation defined. */
- if(((((uint32_t)hx>>31)-1)|yisint)==0) return (x-x)/(x-x);
+ if((n|yisint)==0) return (x-x)/(x-x);
+
+ s = one; /* s (sign of result -ve**odd) = -1 else = 1 */
+ if((n|(yisint-1))==0) s = -one;/* (-ve)**(odd int) */
/* |y| is huge */
if(iy>0x41e00000) { /* if |y| > 2**31 */
@@ -192,23 +194,23 @@ ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/
if(ix>=0x3ff00000) return (hy>0)? huge*huge:tiny*tiny;
}
/* over/underflow if x is not close to one */
- if(ix<0x3fefffff) return (hy<0)? huge*huge:tiny*tiny;
- if(ix>0x3ff00000) return (hy>0)? huge*huge:tiny*tiny;
- /* now |1-x| is tiny <= 2**-20, suffice to compute
+ if(ix<0x3fefffff) return (hy<0)? s*huge*huge:s*tiny*tiny;
+ if(ix>0x3ff00000) return (hy>0)? s*huge*huge:s*tiny*tiny;
+ /* now |1-x| is tiny <= 2**-20, suffice to compute
log(x) by x-x^2/2+x^3/3-x^4/4 */
- t = x-1; /* t has 20 trailing zeros */
+ t = ax-one; /* t has 20 trailing zeros */
w = (t*t)*(0.5-t*(0.3333333333333333333333-t*0.25));
u = ivln2_h*t; /* ivln2_h has 21 sig. bits */
v = t*ivln2_l-w*ivln2;
t1 = u+v;
- SET_LOW_WORD(t1,0);
+ __LO(t1) = 0;
t2 = v-(t1-u);
} else {
- double s2,s_h,s_l,t_h,t_l;
+ double ss,s2,s_h,s_l,t_h,t_l;
n = 0;
/* take care subnormal number */
if(ix<0x00100000)
- {ax *= two53; n -= 53; GET_HIGH_WORD(ix,ax); }
+ {ax *= two53; n -= 53; ix = __HI(ax); }
n += ((ix)>>20)-0x3ff;
j = ix&0x000fffff;
/* determine interval */
@@ -216,54 +218,51 @@ ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/
if(j<=0x3988E) k=0; /* |x|<sqrt(3/2) */
else if(j<0xBB67A) k=1; /* |x|<sqrt(3) */
else {k=0;n+=1;ix -= 0x00100000;}
- SET_HIGH_WORD(ax,ix);
+ __HI(ax) = ix;
- /* compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */
+ /* compute ss = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */
u = ax-bp[k]; /* bp[0]=1.0, bp[1]=1.5 */
v = one/(ax+bp[k]);
- s = u*v;
- s_h = s;
- SET_LOW_WORD(s_h,0);
+ ss = u*v;
+ s_h = ss;
+ __LO(s_h) = 0;
/* t_h=ax+bp[k] High */
t_h = zero;
- SET_HIGH_WORD(t_h,((ix>>1)|0x20000000)+0x00080000+(k<<18));
+ __HI(t_h)=((ix>>1)|0x20000000)+0x00080000+(k<<18);
t_l = ax - (t_h-bp[k]);
s_l = v*((u-s_h*t_h)-s_h*t_l);
/* compute log(ax) */
- s2 = s*s;
+ s2 = ss*ss;
r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6)))));
- r += s_l*(s_h+s);
+ r += s_l*(s_h+ss);
s2 = s_h*s_h;
t_h = 3.0+s2+r;
- SET_LOW_WORD(t_h,0);
+ __LO(t_h) = 0;
t_l = r-((t_h-3.0)-s2);
- /* u+v = s*(1+...) */
+ /* u+v = ss*(1+...) */
u = s_h*t_h;
- v = s_l*t_h+t_l*s;
- /* 2/(3log2)*(s+...) */
+ v = s_l*t_h+t_l*ss;
+ /* 2/(3log2)*(ss+...) */
p_h = u+v;
- SET_LOW_WORD(p_h,0);
+ __LO(p_h) = 0;
p_l = v-(p_h-u);
z_h = cp_h*p_h; /* cp_h+cp_l = 2/(3*log2) */
z_l = cp_l*p_h+p_l*cp+dp_l[k];
- /* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */
+ /* log2(ax) = (ss+..)*2/(3*log2) = n + dp_h + z_h + z_l */
t = (double)n;
t1 = (((z_h+z_l)+dp_h[k])+t);
- SET_LOW_WORD(t1,0);
+ __LO(t1) = 0;
t2 = z_l-(((t1-t)-dp_h[k])-z_h);
}
- s = one; /* s (sign of result -ve**odd) = -1 else = 1 */
- if(((((uint32_t)hx>>31)-1)|(yisint-1))==0)
- s = -one;/* (-ve)**(odd int) */
-
/* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */
y1 = y;
- SET_LOW_WORD(y1,0);
+ __LO(y1) = 0;
p_l = (y-y1)*t1+y*t2;
p_h = y1*t1;
z = p_l+p_h;
- EXTRACT_WORDS(j,i,z);
+ j = __HI(z);
+ i = __LO(z);
if (j>=0x40900000) { /* z >= 1024 */
if(((j-0x40900000)|i)!=0) /* if z > 1024 */
return s*huge*huge; /* overflow */
@@ -287,13 +286,13 @@ ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/
n = j+(0x00100000>>(k+1));
k = ((n&0x7fffffff)>>20)-0x3ff; /* new k for n */
t = zero;
- SET_HIGH_WORD(t,n&~(0x000fffff>>k));
+ __HI(t) = (n&~(0x000fffff>>k));
n = ((n&0x000fffff)|0x00100000)>>(20-k);
if(j<0) n = -n;
p_h -= t;
- }
+ }
t = p_l+p_h;
- SET_LOW_WORD(t,0);
+ __LO(t) = 0;
u = t*lg2_h;
v = (p_l-(t-p_h))*lg2+t*lg2_l;
z = u+v;
@@ -302,11 +301,9 @@ ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/
t1 = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5))));
r = (z*t1)/(t1-two)-(w+z*w);
z = one-(r-z);
- GET_HIGH_WORD(j,z);
+ j = __HI(z);
j += (n<<20);
- if((j>>20)<=0) z = scalbn(z,(int)n); /* subnormal output */
- else SET_HIGH_WORD(z,j);
+ if((j>>20)<=0) z = scalbn(z,n); /* subnormal output */
+ else __HI(z) += (n<<20);
return s*z;
}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/native/fdlibm/e_rem_pio2.c b/native/fdlibm/e_rem_pio2.c
index 543234c60..7242bb232 100644
--- a/native/fdlibm/e_rem_pio2.c
+++ b/native/fdlibm/e_rem_pio2.c
@@ -1,52 +1,50 @@
-/* @(#)e_rem_pio2.c 5.1 93/09/24 */
+/* @(#)e_rem_pio2.c 1.4 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*
*/
/* __ieee754_rem_pio2(x,y)
- *
- * return the remainder of x rem pi/2 in y[0]+y[1]
+ *
+ * return the remainder of x rem pi/2 in y[0]+y[1]
* use __kernel_rem_pio2()
*/
#include "fdlibm.h"
-#ifndef _DOUBLE_IS_32BITS
-
/*
- * Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi
+ * Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi
*/
#ifdef __STDC__
-static const int32_t two_over_pi[] = {
+static const int two_over_pi[] = {
#else
-static int32_t two_over_pi[] = {
+static int two_over_pi[] = {
#endif
-0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62,
-0x95993C, 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A,
-0x424DD2, 0xE00649, 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129,
-0xA73EE8, 0x8235F5, 0x2EBB44, 0x84E99C, 0x7026B4, 0x5F7E41,
-0x3991D6, 0x398353, 0x39F49C, 0x845F8B, 0xBDF928, 0x3B1FF8,
-0x97FFDE, 0x05980F, 0xEF2F11, 0x8B5A0A, 0x6D1F6D, 0x367ECF,
-0x27CB09, 0xB74F46, 0x3F669E, 0x5FEA2D, 0x7527BA, 0xC7EBE5,
-0xF17B3D, 0x0739F7, 0x8A5292, 0xEA6BFB, 0x5FB11F, 0x8D5D08,
-0x560330, 0x46FC7B, 0x6BABF0, 0xCFBC20, 0x9AF436, 0x1DA9E3,
-0x91615E, 0xE61B08, 0x659985, 0x5F14A0, 0x68408D, 0xFFD880,
-0x4D7327, 0x310606, 0x1556CA, 0x73A8C9, 0x60E27B, 0xC08C6B,
+0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62,
+0x95993C, 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A,
+0x424DD2, 0xE00649, 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129,
+0xA73EE8, 0x8235F5, 0x2EBB44, 0x84E99C, 0x7026B4, 0x5F7E41,
+0x3991D6, 0x398353, 0x39F49C, 0x845F8B, 0xBDF928, 0x3B1FF8,
+0x97FFDE, 0x05980F, 0xEF2F11, 0x8B5A0A, 0x6D1F6D, 0x367ECF,
+0x27CB09, 0xB74F46, 0x3F669E, 0x5FEA2D, 0x7527BA, 0xC7EBE5,
+0xF17B3D, 0x0739F7, 0x8A5292, 0xEA6BFB, 0x5FB11F, 0x8D5D08,
+0x560330, 0x46FC7B, 0x6BABF0, 0xCFBC20, 0x9AF436, 0x1DA9E3,
+0x91615E, 0xE61B08, 0x659985, 0x5F14A0, 0x68408D, 0xFFD880,
+0x4D7327, 0x310606, 0x1556CA, 0x73A8C9, 0x60E27B, 0xC08C6B,
};
#ifdef __STDC__
-static const int32_t npio2_hw[] = {
+static const int npio2_hw[] = {
#else
-static int32_t npio2_hw[] = {
+static int npio2_hw[] = {
#endif
0x3FF921FB, 0x400921FB, 0x4012D97C, 0x401921FB, 0x401F6A7A, 0x4022D97C,
0x4025FDBB, 0x402921FB, 0x402C463A, 0x402F6A7A, 0x4031475C, 0x4032D97C,
@@ -67,9 +65,9 @@ static int32_t npio2_hw[] = {
*/
#ifdef __STDC__
-static const double
+static const double
#else
-static double
+static double
#endif
zero = 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
half = 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */
@@ -83,24 +81,22 @@ pio2_3 = 2.02226624871116645580e-21, /* 0x3BA3198A, 0x2E000000 */
pio2_3t = 8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */
#ifdef __STDC__
- int32_t __ieee754_rem_pio2(double x, double *y)
+ int __ieee754_rem_pio2(double x, double *y)
#else
- int32_t __ieee754_rem_pio2(x,y)
+ int __ieee754_rem_pio2(x,y)
double x,y[];
#endif
{
- double z = 0., w, t, r, fn;
+ double z,w,t,r,fn;
double tx[3];
- int32_t i,j,n,ix,hx;
- int e0,nx;
- uint32_t low;
+ int e0,i,j,nx,n,ix,hx;
- GET_HIGH_WORD(hx,x); /* high word of x */
+ hx = __HI(x); /* high word of x */
ix = hx&0x7fffffff;
if(ix<=0x3fe921fb) /* |x| ~<= pi/4 , no need for reduction */
{y[0] = x; y[1] = 0; return 0;}
if(ix<0x4002d97c) { /* |x| < 3pi/4, special case with n=+-1 */
- if(hx>0) {
+ if(hx>0) {
z = x - pio2_1;
if(ix!=0x3ff921fb) { /* 33+53 bit pi is good enough */
y[0] = z - pio2_1t;
@@ -126,31 +122,28 @@ pio2_3t = 8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */
}
if(ix<=0x413921fb) { /* |x| ~<= 2^19*(pi/2), medium size */
t = fabs(x);
- n = (int32_t) (t*invpio2+half);
+ n = (int) (t*invpio2+half);
fn = (double)n;
r = t-fn*pio2_1;
w = fn*pio2_1t; /* 1st round good to 85 bit */
- if(n<32&&ix!=npio2_hw[n-1]) {
+ if(n<32&&ix!=npio2_hw[n-1]) {
y[0] = r-w; /* quick check no cancellation */
} else {
- uint32_t high;
j = ix>>20;
- y[0] = r-w;
- GET_HIGH_WORD(high,y[0]);
- i = j-((high>>20)&0x7ff);
+ y[0] = r-w;
+ i = j-(((__HI(y[0]))>>20)&0x7ff);
if(i>16) { /* 2nd iteration needed, good to 118 */
t = r;
- w = fn*pio2_2;
+ w = fn*pio2_2;
r = t-w;
- w = fn*pio2_2t-((t-r)-w);
+ w = fn*pio2_2t-((t-r)-w);
y[0] = r-w;
- GET_HIGH_WORD(high,y[0]);
- i = j-((high>>20)&0x7ff);
+ i = j-(((__HI(y[0]))>>20)&0x7ff);
if(i>49) { /* 3rd iteration need, 151 bits acc */
t = r; /* will cover all possible cases */
- w = fn*pio2_3;
+ w = fn*pio2_3;
r = t-w;
- w = fn*pio2_3t-((t-r)-w);
+ w = fn*pio2_3t-((t-r)-w);
y[0] = r-w;
}
}
@@ -159,19 +152,18 @@ pio2_3t = 8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */
if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;}
else return n;
}
- /*
+ /*
* all other (large) arguments
*/
if(ix>=0x7ff00000) { /* x is inf or NaN */
y[0]=y[1]=x-x; return 0;
}
/* set z = scalbn(|x|,ilogb(x)-23) */
- GET_LOW_WORD(low,x);
- SET_LOW_WORD(z,low);
- e0 = (int)((ix>>20)-1046); /* e0 = ilogb(z)-23; */
- SET_HIGH_WORD(z, ix - ((int32_t)e0<<20));
+ __LO(z) = __LO(x);
+ e0 = (ix>>20)-1046; /* e0 = ilogb(z)-23; */
+ __HI(z) = ix - (e0<<20);
for(i=0;i<2;i++) {
- tx[i] = (double)((int32_t)(z));
+ tx[i] = (double)((int)(z));
z = (z-tx[i])*two24;
}
tx[2] = z;
@@ -181,5 +173,3 @@ pio2_3t = 8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */
if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;}
return n;
}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/native/fdlibm/e_remainder.c b/native/fdlibm/e_remainder.c
index 4716d8d05..37f276860 100644
--- a/native/fdlibm/e_remainder.c
+++ b/native/fdlibm/e_remainder.c
@@ -1,29 +1,27 @@
-/* @(#)e_remainder.c 5.1 93/09/24 */
+/* @(#)e_remainder.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
/* __ieee754_remainder(x,p)
- * Return :
- * returns x REM p = x - [x/p]*p as if in infinite
- * precise arithmetic, where [x/p] is the (infinite bit)
+ * Return :
+ * returns x REM p = x - [x/p]*p as if in infinite
+ * precise arithmetic, where [x/p] is the (infinite bit)
* integer nearest x/p (in half way case choose the even one).
- * Method :
+ * Method :
* Based on fmod() return x-[x/p]chopped*p exactlp.
*/
#include "fdlibm.h"
-#ifndef _DOUBLE_IS_32BITS
-
#ifdef __STDC__
static const double zero = 0.0;
#else
@@ -38,12 +36,14 @@ static double zero = 0.0;
double x,p;
#endif
{
- int32_t hx,hp;
- uint32_t sx,lx,lp;
+ int hx,hp;
+ unsigned sx,lx,lp;
double p_half;
- EXTRACT_WORDS(hx,lx,x);
- EXTRACT_WORDS(hp,lp,p);
+ hx = __HI(x); /* high word of x */
+ lx = __LO(x); /* low word of x */
+ hp = __HI(p); /* high word of p */
+ lp = __LO(p); /* low word of p */
sx = hx&0x80000000;
hp &= 0x7fffffff;
hx &= 0x7fffffff;
@@ -72,9 +72,6 @@ static double zero = 0.0;
if(x>=p_half) x -= p;
}
}
- GET_HIGH_WORD(hx,x);
- SET_HIGH_WORD(x,hx^sx);
+ __HI(x) ^= sx;
return x;
}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/native/fdlibm/e_scalb.c b/native/fdlibm/e_scalb.c
index 0bb924b43..91e9c6ad2 100644
--- a/native/fdlibm/e_scalb.c
+++ b/native/fdlibm/e_scalb.c
@@ -1,10 +1,10 @@
-/* @(#)e_scalb.c 5.1 93/09/24 */
+/* @(#)e_scalb.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
@@ -19,8 +19,6 @@
#include "fdlibm.h"
-#ifndef _DOUBLE_IS_32BITS
-
#ifdef _SCALB_INT
#ifdef __STDC__
double __ieee754_scalb(double x, int fn)
@@ -51,5 +49,3 @@
return scalbn(x,(int)fn);
#endif
}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/native/fdlibm/e_sinh.c b/native/fdlibm/e_sinh.c
new file mode 100644
index 000000000..8af8a11eb
--- /dev/null
+++ b/native/fdlibm/e_sinh.c
@@ -0,0 +1,82 @@
+
+/* @(#)e_sinh.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/* __ieee754_sinh(x)
+ * Method :
+ * mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2
+ * 1. Replace x by |x| (sinh(-x) = -sinh(x)).
+ * 2.
+ * E + E/(E+1)
+ * 0 <= x <= 22 : sinh(x) := --------------, E=expm1(x)
+ * 2
+ *
+ * 22 <= x <= lnovft : sinh(x) := exp(x)/2
+ * lnovft <= x <= ln2ovft: sinh(x) := exp(x/2)/2 * exp(x/2)
+ * ln2ovft < x : sinh(x) := x*shuge (overflow)
+ *
+ * Special cases:
+ * sinh(x) is |x| if x is +INF, -INF, or NaN.
+ * only sinh(0)=0 is exact for finite x.
+ */
+
+#include "fdlibm.h"
+
+#ifdef __STDC__
+static const double one = 1.0, shuge = 1.0e307;
+#else
+static double one = 1.0, shuge = 1.0e307;
+#endif
+
+#ifdef __STDC__
+ double __ieee754_sinh(double x)
+#else
+ double __ieee754_sinh(x)
+ double x;
+#endif
+{
+ double t,w,h;
+ int ix,jx;
+ unsigned lx;
+
+ /* High word of |x|. */
+ jx = __HI(x);
+ ix = jx&0x7fffffff;
+
+ /* x is INF or NaN */
+ if(ix>=0x7ff00000) return x+x;
+
+ h = 0.5;
+ if (jx<0) h = -h;
+ /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */
+ if (ix < 0x40360000) { /* |x|<22 */
+ if (ix<0x3e300000) /* |x|<2**-28 */
+ if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */
+ t = expm1(fabs(x));
+ if(ix<0x3ff00000) return h*(2.0*t-t*t/(t+one));
+ return h*(t+t/(t+one));
+ }
+
+ /* |x| in [22, log(maxdouble)] return 0.5*exp(|x|) */
+ if (ix < 0x40862E42) return h*__ieee754_exp(fabs(x));
+
+ /* |x| in [log(maxdouble), overflowthresold] */
+ lx = *( (((*(unsigned*)&one)>>29)) + (unsigned*)&x);
+ if (ix<0x408633CE || (ix==0x408633ce)&&(lx<=(unsigned)0x8fb9f87d)) {
+ w = __ieee754_exp(0.5*fabs(x));
+ t = h*w;
+ return t*w;
+ }
+
+ /* |x| > overflowthresold, sinh(x) overflow */
+ return x*shuge;
+}
diff --git a/native/fdlibm/e_sqrt.c b/native/fdlibm/e_sqrt.c
index 1d566a084..ba49f649b 100644
--- a/native/fdlibm/e_sqrt.c
+++ b/native/fdlibm/e_sqrt.c
@@ -1,12 +1,11 @@
-
-/* @(#)e_sqrt.c 5.1 93/09/24 */
+/* @(#)e_sqrt.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
@@ -16,10 +15,10 @@
* ------------------------------------------
* | Use the hardware sqrt if you have one |
* ------------------------------------------
- * Method:
- * Bit by bit method using integer arithmetic. (Slow, but portable)
+ * Method:
+ * Bit by bit method using integer arithmetic. (Slow, but portable)
* 1. Normalization
- * Scale x to y in [1,4) with even powers of 2:
+ * Scale x to y in [1,4) with even powers of 2:
* find an integer k such that 1 <= (y=x*2^(2k)) < 4, then
* sqrt(x) = 2^k * sqrt(y)
* 2. Bit by bit computation
@@ -28,9 +27,9 @@
* i+1 2
* s = 2*q , and y = 2 * ( y - q ). (1)
* i i i i
- *
- * To compute q from q , one checks whether
- * i+1 i
+ *
+ * To compute q from q , one checks whether
+ * i+1 i
*
* -(i+1) 2
* (q + 2 ) <= y. (2)
@@ -40,12 +39,12 @@
* i+1 i i+1 i
*
* With some algebric manipulation, it is not difficult to see
- * that (2) is equivalent to
+ * that (2) is equivalent to
* -(i+1)
* s + 2 <= y (3)
* i i
*
- * The advantage of (3) is that s and y can be computed by
+ * The advantage of (3) is that s and y can be computed by
* i i
* the following recurrence formula:
* if (3) is false
@@ -57,10 +56,10 @@
* -i -(i+1)
* s = s + 2 , y = y - s - 2 (5)
* i+1 i i+1 i i
- *
- * One may easily use induction to prove (4) and (5).
+ *
+ * One may easily use induction to prove (4) and (5).
* Note. Since the left hand side of (3) contain only i+2 bits,
- * it does not necessary to do a full (53-bit) comparison
+ * it does not necessary to do a full (53-bit) comparison
* in (3).
* 3. Final rounding
* After generating the 53 bits result, we compute one more bit.
@@ -70,7 +69,7 @@
* The rounding mode can be detected by checking whether
* huge + tiny is equal to huge, and whether huge - tiny is
* equal to huge for some floating point number "huge" and "tiny".
- *
+ *
* Special cases:
* sqrt(+-0) = +-0 ... exact
* sqrt(inf) = inf
@@ -83,8 +82,6 @@
#include "fdlibm.h"
-#ifndef _DOUBLE_IS_32BITS
-
#ifdef __STDC__
static const double one = 1.0, tiny=1.0e-300;
#else
@@ -99,17 +96,18 @@ static double one = 1.0, tiny=1.0e-300;
#endif
{
double z;
- int32_t sign = (int)0x80000000;
- uint32_t r,t1,s1,ix1,q1;
- int32_t ix0,s0,q,m,t,i;
+ int sign = (int)0x80000000;
+ unsigned r,t1,s1,ix1,q1;
+ int ix0,s0,q,m,t,i;
- EXTRACT_WORDS(ix0,ix1,x);
+ ix0 = __HI(x); /* high word of x */
+ ix1 = __LO(x); /* low word of x */
/* take care of Inf and NaN */
- if((ix0&0x7ff00000)==0x7ff00000) {
+ if((ix0&0x7ff00000)==0x7ff00000) {
return x*x+x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf
sqrt(-inf)=sNaN */
- }
+ }
/* take care of zero */
if(ix0<=0) {
if(((ix0&(~sign))|ix1)==0) return x;/* sqrt(+-0) = +-0 */
@@ -143,12 +141,12 @@ static double one = 1.0, tiny=1.0e-300;
r = 0x00200000; /* r = moving bit from right to left */
while(r!=0) {
- t = s0+r;
- if(t<=ix0) {
- s0 = t+r;
- ix0 -= t;
- q += r;
- }
+ t = s0+r;
+ if(t<=ix0) {
+ s0 = t+r;
+ ix0 -= t;
+ q += r;
+ }
ix0 += ix0 + ((ix1&sign)>>31);
ix1 += ix1;
r>>=1;
@@ -156,11 +154,11 @@ static double one = 1.0, tiny=1.0e-300;
r = sign;
while(r!=0) {
- t1 = s1+r;
+ t1 = s1+r;
t = s0;
- if((t<ix0)||((t==ix0)&&(t1<=ix1))) {
+ if((t<ix0)||((t==ix0)&&(t1<=ix1))) {
s1 = t1+r;
- if(((t1&sign)==(uint32_t)sign)&&(s1&sign)==0) s0 += 1;
+ if(((t1&sign)==sign)&&(s1&sign)==0) s0 += 1;
ix0 -= t;
if (ix1 < t1) ix0 -= 1;
ix1 -= t1;
@@ -176,10 +174,10 @@ static double one = 1.0, tiny=1.0e-300;
z = one-tiny; /* trigger inexact flag */
if (z>=one) {
z = one+tiny;
- if (q1==(uint32_t)0xffffffff) { q1=0; q += 1;}
+ if (q1==(unsigned)0xffffffff) { q1=0; q += 1;}
else if (z>one) {
- if (q1==(uint32_t)0xfffffffe) q+=1;
- q1+=2;
+ if (q1==(unsigned)0xfffffffe) q+=1;
+ q1+=2;
} else
q1 += (q1&1);
}
@@ -188,27 +186,26 @@ static double one = 1.0, tiny=1.0e-300;
ix1 = q1>>1;
if ((q&1)==1) ix1 |= sign;
ix0 += (m <<20);
- INSERT_WORDS(z,ix0,ix1);
+ __HI(z) = ix0;
+ __LO(z) = ix1;
return z;
}
-#endif /* defined(_DOUBLE_IS_32BITS) */
-
/*
Other methods (use floating-point arithmetic)
-------------
-(This is a copy of a drafted paper by Prof W. Kahan
+(This is a copy of a drafted paper by Prof W. Kahan
and K.C. Ng, written in May, 1986)
- Two algorithms are given here to implement sqrt(x)
+ Two algorithms are given here to implement sqrt(x)
(IEEE double precision arithmetic) in software.
Both supply sqrt(x) correctly rounded. The first algorithm (in
Section A) uses newton iterations and involves four divisions.
The second one uses reciproot iterations to avoid division, but
requires more multiplications. Both algorithms need the ability
- to chop results of arithmetic operations instead of round them,
+ to chop results of arithmetic operations instead of round them,
and the INEXACT flag to indicate when an arithmetic operation
- is executed exactly with no roundoff error, all part of the
+ is executed exactly with no roundoff error, all part of the
standard (IEEE 754-1985). The ability to perform shift, add,
subtract and logical AND operations upon 32-bit words is needed
too, though not part of the standard.
@@ -218,7 +215,7 @@ A. sqrt(x) by Newton Iteration
(1) Initial approximation
Let x0 and x1 be the leading and the trailing 32-bit words of
- a floating point number x (in IEEE double format) respectively
+ a floating point number x (in IEEE double format) respectively
1 11 52 ...widths
------------------------------------------------------
@@ -226,7 +223,7 @@ A. sqrt(x) by Newton Iteration
------------------------------------------------------
msb lsb msb lsb ...order
-
+
------------------------ ------------------------
x0: |s| e | f1 | x1: | f2 |
------------------------ ------------------------
@@ -251,7 +248,7 @@ A. sqrt(x) by Newton Iteration
(2) Iterative refinement
- Apply Heron's rule three times to y, we have y approximates
+ Apply Heron's rule three times to y, we have y approximates
sqrt(x) to within 1 ulp (Unit in the Last Place):
y := (y+x/y)/2 ... almost 17 sig. bits
@@ -276,12 +273,12 @@ A. sqrt(x) by Newton Iteration
it requires more multiplications and additions. Also x must be
scaled in advance to avoid spurious overflow in evaluating the
expression 3y*y+x. Hence it is not recommended uless division
- is slow. If division is very slow, then one should use the
+ is slow. If division is very slow, then one should use the
reciproot algorithm given in section B.
(3) Final adjustment
- By twiddling y's last bit it is possible to force y to be
+ By twiddling y's last bit it is possible to force y to be
correctly rounded according to the prevailing rounding mode
as follows. Let r and i be copies of the rounding mode and
inexact flag before entering the square root program. Also we
@@ -312,7 +309,7 @@ A. sqrt(x) by Newton Iteration
I := i; ... restore inexact flag
R := r; ... restore rounded mode
return sqrt(x):=y.
-
+
(4) Special cases
Square root of +inf, +-0, or NaN is itself;
@@ -331,7 +328,7 @@ B. sqrt(x) by Reciproot Iteration
k := 0x5fe80000 - (x0>>1);
y0:= k - T2[63&(k>>14)]. ... y ~ 1/sqrt(x) to 7.8 bits
- Here k is a 32-bit integer and T2[] is an integer array
+ Here k is a 32-bit integer and T2[] is an integer array
containing correction terms. Now magically the floating
value of y (y's leading 32-bit word is y0, the value of
its trailing word y1 is set to zero) approximates 1/sqrt(x)
@@ -352,9 +349,9 @@ B. sqrt(x) by Reciproot Iteration
Apply Reciproot iteration three times to y and multiply the
result by x to get an approximation z that matches sqrt(x)
- to about 1 ulp. To be exact, we will have
+ to about 1 ulp. To be exact, we will have
-1ulp < sqrt(x)-z<1.0625ulp.
-
+
... set rounding mode to Round-to-nearest
y := y*(1.5-0.5*x*y*y) ... almost 15 sig. bits to 1/sqrt(x)
y := y*((1.5-2^-30)+0.5*x*y*y)... about 29 sig. bits to 1/sqrt(x)
@@ -363,14 +360,14 @@ B. sqrt(x) by Reciproot Iteration
z := z + 0.5*z*(1-z*y) ... about 1 ulp to sqrt(x)
Remark 2. The constant 1.5-2^-30 is chosen to bias the error so that
- (a) the term z*y in the final iteration is always less than 1;
+ (a) the term z*y in the final iteration is always less than 1;
(b) the error in the final result is biased upward so that
-1 ulp < sqrt(x) - z < 1.0625 ulp
instead of |sqrt(x)-z|<1.03125ulp.
(3) Final adjustment
- By twiddling y's last bit it is possible to force y to be
+ By twiddling y's last bit it is possible to force y to be
correctly rounded according to the prevailing rounding mode
as follows. Let r and i be copies of the rounding mode and
inexact flag before entering the square root program. Also we
@@ -410,27 +407,27 @@ B. sqrt(x) by Reciproot Iteration
I := 1; ... Raise Inexact flag: z is not exact
else {
j := 1 - [(x0>>20)&1] ... j = logb(x) mod 2
- k := z1 >> 26; ... get z's 25-th and 26-th
+ k := z1 >> 26; ... get z's 25-th and 26-th
fraction bits
I := i or (k&j) or ((k&(j+j+1))!=(x1&3));
}
R:= r ... restore rounded mode
return sqrt(x):=z.
- If multiplication is cheaper then the foregoing red tape, the
+ If multiplication is cheaper then the foregoing red tape, the
Inexact flag can be evaluated by
I := i;
I := (z*z!=x) or I.
- Note that z*z can overwrite I; this value must be sensed if it is
+ Note that z*z can overwrite I; this value must be sensed if it is
True.
Remark 4. If z*z = x exactly, then bit 25 to bit 0 of z1 must be
zero.
--------------------
- z1: | f2 |
+ z1: | f2 |
--------------------
bit 31 bit 0
@@ -447,6 +444,7 @@ B. sqrt(x) by Reciproot Iteration
11 01 even
-------------------------------------------------
- (4) Special cases (see (4) of Section A).
-
+ (4) Special cases (see (4) of Section A).
+
*/
+
diff --git a/native/fdlibm/fdlibm.h b/native/fdlibm/fdlibm.h
index 13ee449d7..881917e10 100644
--- a/native/fdlibm/fdlibm.h
+++ b/native/fdlibm/fdlibm.h
@@ -1,10 +1,9 @@
-/* @(#)fdlibm.h 5.1 93/09/24 */
+/* @(#)fdlibm.h 1.5 04/04/22 */
/*
* ====================================================
- * Copyright (C) 1993, 2000 by Sun Microsystems, Inc. All rights reserved.
+ * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
@@ -36,15 +35,69 @@
#undef __P
#endif
+/* Sometimes it's necessary to define __LITTLE_ENDIAN explicitly
+ but these catch some common cases. */
+
+#if defined(i386) || defined(i486) || \
+ defined(intel) || defined(x86) || defined(i86pc) || \
+ defined(__alpha) || defined(__osf__)
+#define __LITTLE_ENDIAN
+#endif
+
+#ifdef __LITTLE_ENDIAN
+#define __HI(x) *(1+(int*)&x)
+#define __LO(x) *(int*)&x
+#define __HIp(x) *(1+(int*)x)
+#define __LOp(x) *(int*)x
+#else
+#define __HI(x) *(int*)&x
+#define __LO(x) *(1+(int*)&x)
+#define __HIp(x) *(int*)x
+#define __LOp(x) *(1+(int*)x)
+#endif
+
#ifdef __STDC__
#define __P(p) p
#else
#define __P(p) ()
#endif
-#ifndef HUGE
-#define HUGE ((float)3.40282346638528860e+38)
-#endif
+/*
+ * ANSI/POSIX
+ */
+
+extern int signgam;
+
+#define MAXFLOAT ((float)3.40282346638528860e+38)
+
+enum fdversion {fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix};
+
+#define _LIB_VERSION_TYPE enum fdversion
+#define _LIB_VERSION _fdlib_version
+
+/* if global variable _LIB_VERSION is not desirable, one may
+ * change the following to be a constant by:
+ * #define _LIB_VERSION_TYPE const enum version
+ * In that case, after one initializes the value _LIB_VERSION (see
+ * s_lib_version.c) during compile time, it cannot be modified
+ * in the middle of a program
+ */
+extern _LIB_VERSION_TYPE _LIB_VERSION;
+
+#define _IEEE_ fdlibm_ieee
+#define _SVID_ fdlibm_svid
+#define _XOPEN_ fdlibm_xopen
+#define _POSIX_ fdlibm_posix
+
+struct exception {
+ int type;
+ char *name;
+ double arg1;
+ double arg2;
+ double retval;
+};
+
+#define HUGE MAXFLOAT
/*
* set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
@@ -53,6 +106,13 @@
#define X_TLOSS 1.41484755040568800000e+16
+#define DOMAIN 1
+#define SING 2
+#define OVERFLOW 3
+#define UNDERFLOW 4
+#define TLOSS 5
+#define PLOSS 6
+
/* These typedefs are true for the targets running Java. */
#define _IEEE_LIBM
@@ -95,11 +155,7 @@ extern double erf __P((double));
extern double erfc __P((double));
extern double gamma __P((double));
extern double hypot __P((double, double));
-
-#if !defined(isnan) && !defined(HAVE_ISNAN)
-#define isnan(x) ((x) != (x))
-#endif
-
+extern int isnan __P((double));
extern int finite __P((double));
extern double j0 __P((double));
extern double j1 __P((double));
@@ -116,17 +172,42 @@ extern double cbrt __P((double));
extern double logb __P((double));
extern double nextafter __P((double, double));
extern double remainder __P((double, double));
-
-/* Functions that are not documented, and are not in <math.h>. */
-
-extern double logb __P((double));
#ifdef _SCALB_INT
extern double scalb __P((double, int));
#else
extern double scalb __P((double, double));
#endif
+
+extern int matherr __P((struct exception *));
+
+/*
+ * IEEE Test Vector
+ */
extern double significand __P((double));
+/*
+ * Functions callable from C, intended to support IEEE arithmetic.
+ */
+extern double copysign __P((double, double));
+extern int ilogb __P((double));
+extern double rint __P((double));
+extern double scalbn __P((double, int));
+
+/*
+ * BSD math library entry points
+ */
+extern double expm1 __P((double));
+extern double log1p __P((double));
+
+/*
+ * Reentrant version of gamma & lgamma; passes signgam back by reference
+ * as the second argument; user must allocate space for signgam.
+ */
+#ifdef _REENTRANT
+extern double gamma_r __P((double, int *));
+extern double lgamma_r __P((double, int *));
+#endif /* _REENTRANT */
+
/* ieee style elementary functions */
extern double __ieee754_sqrt __P((double));
extern double __ieee754_acos __P((double));
@@ -141,6 +222,8 @@ extern double __ieee754_fmod __P((double,double));
extern double __ieee754_pow __P((double,double));
extern double __ieee754_lgamma_r __P((double,int *));
extern double __ieee754_gamma_r __P((double,int *));
+extern double __ieee754_lgamma __P((double));
+extern double __ieee754_gamma __P((double));
extern double __ieee754_log10 __P((double));
extern double __ieee754_sinh __P((double));
extern double __ieee754_hypot __P((double,double));
@@ -151,7 +234,7 @@ extern double __ieee754_y1 __P((double));
extern double __ieee754_jn __P((int,double));
extern double __ieee754_yn __P((int,double));
extern double __ieee754_remainder __P((double,double));
-extern int32_t __ieee754_rem_pio2 __P((double,double*));
+extern int __ieee754_rem_pio2 __P((double,double*));
#ifdef _SCALB_INT
extern double __ieee754_scalb __P((double,int));
#else
@@ -159,172 +242,11 @@ extern double __ieee754_scalb __P((double,double));
#endif
/* fdlibm kernel function */
-extern double __kernel_standard __P((double,double,int));
+extern double __kernel_standard __P((double,double,int));
extern double __kernel_sin __P((double,double,int));
extern double __kernel_cos __P((double,double));
extern double __kernel_tan __P((double,double,int));
-extern int __kernel_rem_pio2 __P((double*,double*,int,int,int,const int32_t*));
-
-/* Undocumented float functions. */
-extern float logbf __P((float));
-#ifdef _SCALB_INT
-extern float scalbf __P((float, int));
-#else
-extern float scalbf __P((float, float));
-#endif
-extern float significandf __P((float));
-
-/*
- * Functions callable from C, intended to support IEEE arithmetic.
- */
-extern double copysign __P((double, double));
-extern int ilogb __P((double));
-extern double rint __P((double));
-extern float rintf __P((float));
-extern double scalbn __P((double, int));
-
-/* ieee style elementary float functions */
-extern float __ieee754_sqrtf __P((float));
-extern float __ieee754_acosf __P((float));
-extern float __ieee754_acoshf __P((float));
-extern float __ieee754_logf __P((float));
-extern float __ieee754_atanhf __P((float));
-extern float __ieee754_asinf __P((float));
-extern float __ieee754_atan2f __P((float,float));
-extern float __ieee754_expf __P((float));
-extern float __ieee754_coshf __P((float));
-extern float __ieee754_fmodf __P((float,float));
-extern float __ieee754_powf __P((float,float));
-extern float __ieee754_lgammaf_r __P((float,int *));
-extern float __ieee754_gammaf_r __P((float,int *));
-extern float __ieee754_log10f __P((float));
-extern float __ieee754_sinhf __P((float));
-extern float __ieee754_hypotf __P((float,float));
-extern float __ieee754_j0f __P((float));
-extern float __ieee754_j1f __P((float));
-extern float __ieee754_y0f __P((float));
-extern float __ieee754_y1f __P((float));
-extern float __ieee754_jnf __P((int,float));
-extern float __ieee754_ynf __P((int,float));
-extern float __ieee754_remainderf __P((float,float));
-extern int32_t __ieee754_rem_pio2f __P((float,float*));
-#ifdef _SCALB_INT
-extern float __ieee754_scalbf __P((float,int));
-#else
-extern float __ieee754_scalbf __P((float,float));
-#endif
-
-/* float versions of fdlibm kernel functions */
-extern float __kernel_sinf __P((float,float,int));
-extern float __kernel_cosf __P((float,float));
-extern float __kernel_tanf __P((float,float,int));
-extern int __kernel_rem_pio2f __P((float*,float*,int,int,int,const int32_t*));
-
-/* The original code used statements like
- n0 = ((*(int*)&one)>>29)^1; * index of high word *
- ix0 = *(n0+(int*)&x); * high word of x *
- ix1 = *((1-n0)+(int*)&x); * low word of x *
- to dig two 32 bit words out of the 64 bit IEEE floating point
- value. That is non-ANSI, and, moreover, the gcc instruction
- scheduler gets it wrong. We instead use the following macros.
- Unlike the original code, we determine the endianness at compile
- time, not at run time; I don't see much benefit to selecting
- endianness at run time. */
-
-#ifndef __IEEE_BIG_ENDIAN
-#ifndef __IEEE_LITTLE_ENDIAN
- #error Must define endianness
-#endif
-#endif
-
-/* A union which permits us to convert between a double and two 32 bit
- ints. */
-
-#ifdef __IEEE_BIG_ENDIAN
-
-typedef union
-{
- double value;
- struct
- {
- uint32_t msw;
- uint32_t lsw;
- } parts;
-} ieee_double_shape_type;
-
-#endif
-
-#ifdef __IEEE_LITTLE_ENDIAN
-
-typedef union
-{
- double value;
- struct
- {
- uint32_t lsw;
- uint32_t msw;
- } parts;
-} ieee_double_shape_type;
-
-#endif
-
-/* Get two 32 bit ints from a double. */
-
-#define EXTRACT_WORDS(ix0,ix1,d) \
-do { \
- ieee_double_shape_type ew_u; \
- ew_u.value = (d); \
- (ix0) = ew_u.parts.msw; \
- (ix1) = ew_u.parts.lsw; \
-} while (0)
-
-/* Get the more significant 32 bit int from a double. */
-
-#define GET_HIGH_WORD(i,d) \
-do { \
- ieee_double_shape_type gh_u; \
- gh_u.value = (d); \
- (i) = gh_u.parts.msw; \
-} while (0)
-
-/* Get the less significant 32 bit int from a double. */
-
-#define GET_LOW_WORD(i,d) \
-do { \
- ieee_double_shape_type gl_u; \
- gl_u.value = (d); \
- (i) = gl_u.parts.lsw; \
-} while (0)
-
-/* Set a double from two 32 bit ints. */
-
-#define INSERT_WORDS(d,ix0,ix1) \
-do { \
- ieee_double_shape_type iw_u; \
- iw_u.parts.msw = (ix0); \
- iw_u.parts.lsw = (ix1); \
- (d) = iw_u.value; \
-} while (0)
-
-/* Set the more significant 32 bits of a double from an int. */
-
-#define SET_HIGH_WORD(d,v) \
-do { \
- ieee_double_shape_type sh_u; \
- sh_u.value = (d); \
- sh_u.parts.msw = (v); \
- (d) = sh_u.value; \
-} while (0)
-
-/* Set the less significant 32 bits of a double from an int. */
-
-#define SET_LOW_WORD(d,v) \
-do { \
- ieee_double_shape_type sl_u; \
- sl_u.value = (d); \
- sl_u.parts.lsw = (v); \
- (d) = sl_u.value; \
-} while (0)
+extern int __kernel_rem_pio2 __P((double*,double*,int,int,int,const int*));
/* A union which permits us to convert between a float and a 32 bit
int. */
@@ -358,3 +280,4 @@ do { \
#endif
#endif /* __CLASSPATH_FDLIBM_H__ */
+
diff --git a/native/fdlibm/k_cos.c b/native/fdlibm/k_cos.c
index acf50a82e..ab745a3db 100644
--- a/native/fdlibm/k_cos.c
+++ b/native/fdlibm/k_cos.c
@@ -1,12 +1,12 @@
-/* @(#)k_cos.c 5.1 93/09/24 */
+/* @(#)k_cos.c 1.4 96/03/07 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
@@ -15,7 +15,7 @@
* __kernel_cos( x, y )
* kernel cos function on [-pi/4, pi/4], pi/4 ~ 0.785398164
* Input x is assumed to be bounded by ~pi/4 in magnitude.
- * Input y is the tail of x.
+ * Input y is the tail of x.
*
* Algorithm
* 1. Since cos(-x) = cos(x), we need only to consider positive x.
@@ -24,16 +24,16 @@
* [0,pi/4]
* 4 14
* cos(x) ~ 1 - x*x/2 + C1*x + ... + C6*x
- * where the remez error is
- *
+ * where the Remes error is
+ *
* | 2 4 6 8 10 12 14 | -58
* |cos(x)-(1-.5*x +C1*x +C2*x +C3*x +C4*x +C5*x +C6*x )| <= 2
- * | |
- *
- * 4 6 8 10 12 14
+ * | |
+ *
+ * 4 6 8 10 12 14
* 4. let r = C1*x +C2*x +C3*x +C4*x +C5*x +C6*x , then
* cos(x) = 1 - x*x/2 + r
- * since cos(x+y) ~ cos(x) - sin(x)*y
+ * since cos(x+y) ~ cos(x) - sin(x)*y
* ~ cos(x) - x*y,
* a correction term is necessary in cos(x) and hence
* cos(x+y) = 1 - (x*x/2 - (r - x*y))
@@ -48,12 +48,10 @@
#include "fdlibm.h"
-#ifndef _DOUBLE_IS_32BITS
-
#ifdef __STDC__
-static const double
+static const double
#else
-static double
+static double
#endif
one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
C1 = 4.16666666666666019037e-02, /* 0x3FA55555, 0x5555554C */
@@ -71,26 +69,24 @@ C6 = -1.13596475577881948265e-11; /* 0xBDA8FAE9, 0xBE8838D4 */
#endif
{
double a,hz,z,r,qx;
- int32_t ix;
- GET_HIGH_WORD(ix,x);
- ix &= 0x7fffffff; /* ix = |x|'s high word*/
+ int ix;
+ ix = __HI(x)&0x7fffffff; /* ix = |x|'s high word*/
if(ix<0x3e400000) { /* if x < 2**27 */
if(((int)x)==0) return one; /* generate inexact */
}
z = x*x;
r = z*(C1+z*(C2+z*(C3+z*(C4+z*(C5+z*C6)))));
- if(ix < 0x3FD33333) /* if |x| < 0.3 */
+ if(ix < 0x3FD33333) /* if |x| < 0.3 */
return one - (0.5*z - (z*r - x*y));
else {
if(ix > 0x3fe90000) { /* x > 0.78125 */
qx = 0.28125;
} else {
- INSERT_WORDS(qx,ix-0x00200000,0); /* x/4 */
+ __HI(qx) = ix-0x00200000; /* x/4 */
+ __LO(qx) = 0;
}
hz = 0.5*z-qx;
a = one-qx;
return a - (hz - (z*r-x*y));
}
}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/native/fdlibm/k_rem_pio2.c b/native/fdlibm/k_rem_pio2.c
index 2f4ca1725..ec473ac0d 100644
--- a/native/fdlibm/k_rem_pio2.c
+++ b/native/fdlibm/k_rem_pio2.c
@@ -1,12 +1,12 @@
-/* @(#)k_rem_pio2.c 5.1 93/09/24 */
+/* @(#)k_rem_pio2.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
@@ -14,12 +14,12 @@
/*
* __kernel_rem_pio2(x,y,e0,nx,prec,ipio2)
* double x[],y[]; int e0,nx,prec; int ipio2[];
- *
- * __kernel_rem_pio2 return the last three digits of N with
+ *
+ * __kernel_rem_pio2 return the last three digits of N with
* y = x - N*pi/2
* so that |y| < pi/2.
*
- * The method is to compute the integer (mod 8) and fraction parts of
+ * The method is to compute the integer (mod 8) and fraction parts of
* (2/pi)*x without doing the full multiplication. In general we
* skip the part of the product that are known to be a huge integer (
* more accurately, = 0 mod 8 ). Thus the number of operations are
@@ -28,10 +28,10 @@
* (2/pi) is represented by an array of 24-bit integers in ipio2[].
*
* Input parameters:
- * x[] The input value (must be positive) is broken into nx
+ * x[] The input value (must be positive) is broken into nx
* pieces of 24-bit integers in double precision format.
- * x[i] will be the i-th 24 bit of x. The scaled exponent
- * of x[0] is given in input parameter e0 (i.e., x[0]*2^e0
+ * x[i] will be the i-th 24 bit of x. The scaled exponent
+ * of x[0] is given in input parameter e0 (i.e., x[0]*2^e0
* match x's up to 24 bits.
*
* Example of breaking a double positive z into x[0]+x[1]+x[2]:
@@ -68,8 +68,8 @@
* 3 113 bits (quad)
*
* ipio2[]
- * integer array, contains the (24*i)-th to (24*i+23)-th
- * bit of 2/pi after binary point. The corresponding
+ * integer array, contains the (24*i)-th to (24*i+23)-th
+ * bit of 2/pi after binary point. The corresponding
* floating value is
*
* ipio2[i] * 2^(-24(i+1)).
@@ -84,8 +84,8 @@
* in the computation. The recommended value is 2,3,4,
* 6 for single, double, extended,and quad.
*
- * jz local integer variable indicating the number of
- * terms of ipio2[] used.
+ * jz local integer variable indicating the number of
+ * terms of ipio2[] used.
*
* jx nx - 1
*
@@ -105,9 +105,9 @@
* exponent for q[i] would be q0-24*i.
*
* PIo2[] double precision array, obtained by cutting pi/2
- * into 24 bits chunks.
+ * into 24 bits chunks.
*
- * f[] ipio2[] in floating point
+ * f[] ipio2[] in floating point
*
* iq[] integer array by breaking up q[] in 24-bits chunk.
*
@@ -121,20 +121,18 @@
/*
* Constants:
- * The hexadecimal values are the intended ones for the following
- * constants. The decimal values may be used, provided that the
- * compiler will convert from decimal to binary accurately enough
+ * The hexadecimal values are the intended ones for the following
+ * constants. The decimal values may be used, provided that the
+ * compiler will convert from decimal to binary accurately enough
* to produce the hexadecimal values shown.
*/
#include "fdlibm.h"
-#ifndef _DOUBLE_IS_32BITS
-
#ifdef __STDC__
static const int init_jk[] = {2,3,4,6}; /* initial value for jk */
#else
-static int init_jk[] = {2,3,4,6};
+static int init_jk[] = {2,3,4,6};
#endif
#ifdef __STDC__
@@ -153,9 +151,9 @@ static double PIo2[] = {
};
#ifdef __STDC__
-static const double
+static const double
#else
-static double
+static double
#endif
zero = 0.0,
one = 1.0,
@@ -163,13 +161,13 @@ two24 = 1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */
twon24 = 5.96046447753906250000e-08; /* 0x3E700000, 0x00000000 */
#ifdef __STDC__
- int __kernel_rem_pio2(double *x, double *y, int e0, int nx, int prec, const int32_t *ipio2)
+ int __kernel_rem_pio2(double *x, double *y, int e0, int nx, int prec, const int *ipio2)
#else
- int __kernel_rem_pio2(x,y,e0,nx,prec,ipio2)
- double x[], y[]; int e0,nx,prec; int32_t ipio2[];
+ int __kernel_rem_pio2(x,y,e0,nx,prec,ipio2)
+ double x[], y[]; int e0,nx,prec; int ipio2[];
#endif
{
- int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih;
+ int jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih;
double z,fw,f[20],fq[20],q[20];
/* initialize jk*/
@@ -194,22 +192,22 @@ twon24 = 5.96046447753906250000e-08; /* 0x3E700000, 0x00000000 */
recompute:
/* distill q[] into iq[] reversingly */
for(i=0,j=jz,z=q[jz];j>0;i++,j--) {
- fw = (double)((int32_t)(twon24* z));
- iq[i] = (int32_t)(z-two24*fw);
+ fw = (double)((int)(twon24* z));
+ iq[i] = (int)(z-two24*fw);
z = q[j-1]+fw;
}
/* compute n */
- z = scalbn(z,(int)q0); /* actual value of z */
+ z = scalbn(z,q0); /* actual value of z */
z -= 8.0*floor(z*0.125); /* trim off integer >= 8 */
- n = (int32_t) z;
+ n = (int) z;
z -= (double)n;
ih = 0;
if(q0>0) { /* need iq[jz-1] to determine n */
i = (iq[jz-1]>>(24-q0)); n += i;
iq[jz-1] -= i<<(24-q0);
ih = iq[jz-1]>>(23-q0);
- }
+ }
else if(q0==0) ih = iq[jz-1]>>23;
else if(z>=0.5) ih=2;
@@ -233,7 +231,7 @@ recompute:
}
if(ih==2) {
z = one - z;
- if(carry!=0) z -= scalbn(one,(int)q0);
+ if(carry!=0) z -= scalbn(one,q0);
}
}
@@ -259,17 +257,17 @@ recompute:
jz -= 1; q0 -= 24;
while(iq[jz]==0) { jz--; q0-=24;}
} else { /* break z into 24-bit if necessary */
- z = scalbn(z,-(int)q0);
- if(z>=two24) {
- fw = (double)((int32_t)(twon24*z));
- iq[jz] = (int32_t)(z-two24*fw);
+ z = scalbn(z,-q0);
+ if(z>=two24) {
+ fw = (double)((int)(twon24*z));
+ iq[jz] = (int)(z-two24*fw);
jz += 1; q0 += 24;
- iq[jz] = (int32_t) fw;
- } else iq[jz] = (int32_t) z ;
+ iq[jz] = (int) fw;
+ } else iq[jz] = (int) z ;
}
/* convert integer "bit" chunk to floating-point value */
- fw = scalbn(one,(int)q0);
+ fw = scalbn(one,q0);
for(i=jz;i>=0;i--) {
q[i] = fw*(double)iq[i]; fw*=twon24;
}
@@ -285,29 +283,29 @@ recompute:
case 0:
fw = 0.0;
for (i=jz;i>=0;i--) fw += fq[i];
- y[0] = (ih==0)? fw: -fw;
+ y[0] = (ih==0)? fw: -fw;
break;
case 1:
case 2:
fw = 0.0;
- for (i=jz;i>=0;i--) fw += fq[i];
- y[0] = (ih==0)? fw: -fw;
+ for (i=jz;i>=0;i--) fw += fq[i];
+ y[0] = (ih==0)? fw: -fw;
fw = fq[0]-fw;
for (i=1;i<=jz;i++) fw += fq[i];
- y[1] = (ih==0)? fw: -fw;
+ y[1] = (ih==0)? fw: -fw;
break;
case 3: /* painful */
for (i=jz;i>0;i--) {
- fw = fq[i-1]+fq[i];
+ fw = fq[i-1]+fq[i];
fq[i] += fq[i-1]-fw;
fq[i-1] = fw;
}
for (i=jz;i>1;i--) {
- fw = fq[i-1]+fq[i];
+ fw = fq[i-1]+fq[i];
fq[i] += fq[i-1]-fw;
fq[i-1] = fw;
}
- for (fw=0.0,i=jz;i>=2;i--) fw += fq[i];
+ for (fw=0.0,i=jz;i>=2;i--) fw += fq[i];
if(ih==0) {
y[0] = fq[0]; y[1] = fq[1]; y[2] = fw;
} else {
@@ -316,5 +314,3 @@ recompute:
}
return n&7;
}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/native/fdlibm/k_sin.c b/native/fdlibm/k_sin.c
index b4ad387c5..dfcad764e 100644
--- a/native/fdlibm/k_sin.c
+++ b/native/fdlibm/k_sin.c
@@ -1,12 +1,12 @@
-/* @(#)k_sin.c 5.1 93/09/24 */
+/* @(#)k_sin.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
@@ -15,24 +15,24 @@
* kernel sin function on [-pi/4, pi/4], pi/4 ~ 0.7854
* Input x is assumed to be bounded by ~pi/4 in magnitude.
* Input y is the tail of x.
- * Input iy indicates whether y is 0. (if iy=0, y assume to be 0).
+ * Input iy indicates whether y is 0. (if iy=0, y assume to be 0).
*
* Algorithm
- * 1. Since sin(-x) = -sin(x), we need only to consider positive x.
+ * 1. Since sin(-x) = -sin(x), we need only to consider positive x.
* 2. if x < 2^-27 (hx<0x3e400000 0), return x with inexact if x!=0.
* 3. sin(x) is approximated by a polynomial of degree 13 on
* [0,pi/4]
* 3 13
* sin(x) ~ x + S1*x + ... + S6*x
* where
- *
+ *
* |sin(x) 2 4 6 8 10 12 | -58
* |----- - (1+S1*x +S2*x +S3*x +S4*x +S5*x +S6*x )| <= 2
- * | x |
- *
+ * | x |
+ *
* 4. sin(x+y) = sin(x) + sin'(x')*y
* ~ sin(x) + (1-x*x/2)*y
- * For better accuracy, let
+ * For better accuracy, let
* 3 2 2 2 2
* r = x *(S2+x *(S3+x *(S4+x *(S5+x *S6))))
* then 3 2
@@ -41,12 +41,10 @@
#include "fdlibm.h"
-#ifndef _DOUBLE_IS_32BITS
-
#ifdef __STDC__
-static const double
+static const double
#else
-static double
+static double
#endif
half = 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */
S1 = -1.66666666666666324348e-01, /* 0xBFC55555, 0x55555549 */
@@ -64,9 +62,8 @@ S6 = 1.58969099521155010221e-10; /* 0x3DE5D93A, 0x5ACFD57C */
#endif
{
double z,r,v;
- int32_t ix;
- GET_HIGH_WORD(ix,x);
- ix &= 0x7fffffff; /* high word of x */
+ int ix;
+ ix = __HI(x)&0x7fffffff; /* high word of x */
if(ix<0x3e400000) /* |x| < 2**-27 */
{if((int)x==0) return x;} /* generate inexact */
z = x*x;
@@ -75,5 +72,3 @@ S6 = 1.58969099521155010221e-10; /* 0x3DE5D93A, 0x5ACFD57C */
if(iy==0) return x+v*(S1+z*r);
else return x-((z*(half*y-v*r)-y)-v*S1);
}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/native/fdlibm/k_tan.c b/native/fdlibm/k_tan.c
index a1067a70a..017c1e57c 100644
--- a/native/fdlibm/k_tan.c
+++ b/native/fdlibm/k_tan.c
@@ -1,22 +1,21 @@
+#pragma ident "@(#)k_tan.c 1.5 04/04/22 SMI"
-/* @(#)k_tan.c 5.1 93/09/24 */
/*
* ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
+/* INDENT OFF */
/* __kernel_tan( x, y, k )
* kernel tan function on [-pi/4, pi/4], pi/4 ~ 0.7854
* Input x is assumed to be bounded by ~pi/4 in magnitude.
* Input y is the tail of x.
- * Input k indicates whether tan (if k=1) or
- * -1/tan (if k= -1) is returned.
+ * Input k indicates whether tan (if k = 1) or -1/tan (if k = -1) is returned.
*
* Algorithm
* 1. Since tan(-x) = -tan(x), we need only to consider positive x.
@@ -47,86 +46,103 @@
#include "fdlibm.h"
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
-static const double
-#else
-static double
-#endif
-one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
-pio4 = 7.85398163397448278999e-01, /* 0x3FE921FB, 0x54442D18 */
-pio4lo= 3.06161699786838301793e-17, /* 0x3C81A626, 0x33145C07 */
-T[] = {
- 3.33333333333334091986e-01, /* 0x3FD55555, 0x55555563 */
- 1.33333333333201242699e-01, /* 0x3FC11111, 0x1110FE7A */
- 5.39682539762260521377e-02, /* 0x3FABA1BA, 0x1BB341FE */
- 2.18694882948595424599e-02, /* 0x3F9664F4, 0x8406D637 */
- 8.86323982359930005737e-03, /* 0x3F8226E3, 0xE96E8493 */
- 3.59207910759131235356e-03, /* 0x3F6D6D22, 0xC9560328 */
- 1.45620945432529025516e-03, /* 0x3F57DBC8, 0xFEE08315 */
- 5.88041240820264096874e-04, /* 0x3F4344D8, 0xF2F26501 */
- 2.46463134818469906812e-04, /* 0x3F3026F7, 0x1A8D1068 */
- 7.81794442939557092300e-05, /* 0x3F147E88, 0xA03792A6 */
- 7.14072491382608190305e-05, /* 0x3F12B80F, 0x32F0A7E9 */
- -1.85586374855275456654e-05, /* 0xBEF375CB, 0xDB605373 */
- 2.59073051863633712884e-05, /* 0x3EFB2A70, 0x74BF7AD4 */
+static const double xxx[] = {
+ 3.33333333333334091986e-01, /* 3FD55555, 55555563 */
+ 1.33333333333201242699e-01, /* 3FC11111, 1110FE7A */
+ 5.39682539762260521377e-02, /* 3FABA1BA, 1BB341FE */
+ 2.18694882948595424599e-02, /* 3F9664F4, 8406D637 */
+ 8.86323982359930005737e-03, /* 3F8226E3, E96E8493 */
+ 3.59207910759131235356e-03, /* 3F6D6D22, C9560328 */
+ 1.45620945432529025516e-03, /* 3F57DBC8, FEE08315 */
+ 5.88041240820264096874e-04, /* 3F4344D8, F2F26501 */
+ 2.46463134818469906812e-04, /* 3F3026F7, 1A8D1068 */
+ 7.81794442939557092300e-05, /* 3F147E88, A03792A6 */
+ 7.14072491382608190305e-05, /* 3F12B80F, 32F0A7E9 */
+ -1.85586374855275456654e-05, /* BEF375CB, DB605373 */
+ 2.59073051863633712884e-05, /* 3EFB2A70, 74BF7AD4 */
+/* one */ 1.00000000000000000000e+00, /* 3FF00000, 00000000 */
+/* pio4 */ 7.85398163397448278999e-01, /* 3FE921FB, 54442D18 */
+/* pio4lo */ 3.06161699786838301793e-17 /* 3C81A626, 33145C07 */
};
+#define one xxx[13]
+#define pio4 xxx[14]
+#define pio4lo xxx[15]
+#define T xxx
+/* INDENT ON */
+
+double
+__kernel_tan(double x, double y, int iy) {
+ double z, r, v, w, s;
+ int ix, hx;
+
+ hx = __HI(x); /* high word of x */
+ ix = hx & 0x7fffffff; /* high word of |x| */
+ if (ix < 0x3e300000) { /* x < 2**-28 */
+ if ((int) x == 0) { /* generate inexact */
+ if (((ix | __LO(x)) | (iy + 1)) == 0)
+ return one / fabs(x);
+ else {
+ if (iy == 1)
+ return x;
+ else { /* compute -1 / (x+y) carefully */
+ double a, t;
-#ifdef __STDC__
- double __kernel_tan(double x, double y, int iy)
-#else
- double __kernel_tan(x, y, iy)
- double x,y; int iy;
-#endif
-{
- double z,r,v,w,s;
- int32_t ix,hx;
- GET_HIGH_WORD(hx,x);
- ix = hx&0x7fffffff; /* high word of |x| */
- if(ix<0x3e300000) /* x < 2**-28 */
- {if((int)x==0) { /* generate inexact */
- uint32_t low;
- GET_LOW_WORD(low,x);
- if(((ix|low)|(iy+1))==0) return one/fabs(x);
- else return (iy==1)? x: -one/x;
- }
- }
- if(ix>=0x3FE59428) { /* |x|>=0.6744 */
- if(hx<0) {x = -x; y = -y;}
- z = pio4-x;
- w = pio4lo-y;
- x = z+w; y = 0.0;
+ z = w = x + y;
+ __LO(z) = 0;
+ v = y - (z - x);
+ t = a = -one / w;
+ __LO(t) = 0;
+ s = one + t * z;
+ return t + a * (s + t * v);
+ }
+ }
+ }
}
- z = x*x;
- w = z*z;
- /* Break x^5*(T[1]+x^2*T[2]+...) into
- * x^5(T[1]+x^4*T[3]+...+x^20*T[11]) +
- * x^5(x^2*(T[2]+x^4*T[4]+...+x^22*[T12]))
- */
- r = T[1]+w*(T[3]+w*(T[5]+w*(T[7]+w*(T[9]+w*T[11]))));
- v = z*(T[2]+w*(T[4]+w*(T[6]+w*(T[8]+w*(T[10]+w*T[12])))));
- s = z*x;
- r = y + z*(s*(r+v)+y);
- r += T[0]*s;
- w = x+r;
- if(ix>=0x3FE59428) {
- v = (double)iy;
- return (double)(1-((hx>>30)&2))*(v-2.0*(x-(w*w/(w+v)-r)));
+ if (ix >= 0x3FE59428) { /* |x| >= 0.6744 */
+ if (hx < 0) {
+ x = -x;
+ y = -y;
+ }
+ z = pio4 - x;
+ w = pio4lo - y;
+ x = z + w;
+ y = 0.0;
}
- if(iy==1) return w;
- else { /* if allow error up to 2 ulp,
- simply return -1.0/(x+r) here */
- /* compute -1.0/(x+r) accurately */
- double a,t;
- z = w;
- SET_LOW_WORD(z,0);
- v = r-(z - x); /* z+v = r+x */
- t = a = -1.0/w; /* a = -1.0/w */
- SET_LOW_WORD(t,0);
- s = 1.0+t*z;
- return t+a*(s+t*v);
+ z = x * x;
+ w = z * z;
+ /*
+ * Break x^5*(T[1]+x^2*T[2]+...) into
+ * x^5(T[1]+x^4*T[3]+...+x^20*T[11]) +
+ * x^5(x^2*(T[2]+x^4*T[4]+...+x^22*[T12]))
+ */
+ r = T[1] + w * (T[3] + w * (T[5] + w * (T[7] + w * (T[9] +
+ w * T[11]))));
+ v = z * (T[2] + w * (T[4] + w * (T[6] + w * (T[8] + w * (T[10] +
+ w * T[12])))));
+ s = z * x;
+ r = y + z * (s * (r + v) + y);
+ r += T[0] * s;
+ w = x + r;
+ if (ix >= 0x3FE59428) {
+ v = (double) iy;
+ return (double) (1 - ((hx >> 30) & 2)) *
+ (v - 2.0 * (x - (w * w / (w + v) - r)));
+ }
+ if (iy == 1)
+ return w;
+ else {
+ /*
+ * if allow error up to 2 ulp, simply return
+ * -1.0 / (x+r) here
+ */
+ /* compute -1.0 / (x+r) accurately */
+ double a, t;
+ z = w;
+ __LO(z) = 0;
+ v = r - (z - x); /* z+v = r+x */
+ t = a = -1.0 / w; /* a = -1.0/w */
+ __LO(t) = 0;
+ s = 1.0 + t * z;
+ return t + a * (s + t * v);
}
}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/native/fdlibm/namespace.h b/native/fdlibm/namespace.h
index f8bfde861..2e6e52bb5 100644
--- a/native/fdlibm/namespace.h
+++ b/native/fdlibm/namespace.h
@@ -8,10 +8,14 @@
#define tan ClasspathMath_tan
#define cosh ClasspathMath_cosh
#define sinh ClasspathMath_sinh
+#define tanh ClasspathMath_tanh
#define exp ClasspathMath_exp
#define frexp ClasspathMath_frexp
#define ldexp ClasspathMath_ldexp
+#define expm1 ClasspathMath_expm1
#define log ClasspathMath_log
+#define log10 ClasspathMath_log10
+#define log1p ClasspathMath_log1p
#define modf ClasspathMath_modf
#define pow ClasspathMath_pow
#define sqrt ClasspathMath_sqrt
diff --git a/native/fdlibm/s_atan.c b/native/fdlibm/s_atan.c
index 2ee745854..0093eafdf 100644
--- a/native/fdlibm/s_atan.c
+++ b/native/fdlibm/s_atan.c
@@ -1,58 +1,17 @@
-/* @(#)s_atan.c 5.1 93/09/24 */
+/* @(#)s_atan.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*
*/
-/*
-FUNCTION
- <<atan>>, <<atanf>>---arc tangent
-
-INDEX
- atan
-INDEX
- atanf
-
-ANSI_SYNOPSIS
- #include <math.h>
- double atan(double <[x]>);
- float atanf(float <[x]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double atan(<[x]>);
- double <[x]>;
-
- float atanf(<[x]>);
- float <[x]>;
-
-DESCRIPTION
-
-<<atan>> computes the inverse tangent (arc tangent) of the input value.
-
-<<atanf>> is identical to <<atan>>, save that it operates on <<floats>>.
-
-RETURNS
-@ifinfo
-<<atan>> returns a value in radians, in the range of -pi/2 to pi/2.
-@end ifinfo
-@tex
-<<atan>> returns a value in radians, in the range of $-\pi/2$ to $\pi/2$.
-@end tex
-
-PORTABILITY
-<<atan>> is ANSI C. <<atanf>> is an extension.
-
-*/
-
/* atan(x)
* Method
* 1. Reduce x to positive by atan(x) = -atan(-x).
@@ -67,16 +26,14 @@ PORTABILITY
* [39/16,INF] atan(x) = atan(INF) + atan( -1/t )
*
* Constants:
- * The hexadecimal values are the intended ones for the following
- * constants. The decimal values may be used, provided that the
- * compiler will convert from decimal to binary accurately enough
+ * The hexadecimal values are the intended ones for the following
+ * constants. The decimal values may be used, provided that the
+ * compiler will convert from decimal to binary accurately enough
* to produce the hexadecimal values shown.
*/
#include "fdlibm.h"
-#ifndef _DOUBLE_IS_32BITS
-
#ifdef __STDC__
static const double atanhi[] = {
#else
@@ -118,9 +75,9 @@ static double aT[] = {
};
#ifdef __STDC__
- static const double
+ static const double
#else
- static double
+ static double
#endif
one = 1.0,
huge = 1.0e300;
@@ -133,15 +90,13 @@ huge = 1.0e300;
#endif
{
double w,s1,s2,z;
- int32_t ix,hx,id;
+ int ix,hx,id;
- GET_HIGH_WORD(hx,x);
+ hx = __HI(x);
ix = hx&0x7fffffff;
if(ix>=0x44100000) { /* if |x| >= 2^66 */
- uint32_t low;
- GET_LOW_WORD(low,x);
if(ix>0x7ff00000||
- (ix==0x7ff00000&&(low!=0)))
+ (ix==0x7ff00000&&(__LO(x)!=0)))
return x+x; /* NaN */
if(hx>0) return atanhi[3]+atanlo[3];
else return -atanhi[3]-atanlo[3];
@@ -154,9 +109,9 @@ huge = 1.0e300;
x = fabs(x);
if (ix < 0x3ff30000) { /* |x| < 1.1875 */
if (ix < 0x3fe60000) { /* 7/16 <=|x|<11/16 */
- id = 0; x = (2.0*x-one)/(2.0+x);
+ id = 0; x = (2.0*x-one)/(2.0+x);
} else { /* 11/16<=|x|< 19/16 */
- id = 1; x = (x-one)/(x+one);
+ id = 1; x = (x-one)/(x+one);
}
} else {
if (ix < 0x40038000) { /* |x| < 2.4375 */
@@ -177,5 +132,3 @@ huge = 1.0e300;
return (hx<0)? -z:z;
}
}
-
-#endif /* _DOUBLE_IS_32BITS */
diff --git a/native/fdlibm/s_cbrt.c b/native/fdlibm/s_cbrt.c
new file mode 100644
index 000000000..734e01cf5
--- /dev/null
+++ b/native/fdlibm/s_cbrt.c
@@ -0,0 +1,87 @@
+
+/* @(#)s_cbrt.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ *
+ */
+
+#include "fdlibm.h"
+
+/* cbrt(x)
+ * Return cube root of x
+ */
+#ifdef __STDC__
+static const unsigned
+#else
+static unsigned
+#endif
+ B1 = 715094163, /* B1 = (682-0.03306235651)*2**20 */
+ B2 = 696219795; /* B2 = (664-0.03306235651)*2**20 */
+
+#ifdef __STDC__
+static const double
+#else
+static double
+#endif
+C = 5.42857142857142815906e-01, /* 19/35 = 0x3FE15F15, 0xF15F15F1 */
+D = -7.05306122448979611050e-01, /* -864/1225 = 0xBFE691DE, 0x2532C834 */
+E = 1.41428571428571436819e+00, /* 99/70 = 0x3FF6A0EA, 0x0EA0EA0F */
+F = 1.60714285714285720630e+00, /* 45/28 = 0x3FF9B6DB, 0x6DB6DB6E */
+G = 3.57142857142857150787e-01; /* 5/14 = 0x3FD6DB6D, 0xB6DB6DB7 */
+
+#ifdef __STDC__
+ double cbrt(double x)
+#else
+ double cbrt(x)
+ double x;
+#endif
+{
+ int hx;
+ double r,s,t=0.0,w;
+ unsigned sign;
+
+
+ hx = __HI(x); /* high word of x */
+ sign=hx&0x80000000; /* sign= sign(x) */
+ hx ^=sign;
+ if(hx>=0x7ff00000) return(x+x); /* cbrt(NaN,INF) is itself */
+ if((hx|__LO(x))==0)
+ return(x); /* cbrt(0) is itself */
+
+ __HI(x) = hx; /* x <- |x| */
+ /* rough cbrt to 5 bits */
+ if(hx<0x00100000) /* subnormal number */
+ {__HI(t)=0x43500000; /* set t= 2**54 */
+ t*=x; __HI(t)=__HI(t)/3+B2;
+ }
+ else
+ __HI(t)=hx/3+B1;
+
+
+ /* new cbrt to 23 bits, may be implemented in single precision */
+ r=t*t/x;
+ s=C+r*t;
+ t*=G+F/(s+E+D/s);
+
+ /* chopped to 20 bits and make it larger than cbrt(x) */
+ __LO(t)=0; __HI(t)+=0x00000001;
+
+
+ /* one step newton iteration to 53 bits with error less than 0.667 ulps */
+ s=t*t; /* t*t is exact */
+ r=x/s;
+ w=t+t;
+ r=(r-t)/(w+r); /* r-s is exact */
+ t=t+t*r;
+
+ /* retore the sign bit */
+ __HI(t) |= sign;
+ return(t);
+}
diff --git a/native/fdlibm/s_ceil.c b/native/fdlibm/s_ceil.c
index 250373b40..af74592ed 100644
--- a/native/fdlibm/s_ceil.c
+++ b/native/fdlibm/s_ceil.c
@@ -1,12 +1,12 @@
-/* @(#)s_ceil.c 5.1 93/09/24 */
+/* @(#)s_ceil.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
@@ -22,8 +22,6 @@
#include "fdlibm.h"
-#ifndef _DOUBLE_IS_32BITS
-
#ifdef __STDC__
static const double huge = 1.0e300;
#else
@@ -37,14 +35,15 @@ static double huge = 1.0e300;
double x;
#endif
{
- int32_t i0,i1,j0;
- uint32_t i,j;
- EXTRACT_WORDS(i0,i1,x);
+ int i0,i1,j0;
+ unsigned i,j;
+ i0 = __HI(x);
+ i1 = __LO(x);
j0 = ((i0>>20)&0x7ff)-0x3ff;
if(j0<20) {
if(j0<0) { /* raise inexact if x != 0 */
if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */
- if(i0<0) {i0=0x80000000;i1=0;}
+ if(i0<0) {i0=0x80000000;i1=0;}
else if((i0|i1)!=0) { i0=0x3ff00000;i1=0;}
}
} else {
@@ -59,22 +58,21 @@ static double huge = 1.0e300;
if(j0==0x400) return x+x; /* inf or NaN */
else return x; /* x is integral */
} else {
- i = ((uint32_t)(0xffffffff))>>(j0-20);
+ i = ((unsigned)(0xffffffff))>>(j0-20);
if((i1&i)==0) return x; /* x is integral */
if(huge+x>0.0) { /* raise inexact flag */
if(i0>0) {
- if(j0==20) i0+=1;
+ if(j0==20) i0+=1;
else {
j = i1 + (1<<(52-j0));
- if(j<(uint32_t)i1) i0+=1; /* got a carry */
+ if(j<i1) i0+=1; /* got a carry */
i1 = j;
}
}
i1 &= (~i);
}
}
- INSERT_WORDS(x,i0,i1);
+ __HI(x) = i0;
+ __LO(x) = i1;
return x;
}
-
-#endif /* _DOUBLE_IS_32BITS */
diff --git a/native/fdlibm/s_copysign.c b/native/fdlibm/s_copysign.c
index 4804df130..21eec341b 100644
--- a/native/fdlibm/s_copysign.c
+++ b/native/fdlibm/s_copysign.c
@@ -1,61 +1,17 @@
-/* @(#)s_copysign.c 5.1 93/09/24 */
+/* @(#)s_copysign.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
/*
-FUNCTION
-<<copysign>>, <<copysignf>>---sign of <[y]>, magnitude of <[x]>
-
-INDEX
- copysign
-INDEX
- copysignf
-
-ANSI_SYNOPSIS
- #include <math.h>
- double copysign (double <[x]>, double <[y]>);
- float copysignf (float <[x]>, float <[y]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double copysign (<[x]>, <[y]>)
- double <[x]>;
- double <[y]>;
-
- float copysignf (<[x]>, <[y]>)
- float <[x]>;
- float <[y]>;
-
-DESCRIPTION
-<<copysign>> constructs a number with the magnitude (absolute value)
-of its first argument, <[x]>, and the sign of its second argument,
-<[y]>.
-
-<<copysignf>> does the same thing; the two functions differ only in
-the type of their arguments and result.
-
-RETURNS
-<<copysign>> returns a <<double>> with the magnitude of
-<[x]> and the sign of <[y]>.
-<<copysignf>> returns a <<float>> with the magnitude of
-<[x]> and the sign of <[y]>.
-
-PORTABILITY
-<<copysign>> is not required by either ANSI C or the System V Interface
-Definition (Issue 2).
-
-*/
-
-/*
* copysign(double x, double y)
* copysign(x,y) returns a value with the magnitude of x and
* with the sign bit of y.
@@ -63,8 +19,6 @@ Definition (Issue 2).
#include "fdlibm.h"
-#ifndef _DOUBLE_IS_32BITS
-
#ifdef __STDC__
double copysign(double x, double y)
#else
@@ -72,11 +26,6 @@ Definition (Issue 2).
double x,y;
#endif
{
- uint32_t hx,hy;
- GET_HIGH_WORD(hx,x);
- GET_HIGH_WORD(hy,y);
- SET_HIGH_WORD(x,(hx&0x7fffffff)|(hy&0x80000000));
+ __HI(x) = (__HI(x)&0x7fffffff)|(__HI(y)&0x80000000);
return x;
}
-
-#endif /* _DOUBLE_IS_32BITS */
diff --git a/native/fdlibm/s_cos.c b/native/fdlibm/s_cos.c
index be1538d4c..3bab516d2 100644
--- a/native/fdlibm/s_cos.c
+++ b/native/fdlibm/s_cos.c
@@ -1,12 +1,12 @@
-/* @(#)s_cos.c 5.1 93/09/24 */
+/* @(#)s_cos.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
@@ -20,8 +20,8 @@
* __ieee754_rem_pio2 ... argument reduction routine
*
* Method.
- * Let S,C and T denote the sin, cos and tan respectively on
- * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2
+ * Let S,C and T denote the sin, cos and tan respectively on
+ * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2
* in [-pi/4 , +pi/4], and let n = k mod 4.
* We have
*
@@ -39,13 +39,11 @@
* trig(NaN) is that NaN;
*
* Accuracy:
- * TRIG(x) returns trig(x) nearly rounded
+ * TRIG(x) returns trig(x) nearly rounded
*/
#include "fdlibm.h"
-#ifndef _DOUBLE_IS_32BITS
-
#ifdef __STDC__
double cos(double x)
#else
@@ -54,10 +52,10 @@
#endif
{
double y[2],z=0.0;
- int32_t n,ix;
+ int n, ix;
/* High word of x. */
- GET_HIGH_WORD(ix,x);
+ ix = __HI(x);
/* |x| ~< pi/4 */
ix &= 0x7fffffff;
@@ -78,5 +76,3 @@
}
}
}
-
-#endif /* _DOUBLE_IS_32BITS */
diff --git a/native/fdlibm/s_expm1.c b/native/fdlibm/s_expm1.c
new file mode 100644
index 000000000..e4dd820cd
--- /dev/null
+++ b/native/fdlibm/s_expm1.c
@@ -0,0 +1,215 @@
+
+/* @(#)s_expm1.c 1.5 04/04/22 */
+/*
+ * ====================================================
+ * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/* expm1(x)
+ * Returns exp(x)-1, the exponential of x minus 1.
+ *
+ * Method
+ * 1. Argument reduction:
+ * Given x, find r and integer k such that
+ *
+ * x = k*ln2 + r, |r| <= 0.5*ln2 ~ 0.34658
+ *
+ * Here a correction term c will be computed to compensate
+ * the error in r when rounded to a floating-point number.
+ *
+ * 2. Approximating expm1(r) by a special rational function on
+ * the interval [0,0.34658]:
+ * Since
+ * r*(exp(r)+1)/(exp(r)-1) = 2+ r^2/6 - r^4/360 + ...
+ * we define R1(r*r) by
+ * r*(exp(r)+1)/(exp(r)-1) = 2+ r^2/6 * R1(r*r)
+ * That is,
+ * R1(r**2) = 6/r *((exp(r)+1)/(exp(r)-1) - 2/r)
+ * = 6/r * ( 1 + 2.0*(1/(exp(r)-1) - 1/r))
+ * = 1 - r^2/60 + r^4/2520 - r^6/100800 + ...
+ * We use a special Remes algorithm on [0,0.347] to generate
+ * a polynomial of degree 5 in r*r to approximate R1. The
+ * maximum error of this polynomial approximation is bounded
+ * by 2**-61. In other words,
+ * R1(z) ~ 1.0 + Q1*z + Q2*z**2 + Q3*z**3 + Q4*z**4 + Q5*z**5
+ * where Q1 = -1.6666666666666567384E-2,
+ * Q2 = 3.9682539681370365873E-4,
+ * Q3 = -9.9206344733435987357E-6,
+ * Q4 = 2.5051361420808517002E-7,
+ * Q5 = -6.2843505682382617102E-9;
+ * (where z=r*r, and the values of Q1 to Q5 are listed below)
+ * with error bounded by
+ * | 5 | -61
+ * | 1.0+Q1*z+...+Q5*z - R1(z) | <= 2
+ * | |
+ *
+ * expm1(r) = exp(r)-1 is then computed by the following
+ * specific way which minimize the accumulation rounding error:
+ * 2 3
+ * r r [ 3 - (R1 + R1*r/2) ]
+ * expm1(r) = r + --- + --- * [--------------------]
+ * 2 2 [ 6 - r*(3 - R1*r/2) ]
+ *
+ * To compensate the error in the argument reduction, we use
+ * expm1(r+c) = expm1(r) + c + expm1(r)*c
+ * ~ expm1(r) + c + r*c
+ * Thus c+r*c will be added in as the correction terms for
+ * expm1(r+c). Now rearrange the term to avoid optimization
+ * screw up:
+ * ( 2 2 )
+ * ({ ( r [ R1 - (3 - R1*r/2) ] ) } r )
+ * expm1(r+c)~r - ({r*(--- * [--------------------]-c)-c} - --- )
+ * ({ ( 2 [ 6 - r*(3 - R1*r/2) ] ) } 2 )
+ * ( )
+ *
+ * = r - E
+ * 3. Scale back to obtain expm1(x):
+ * From step 1, we have
+ * expm1(x) = either 2^k*[expm1(r)+1] - 1
+ * = or 2^k*[expm1(r) + (1-2^-k)]
+ * 4. Implementation notes:
+ * (A). To save one multiplication, we scale the coefficient Qi
+ * to Qi*2^i, and replace z by (x^2)/2.
+ * (B). To achieve maximum accuracy, we compute expm1(x) by
+ * (i) if x < -56*ln2, return -1.0, (raise inexact if x!=inf)
+ * (ii) if k=0, return r-E
+ * (iii) if k=-1, return 0.5*(r-E)-0.5
+ * (iv) if k=1 if r < -0.25, return 2*((r+0.5)- E)
+ * else return 1.0+2.0*(r-E);
+ * (v) if (k<-2||k>56) return 2^k(1-(E-r)) - 1 (or exp(x)-1)
+ * (vi) if k <= 20, return 2^k((1-2^-k)-(E-r)), else
+ * (vii) return 2^k(1-((E+2^-k)-r))
+ *
+ * Special cases:
+ * expm1(INF) is INF, expm1(NaN) is NaN;
+ * expm1(-INF) is -1, and
+ * for finite argument, only expm1(0)=0 is exact.
+ *
+ * Accuracy:
+ * according to an error analysis, the error is always less than
+ * 1 ulp (unit in the last place).
+ *
+ * Misc. info.
+ * For IEEE double
+ * if x > 7.09782712893383973096e+02 then expm1(x) overflow
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following
+ * constants. The decimal values may be used, provided that the
+ * compiler will convert from decimal to binary accurately enough
+ * to produce the hexadecimal values shown.
+ */
+
+#include "fdlibm.h"
+
+#ifdef __STDC__
+static const double
+#else
+static double
+#endif
+one = 1.0,
+huge = 1.0e+300,
+tiny = 1.0e-300,
+o_threshold = 7.09782712893383973096e+02,/* 0x40862E42, 0xFEFA39EF */
+ln2_hi = 6.93147180369123816490e-01,/* 0x3fe62e42, 0xfee00000 */
+ln2_lo = 1.90821492927058770002e-10,/* 0x3dea39ef, 0x35793c76 */
+invln2 = 1.44269504088896338700e+00,/* 0x3ff71547, 0x652b82fe */
+ /* scaled coefficients related to expm1 */
+Q1 = -3.33333333333331316428e-02, /* BFA11111 111110F4 */
+Q2 = 1.58730158725481460165e-03, /* 3F5A01A0 19FE5585 */
+Q3 = -7.93650757867487942473e-05, /* BF14CE19 9EAADBB7 */
+Q4 = 4.00821782732936239552e-06, /* 3ED0CFCA 86E65239 */
+Q5 = -2.01099218183624371326e-07; /* BE8AFDB7 6E09C32D */
+
+#ifdef __STDC__
+ double expm1(double x)
+#else
+ double expm1(x)
+ double x;
+#endif
+{
+ double y,hi,lo,c,t,e,hxs,hfx,r1;
+ int k,xsb;
+ unsigned hx;
+
+ hx = __HI(x); /* high word of x */
+ xsb = hx&0x80000000; /* sign bit of x */
+ if(xsb==0) y=x; else y= -x; /* y = |x| */
+ hx &= 0x7fffffff; /* high word of |x| */
+
+ /* filter out huge and non-finite argument */
+ if(hx >= 0x4043687A) { /* if |x|>=56*ln2 */
+ if(hx >= 0x40862E42) { /* if |x|>=709.78... */
+ if(hx>=0x7ff00000) {
+ if(((hx&0xfffff)|__LO(x))!=0)
+ return x+x; /* NaN */
+ else return (xsb==0)? x:-1.0;/* exp(+-inf)={inf,-1} */
+ }
+ if(x > o_threshold) return huge*huge; /* overflow */
+ }
+ if(xsb!=0) { /* x < -56*ln2, return -1.0 with inexact */
+ if(x+tiny<0.0) /* raise inexact */
+ return tiny-one; /* return -1 */
+ }
+ }
+
+ /* argument reduction */
+ if(hx > 0x3fd62e42) { /* if |x| > 0.5 ln2 */
+ if(hx < 0x3FF0A2B2) { /* and |x| < 1.5 ln2 */
+ if(xsb==0)
+ {hi = x - ln2_hi; lo = ln2_lo; k = 1;}
+ else
+ {hi = x + ln2_hi; lo = -ln2_lo; k = -1;}
+ } else {
+ k = invln2*x+((xsb==0)?0.5:-0.5);
+ t = k;
+ hi = x - t*ln2_hi; /* t*ln2_hi is exact here */
+ lo = t*ln2_lo;
+ }
+ x = hi - lo;
+ c = (hi-x)-lo;
+ }
+ else if(hx < 0x3c900000) { /* when |x|<2**-54, return x */
+ t = huge+x; /* return x with inexact flags when x!=0 */
+ return x - (t-(huge+x));
+ }
+ else k = 0;
+
+ /* x is now in primary range */
+ hfx = 0.5*x;
+ hxs = x*hfx;
+ r1 = one+hxs*(Q1+hxs*(Q2+hxs*(Q3+hxs*(Q4+hxs*Q5))));
+ t = 3.0-r1*hfx;
+ e = hxs*((r1-t)/(6.0 - x*t));
+ if(k==0) return x - (x*e-hxs); /* c is 0 */
+ else {
+ e = (x*(e-c)-c);
+ e -= hxs;
+ if(k== -1) return 0.5*(x-e)-0.5;
+ if(k==1)
+ if(x < -0.25) return -2.0*(e-(x+0.5));
+ else return one+2.0*(x-e);
+ if (k <= -2 || k>56) { /* suffice to return exp(x)-1 */
+ y = one-(e-x);
+ __HI(y) += (k<<20); /* add k to y's exponent */
+ return y-one;
+ }
+ t = one;
+ if(k<20) {
+ __HI(t) = 0x3ff00000 - (0x200000>>k); /* t=1-2^-k */
+ y = t-(e-x);
+ __HI(y) += (k<<20); /* add k to y's exponent */
+ } else {
+ __HI(t) = ((0x3ff-k)<<20); /* 2^-k */
+ y = x-(e+t);
+ y += one;
+ __HI(y) += (k<<20); /* add k to y's exponent */
+ }
+ }
+ return y;
+}
diff --git a/native/fdlibm/s_fabs.c b/native/fdlibm/s_fabs.c
index dfee33fec..0c4dd6436 100644
--- a/native/fdlibm/s_fabs.c
+++ b/native/fdlibm/s_fabs.c
@@ -1,62 +1,22 @@
-/* @(#)s_fabs.c 5.1 93/09/24 */
+/* @(#)s_fabs.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
/*
-FUNCTION
- <<fabs>>, <<fabsf>>---absolute value (magnitude)
-INDEX
- fabs
-INDEX
- fabsf
-
-ANSI_SYNOPSIS
- #include <math.h>
- double fabs(double <[x]>);
- float fabsf(float <[x]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double fabs(<[x]>)
- double <[x]>;
-
- float fabsf(<[x]>)
- float <[x]>;
-
-DESCRIPTION
-<<fabs>> and <<fabsf>> calculate
-@tex
-$|x|$,
-@end tex
-the absolute value (magnitude) of the argument <[x]>, by direct
-manipulation of the bit representation of <[x]>.
-
-RETURNS
-The calculated value is returned. No errors are detected.
-
-PORTABILITY
-<<fabs>> is ANSI.
-<<fabsf>> is an extension.
-
-*/
-
-/*
* fabs(x) returns the absolute value of x.
*/
#include "fdlibm.h"
-#ifndef _DOUBLE_IS_32BITS
-
#ifdef __STDC__
double fabs(double x)
#else
@@ -64,10 +24,6 @@ PORTABILITY
double x;
#endif
{
- uint32_t high;
- GET_HIGH_WORD(high,x);
- SET_HIGH_WORD(x,high&0x7fffffff);
+ __HI(x) &= 0x7fffffff;
return x;
}
-
-#endif /* _DOUBLE_IS_32BITS */
diff --git a/native/fdlibm/s_finite.c b/native/fdlibm/s_finite.c
index 3e6c8122b..42e1728d7 100644
--- a/native/fdlibm/s_finite.c
+++ b/native/fdlibm/s_finite.c
@@ -19,13 +19,13 @@
#include "fdlibm.h"
#ifdef __STDC__
- int finite(double x)
+ int finite(double x)
#else
- int finite(x)
- double x;
+ int finite(x)
+ double x;
#endif
{
- uint32_t high;
- GET_HIGH_WORD(high,x);
- return (unsigned)((high&0x7fffffff)-0x7ff00000)>>31;
+ int hx;
+ hx = __HI(x);
+ return (unsigned)((hx&0x7fffffff)-0x7ff00000)>>31;
}
diff --git a/native/fdlibm/s_floor.c b/native/fdlibm/s_floor.c
index 77e39cb7d..b37c41ba4 100644
--- a/native/fdlibm/s_floor.c
+++ b/native/fdlibm/s_floor.c
@@ -1,70 +1,17 @@
-/* @(#)s_floor.c 5.1 93/09/24 */
+/* @(#)s_floor.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
/*
-FUNCTION
-<<floor>>, <<floorf>>, <<ceil>>, <<ceilf>>---floor and ceiling
-INDEX
- floor
-INDEX
- floorf
-INDEX
- ceil
-INDEX
- ceilf
-
-ANSI_SYNOPSIS
- #include <math.h>
- double floor(double <[x]>);
- float floorf(float <[x]>);
- double ceil(double <[x]>);
- float ceilf(float <[x]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double floor(<[x]>)
- double <[x]>;
- float floorf(<[x]>)
- float <[x]>;
- double ceil(<[x]>)
- double <[x]>;
- float ceilf(<[x]>)
- float <[x]>;
-
-DESCRIPTION
-<<floor>> and <<floorf>> find
-@tex
-$\lfloor x \rfloor$,
-@end tex
-the nearest integer less than or equal to <[x]>.
-<<ceil>> and <<ceilf>> find
-@tex
-$\lceil x\rceil$,
-@end tex
-the nearest integer greater than or equal to <[x]>.
-
-RETURNS
-<<floor>> and <<ceil>> return the integer result as a double.
-<<floorf>> and <<ceilf>> return the integer result as a float.
-
-PORTABILITY
-<<floor>> and <<ceil>> are ANSI.
-<<floorf>> and <<ceilf>> are extensions.
-
-
-*/
-
-/*
* floor(x)
* Return x rounded toward -inf to integral value
* Method:
@@ -75,8 +22,6 @@ PORTABILITY
#include "fdlibm.h"
-#ifndef _DOUBLE_IS_32BITS
-
#ifdef __STDC__
static const double huge = 1.0e300;
#else
@@ -90,14 +35,15 @@ static double huge = 1.0e300;
double x;
#endif
{
- int32_t i0,i1,j0;
- uint32_t i,j;
- EXTRACT_WORDS(i0,i1,x);
+ int i0,i1,j0;
+ unsigned i,j;
+ i0 = __HI(x);
+ i1 = __LO(x);
j0 = ((i0>>20)&0x7ff)-0x3ff;
if(j0<20) {
if(j0<0) { /* raise inexact if x != 0 */
if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */
- if(i0>=0) {i0=i1=0;}
+ if(i0>=0) {i0=i1=0;}
else if(((i0&0x7fffffff)|i1)!=0)
{ i0=0xbff00000;i1=0;}
}
@@ -113,22 +59,21 @@ static double huge = 1.0e300;
if(j0==0x400) return x+x; /* inf or NaN */
else return x; /* x is integral */
} else {
- i = ((uint32_t)(0xffffffff))>>(j0-20);
+ i = ((unsigned)(0xffffffff))>>(j0-20);
if((i1&i)==0) return x; /* x is integral */
if(huge+x>0.0) { /* raise inexact flag */
if(i0<0) {
- if(j0==20) i0+=1;
+ if(j0==20) i0+=1;
else {
j = i1+(1<<(52-j0));
- if(j<(uint32_t)i1) i0 +=1 ; /* got a carry */
+ if(j<i1) i0 +=1 ; /* got a carry */
i1=j;
}
}
i1 &= (~i);
}
}
- INSERT_WORDS(x,i0,i1);
+ __HI(x) = i0;
+ __LO(x) = i1;
return x;
}
-
-#endif /* _DOUBLE_IS_32BITS */
diff --git a/native/fdlibm/s_log1p.c b/native/fdlibm/s_log1p.c
new file mode 100644
index 000000000..12757f2c2
--- /dev/null
+++ b/native/fdlibm/s_log1p.c
@@ -0,0 +1,165 @@
+
+/* @(#)s_log1p.c 1.4 96/03/07 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/* double log1p(double x)
+ *
+ * Method :
+ * 1. Argument Reduction: find k and f such that
+ * 1+x = 2^k * (1+f),
+ * where sqrt(2)/2 < 1+f < sqrt(2) .
+ *
+ * Note. If k=0, then f=x is exact. However, if k!=0, then f
+ * may not be representable exactly. In that case, a correction
+ * term is need. Let u=1+x rounded. Let c = (1+x)-u, then
+ * log(1+x) - log(u) ~ c/u. Thus, we proceed to compute log(u),
+ * and add back the correction term c/u.
+ * (Note: when x > 2**53, one can simply return log(x))
+ *
+ * 2. Approximation of log1p(f).
+ * Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s)
+ * = 2s + 2/3 s**3 + 2/5 s**5 + .....,
+ * = 2s + s*R
+ * We use a special Remes algorithm on [0,0.1716] to generate
+ * a polynomial of degree 14 to approximate R The maximum error
+ * of this polynomial approximation is bounded by 2**-58.45. In
+ * other words,
+ * 2 4 6 8 10 12 14
+ * R(z) ~ Lp1*s +Lp2*s +Lp3*s +Lp4*s +Lp5*s +Lp6*s +Lp7*s
+ * (the values of Lp1 to Lp7 are listed in the program)
+ * and
+ * | 2 14 | -58.45
+ * | Lp1*s +...+Lp7*s - R(z) | <= 2
+ * | |
+ * Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2.
+ * In order to guarantee error in log below 1ulp, we compute log
+ * by
+ * log1p(f) = f - (hfsq - s*(hfsq+R)).
+ *
+ * 3. Finally, log1p(x) = k*ln2 + log1p(f).
+ * = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo)))
+ * Here ln2 is split into two floating point number:
+ * ln2_hi + ln2_lo,
+ * where n*ln2_hi is always exact for |n| < 2000.
+ *
+ * Special cases:
+ * log1p(x) is NaN with signal if x < -1 (including -INF) ;
+ * log1p(+INF) is +INF; log1p(-1) is -INF with signal;
+ * log1p(NaN) is that NaN with no signal.
+ *
+ * Accuracy:
+ * according to an error analysis, the error is always less than
+ * 1 ulp (unit in the last place).
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following
+ * constants. The decimal values may be used, provided that the
+ * compiler will convert from decimal to binary accurately enough
+ * to produce the hexadecimal values shown.
+ *
+ * Note: Assuming log() return accurate answer, the following
+ * algorithm can be used to compute log1p(x) to within a few ULP:
+ *
+ * u = 1+x;
+ * if(u==1.0) return x ; else
+ * return log(u)*(x/(u-1.0));
+ *
+ * See HP-15C Advanced Functions Handbook, p.193.
+ */
+
+#include "fdlibm.h"
+
+#ifdef __STDC__
+static const double
+#else
+static double
+#endif
+ln2_hi = 6.93147180369123816490e-01, /* 3fe62e42 fee00000 */
+ln2_lo = 1.90821492927058770002e-10, /* 3dea39ef 35793c76 */
+two54 = 1.80143985094819840000e+16, /* 43500000 00000000 */
+Lp1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */
+Lp2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */
+Lp3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */
+Lp4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */
+Lp5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */
+Lp6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */
+Lp7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
+
+static double zero = 0.0;
+
+#ifdef __STDC__
+ double log1p(double x)
+#else
+ double log1p(x)
+ double x;
+#endif
+{
+ double hfsq,f,c,s,z,R,u;
+ int k,hx,hu,ax;
+
+ hx = __HI(x); /* high word of x */
+ ax = hx&0x7fffffff;
+
+ k = 1;
+ if (hx < 0x3FDA827A) { /* x < 0.41422 */
+ if(ax>=0x3ff00000) { /* x <= -1.0 */
+ if(x==-1.0) return -two54/zero; /* log1p(-1)=+inf */
+ else return (x-x)/(x-x); /* log1p(x<-1)=NaN */
+ }
+ if(ax<0x3e200000) { /* |x| < 2**-29 */
+ if(two54+x>zero /* raise inexact */
+ &&ax<0x3c900000) /* |x| < 2**-54 */
+ return x;
+ else
+ return x - x*x*0.5;
+ }
+ if(hx>0||hx<=((int)0xbfd2bec3)) {
+ k=0;f=x;hu=1;} /* -0.2929<x<0.41422 */
+ }
+ if (hx >= 0x7ff00000) return x+x;
+ if(k!=0) {
+ if(hx<0x43400000) {
+ u = 1.0+x;
+ hu = __HI(u); /* high word of u */
+ k = (hu>>20)-1023;
+ c = (k>0)? 1.0-(u-x):x-(u-1.0);/* correction term */
+ c /= u;
+ } else {
+ u = x;
+ hu = __HI(u); /* high word of u */
+ k = (hu>>20)-1023;
+ c = 0;
+ }
+ hu &= 0x000fffff;
+ if(hu<0x6a09e) {
+ __HI(u) = hu|0x3ff00000; /* normalize u */
+ } else {
+ k += 1;
+ __HI(u) = hu|0x3fe00000; /* normalize u/2 */
+ hu = (0x00100000-hu)>>2;
+ }
+ f = u-1.0;
+ }
+ hfsq=0.5*f*f;
+ if(hu==0) { /* |f| < 2**-20 */
+ if(f==zero) if(k==0) return zero;
+ else {c += k*ln2_lo; return k*ln2_hi+c;}
+ R = hfsq*(1.0-0.66666666666666666*f);
+ if(k==0) return f-R; else
+ return k*ln2_hi-((R-(k*ln2_lo+c))-f);
+ }
+ s = f/(2.0+f);
+ z = s*s;
+ R = z*(Lp1+z*(Lp2+z*(Lp3+z*(Lp4+z*(Lp5+z*(Lp6+z*Lp7))))));
+ if(k==0) return f-(hfsq-s*(hfsq+R)); else
+ return k*ln2_hi-((hfsq-(s*(hfsq+R)+(k*ln2_lo+c)))-f);
+}
diff --git a/native/fdlibm/s_rint.c b/native/fdlibm/s_rint.c
index 5d3f8114e..3095e0d38 100644
--- a/native/fdlibm/s_rint.c
+++ b/native/fdlibm/s_rint.c
@@ -1,12 +1,12 @@
-/* @(#)s_rint.c 5.1 93/09/24 */
+/* @(#)s_rint.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
@@ -23,12 +23,10 @@
#include "fdlibm.h"
-#ifndef _DOUBLE_IS_32BITS
-
#ifdef __STDC__
static const double
#else
-static double
+static double
#endif
TWO52[2]={
4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
@@ -42,24 +40,24 @@ TWO52[2]={
double x;
#endif
{
- int32_t i0,j0,sx;
- uint32_t i,i1;
- double t;
- volatile double w;
- EXTRACT_WORDS(i0,i1,x);
+ int i0,j0,sx;
+ unsigned i,i1;
+ double w,t;
+ i0 = __HI(x);
sx = (i0>>31)&1;
+ i1 = __LO(x);
j0 = ((i0>>20)&0x7ff)-0x3ff;
if(j0<20) {
- if(j0<0) {
+ if(j0<0) {
if(((i0&0x7fffffff)|i1)==0) return x;
i1 |= (i0&0x0fffff);
i0 &= 0xfffe0000;
i0 |= ((i1|-i1)>>12)&0x80000;
- SET_HIGH_WORD(x,i0);
+ __HI(x)=i0;
w = TWO52[sx]+x;
t = w-TWO52[sx];
- GET_HIGH_WORD(i0,t);
- SET_HIGH_WORD(t,(i0&0x7fffffff)|(sx<<31));
+ i0 = __HI(t);
+ __HI(t) = (i0&0x7fffffff)|(sx<<31);
return t;
} else {
i = (0x000fffff)>>j0;
@@ -74,14 +72,13 @@ TWO52[2]={
if(j0==0x400) return x+x; /* inf or NaN */
else return x; /* x is integral */
} else {
- i = ((uint32_t)(0xffffffff))>>(j0-20);
+ i = ((unsigned)(0xffffffff))>>(j0-20);
if((i1&i)==0) return x; /* x is integral */
i>>=1;
if((i1&i)!=0) i1 = (i1&(~i))|((0x40000000)>>(j0-20));
}
- INSERT_WORDS(x,i0,i1);
+ __HI(x) = i0;
+ __LO(x) = i1;
w = TWO52[sx]+x;
return w-TWO52[sx];
}
-
-#endif /* _DOUBLE_IS_32BITS */
diff --git a/native/fdlibm/s_scalbn.c b/native/fdlibm/s_scalbn.c
index 36ee88981..329be8b89 100644
--- a/native/fdlibm/s_scalbn.c
+++ b/native/fdlibm/s_scalbn.c
@@ -1,64 +1,25 @@
-/* @(#)s_scalbn.c 5.1 93/09/24 */
+/* @(#)s_scalbn.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
-/*
-FUNCTION
-<<scalbn>>, <<scalbnf>>---scale by integer
-INDEX
- scalbn
-INDEX
- scalbnf
-
-ANSI_SYNOPSIS
- #include <math.h>
- double scalbn(double <[x]>, int <[y]>);
- float scalbnf(float <[x]>, int <[y]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double scalbn(<[x]>,<[y]>)
- double <[x]>;
- int <[y]>;
- float scalbnf(<[x]>,<[y]>)
- float <[x]>;
- int <[y]>;
-
-DESCRIPTION
-<<scalbn>> and <<scalbnf>> scale <[x]> by <[n]>, returning <[x]> times
-2 to the power <[n]>. The result is computed by manipulating the
-exponent, rather than by actually performing an exponentiation or
-multiplication.
-
-RETURNS
-<[x]> times 2 to the power <[n]>.
-
-PORTABILITY
-Neither <<scalbn>> nor <<scalbnf>> is required by ANSI C or by the System V
-Interface Definition (Issue 2).
-
-*/
-
-/*
+/*
* scalbn (double x, int n)
- * scalbn(x,n) returns x* 2**n computed by exponent
- * manipulation rather than by actually performing an
+ * scalbn(x,n) returns x* 2**n computed by exponent
+ * manipulation rather than by actually performing an
* exponentiation or a multiplication.
*/
#include "fdlibm.h"
-#ifndef _DOUBLE_IS_32BITS
-
#ifdef __STDC__
static const double
#else
@@ -76,29 +37,27 @@ tiny = 1.0e-300;
double x; int n;
#endif
{
- int32_t k,hx,lx;
- EXTRACT_WORDS(hx,lx,x);
+ int k,hx,lx;
+ hx = __HI(x);
+ lx = __LO(x);
k = (hx&0x7ff00000)>>20; /* extract exponent */
if (k==0) { /* 0 or subnormal x */
if ((lx|(hx&0x7fffffff))==0) return x; /* +-0 */
- x *= two54;
- GET_HIGH_WORD(hx,x);
- k = ((hx&0x7ff00000)>>20) - 54;
+ x *= two54;
+ hx = __HI(x);
+ k = ((hx&0x7ff00000)>>20) - 54;
if (n< -50000) return tiny*x; /*underflow*/
}
if (k==0x7ff) return x+x; /* NaN or Inf */
- k = k+n;
+ k = k+n;
if (k > 0x7fe) return huge*copysign(huge,x); /* overflow */
if (k > 0) /* normal result */
- {SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); return x;}
- if (k <= -54) {
+ {__HI(x) = (hx&0x800fffff)|(k<<20); return x;}
+ if (k <= -54)
if (n > 50000) /* in case integer overflow in n+k */
return huge*copysign(huge,x); /*overflow*/
else return tiny*copysign(tiny,x); /*underflow*/
- }
k += 54; /* subnormal result */
- SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20));
+ __HI(x) = (hx&0x800fffff)|(k<<20);
return x*twom54;
}
-
-#endif /* _DOUBLE_IS_32BITS */
diff --git a/native/fdlibm/s_sin.c b/native/fdlibm/s_sin.c
index d31545554..43394e577 100644
--- a/native/fdlibm/s_sin.c
+++ b/native/fdlibm/s_sin.c
@@ -1,66 +1,16 @@
-/* @(#)s_sin.c 5.1 93/09/24 */
+/* @(#)s_sin.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
-/*
-FUNCTION
- <<sin>>, <<sinf>>, <<cos>>, <<cosf>>---sine or cosine
-INDEX
-sin
-INDEX
-sinf
-INDEX
-cos
-INDEX
-cosf
-ANSI_SYNOPSIS
- #include <math.h>
- double sin(double <[x]>);
- float sinf(float <[x]>);
- double cos(double <[x]>);
- float cosf(float <[x]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double sin(<[x]>)
- double <[x]>;
- float sinf(<[x]>)
- float <[x]>;
-
- double cos(<[x]>)
- double <[x]>;
- float cosf(<[x]>)
- float <[x]>;
-
-DESCRIPTION
- <<sin>> and <<cos>> compute (respectively) the sine and cosine
- of the argument <[x]>. Angles are specified in radians.
-
- <<sinf>> and <<cosf>> are identical, save that they take and
- return <<float>> values.
-
-
-RETURNS
- The sine or cosine of <[x]> is returned.
-
-PORTABILITY
- <<sin>> and <<cos>> are ANSI C.
- <<sinf>> and <<cosf>> are extensions.
-
-QUICKREF
- sin ansi pure
- sinf - pure
-*/
-
/* sin(x)
* Return sine function of x.
*
@@ -70,8 +20,8 @@ QUICKREF
* __ieee754_rem_pio2 ... argument reduction routine
*
* Method.
- * Let S,C and T denote the sin, cos and tan respectively on
- * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2
+ * Let S,C and T denote the sin, cos and tan respectively on
+ * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2
* in [-pi/4 , +pi/4], and let n = k mod 4.
* We have
*
@@ -89,13 +39,11 @@ QUICKREF
* trig(NaN) is that NaN;
*
* Accuracy:
- * TRIG(x) returns trig(x) nearly rounded
+ * TRIG(x) returns trig(x) nearly rounded
*/
#include "fdlibm.h"
-#ifndef _DOUBLE_IS_32BITS
-
#ifdef __STDC__
double sin(double x)
#else
@@ -104,10 +52,10 @@ QUICKREF
#endif
{
double y[2],z=0.0;
- int32_t n,ix;
+ int n, ix;
/* High word of x. */
- GET_HIGH_WORD(ix,x);
+ ix = __HI(x);
/* |x| ~< pi/4 */
ix &= 0x7fffffff;
@@ -128,5 +76,3 @@ QUICKREF
}
}
}
-
-#endif /* _DOUBLE_IS_32BITS */
diff --git a/native/fdlibm/s_tan.c b/native/fdlibm/s_tan.c
index 20995fcbd..1f5564bce 100644
--- a/native/fdlibm/s_tan.c
+++ b/native/fdlibm/s_tan.c
@@ -1,54 +1,16 @@
-/* @(#)s_tan.c 5.1 93/09/24 */
+/* @(#)s_tan.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
-
-/*
-
-FUNCTION
- <<tan>>, <<tanf>>---tangent
-
-INDEX
-tan
-INDEX
-tanf
-
-ANSI_SYNOPSIS
- #include <math.h>
- double tan(double <[x]>);
- float tanf(float <[x]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double tan(<[x]>)
- double <[x]>;
-
- float tanf(<[x]>)
- float <[x]>;
-
-
-DESCRIPTION
-<<tan>> computes the tangent of the argument <[x]>.
-Angles are specified in radians.
-
-<<tanf>> is identical, save that it takes and returns <<float>> values.
-
-RETURNS
-The tangent of <[x]> is returned.
-
-PORTABILITY
-<<tan>> is ANSI. <<tanf>> is an extension.
-*/
-
/* tan(x)
* Return tangent function of x.
*
@@ -57,8 +19,8 @@ PORTABILITY
* __ieee754_rem_pio2 ... argument reduction routine
*
* Method.
- * Let S,C and T denote the sin, cos and tan respectively on
- * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2
+ * Let S,C and T denote the sin, cos and tan respectively on
+ * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2
* in [-pi/4 , +pi/4], and let n = k mod 4.
* We have
*
@@ -76,13 +38,11 @@ PORTABILITY
* trig(NaN) is that NaN;
*
* Accuracy:
- * TRIG(x) returns trig(x) nearly rounded
+ * TRIG(x) returns trig(x) nearly rounded
*/
#include "fdlibm.h"
-#ifndef _DOUBLE_IS_32BITS
-
#ifdef __STDC__
double tan(double x)
#else
@@ -91,10 +51,10 @@ PORTABILITY
#endif
{
double y[2],z=0.0;
- int32_t n,ix;
+ int n, ix;
/* High word of x. */
- GET_HIGH_WORD(ix,x);
+ ix = __HI(x);
/* |x| ~< pi/4 */
ix &= 0x7fffffff;
@@ -110,5 +70,3 @@ PORTABILITY
-1 -- n odd */
}
}
-
-#endif /* _DOUBLE_IS_32BITS */
diff --git a/native/fdlibm/s_tanh.c b/native/fdlibm/s_tanh.c
new file mode 100644
index 000000000..7d77c2eac
--- /dev/null
+++ b/native/fdlibm/s_tanh.c
@@ -0,0 +1,82 @@
+
+/* @(#)s_tanh.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/* Tanh(x)
+ * Return the Hyperbolic Tangent of x
+ *
+ * Method :
+ * x -x
+ * e - e
+ * 0. tanh(x) is defined to be -----------
+ * x -x
+ * e + e
+ * 1. reduce x to non-negative by tanh(-x) = -tanh(x).
+ * 2. 0 <= x <= 2**-55 : tanh(x) := x*(one+x)
+ * -t
+ * 2**-55 < x <= 1 : tanh(x) := -----; t = expm1(-2x)
+ * t + 2
+ * 2
+ * 1 <= x <= 22.0 : tanh(x) := 1- ----- ; t=expm1(2x)
+ * t + 2
+ * 22.0 < x <= INF : tanh(x) := 1.
+ *
+ * Special cases:
+ * tanh(NaN) is NaN;
+ * only tanh(0)=0 is exact for finite argument.
+ */
+
+#include "fdlibm.h"
+
+#ifdef __STDC__
+static const double one=1.0, two=2.0, tiny = 1.0e-300;
+#else
+static double one=1.0, two=2.0, tiny = 1.0e-300;
+#endif
+
+#ifdef __STDC__
+ double tanh(double x)
+#else
+ double tanh(x)
+ double x;
+#endif
+{
+ double t,z;
+ int jx,ix;
+
+ /* High word of |x|. */
+ jx = __HI(x);
+ ix = jx&0x7fffffff;
+
+ /* x is INF or NaN */
+ if(ix>=0x7ff00000) {
+ if (jx>=0) return one/x+one; /* tanh(+-inf)=+-1 */
+ else return one/x-one; /* tanh(NaN) = NaN */
+ }
+
+ /* |x| < 22 */
+ if (ix < 0x40360000) { /* |x|<22 */
+ if (ix<0x3c800000) /* |x|<2**-55 */
+ return x*(one+x); /* tanh(small) = small */
+ if (ix>=0x3ff00000) { /* |x|>=1 */
+ t = expm1(two*fabs(x));
+ z = one - two/(t+two);
+ } else {
+ t = expm1(-two*fabs(x));
+ z= -t/(t+two);
+ }
+ /* |x| > 22, return +-1 */
+ } else {
+ z = one - tiny; /* raised inexact flag */
+ }
+ return (jx>=0)? z: -z;
+}
diff --git a/native/fdlibm/w_acos.c b/native/fdlibm/w_acos.c
index c9ca99c40..e463eaf9c 100644
--- a/native/fdlibm/w_acos.c
+++ b/native/fdlibm/w_acos.c
@@ -1,10 +1,10 @@
-/* @(#)w_acos.c 5.1 93/09/24 */
+/* @(#)w_acos.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
@@ -12,74 +12,11 @@
*/
/*
-FUNCTION
- <<acos>>, <<acosf>>---arc cosine
-
-INDEX
- acos
-INDEX
- acosf
-
-ANSI_SYNOPSIS
- #include <math.h>
- double acos(double <[x]>);
- float acosf(float <[x]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double acos(<[x]>)
- double <[x]>;
-
- float acosf(<[x]>)
- float <[x]>;
-
-
-
-DESCRIPTION
-
- <<acos>> computes the inverse cosine (arc cosine) of the input value.
- Arguments to <<acos>> must be in the range @minus{}1 to 1.
-
- <<acosf>> is identical to <<acos>>, except that it performs
- its calculations on <<floats>>.
-
-RETURNS
- @ifinfo
- <<acos>> and <<acosf>> return values in radians, in the range of 0 to pi.
- @end ifinfo
- @tex
- <<acos>> and <<acosf>> return values in radians, in the range of <<0>> to $\pi$.
- @end tex
-
- If <[x]> is not between @minus{}1 and 1, the returned value is NaN
- (not a number) the global variable <<errno>> is set to <<EDOM>>, and a
- <<DOMAIN error>> message is sent as standard error output.
-
- You can modify error handling for these functions using <<matherr>>.
-
-
-QUICKREF ANSI SVID POSIX RENTRANT
- acos y,y,y,m
- acosf n,n,n,m
-
-MATHREF
- acos, [-1,1], acos(arg),,,
- acos, NAN, arg,DOMAIN,EDOM
-
-MATHREF
- acosf, [-1,1], acosf(arg),,,
- acosf, NAN, argf,DOMAIN,EDOM
-
-*/
-
-/*
* wrap_acos(x)
*/
#include "fdlibm.h"
-#include <errno.h>
-#ifndef _DOUBLE_IS_32BITS
#ifdef __STDC__
double acos(double x) /* wrapper acos */
@@ -92,27 +29,11 @@ MATHREF
return __ieee754_acos(x);
#else
double z;
- struct exception exc;
- z = __ieee754_acos(x);
+ z = __ieee754_acos(x);
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
- if(fabs(x)>1.0) {
- /* acos(|x|>1) */
- exc.type = DOMAIN;
- exc.name = "acos";
- exc.err = 0;
- exc.arg1 = exc.arg2 = x;
- exc.retval = 0.0;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
+ if(fabs(x)>1.0) {
+ return __kernel_standard(x,x,1); /* acos(|x|>1) */
} else
return z;
#endif
}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/native/fdlibm/w_asin.c b/native/fdlibm/w_asin.c
index f6cb271d3..e8182857c 100644
--- a/native/fdlibm/w_asin.c
+++ b/native/fdlibm/w_asin.c
@@ -1,10 +1,10 @@
-/* @(#)w_asin.c 5.1 93/09/24 */
+/* @(#)w_asin.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
@@ -12,77 +12,13 @@
*
*/
-/*
-FUNCTION
- <<asin>>, <<asinf>>---arc sine
-
-INDEX
- asin
-INDEX
- asinf
-
-ANSI_SYNOPSIS
- #include <math.h>
- double asin(double <[x]>);
- float asinf(float <[x]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double asin(<[x]>)
- double <[x]>;
-
- float asinf(<[x]>)
- float <[x]>;
-
-
-DESCRIPTION
-
-<<asin>> computes the inverse sine (arc sine) of the argument <[x]>.
-Arguments to <<asin>> must be in the range @minus{}1 to 1.
-
-<<asinf>> is identical to <<asin>>, other than taking and
-returning floats.
-
-You can modify error handling for these routines using <<matherr>>.
-
-RETURNS
-@ifinfo
-<<asin>> returns values in radians, in the range of -pi/2 to pi/2.
-@end ifinfo
-@tex
-<<asin>> returns values in radians, in the range of $-\pi/2$ to $\pi/2$.
-@end tex
-
-If <[x]> is not in the range @minus{}1 to 1, <<asin>> and <<asinf>>
-return NaN (not a number), set the global variable <<errno>> to
-<<EDOM>>, and issue a <<DOMAIN error>> message.
-
-You can change this error treatment using <<matherr>>.
-
-QUICKREF ANSI SVID POSIX RENTRANT
- asin y,y,y,m
- asinf n,n,n,m
-
-MATHREF
- asin, -1<=arg<=1, asin(arg),,,
- asin, NAN, arg,EDOM, DOMAIN
-
-MATHREF
- asinf, -1<=arg<=1, asin(arg),,,
- asinf, NAN, arg,EDOM, DOMAIN
-
-
-*/
-
/*
* wrapper asin(x)
*/
#include "fdlibm.h"
-#include <errno.h>
-#ifndef _DOUBLE_IS_32BITS
#ifdef __STDC__
double asin(double x) /* wrapper asin */
@@ -95,27 +31,11 @@ MATHREF
return __ieee754_asin(x);
#else
double z;
- struct exception exc;
z = __ieee754_asin(x);
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
if(fabs(x)>1.0) {
- /* asin(|x|>1) */
- exc.type = DOMAIN;
- exc.name = "asin";
- exc.err = 0;
- exc.arg1 = exc.arg2 = x;
- exc.retval = 0.0;
- if(_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
+ return __kernel_standard(x,x,2); /* asin(|x|>1) */
} else
return z;
#endif
}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/native/fdlibm/w_atan2.c b/native/fdlibm/w_atan2.c
index 91742c72b..80ad39b35 100644
--- a/native/fdlibm/w_atan2.c
+++ b/native/fdlibm/w_atan2.c
@@ -1,10 +1,10 @@
-/* @(#)w_atan2.c 5.1 93/09/24 */
+/* @(#)w_atan2.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
@@ -12,72 +12,12 @@
*
*/
-/*
-FUNCTION
- <<atan2>>, <<atan2f>>---arc tangent of y/x
-
-INDEX
- atan2
-INDEX
- atan2f
-
-ANSI_SYNOPSIS
- #include <math.h>
- double atan2(double <[y]>,double <[x]>);
- float atan2f(float <[y]>,float <[x]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double atan2(<[y]>,<[x]>);
- double <[y]>;
- double <[x]>;
-
- float atan2f(<[y]>,<[x]>);
- float <[y]>;
- float <[x]>;
-
-DESCRIPTION
-
-<<atan2>> computes the inverse tangent (arc tangent) of <[y]>/<[x]>.
-<<atan2>> produces the correct result even for angles near
-@ifinfo
-pi/2 or -pi/2
-@end ifinfo
-@tex
-$\pi/2$ or $-\pi/2$
-@end tex
-(that is, when <[x]> is near 0).
-
-<<atan2f>> is identical to <<atan2>>, save that it takes and returns
-<<float>>.
-
-RETURNS
-<<atan2>> and <<atan2f>> return a value in radians, in the range of
-@ifinfo
--pi to pi.
-@end ifinfo
-@tex
-$-\pi$ to $\pi$.
-@end tex
-
-If both <[x]> and <[y]> are 0.0, <<atan2>> causes a <<DOMAIN>> error.
-
-You can modify error handling for these functions using <<matherr>>.
-
-PORTABILITY
-<<atan2>> is ANSI C. <<atan2f>> is an extension.
-
-
-*/
-
/*
* wrapper atan2(y,x)
*/
#include "fdlibm.h"
-#include <errno.h>
-#ifndef _DOUBLE_IS_32BITS
#ifdef __STDC__
double atan2(double y, double x) /* wrapper atan2 */
@@ -90,28 +30,11 @@ PORTABILITY
return __ieee754_atan2(y,x);
#else
double z;
- struct exception exc;
z = __ieee754_atan2(y,x);
if(_LIB_VERSION == _IEEE_||isnan(x)||isnan(y)) return z;
if(x==0.0&&y==0.0) {
- /* atan2(+-0,+-0) */
- exc.arg1 = y;
- exc.arg2 = x;
- exc.type = DOMAIN;
- exc.name = "atan2";
- exc.err = 0;
- exc.retval = 0.0;
- if(_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
+ return __kernel_standard(y,x,3); /* atan2(+-0,+-0) */
} else
return z;
#endif
}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/native/fdlibm/w_cosh.c b/native/fdlibm/w_cosh.c
new file mode 100644
index 000000000..1848726c9
--- /dev/null
+++ b/native/fdlibm/w_cosh.c
@@ -0,0 +1,38 @@
+
+/* @(#)w_cosh.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/*
+ * wrapper cosh(x)
+ */
+
+#include "fdlibm.h"
+
+#ifdef __STDC__
+ double cosh(double x) /* wrapper cosh */
+#else
+ double cosh(x) /* wrapper cosh */
+ double x;
+#endif
+{
+#ifdef _IEEE_LIBM
+ return __ieee754_cosh(x);
+#else
+ double z;
+ z = __ieee754_cosh(x);
+ if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
+ if(fabs(x)>7.10475860073943863426e+02) {
+ return __kernel_standard(x,x,5); /* cosh overflow */
+ } else
+ return z;
+#endif
+}
diff --git a/native/fdlibm/w_exp.c b/native/fdlibm/w_exp.c
index 45e087b45..7819ca133 100644
--- a/native/fdlibm/w_exp.c
+++ b/native/fdlibm/w_exp.c
@@ -1,71 +1,20 @@
-/* @(#)w_exp.c 5.1 93/09/24 */
+/* @(#)w_exp.c 1.4 04/04/22 */
/*
* ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
-/*
-FUNCTION
- <<exp>>, <<expf>>---exponential
-INDEX
- exp
-INDEX
- expf
-
-ANSI_SYNOPSIS
- #include <math.h>
- double exp(double <[x]>);
- float expf(float <[x]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double exp(<[x]>);
- double <[x]>;
-
- float expf(<[x]>);
- float <[x]>;
-
-DESCRIPTION
- <<exp>> and <<expf>> calculate the exponential of <[x]>, that is,
- @ifinfo
- e raised to the power <[x]> (where e
- @end ifinfo
- @tex
- $e^x$ (where $e$
- @end tex
- is the base of the natural system of logarithms, approximately 2.71828).
-
- You can use the (non-ANSI) function <<matherr>> to specify
- error handling for these functions.
-
-RETURNS
- On success, <<exp>> and <<expf>> return the calculated value.
- If the result underflows, the returned value is <<0>>. If the
- result overflows, the returned value is <<HUGE_VAL>>. In
- either case, <<errno>> is set to <<ERANGE>>.
-
-PORTABILITY
- <<exp>> is ANSI C. <<expf>> is an extension.
-
-*/
-
/*
* wrapper exp(x)
*/
#include "fdlibm.h"
-#include <errno.h>
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifndef _IEEE_LIBM
#ifdef __STDC__
static const double
@@ -75,8 +24,6 @@ static double
o_threshold= 7.09782712893383973096e+02, /* 0x40862E42, 0xFEFA39EF */
u_threshold= -7.45133219101941108420e+02; /* 0xc0874910, 0xD52D3051 */
-#endif
-
#ifdef __STDC__
double exp(double x) /* wrapper exp */
#else
@@ -88,53 +35,14 @@ u_threshold= -7.45133219101941108420e+02; /* 0xc0874910, 0xD52D3051 */
return __ieee754_exp(x);
#else
double z;
- struct exception exc;
z = __ieee754_exp(x);
if(_LIB_VERSION == _IEEE_) return z;
if(finite(x)) {
- if(x>o_threshold) {
- /* exp(finite) overflow */
-#ifndef HUGE_VAL
-#define HUGE_VAL inf
- double inf = 0.0;
-
- SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */
-#endif
- exc.type = OVERFLOW;
- exc.name = "exp";
- exc.err = 0;
- exc.arg1 = exc.arg2 = x;
- if (_LIB_VERSION == _SVID_)
- exc.retval = HUGE;
- else
- exc.retval = HUGE_VAL;
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- errno = ERANGE;
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
- } else if(x<u_threshold) {
- /* exp(finite) underflow */
- exc.type = UNDERFLOW;
- exc.name = "exp";
- exc.err = 0;
- exc.arg1 = exc.arg2 = x;
- exc.retval = 0.0;
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- errno = ERANGE;
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
- }
+ if(x>o_threshold)
+ return __kernel_standard(x,x,6); /* exp overflow */
+ else if(x<u_threshold)
+ return __kernel_standard(x,x,7); /* exp underflow */
}
return z;
#endif
}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/native/fdlibm/w_fmod.c b/native/fdlibm/w_fmod.c
index b6b36cb76..9d9f3a89e 100644
--- a/native/fdlibm/w_fmod.c
+++ b/native/fdlibm/w_fmod.c
@@ -1,10 +1,10 @@
-/* @(#)w_fmod.c 5.1 93/09/24 */
+/* @(#)w_fmod.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
@@ -12,59 +12,11 @@
*/
/*
-FUNCTION
-<<fmod>>, <<fmodf>>---floating-point remainder (modulo)
-
-INDEX
-fmod
-INDEX
-fmodf
-
-ANSI_SYNOPSIS
-#include <math.h>
-double fmod(double <[x]>, double <[y]>)
-float fmodf(float <[x]>, float <[y]>)
-
-TRAD_SYNOPSIS
-#include <math.h>
-double fmod(<[x]>, <[y]>)
-double (<[x]>, <[y]>);
-
-float fmodf(<[x]>, <[y]>)
-float (<[x]>, <[y]>);
-
-DESCRIPTION
-The <<fmod>> and <<fmodf>> functions compute the floating-point
-remainder of <[x]>/<[y]> (<[x]> modulo <[y]>).
-
-RETURNS
-The <<fmod>> function returns the value
-@ifinfo
-<[x]>-<[i]>*<[y]>,
-@end ifinfo
-@tex
-$x-i\times y$,
-@end tex
-for the largest integer <[i]> such that, if <[y]> is nonzero, the
-result has the same sign as <[x]> and magnitude less than the
-magnitude of <[y]>.
-
-<<fmod(<[x]>,0)>> returns NaN, and sets <<errno>> to <<EDOM>>.
-
-You can modify error treatment for these functions using <<matherr>>.
-
-PORTABILITY
-<<fmod>> is ANSI C. <<fmodf>> is an extension.
-*/
-
-/*
* wrapper fmod(x,y)
*/
#include "fdlibm.h"
-#include <errno.h>
-#ifndef _DOUBLE_IS_32BITS
#ifdef __STDC__
double fmod(double x, double y) /* wrapper fmod */
@@ -77,31 +29,11 @@ PORTABILITY
return __ieee754_fmod(x,y);
#else
double z;
- struct exception exc;
z = __ieee754_fmod(x,y);
if(_LIB_VERSION == _IEEE_ ||isnan(y)||isnan(x)) return z;
if(y==0.0) {
- /* fmod(x,0) */
- exc.type = DOMAIN;
- exc.name = "fmod";
- exc.arg1 = x;
- exc.arg2 = y;
- exc.err = 0;
- if (_LIB_VERSION == _SVID_)
- exc.retval = x;
- else
- exc.retval = 0.0/0.0;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
+ return __kernel_standard(x,y,27); /* fmod(x,0) */
} else
return z;
#endif
}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/native/fdlibm/w_hypot.c b/native/fdlibm/w_hypot.c
new file mode 100644
index 000000000..64d053291
--- /dev/null
+++ b/native/fdlibm/w_hypot.c
@@ -0,0 +1,39 @@
+
+/* @(#)w_hypot.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/*
+ * wrapper hypot(x,y)
+ */
+
+#include "fdlibm.h"
+
+
+#ifdef __STDC__
+ double hypot(double x, double y)/* wrapper hypot */
+#else
+ double hypot(x,y) /* wrapper hypot */
+ double x,y;
+#endif
+{
+#ifdef _IEEE_LIBM
+ return __ieee754_hypot(x,y);
+#else
+ double z;
+ z = __ieee754_hypot(x,y);
+ if(_LIB_VERSION == _IEEE_) return z;
+ if((!finite(z))&&finite(x)&&finite(y))
+ return __kernel_standard(x,y,4); /* hypot overflow */
+ else
+ return z;
+#endif
+}
diff --git a/native/fdlibm/w_log.c b/native/fdlibm/w_log.c
index dcc8b9762..0eb8f0b8c 100644
--- a/native/fdlibm/w_log.c
+++ b/native/fdlibm/w_log.c
@@ -1,10 +1,10 @@
-/* @(#)w_log.c 5.1 93/09/24 */
+/* @(#)w_log.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
@@ -12,54 +12,11 @@
*/
/*
-FUNCTION
- <<log>>, <<logf>>---natural logarithms
-
-INDEX
- log
-INDEX
- logf
-
-ANSI_SYNOPSIS
- #include <math.h>
- double log(double <[x]>);
- float logf(float <[x]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double log(<[x]>);
- double <[x]>;
-
- float logf(<[x]>);
- float <[x]>;
-
-DESCRIPTION
-Return the natural logarithm of <[x]>, that is, its logarithm base e
-(where e is the base of the natural system of logarithms, 2.71828@dots{}).
-<<log>> and <<logf>> are identical save for the return and argument types.
-
-You can use the (non-ANSI) function <<matherr>> to specify error
-handling for these functions.
-
-RETURNS
-Normally, returns the calculated value. When <[x]> is zero, the
-returned value is <<-HUGE_VAL>> and <<errno>> is set to <<ERANGE>>.
-When <[x]> is negative, the returned value is <<-HUGE_VAL>> and
-<<errno>> is set to <<EDOM>>. You can control the error behavior via
-<<matherr>>.
-
-PORTABILITY
-<<log>> is ANSI, <<logf>> is an extension.
-*/
-
-/*
* wrapper log(x)
*/
#include "fdlibm.h"
-#include <errno.h>
-#ifndef _DOUBLE_IS_32BITS
#ifdef __STDC__
double log(double x) /* wrapper log */
@@ -72,44 +29,11 @@ PORTABILITY
return __ieee754_log(x);
#else
double z;
- struct exception exc;
z = __ieee754_log(x);
if(_LIB_VERSION == _IEEE_ || isnan(x) || x > 0.0) return z;
-#ifndef HUGE_VAL
-#define HUGE_VAL inf
- double inf = 0.0;
-
- SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */
-#endif
- exc.name = "log";
- exc.err = 0;
- exc.arg1 = x;
- exc.arg2 = x;
- if (_LIB_VERSION == _SVID_)
- exc.retval = -HUGE;
- else
- exc.retval = -HUGE_VAL;
- if(x==0.0) {
- /* log(0) */
- exc.type = SING;
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- } else {
- /* log(x<0) */
- exc.type = DOMAIN;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
+ if(x==0.0)
+ return __kernel_standard(x,x,16); /* log(0) */
+ else
+ return __kernel_standard(x,x,17); /* log(x<0) */
#endif
}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/native/fdlibm/w_log10.c b/native/fdlibm/w_log10.c
new file mode 100644
index 000000000..2bdebc79a
--- /dev/null
+++ b/native/fdlibm/w_log10.c
@@ -0,0 +1,42 @@
+
+/* @(#)w_log10.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/*
+ * wrapper log10(X)
+ */
+
+#include "fdlibm.h"
+
+
+#ifdef __STDC__
+ double log10(double x) /* wrapper log10 */
+#else
+ double log10(x) /* wrapper log10 */
+ double x;
+#endif
+{
+#ifdef _IEEE_LIBM
+ return __ieee754_log10(x);
+#else
+ double z;
+ z = __ieee754_log10(x);
+ if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
+ if(x<=0.0) {
+ if(x==0.0)
+ return __kernel_standard(x,x,18); /* log10(0) */
+ else
+ return __kernel_standard(x,x,19); /* log10(x<0) */
+ } else
+ return z;
+#endif
+}
diff --git a/native/fdlibm/w_pow.c b/native/fdlibm/w_pow.c
index 3df099a17..850c1162b 100644
--- a/native/fdlibm/w_pow.c
+++ b/native/fdlibm/w_pow.c
@@ -1,68 +1,23 @@
-/* @(#)w_pow.c 5.2 93/10/01 */
+/* @(#)w_pow.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
-/*
-FUNCTION
- <<pow>>, <<powf>>---x to the power y
-INDEX
- pow
-INDEX
- powf
-
-
-ANSI_SYNOPSIS
- #include <math.h>
- double pow(double <[x]>, double <[y]>);
- float pow(float <[x]>, float <[y]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double pow(<[x]>, <[y]>);
- double <[x]>, <[y]>;
-
- float pow(<[x]>, <[y]>);
- float <[x]>, <[y]>;
-
-DESCRIPTION
- <<pow>> and <<powf>> calculate <[x]> raised to the exp1.0nt <[y]>.
- @tex
- (That is, $x^y$.)
- @end tex
-
-RETURNS
- On success, <<pow>> and <<powf>> return the value calculated.
-
- When the argument values would produce overflow, <<pow>>
- returns <<HUGE_VAL>> and set <<errno>> to <<ERANGE>>. If the
- argument <[x]> passed to <<pow>> or <<powf>> is a negative
- noninteger, and <[y]> is also not an integer, then <<errno>>
- is set to <<EDOM>>. If <[x]> and <[y]> are both 0, then
- <<pow>> and <<powf>> return <<1>>.
-
- You can modify error handling for these functions using <<matherr>>.
-
-PORTABILITY
- <<pow>> is ANSI C. <<powf>> is an extension. */
-
/*
* wrapper pow(x,y) return x**y
*/
#include "fdlibm.h"
-#include <errno.h>
-#ifndef _DOUBLE_IS_32BITS
#ifdef __STDC__
double pow(double x, double y) /* wrapper pow */
@@ -75,157 +30,31 @@ PORTABILITY
return __ieee754_pow(x,y);
#else
double z;
-#ifndef HUGE_VAL
-#define HUGE_VAL inf
- double inf = 0.0;
-
- SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */
-#endif
- struct exception exc;
z=__ieee754_pow(x,y);
if(_LIB_VERSION == _IEEE_|| isnan(y)) return z;
if(isnan(x)) {
- if(y==0.0) {
- /* pow(NaN,0.0) */
- /* error only if _LIB_VERSION == _SVID_ & _XOPEN_ */
- exc.type = DOMAIN;
- exc.name = "pow";
- exc.err = 0;
- exc.arg1 = x;
- exc.arg2 = y;
- exc.retval = x;
- if (_LIB_VERSION == _IEEE_ ||
- _LIB_VERSION == _POSIX_) exc.retval = 1.0;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
- } else
+ if(y==0.0)
+ return __kernel_standard(x,y,42); /* pow(NaN,0.0) */
+ else
return z;
}
if(x==0.0){
- if(y==0.0) {
- /* pow(0.0,0.0) */
- /* error only if _LIB_VERSION == _SVID_ */
- exc.type = DOMAIN;
- exc.name = "pow";
- exc.err = 0;
- exc.arg1 = x;
- exc.arg2 = y;
- exc.retval = 0.0;
- if (_LIB_VERSION != _SVID_) exc.retval = 1.0;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
- }
- if(finite(y)&&y<0.0) {
- /* 0**neg */
- exc.type = DOMAIN;
- exc.name = "pow";
- exc.err = 0;
- exc.arg1 = x;
- exc.arg2 = y;
- if (_LIB_VERSION == _SVID_)
- exc.retval = 0.0;
- else
- exc.retval = -HUGE_VAL;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
- }
+ if(y==0.0)
+ return __kernel_standard(x,y,20); /* pow(0.0,0.0) */
+ if(finite(y)&&y<0.0)
+ return __kernel_standard(x,y,23); /* pow(0.0,negative) */
return z;
}
if(!finite(z)) {
if(finite(x)&&finite(y)) {
- if(isnan(z)) {
- /* neg**non-integral */
- exc.type = DOMAIN;
- exc.name = "pow";
- exc.err = 0;
- exc.arg1 = x;
- exc.arg2 = y;
- if (_LIB_VERSION == _SVID_)
- exc.retval = 0.0;
- else
- exc.retval = 0.0/0.0; /* X/Open allow NaN */
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
- } else {
- /* pow(x,y) overflow */
- exc.type = OVERFLOW;
- exc.name = "pow";
- exc.err = 0;
- exc.arg1 = x;
- exc.arg2 = y;
- if (_LIB_VERSION == _SVID_) {
- exc.retval = HUGE;
- y *= 0.5;
- if(x<0.0&&rint(y)!=y) exc.retval = -HUGE;
- } else {
- exc.retval = HUGE_VAL;
- y *= 0.5;
- if(x<0.0&&rint(y)!=y) exc.retval = -HUGE_VAL;
- }
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- errno = ERANGE;
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
- }
+ if(isnan(z))
+ return __kernel_standard(x,y,24); /* pow neg**non-int */
+ else
+ return __kernel_standard(x,y,21); /* pow overflow */
}
}
- if(z==0.0&&finite(x)&&finite(y)) {
- /* pow(x,y) underflow */
- exc.type = UNDERFLOW;
- exc.name = "pow";
- exc.err = 0;
- exc.arg1 = x;
- exc.arg2 = y;
- exc.retval = 0.0;
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- errno = ERANGE;
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
- }
+ if(z==0.0&&finite(x)&&finite(y))
+ return __kernel_standard(x,y,22); /* pow underflow */
return z;
#endif
}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/native/fdlibm/w_remainder.c b/native/fdlibm/w_remainder.c
index a06be0e7b..8e65c207e 100644
--- a/native/fdlibm/w_remainder.c
+++ b/native/fdlibm/w_remainder.c
@@ -1,68 +1,21 @@
-/* @(#)w_remainder.c 5.1 93/09/24 */
+/* @(#)w_remainder.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
-/*
-FUNCTION
-<<rint>>, <<rintf>>, <<remainder>>, <<remainderf>>---round and remainder
-INDEX
- rint
-INDEX
- rintf
-INDEX
- remainder
-INDEX
- remainderf
-
-ANSI_SYNOPSIS
- #include <math.h>
- double rint(double <[x]>);
- float rintf(float <[x]>);
- double remainder(double <[x]>, double <[y]>);
- float remainderf(float <[x]>, float <[y]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double rint(<[x]>)
- double <[x]>;
- float rintf(<[x]>)
- float <[x]>;
- double remainder(<[x]>,<[y]>)
- double <[x]>, <[y]>;
- float remainderf(<[x]>,<[y]>)
- float <[x]>, <[y]>;
-
-DESCRIPTION
-<<rint>> and <<rintf>> returns their argument rounded to the nearest
-integer. <<remainder>> and <<remainderf>> find the remainder of
-<[x]>/<[y]>; this value is in the range -<[y]>/2 .. +<[y]>/2.
-
-RETURNS
-<<rint>> and <<remainder>> return the integer result as a double.
-
-PORTABILITY
-<<rint>> and <<remainder>> are System V release 4. <<rintf>> and
-<<remainderf>> are extensions.
-
-*/
-
/*
* wrapper remainder(x,p)
*/
#include "fdlibm.h"
-#include <errno.h>
-
-#ifndef _DOUBLE_IS_32BITS
#ifdef __STDC__
double remainder(double x, double y) /* wrapper remainder */
@@ -75,45 +28,11 @@ PORTABILITY
return __ieee754_remainder(x,y);
#else
double z;
- struct exception exc;
z = __ieee754_remainder(x,y);
if(_LIB_VERSION == _IEEE_ || isnan(y)) return z;
- if(y==0.0) {
- /* remainder(x,0) */
- exc.type = DOMAIN;
- exc.name = "remainder";
- exc.err = 0;
- exc.arg1 = x;
- exc.arg2 = y;
- exc.retval = 0.0/0.0;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
- } else
+ if(y==0.0)
+ return __kernel_standard(x,y,28); /* remainder(x,0) */
+ else
return z;
#endif
}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/native/fdlibm/w_sinh.c b/native/fdlibm/w_sinh.c
new file mode 100644
index 000000000..f328ddec9
--- /dev/null
+++ b/native/fdlibm/w_sinh.c
@@ -0,0 +1,38 @@
+
+/* @(#)w_sinh.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/*
+ * wrapper sinh(x)
+ */
+
+#include "fdlibm.h"
+
+#ifdef __STDC__
+ double sinh(double x) /* wrapper sinh */
+#else
+ double sinh(x) /* wrapper sinh */
+ double x;
+#endif
+{
+#ifdef _IEEE_LIBM
+ return __ieee754_sinh(x);
+#else
+ double z;
+ z = __ieee754_sinh(x);
+ if(_LIB_VERSION == _IEEE_) return z;
+ if(!finite(z)&&finite(x)) {
+ return __kernel_standard(x,x,25); /* sinh overflow */
+ } else
+ return z;
+#endif
+}
diff --git a/native/fdlibm/w_sqrt.c b/native/fdlibm/w_sqrt.c
index 23a793ce7..4dd589e25 100644
--- a/native/fdlibm/w_sqrt.c
+++ b/native/fdlibm/w_sqrt.c
@@ -1,58 +1,21 @@
-/* @(#)w_sqrt.c 5.1 93/09/24 */
+/* @(#)w_sqrt.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
- * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
-/*
-FUNCTION
- <<sqrt>>, <<sqrtf>>---positive square root
-
-INDEX
- sqrt
-INDEX
- sqrtf
-
-ANSI_SYNOPSIS
- #include <math.h>
- double sqrt(double <[x]>);
- float sqrtf(float <[x]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double sqrt(<[x]>);
- float sqrtf(<[x]>);
-
-DESCRIPTION
- <<sqrt>> computes the positive square root of the argument.
- You can modify error handling for this function with
- <<matherr>>.
-
-RETURNS
- On success, the square root is returned. If <[x]> is real and
- positive, then the result is positive. If <[x]> is real and
- negative, the global value <<errno>> is set to <<EDOM>> (domain error).
-
-
-PORTABILITY
- <<sqrt>> is ANSI C. <<sqrtf>> is an extension.
-*/
-
/*
* wrapper sqrt(x)
*/
#include "fdlibm.h"
-#include <errno.h>
-
-#ifndef _DOUBLE_IS_32BITS
#ifdef __STDC__
double sqrt(double x) /* wrapper sqrt */
@@ -64,30 +27,12 @@ PORTABILITY
#ifdef _IEEE_LIBM
return __ieee754_sqrt(x);
#else
- struct exception exc;
double z;
z = __ieee754_sqrt(x);
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
if(x<0.0) {
- exc.type = DOMAIN;
- exc.name = "sqrt";
- exc.err = 0;
- exc.arg1 = exc.arg2 = x;
- if (_LIB_VERSION == _SVID_)
- exc.retval = 0.0;
- else
- exc.retval = 0.0/0.0;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
+ return __kernel_standard(x,x,26); /* sqrt(negative) */
} else
return z;
#endif
}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
index 092e997a3..c95ea614b 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
@@ -1,5 +1,5 @@
/* gnu_java_awt_peer_gtk_GdkGraphics2d.c
- Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,6 +35,7 @@
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+#include "jcl.h"
#include "gtkcairopeer.h"
#include "gdkfont.h"
#include "gnu_java_awt_peer_gtk_GdkGraphics2D.h"
@@ -261,7 +262,14 @@ init_graphics2d_as_renderable (struct graphics2d *gr)
static void
begin_drawing_operation (JNIEnv *env, struct graphics2d * gr)
{
- g_assert(cairo_status (gr->cr) == CAIRO_STATUS_SUCCESS);
+ cairo_status_t cst = cairo_status (gr->cr);
+ if (cst != CAIRO_STATUS_SUCCESS)
+ {
+ const char *detail = cairo_status_to_string (cst);
+ JCL_ThrowException (env, "java/lang/InternalError", detail);
+ (*env)->ExceptionDescribe (env);
+ return;
+ }
switch (gr->mode)
{
@@ -312,7 +320,19 @@ begin_drawing_operation (JNIEnv *env, struct graphics2d * gr)
static void
end_drawing_operation (JNIEnv *env, struct graphics2d * gr)
{
- g_assert(cairo_status (gr->cr) == CAIRO_STATUS_SUCCESS);
+ cairo_status_t cst = cairo_status (gr->cr);
+ if (cst != CAIRO_STATUS_SUCCESS)
+ {
+ /* Report error. */
+ const char *detail = cairo_status_to_string (cst);
+ JCL_ThrowException (env, "java/lang/InternalError", detail);
+ (*env)->ExceptionDescribe (env);
+
+ /* Recreate cairo status. */
+ cairo_destroy (gr->cr);
+ gr->cr = cairo_create (gr->surface);
+ return;
+ }
switch (gr->mode)
{
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
index b74b0a265..297b4f853 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
@@ -1,5 +1,6 @@
/* gtkcheckboxpeer.c -- Native implementation of GtkCheckboxPeer
- Copyright (C) 1998, 1999, 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2002, 2003, 2004, 2006
+ Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -52,7 +53,7 @@ cp_gtk_checkbox_init_jni (void)
postItemEventID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gtkcheckboxpeer,
"postItemEvent",
- "(Ljava/lang/Object;I)V");
+ "(Ljava/lang/Object;Z)V");
}
static void item_toggled_cb (GtkToggleButton *item, jobject peer);
@@ -230,7 +231,5 @@ item_toggled_cb (GtkToggleButton *item, jobject peer)
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postItemEventID,
peer,
- item->active ?
- (jint) AWT_ITEM_SELECTED :
- (jint) AWT_ITEM_DESELECTED);
+ item->active);
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer.c
index 563a0257e..ca765c15c 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer.c
@@ -1,6 +1,6 @@
/* gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer.c -- Native
implementation of GtkEmbeddedWindowPeer
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -53,6 +53,8 @@ Java_gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer_create
window = gtk_plug_new ((GdkNativeWindow) socket_id);
+ gtk_window_set_decorated (GTK_WINDOW (window), FALSE);
+
fixed = gtk_fixed_new ();
gtk_container_add (GTK_CONTAINER (window), fixed);
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c
index a5c0074c0..1a21126a8 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c
@@ -1,5 +1,5 @@
/* gtkmenubarpeer.c -- Native implementation of GtkMenuBarPeer
- Copyright (C) 1999 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -74,32 +74,6 @@ Java_gnu_java_awt_peer_gtk_GtkMenuBarPeer_addMenu
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GtkMenuBarPeer_nativeSetHelpMenu
- (JNIEnv *env, jobject obj, jobject menupeer)
-{
- static void *helpmenu;
- void *mbar, *menu;
- GList *list;
-
- gdk_threads_enter ();
-
- mbar = NSA_GET_PTR (env, obj);
- menu = NSA_GET_PTR (env, menupeer);
-
- if (helpmenu != NULL)
- {
- list = gtk_container_get_children (GTK_CONTAINER (mbar));
- while (list != NULL && list->data != helpmenu)
- list = list->next;
- if (list != NULL && list->data == helpmenu)
- gtk_container_remove (GTK_CONTAINER (mbar), GTK_WIDGET (list->data));
- }
- helpmenu = menu;
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkMenuBarPeer_delMenu
(JNIEnv *env, jobject obj, jint index)
{
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollbarPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollbarPeer.c
index 396862710..bec1e63c4 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollbarPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollbarPeer.c
@@ -1,5 +1,5 @@
/* gtkscrollbarpeer.c -- Native implementation of GtkScrollbarPeer
- Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -86,6 +86,14 @@ Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_create
gdk_threads_enter ();
+ /* A little hack because gtk_range_set_range() doesn't allow min == max. */
+ if (min == max)
+ {
+ if (visible_amount == 0)
+ visible_amount = 1;
+ max++;
+ }
+
adj = gtk_adjustment_new ((gdouble) value,
(gdouble) min,
(gdouble) max,
@@ -171,7 +179,7 @@ Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_setPageIncrement
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_setValues
+Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_setBarValues
(JNIEnv *env, jobject obj, jint value, jint visible, jint min, jint max)
{
void *ptr;
@@ -181,6 +189,14 @@ Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_setValues
gdk_threads_enter ();
+ /* A little hack because gtk_range_set_range() doesn't allow min == max. */
+ if (min == max)
+ {
+ if (visible == 0)
+ visible = 1;
+ max++;
+ }
+
adj = gtk_range_get_adjustment (GTK_RANGE (ptr));
adj->page_size = (gdouble) visible;
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c
index 0ddab05c3..30b4a0fda 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c
@@ -224,39 +224,6 @@ Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_setEchoChar
gdk_threads_leave ();
}
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_gtkWidgetModifyFont
- (JNIEnv *env, jobject obj, jstring name, jint style, jint size)
-{
- const char *font_name;
- void *ptr;
- PangoFontDescription *font_desc;
-
- gdk_threads_enter();
-
- ptr = NSA_GET_PTR (env, obj);
-
- font_name = (*env)->GetStringUTFChars (env, name, NULL);
-
- font_desc = pango_font_description_from_string (font_name);
- pango_font_description_set_size (font_desc,
- size * cp_gtk_dpi_conversion_factor);
-
- if (style & AWT_STYLE_BOLD)
- pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
-
- if (style & AWT_STYLE_ITALIC)
- pango_font_description_set_style (font_desc, PANGO_STYLE_OBLIQUE);
-
- gtk_widget_modify_font (GTK_WIDGET (ptr), font_desc);
-
- pango_font_description_free (font_desc);
-
- (*env)->ReleaseStringUTFChars (env, name, font_name);
-
- gdk_threads_leave();
-}
-
JNIEXPORT jint JNICALL
Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_getCaretPosition
(JNIEnv *env, jobject obj)
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
index ac8f6a8ff..a3cea8c4a 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
@@ -1,5 +1,6 @@
/* gtkwindowpeer.c -- Native implementation of GtkWindowPeer
- Copyright (C) 1998, 1999, 2002, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2002, 2004, 2005, 2006
+ Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -1393,6 +1394,32 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetBounds
}
JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetLocationUnlocked
+ (JNIEnv *env, jobject obj, jint x, jint y)
+{
+ void *ptr;
+
+ ptr = NSA_GET_PTR (env, obj);
+
+ gtk_window_move (GTK_WINDOW(ptr), x, y);
+
+ if (GTK_WIDGET (ptr)->window != NULL)
+ gdk_window_move (GTK_WIDGET (ptr)->window, x, y);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetLocation
+ (JNIEnv *env, jobject obj, jint x, jint y)
+{
+ gdk_threads_enter ();
+
+ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetLocationUnlocked
+ (env, obj, x, y);
+
+ gdk_threads_leave ();
+}
+
+JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetBoundsUnlocked
(JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
{
@@ -1437,21 +1464,21 @@ window_get_frame_extents (GtkWidget *window,
/* Guess frame extents in case _NET_FRAME_EXTENTS is not
supported. */
- if (gtk_window_get_decorated (GTK_WINDOW (window)))
- {
- *top = 23;
- *left = 6;
- *bottom = 6;
- *right = 6;
- }
- else
+ if (!gtk_window_get_decorated (GTK_WINDOW (window)))
{
*top = 0;
*left = 0;
*bottom = 0;
*right = 0;
+
+ return;
}
+ *top = 23;
+ *left = 6;
+ *bottom = 6;
+ *right = 6;
+
/* Request that the window manager set window's
_NET_FRAME_EXTENTS property. */
request_frame_extents (window);
diff --git a/native/jni/java-lang/Makefile.am b/native/jni/java-lang/Makefile.am
index fb8390f08..db8a3a6a4 100644
--- a/native/jni/java-lang/Makefile.am
+++ b/native/jni/java-lang/Makefile.am
@@ -3,7 +3,7 @@ nativelib_LTLIBRARIES = libjavalang.la libjavalangreflect.la
libjavalang_la_SOURCES = java_lang_VMSystem.c \
java_lang_VMFloat.c \
java_lang_VMDouble.c \
- java_lang_Math.c \
+ java_lang_VMMath.c \
java_lang_VMProcess.c
libjavalang_la_LIBADD = $(wildcard $(top_builddir)/native/fdlibm/*.lo) \
diff --git a/native/jni/java-lang/java_lang_VMDouble.c b/native/jni/java-lang/java_lang_VMDouble.c
index 076f42b86..8435c3fdb 100644
--- a/native/jni/java-lang/java_lang_VMDouble.c
+++ b/native/jni/java-lang/java_lang_VMDouble.c
@@ -1,5 +1,5 @@
/* VMDouble.c - java.lang.VMDouble native functions
- Copyright (C) 1998, 1999, 2001, 2003, 2004i, 2005
+ Copyright (C) 1998, 1999, 2001, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -123,6 +123,16 @@ Java_java_lang_VMDouble_doubleToLongBits
jlong e, f;
val.d = doubleValue;
+#if defined(__IEEE_BYTES_LITTLE_ENDIAN)
+ /* On little endian ARM processors when using FPA, word order of
+ doubles is still big endian. So take that into account here. When
+ using VFP, word order of doubles follows byte order. */
+
+#define SWAP_DOUBLE(a) (((a) << 32) | (((a) >> 32) & 0x00000000ffffffff))
+
+ val.j = SWAP_DOUBLE(val.j);
+#endif
+
e = val.j & 0x7ff0000000000000LL;
f = val.j & 0x000fffffffffffffLL;
@@ -144,6 +154,11 @@ Java_java_lang_VMDouble_doubleToRawLongBits
{
jvalue val;
val.d = doubleValue;
+
+#if defined(__IEEE_BYTES_LITTLE_ENDIAN)
+ val.j = SWAP_DOUBLE(val.j);
+#endif
+
return val.j;
}
@@ -159,6 +174,11 @@ Java_java_lang_VMDouble_longBitsToDouble
{
jvalue val;
val.j = longValue;
+
+#if defined(__IEEE_BYTES_LITTLE_ENDIAN)
+ val.j = SWAP_DOUBLE(val.j);
+#endif
+
return val.d;
}
diff --git a/native/jni/java-lang/java_lang_Math.c b/native/jni/java-lang/java_lang_VMMath.c
index b4b88a775..de7851f9b 100644
--- a/native/jni/java-lang/java_lang_Math.c
+++ b/native/jni/java-lang/java_lang_VMMath.c
@@ -1,5 +1,5 @@
-/* Math.c - java.lang.Math native functions
- Copyright (C) 1998, 1999, 2004 Free Software Foundation, Inc.
+/* VMMath.c - java.lang.VMMath native functions
+ Copyright (C) 1998, 1999, 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,11 +37,11 @@ exception statement from your version. */
#include <config.h>
-#include <java_lang_Math.h>
+#include <java_lang_VMMath.h>
#include <fdlibm.h>
JNIEXPORT jdouble JNICALL
-Java_java_lang_Math_sin
+Java_java_lang_VMMath_sin
(JNIEnv * env __attribute__ ((__unused__)),
jclass cls __attribute__ ((__unused__)), jdouble x)
{
@@ -49,7 +49,7 @@ Java_java_lang_Math_sin
}
JNIEXPORT jdouble JNICALL
-Java_java_lang_Math_cos
+Java_java_lang_VMMath_cos
(JNIEnv * env __attribute__ ((__unused__)),
jclass cls __attribute__ ((__unused__)), jdouble x)
{
@@ -57,7 +57,7 @@ Java_java_lang_Math_cos
}
JNIEXPORT jdouble JNICALL
-Java_java_lang_Math_tan
+Java_java_lang_VMMath_tan
(JNIEnv * env __attribute__ ((__unused__)),
jclass cls __attribute__ ((__unused__)), jdouble x)
{
@@ -65,7 +65,7 @@ Java_java_lang_Math_tan
}
JNIEXPORT jdouble JNICALL
-Java_java_lang_Math_asin
+Java_java_lang_VMMath_asin
(JNIEnv * env __attribute__ ((__unused__)),
jclass cls __attribute__ ((__unused__)), jdouble x)
{
@@ -73,7 +73,7 @@ Java_java_lang_Math_asin
}
JNIEXPORT jdouble JNICALL
-Java_java_lang_Math_acos
+Java_java_lang_VMMath_acos
(JNIEnv * env __attribute__ ((__unused__)),
jclass cls __attribute__ ((__unused__)), jdouble x)
{
@@ -81,7 +81,7 @@ Java_java_lang_Math_acos
}
JNIEXPORT jdouble JNICALL
-Java_java_lang_Math_atan
+Java_java_lang_VMMath_atan
(JNIEnv * env __attribute__ ((__unused__)),
jclass cls __attribute__ ((__unused__)), jdouble x)
{
@@ -89,7 +89,7 @@ Java_java_lang_Math_atan
}
JNIEXPORT jdouble JNICALL
-Java_java_lang_Math_atan2
+Java_java_lang_VMMath_atan2
(JNIEnv * env __attribute__ ((__unused__)),
jclass cls __attribute__ ((__unused__)), jdouble y, jdouble x)
{
@@ -97,7 +97,7 @@ Java_java_lang_Math_atan2
}
JNIEXPORT jdouble JNICALL
-Java_java_lang_Math_exp
+Java_java_lang_VMMath_exp
(JNIEnv * env __attribute__ ((__unused__)),
jclass cls __attribute__ ((__unused__)), jdouble x)
{
@@ -105,7 +105,7 @@ Java_java_lang_Math_exp
}
JNIEXPORT jdouble JNICALL
-Java_java_lang_Math_log
+Java_java_lang_VMMath_log
(JNIEnv * env __attribute__ ((__unused__)),
jclass cls __attribute__ ((__unused__)), jdouble x)
{
@@ -113,7 +113,7 @@ Java_java_lang_Math_log
}
JNIEXPORT jdouble JNICALL
-Java_java_lang_Math_sqrt
+Java_java_lang_VMMath_sqrt
(JNIEnv * env __attribute__ ((__unused__)),
jclass cls __attribute__ ((__unused__)), jdouble x)
{
@@ -121,7 +121,7 @@ Java_java_lang_Math_sqrt
}
JNIEXPORT jdouble JNICALL
-Java_java_lang_Math_pow
+Java_java_lang_VMMath_pow
(JNIEnv * env __attribute__ ((__unused__)),
jclass cls __attribute__ ((__unused__)), jdouble x, jdouble y)
{
@@ -129,7 +129,7 @@ Java_java_lang_Math_pow
}
JNIEXPORT jdouble JNICALL
-Java_java_lang_Math_IEEEremainder
+Java_java_lang_VMMath_IEEEremainder
(JNIEnv * env __attribute__ ((__unused__)),
jclass cls __attribute__ ((__unused__)), jdouble x, jdouble y)
{
@@ -137,7 +137,7 @@ Java_java_lang_Math_IEEEremainder
}
JNIEXPORT jdouble JNICALL
-Java_java_lang_Math_ceil
+Java_java_lang_VMMath_ceil
(JNIEnv * env __attribute__ ((__unused__)),
jclass cls __attribute__ ((__unused__)), jdouble x)
{
@@ -145,7 +145,7 @@ Java_java_lang_Math_ceil
}
JNIEXPORT jdouble JNICALL
-Java_java_lang_Math_floor
+Java_java_lang_VMMath_floor
(JNIEnv * env __attribute__ ((__unused__)),
jclass cls __attribute__ ((__unused__)), jdouble x)
{
@@ -153,9 +153,73 @@ Java_java_lang_Math_floor
}
JNIEXPORT jdouble JNICALL
-Java_java_lang_Math_rint
+Java_java_lang_VMMath_rint
(JNIEnv * env __attribute__ ((__unused__)),
jclass cls __attribute__ ((__unused__)), jdouble x)
{
return rint (x);
}
+
+JNIEXPORT jdouble JNICALL
+Java_java_lang_VMMath_cbrt
+ (JNIEnv * env __attribute__ ((__unused__)),
+ jclass cls __attribute__ ((__unused__)), jdouble x)
+{
+ return cbrt (x);
+}
+
+JNIEXPORT jdouble JNICALL
+Java_java_lang_VMMath_cosh
+ (JNIEnv * env __attribute__ ((__unused__)),
+ jclass cls __attribute__ ((__unused__)), jdouble x)
+{
+ return cosh (x);
+}
+
+JNIEXPORT jdouble JNICALL
+Java_java_lang_VMMath_expm1
+ (JNIEnv * env __attribute__ ((__unused__)),
+ jclass cls __attribute__ ((__unused__)), jdouble x)
+{
+ return expm1 (x);
+}
+
+JNIEXPORT jdouble JNICALL
+Java_java_lang_VMMath_hypot
+ (JNIEnv * env __attribute__ ((__unused__)),
+ jclass cls __attribute__ ((__unused__)), jdouble x, jdouble y)
+{
+ return hypot (x, y);
+}
+
+JNIEXPORT jdouble JNICALL
+Java_java_lang_VMMath_log10
+ (JNIEnv * env __attribute__ ((__unused__)),
+ jclass cls __attribute__ ((__unused__)), jdouble x)
+{
+ return log10 (x);
+}
+
+JNIEXPORT jdouble JNICALL
+Java_java_lang_VMMath_log1p
+ (JNIEnv * env __attribute__ ((__unused__)),
+ jclass cls __attribute__ ((__unused__)), jdouble x)
+{
+ return log1p (x);
+}
+
+JNIEXPORT jdouble JNICALL
+Java_java_lang_VMMath_sinh
+ (JNIEnv * env __attribute__ ((__unused__)),
+ jclass cls __attribute__ ((__unused__)), jdouble x)
+{
+ return sinh (x);
+}
+
+JNIEXPORT jdouble JNICALL
+Java_java_lang_VMMath_tanh
+ (JNIEnv * env __attribute__ ((__unused__)),
+ jclass cls __attribute__ ((__unused__)), jdouble x)
+{
+ return tanh (x);
+}
diff --git a/native/jni/java-net/javanet.c b/native/jni/java-net/javanet.c
index 0f296a604..0a1b84a8e 100644
--- a/native/jni/java-net/javanet.c
+++ b/native/jni/java-net/javanet.c
@@ -559,7 +559,7 @@ _javanet_connect (JNIEnv * env, jobject this, jobject addr, jint port,
&& (TARGET_NATIVE_LAST_ERROR ()
!= TARGET_NATIVE_ERROR_INTERRUPT_FUNCTION_CALL))
{
- JCL_ThrowException (env, IO_EXCEPTION,
+ JCL_ThrowException (env, CONNECT_EXCEPTION,
TARGET_NATIVE_LAST_ERROR_STRING ());
return;
}
diff --git a/native/jni/java-net/javanet.h b/native/jni/java-net/javanet.h
index c173b1059..785b0b082 100644
--- a/native/jni/java-net/javanet.h
+++ b/native/jni/java-net/javanet.h
@@ -50,6 +50,7 @@ exception statement from your version. */
/* Exception Classes */
#define BIND_EXCEPTION "java/net/BindException"
#define IO_EXCEPTION "java/io/IOException"
+#define CONNECT_EXCEPTION "java/net/ConnectException"
#define SOCKET_EXCEPTION "java/net/SocketException"
#define UNKNOWN_HOST_EXCEPTION "java/net/UnknownHostException"