Sync libm with upstream FreeBSD.
Upstream SHA 78599c32efed3247d165302a1fbe8d9203e38974.
Test: treehugger
Change-Id: Ib103d211315e320df89a6f0bcb30cd8ba67dd603
diff --git a/libm/upstream-freebsd/lib/msun/ld128/k_expl.h b/libm/upstream-freebsd/lib/msun/ld128/k_expl.h
index b80d00e..159338f 100644
--- a/libm/upstream-freebsd/lib/msun/ld128/k_expl.h
+++ b/libm/upstream-freebsd/lib/msun/ld128/k_expl.h
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/lib/msun/ld128/k_expl.h 336545 2018-07-20 12:42:24Z bde $");
+__FBSDID("$FreeBSD$");
/*
* ld128 version of k_expl.h. See ../ld80/s_expl.c for most comments.
@@ -265,7 +265,8 @@
/*
* XXX: the rest of the functions are identical for ld80 and ld128.
* However, we should use scalbnl() for ld128, since long double
- * multiplication is very slow on the only supported ld128 arch (sparc64).
+ * multiplication was very slow on sparc64 and no new evaluation has
+ * been made for aarch64 and/or riscv.
*/
static inline void
@@ -299,7 +300,7 @@
static inline long double complex
__ldexp_cexpl(long double complex z, int expt)
{
- long double exp_x, hi, lo;
+ long double c, exp_x, hi, lo, s;
long double x, y, scale1, scale2;
int half_expt, k;
@@ -307,16 +308,17 @@
y = cimagl(z);
__k_expl(x, &hi, &lo, &k);
- exp_x = (lo + hi) * 0x1p16382;
+ exp_x = (lo + hi) * 0x1p16382L;
expt += k - 16382;
scale1 = 1;
half_expt = expt / 2;
SET_LDBL_EXPSIGN(scale1, BIAS + half_expt);
scale2 = 1;
- SET_LDBL_EXPSIGN(scale1, BIAS + expt - half_expt);
+ SET_LDBL_EXPSIGN(scale2, BIAS + expt - half_expt);
- return (CMPLXL(cos(y) * exp_x * scale1 * scale2,
- sinl(y) * exp_x * scale1 * scale2));
+ sincosl(y, &s, &c);
+ return (CMPLXL(c * exp_x * scale1 * scale2,
+ s * exp_x * scale1 * scale2));
}
#endif /* _COMPLEX_H */