diff options
author | Elliott Hughes <enh@google.com> | 2019-10-24 18:13:32 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2019-10-24 18:13:32 -0700 |
commit | ff49a3c03a1de63968e1b832bf3ffb6987fb83b4 (patch) | |
tree | 8f1a6ded2f96e7ab88373f96ee03cc679f2ae2cb /libm | |
parent | 6e5d06336a4d1e013c921437d59918b66fa5fd6a (diff) |
libm: sync with upstream FreeBSD.
Bug: http://b/143311272
Test: ran tests
Change-Id: I0fbf94fb5cd13e64a55957d0f951757746d0367a
Diffstat (limited to 'libm')
-rw-r--r-- | libm/upstream-freebsd/lib/msun/src/e_exp.c | 6 | ||||
-rw-r--r-- | libm/upstream-freebsd/lib/msun/src/e_expf.c | 6 | ||||
-rw-r--r-- | libm/upstream-freebsd/lib/msun/src/e_j0.c | 8 | ||||
-rw-r--r-- | libm/upstream-freebsd/lib/msun/src/e_j0f.c | 8 | ||||
-rw-r--r-- | libm/upstream-freebsd/lib/msun/src/e_j1.c | 8 | ||||
-rw-r--r-- | libm/upstream-freebsd/lib/msun/src/e_j1f.c | 8 | ||||
-rw-r--r-- | libm/upstream-freebsd/lib/msun/src/e_jn.c | 24 | ||||
-rw-r--r-- | libm/upstream-freebsd/lib/msun/src/s_expm1.c | 4 | ||||
-rw-r--r-- | libm/upstream-freebsd/lib/msun/src/s_expm1f.c | 4 | ||||
-rw-r--r-- | libm/upstream-freebsd/lib/msun/src/s_lround.c | 8 |
10 files changed, 39 insertions, 45 deletions
diff --git a/libm/upstream-freebsd/lib/msun/src/e_exp.c b/libm/upstream-freebsd/lib/msun/src/e_exp.c index 94c9769da..dd88d3e91 100644 --- a/libm/upstream-freebsd/lib/msun/src/e_exp.c +++ b/libm/upstream-freebsd/lib/msun/src/e_exp.c @@ -11,7 +11,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); +__FBSDID("$FreeBSD: head/lib/msun/src/e_exp.c 352710 2019-09-25 18:50:57Z dim $"); /* __ieee754_exp(x) * Returns the exponential of x. @@ -145,9 +145,9 @@ __ieee754_exp(double x) /* default IEEE double exp */ /* x is now in primary range */ t = x*x; if(k >= -1021) - INSERT_WORDS(twopk,0x3ff00000+(k<<20), 0); + INSERT_WORDS(twopk,((u_int32_t)(0x3ff+k))<<20, 0); else - INSERT_WORDS(twopk,0x3ff00000+((k+1000)<<20), 0); + INSERT_WORDS(twopk,((u_int32_t)(0x3ff+(k+1000)))<<20, 0); c = x - t*(P1+t*(P2+t*(P3+t*(P4+t*P5)))); if(k==0) return one-((x*c)/(c-2.0)-x); else y = one-((lo-(x*c)/(2.0-c))-hi); diff --git a/libm/upstream-freebsd/lib/msun/src/e_expf.c b/libm/upstream-freebsd/lib/msun/src/e_expf.c index b1fe2c537..aaf6d5f6c 100644 --- a/libm/upstream-freebsd/lib/msun/src/e_expf.c +++ b/libm/upstream-freebsd/lib/msun/src/e_expf.c @@ -14,7 +14,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); +__FBSDID("$FreeBSD: head/lib/msun/src/e_expf.c 352710 2019-09-25 18:50:57Z dim $"); #include <float.h> @@ -83,9 +83,9 @@ __ieee754_expf(float x) /* x is now in primary range */ t = x*x; if(k >= -125) - SET_FLOAT_WORD(twopk,0x3f800000+(k<<23)); + SET_FLOAT_WORD(twopk,((u_int32_t)(0x7f+k))<<23); else - SET_FLOAT_WORD(twopk,0x3f800000+((k+100)<<23)); + SET_FLOAT_WORD(twopk,((u_int32_t)(0x7f+(k+100)))<<23); c = x - t*(P1+t*P2); if(k==0) return one-((x*c)/(c-(float)2.0)-x); else y = one-((lo-(x*c)/((float)2.0-c))-hi); diff --git a/libm/upstream-freebsd/lib/msun/src/e_j0.c b/libm/upstream-freebsd/lib/msun/src/e_j0.c index 6bca542fb..a008b42c0 100644 --- a/libm/upstream-freebsd/lib/msun/src/e_j0.c +++ b/libm/upstream-freebsd/lib/msun/src/e_j0.c @@ -11,7 +11,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/lib/msun/src/e_j0.c 343023 2019-01-14 15:48:35Z pfg $"); +__FBSDID("$FreeBSD: head/lib/msun/src/e_j0.c 343953 2019-02-10 08:46:07Z peterj $"); /* __ieee754_j0(x), __ieee754_y0(x) * Bessel function of the first and second kinds of order zero. @@ -93,8 +93,7 @@ __ieee754_j0(double x) if(ix>=0x7ff00000) return one/(x*x); x = fabs(x); if(ix >= 0x40000000) { /* |x| >= 2.0 */ - s = sin(x); - c = cos(x); + sincos(x, &s, &c); ss = s-c; cc = s+c; if(ix<0x7fe00000) { /* Make sure x+x does not overflow. */ @@ -173,8 +172,7 @@ __ieee754_y0(double x) * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) * to compute the worse one. */ - s = sin(x); - c = cos(x); + sincos(x, &s, &c); ss = s-c; cc = s+c; /* diff --git a/libm/upstream-freebsd/lib/msun/src/e_j0f.c b/libm/upstream-freebsd/lib/msun/src/e_j0f.c index 714caac1d..495a5e54b 100644 --- a/libm/upstream-freebsd/lib/msun/src/e_j0f.c +++ b/libm/upstream-freebsd/lib/msun/src/e_j0f.c @@ -14,7 +14,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/lib/msun/src/e_j0f.c 343023 2019-01-14 15:48:35Z pfg $"); +__FBSDID("$FreeBSD: head/lib/msun/src/e_j0f.c 343953 2019-02-10 08:46:07Z peterj $"); /* * See e_j0.c for complete comments. @@ -55,8 +55,7 @@ __ieee754_j0f(float x) if(ix>=0x7f800000) return one/(x*x); x = fabsf(x); if(ix >= 0x40000000) { /* |x| >= 2.0 */ - s = sinf(x); - c = cosf(x); + sincosf(x, &s, &c); ss = s-c; cc = s+c; if(ix<0x7f000000) { /* Make sure x+x does not overflow. */ @@ -128,8 +127,7 @@ __ieee754_y0f(float x) * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) * to compute the worse one. */ - s = sinf(x); - c = cosf(x); + sincosf(x, &s, &c); ss = s-c; cc = s+c; /* diff --git a/libm/upstream-freebsd/lib/msun/src/e_j1.c b/libm/upstream-freebsd/lib/msun/src/e_j1.c index 78bb3292b..6d1c41c5b 100644 --- a/libm/upstream-freebsd/lib/msun/src/e_j1.c +++ b/libm/upstream-freebsd/lib/msun/src/e_j1.c @@ -11,7 +11,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/lib/msun/src/e_j1.c 336089 2018-07-08 16:26:13Z markj $"); +__FBSDID("$FreeBSD: head/lib/msun/src/e_j1.c 343953 2019-02-10 08:46:07Z peterj $"); /* __ieee754_j1(x), __ieee754_y1(x) * Bessel function of the first and second kinds of order zero. @@ -94,8 +94,7 @@ __ieee754_j1(double x) if(ix>=0x7ff00000) return one/x; y = fabs(x); if(ix >= 0x40000000) { /* |x| >= 2.0 */ - s = sin(y); - c = cos(y); + sincos(y, &s, &c); ss = -s-c; cc = s-c; if(ix<0x7fe00000) { /* make sure y+y not overflow */ @@ -159,8 +158,7 @@ __ieee754_y1(double x) /* y1(x<0) = NaN and raise invalid exception. */ if(hx<0) return vzero/vzero; if(ix >= 0x40000000) { /* |x| >= 2.0 */ - s = sin(x); - c = cos(x); + sincos(x, &s, &c); ss = -s-c; cc = s-c; if(ix<0x7fe00000) { /* make sure x+x not overflow */ diff --git a/libm/upstream-freebsd/lib/msun/src/e_j1f.c b/libm/upstream-freebsd/lib/msun/src/e_j1f.c index 3abe201f5..31fc28a5d 100644 --- a/libm/upstream-freebsd/lib/msun/src/e_j1f.c +++ b/libm/upstream-freebsd/lib/msun/src/e_j1f.c @@ -14,7 +14,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/lib/msun/src/e_j1f.c 336089 2018-07-08 16:26:13Z markj $"); +__FBSDID("$FreeBSD: head/lib/msun/src/e_j1f.c 343953 2019-02-10 08:46:07Z peterj $"); /* * See e_j1.c for complete comments. @@ -56,8 +56,7 @@ __ieee754_j1f(float x) if(ix>=0x7f800000) return one/x; y = fabsf(x); if(ix >= 0x40000000) { /* |x| >= 2.0 */ - s = sinf(y); - c = cosf(y); + sincosf(y, &s, &c); ss = -s-c; cc = s-c; if(ix<0x7f000000) { /* make sure y+y not overflow */ @@ -114,8 +113,7 @@ __ieee754_y1f(float x) if(ix==0) return -one/vzero; if(hx<0) return vzero/vzero; if(ix >= 0x40000000) { /* |x| >= 2.0 */ - s = sinf(x); - c = cosf(x); + sincosf(x, &s, &c); ss = -s-c; cc = s-c; if(ix<0x7f000000) { /* make sure x+x not overflow */ diff --git a/libm/upstream-freebsd/lib/msun/src/e_jn.c b/libm/upstream-freebsd/lib/msun/src/e_jn.c index 58ec905c9..c039cf234 100644 --- a/libm/upstream-freebsd/lib/msun/src/e_jn.c +++ b/libm/upstream-freebsd/lib/msun/src/e_jn.c @@ -11,7 +11,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/lib/msun/src/e_jn.c 336089 2018-07-08 16:26:13Z markj $"); +__FBSDID("$FreeBSD: head/lib/msun/src/e_jn.c 343953 2019-02-10 08:46:07Z peterj $"); /* * __ieee754_jn(n, x), __ieee754_yn(n, x) @@ -54,7 +54,7 @@ double __ieee754_jn(int n, double x) { int32_t i,hx,ix,lx, sgn; - double a, b, temp, di; + double a, b, c, s, temp, di; double z, w; /* J(-n,x) = (-1)^n * J(n, x), J(n, -x) = (-1)^n * J(n, x) @@ -91,11 +91,12 @@ __ieee754_jn(int n, double x) * 2 -s+c -c-s * 3 s+c c-s */ + sincos(x, &s, &c); switch(n&3) { - case 0: temp = cos(x)+sin(x); break; - case 1: temp = -cos(x)+sin(x); break; - case 2: temp = -cos(x)-sin(x); break; - case 3: temp = cos(x)-sin(x); break; + case 0: temp = c+s; break; + case 1: temp = -c+s; break; + case 2: temp = -c-s; break; + case 3: temp = c-s; break; } b = invsqrtpi*temp/sqrt(x); } else { @@ -216,7 +217,7 @@ __ieee754_yn(int n, double x) { int32_t i,hx,ix,lx; int32_t sign; - double a, b, temp; + double a, b, c, s, temp; EXTRACT_WORDS(hx,lx,x); ix = 0x7fffffff&hx; @@ -248,11 +249,12 @@ __ieee754_yn(int n, double x) * 2 -s+c -c-s * 3 s+c c-s */ + sincos(x, &s, &c); switch(n&3) { - case 0: temp = sin(x)-cos(x); break; - case 1: temp = -sin(x)-cos(x); break; - case 2: temp = -sin(x)+cos(x); break; - case 3: temp = sin(x)+cos(x); break; + case 0: temp = s-c; break; + case 1: temp = -s-c; break; + case 2: temp = -s+c; break; + case 3: temp = s+c; break; } b = invsqrtpi*temp/sqrt(x); } else { diff --git a/libm/upstream-freebsd/lib/msun/src/s_expm1.c b/libm/upstream-freebsd/lib/msun/src/s_expm1.c index 37998a387..21256ce5a 100644 --- a/libm/upstream-freebsd/lib/msun/src/s_expm1.c +++ b/libm/upstream-freebsd/lib/msun/src/s_expm1.c @@ -11,7 +11,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); +__FBSDID("$FreeBSD: head/lib/msun/src/s_expm1.c 352710 2019-09-25 18:50:57Z dim $"); /* expm1(x) * Returns exp(x)-1, the exponential of x minus 1. @@ -188,7 +188,7 @@ expm1(double x) e = hxs*((r1-t)/(6.0 - x*t)); if(k==0) return x - (x*e-hxs); /* c is 0 */ else { - INSERT_WORDS(twopk,0x3ff00000+(k<<20),0); /* 2^k */ + INSERT_WORDS(twopk,((u_int32_t)(0x3ff+k))<<20,0); /* 2^k */ e = (x*(e-c)-c); e -= hxs; if(k== -1) return 0.5*(x-e)-0.5; diff --git a/libm/upstream-freebsd/lib/msun/src/s_expm1f.c b/libm/upstream-freebsd/lib/msun/src/s_expm1f.c index c0a39340f..4d9ab36b7 100644 --- a/libm/upstream-freebsd/lib/msun/src/s_expm1f.c +++ b/libm/upstream-freebsd/lib/msun/src/s_expm1f.c @@ -14,7 +14,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); +__FBSDID("$FreeBSD: head/lib/msun/src/s_expm1f.c 352710 2019-09-25 18:50:57Z dim $"); #include <float.h> @@ -94,7 +94,7 @@ expm1f(float x) e = hxs*((r1-t)/((float)6.0 - x*t)); if(k==0) return x - (x*e-hxs); /* c is 0 */ else { - SET_FLOAT_WORD(twopk,0x3f800000+(k<<23)); /* 2^k */ + SET_FLOAT_WORD(twopk,((u_int32_t)(0x7f+k))<<23); /* 2^k */ e = (x*(e-c)-c); e -= hxs; if(k== -1) return (float)0.5*(x-e)-(float)0.5; diff --git a/libm/upstream-freebsd/lib/msun/src/s_lround.c b/libm/upstream-freebsd/lib/msun/src/s_lround.c index b6a25b733..ce2aee779 100644 --- a/libm/upstream-freebsd/lib/msun/src/s_lround.c +++ b/libm/upstream-freebsd/lib/msun/src/s_lround.c @@ -32,7 +32,7 @@ #include <math.h> #ifndef type -__FBSDID("$FreeBSD: head/lib/msun/src/s_lround.c 326219 2017-11-26 02:00:33Z pfg $"); +__FBSDID("$FreeBSD: head/lib/msun/src/s_lround.c 353329 2019-10-08 21:39:51Z brooks $"); #define type double #define roundit round #define dtype long @@ -49,9 +49,9 @@ __FBSDID("$FreeBSD: head/lib/msun/src/s_lround.c 326219 2017-11-26 02:00:33Z pfg * that everything is in range. At compile time, INRANGE(x) should reduce to * two floating-point comparisons in the former case, or TRUE otherwise. */ -static const type dtype_min = DTYPE_MIN - 0.5; -static const type dtype_max = DTYPE_MAX + 0.5; -#define INRANGE(x) (dtype_max - DTYPE_MAX != 0.5 || \ +static const type dtype_min = (type)DTYPE_MIN - 0.5; +static const type dtype_max = (type)DTYPE_MAX + 0.5; +#define INRANGE(x) (dtype_max - (type)DTYPE_MAX != 0.5 || \ ((x) > dtype_min && (x) < dtype_max)) dtype |