libm: sync with upstream FreeBSD.
Test: ran tests
Change-Id: I16b5930b0dc652ceac60d8ed1d57c6126c74699c
diff --git a/libm/upstream-freebsd/lib/msun/src/e_j0.c b/libm/upstream-freebsd/lib/msun/src/e_j0.c
index cfa71c2..6bca542 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 336089 2018-07-08 16:26:13Z markj $");
+__FBSDID("$FreeBSD: head/lib/msun/src/e_j0.c 343023 2019-01-14 15:48:35Z pfg $");
/* __ieee754_j0(x), __ieee754_y0(x)
* Bessel function of the first and second kinds of order zero.
@@ -80,7 +80,7 @@
S03 = 5.13546550207318111446e-07, /* 0x3EA13B54, 0xCE84D5A9 */
S04 = 1.16614003333790000205e-09; /* 0x3E1408BC, 0xF4745D8F */
-static const double zero = 0.0;
+static const double zero = 0, qrtr = 0.25;
double
__ieee754_j0(double x)
@@ -97,7 +97,7 @@
c = cos(x);
ss = s-c;
cc = s+c;
- if(ix<0x7fe00000) { /* make sure x+x not overflow */
+ if(ix<0x7fe00000) { /* Make sure x+x does not overflow. */
z = -cos(x+x);
if ((s*c)<zero) cc = z/ss;
else ss = z/cc;
@@ -123,9 +123,9 @@
r = z*(R02+z*(R03+z*(R04+z*R05)));
s = one+z*(S01+z*(S02+z*(S03+z*S04)));
if(ix < 0x3FF00000) { /* |x| < 1.00 */
- return one + z*(-0.25+(r/s));
+ return one + z*((r/s)-qrtr);
} else {
- u = 0.5*x;
+ u = x/2;
return((one+u)*(one-u)+z*(r/s));
}
}
@@ -374,6 +374,7 @@
static __inline double
qzero(double x)
{
+ static const double eighth = 0.125;
const double *p,*q;
double s,r,z;
int32_t ix;
@@ -386,5 +387,5 @@
z = one/(x*x);
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
- return (-.125 + r/s)/x;
+ return (r/s-eighth)/x;
}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_j0f.c b/libm/upstream-freebsd/lib/msun/src/e_j0f.c
index e53b218..714caac 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 283032 2015-05-17 16:27:06Z kargl $");
+__FBSDID("$FreeBSD: head/lib/msun/src/e_j0f.c 343023 2019-01-14 15:48:35Z pfg $");
/*
* See e_j0.c for complete comments.
@@ -42,7 +42,7 @@
S03 = 5.1354652442e-07, /* 0x3509daa6 */
S04 = 1.1661400734e-09; /* 0x30a045e8 */
-static const float zero = 0.0;
+static const float zero = 0, qrtr = 0.25;
float
__ieee754_j0f(float x)
@@ -59,7 +59,7 @@
c = cosf(x);
ss = s-c;
cc = s+c;
- if(ix<0x7f000000) { /* make sure x+x not overflow */
+ if(ix<0x7f000000) { /* Make sure x+x does not overflow. */
z = -cosf(x+x);
if ((s*c)<zero) cc = z/ss;
else ss = z/cc;
@@ -85,9 +85,9 @@
r = z*(R02+z*(R03+z*(R04+z*R05)));
s = one+z*(S01+z*(S02+z*(S03+z*S04)));
if(ix < 0x3F800000) { /* |x| < 1.00 */
- return one + z*((float)-0.25+(r/s));
+ return one + z*((r/s)-qrtr);
} else {
- u = (float)0.5*x;
+ u = x/2;
return((one+u)*(one-u)+z*(r/s));
}
}
@@ -328,6 +328,7 @@
static __inline float
qzerof(float x)
{
+ static const float eighth = 0.125;
const float *p,*q;
float s,r,z;
int32_t ix;
@@ -340,5 +341,5 @@
z = one/(x*x);
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
- return (-(float).125 + r/s)/x;
+ return (r/s-eighth)/x;
}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_pow.c b/libm/upstream-freebsd/lib/msun/src/e_pow.c
index 411dd52..b4f6a5a 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_pow.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_pow.c
@@ -10,7 +10,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/lib/msun/src/e_pow.c 336362 2018-07-17 07:42:14Z bde $");
+__FBSDID("$FreeBSD: head/lib/msun/src/e_pow.c 342851 2019-01-07 17:35:09Z pfg $");
/* __ieee754_pow(x,y) return x**y
*
@@ -133,7 +133,7 @@
k = (iy>>20)-0x3ff; /* exponent */
if(k>20) {
j = ly>>(52-k);
- if((j<<(52-k))==ly) yisint = 2-(j&1);
+ if(((u_int32_t)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);
diff --git a/libm/upstream-freebsd/lib/msun/src/e_rem_pio2.c b/libm/upstream-freebsd/lib/msun/src/e_rem_pio2.c
index be2630b..3e62c2b 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_rem_pio2.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_rem_pio2.c
@@ -14,7 +14,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/lib/msun/src/e_rem_pio2.c 336545 2018-07-20 12:42:24Z bde $");
/* __ieee754_rem_pio2(x,y)
*
@@ -127,14 +127,8 @@
}
if(ix<0x413921fb) { /* |x| ~< 2^20*(pi/2), medium size */
medium:
- /* Use a specialized rint() to get fn. Assume round-to-nearest. */
- STRICT_ASSIGN(double,fn,x*invpio2+0x1.8p52);
- fn = fn-0x1.8p52;
-#ifdef HAVE_EFFICIENT_IRINT
+ fn = rnint((double_t)x*invpio2);
n = irint(fn);
-#else
- n = (int32_t)fn;
-#endif
r = x-fn*pio2_1;
w = fn*pio2_1t; /* 1st round good to 85 bit */
{
diff --git a/libm/upstream-freebsd/lib/msun/src/e_rem_pio2f.c b/libm/upstream-freebsd/lib/msun/src/e_rem_pio2f.c
index f1ee7a0..2a89d27 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_rem_pio2f.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_rem_pio2f.c
@@ -15,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/lib/msun/src/e_rem_pio2f.c 336545 2018-07-20 12:42:24Z bde $");
/* __ieee754_rem_pio2f(x,y)
*
@@ -55,14 +55,8 @@
ix = hx&0x7fffffff;
/* 33+53 bit pi is good enough for medium size */
if(ix<0x4dc90fdb) { /* |x| ~< 2^28*(pi/2), medium size */
- /* Use a specialized rint() to get fn. Assume round-to-nearest. */
- STRICT_ASSIGN(double,fn,x*invpio2+0x1.8p52);
- fn = fn-0x1.8p52;
-#ifdef HAVE_EFFICIENT_IRINT
+ fn = rnint((float_t)x*invpio2);
n = irint(fn);
-#else
- n = (int32_t)fn;
-#endif
r = x-fn*pio2_1;
w = fn*pio2_1t;
*y = r-w;
diff --git a/libm/upstream-freebsd/lib/msun/src/k_rem_pio2.c b/libm/upstream-freebsd/lib/msun/src/k_rem_pio2.c
index 81363d4..0869e03 100644
--- a/libm/upstream-freebsd/lib/msun/src/k_rem_pio2.c
+++ b/libm/upstream-freebsd/lib/msun/src/k_rem_pio2.c
@@ -12,7 +12,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/lib/msun/src/k_rem_pio2.c 298896 2016-05-01 19:37:33Z pfg $");
+__FBSDID("$FreeBSD: head/lib/msun/src/k_rem_pio2.c 342651 2018-12-31 15:43:06Z pfg $");
/*
* __kernel_rem_pio2(x,y,e0,nx,prec)
@@ -52,7 +52,7 @@
* 64-bit precision 2
* 113-bit precision 3
* The actual value is the sum of them. Thus for 113-bit
- * precison, one may have to do something like:
+ * precision, one may have to do something like:
*
* long double t,w,r_head, r_tail;
* t = (long double)y[2] + (long double)y[1];
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cbrt.c b/libm/upstream-freebsd/lib/msun/src/s_cbrt.c
index d75ad0b..268425e 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_cbrt.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_cbrt.c
@@ -13,8 +13,9 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/lib/msun/src/s_cbrt.c 298896 2016-05-01 19:37:33Z pfg $");
+__FBSDID("$FreeBSD: head/lib/msun/src/s_cbrt.c 342563 2018-12-28 01:34:08Z jhibbits $");
+#include <float.h>
#include "math.h"
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cpow.c b/libm/upstream-freebsd/lib/msun/src/s_cpow.c
index 9be5c51..1cb99aa 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_cpow.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_cpow.c
@@ -44,11 +44,12 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/lib/msun/src/s_cpow.c 336299 2018-07-15 00:23:10Z mmacy $");
+__FBSDID("$FreeBSD: head/lib/msun/src/s_cpow.c 336563 2018-07-20 18:27:30Z dim $");
#include <complex.h>
#include <float.h>
#include <math.h>
+#include "math_private.h"
double complex
cpow(double complex a, double complex z)
@@ -60,7 +61,7 @@
y = cimag (z);
absa = cabs (a);
if (absa == 0.0) {
- return (0.0 + 0.0 * I);
+ return (CMPLX(0.0, 0.0));
}
arga = carg (a);
r = pow (absa, x);
@@ -69,6 +70,6 @@
r = r * exp (-y * arga);
theta = theta + y * log (absa);
}
- w = r * cos (theta) + (r * sin (theta)) * I;
+ w = CMPLX(r * cos (theta), r * sin (theta));
return (w);
}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cpowf.c b/libm/upstream-freebsd/lib/msun/src/s_cpowf.c
index 6e27f57..a2ef525 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_cpowf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_cpowf.c
@@ -44,10 +44,11 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/lib/msun/src/s_cpowf.c 336299 2018-07-15 00:23:10Z mmacy $");
+__FBSDID("$FreeBSD: head/lib/msun/src/s_cpowf.c 336563 2018-07-20 18:27:30Z dim $");
#include <complex.h>
#include <math.h>
+#include "math_private.h"
float complex
cpowf(float complex a, float complex z)
@@ -59,7 +60,7 @@
y = cimagf(z);
absa = cabsf (a);
if (absa == 0.0f) {
- return (0.0f + 0.0f * I);
+ return (CMPLXF(0.0f, 0.0f));
}
arga = cargf (a);
r = powf (absa, x);
@@ -68,6 +69,6 @@
r = r * expf (-y * arga);
theta = theta + y * logf (absa);
}
- w = r * cosf (theta) + (r * sinf (theta)) * I;
+ w = CMPLXF(r * cosf (theta), r * sinf (theta));
return (w);
}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cpowl.c b/libm/upstream-freebsd/lib/msun/src/s_cpowl.c
index fcb5c7f..f9c6373 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_cpowl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_cpowl.c
@@ -44,10 +44,11 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/lib/msun/src/s_cpowl.c 336299 2018-07-15 00:23:10Z mmacy $");
+__FBSDID("$FreeBSD: head/lib/msun/src/s_cpowl.c 336563 2018-07-20 18:27:30Z dim $");
#include <complex.h>
#include <math.h>
+#include "math_private.h"
long double complex
cpowl(long double complex a, long double complex z)
@@ -59,7 +60,7 @@
y = cimagl(z);
absa = cabsl(a);
if (absa == 0.0L) {
- return (0.0L + 0.0L * I);
+ return (CMPLXL(0.0L, 0.0L));
}
arga = cargl(a);
r = powl(absa, x);
@@ -68,6 +69,6 @@
r = r * expl(-y * arga);
theta = theta + y * logl(absa);
}
- w = r * cosl(theta) + (r * sinl(theta)) * I;
+ w = CMPLXL(r * cosl(theta), r * sinl(theta));
return (w);
}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cproj.c b/libm/upstream-freebsd/lib/msun/src/s_cproj.c
index 3083f2b..7677b5f 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_cproj.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_cproj.c
@@ -27,9 +27,10 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/lib/msun/src/s_cproj.c 326219 2017-11-26 02:00:33Z pfg $");
+__FBSDID("$FreeBSD: head/lib/msun/src/s_cproj.c 342563 2018-12-28 01:34:08Z jhibbits $");
#include <complex.h>
+#include <float.h>
#include <math.h>
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_erf.c b/libm/upstream-freebsd/lib/msun/src/s_erf.c
index e1d63bc..3e39d80 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_erf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_erf.c
@@ -11,7 +11,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/lib/msun/src/s_erf.c 342563 2018-12-28 01:34:08Z jhibbits $");
/* double erf(double x)
* double erfc(double x)
@@ -107,7 +107,7 @@
* erfc/erf(NaN) is NaN
*/
-
+#include <float.h>
#include "math.h"
#include "math_private.h"