[6/6] Make shared ldbl files more shareable.
Commit Message
Use integer constants when equivalent, and use ldouble_t
to enable sharing with the _Float128 variants.
* math/e_exp2l.c (__ieee754_exp2l): Replace long double
with ldouble_t, and use integer constants as appropriate.
* math/s_fdiml.c: (__fdiml): Likewise.
* math/k_rem_pio2l.c: (__kernel_rem_pio2l): Replace
long double with ldouble_t.
* math/s_ldexpl.c: (__ldexpl): Likewise.
* math/s_nextdownl.c: (__nextdownl): Likewise.
* math/s_fmaxl.c: (__fmaxl): Likewise, and include
math_private.h for alias.
* math/s_fminl.c: (__fminl): Likewise.
---
math/e_exp2l.c | 20 ++++++++++----------
math/k_rem_pio2l.c | 2 +-
math/s_fdiml.c | 10 ++++++----
math/s_fmaxl.c | 5 +++--
math/s_fminl.c | 5 +++--
math/s_ldexpl.c | 3 ++-
math/s_nextdownl.c | 4 ++--
7 files changed, 27 insertions(+), 22 deletions(-)
Comments
On Tue, 16 Aug 2016, Paul E. Murphy wrote:
> * math/s_fdiml.c: (__fdiml): Likewise.
Some functions here, such as fdim, seem like good candidates to convert to
the type-generic infrastructure used for complex functions, rather than
making special changes just to the long double versions.
> * math/k_rem_pio2l.c: (__kernel_rem_pio2l): Replace
> long double with ldouble_t.
Nothing ever needs this function. Replace the file with just a comment
and you can get rid of various architecture-specific variants that do just
that.
@@ -27,20 +27,20 @@
# define LDBL_EPSILON 0x1p-106L
#endif
-long double
-__ieee754_exp2l (long double x)
+ldouble_t
+__ieee754_exp2l (ldouble_t x)
{
- if (__glibc_likely (isless (x, (long double) LDBL_MAX_EXP)))
+ if (__glibc_likely (isless (x, (ldouble_t) LDBL_MAX_EXP)))
{
- if (__builtin_expect (isgreaterequal (x, (long double) (LDBL_MIN_EXP
- - LDBL_MANT_DIG
- - 1)), 1))
+ if (__builtin_expect (isgreaterequal (x, (ldouble_t) (LDBL_MIN_EXP
+ - LDBL_MANT_DIG
+ - 1)), 1))
{
int intx = (int) x;
- long double fractx = x - intx;
- long double result;
- if (fabsl (fractx) < LDBL_EPSILON / 4.0L)
- result = __scalbnl (1.0L + fractx, intx);
+ ldouble_t fractx = x - intx;
+ ldouble_t result;
+ if (fabsl (fractx) < LDBL_EPSILON / 4)
+ result = __scalbnl (1 + fractx, intx);
else
result = __scalbnl (__ieee754_expl (M_LN2l * fractx), intx);
math_check_force_underflow_nonneg (result);
@@ -4,7 +4,7 @@
#include <errno.h>
int
-__kernel_rem_pio2l (long double *x, long double *y, int e0, int nx, int prec,
+__kernel_rem_pio2l (ldouble_t *x, ldouble_t *y, int e0, int nx, int prec,
const int *ipio2)
{
fputs ("__kernel_rem_pio2l not implemented\n", stderr);
@@ -20,13 +20,15 @@
#include <errno.h>
#include <math.h>
-long double
-__fdiml (long double x, long double y)
+#include <math_private.h>
+
+ldouble_t
+__fdiml (ldouble_t x, ldouble_t y)
{
if (islessequal (x, y))
- return 0.0f;
+ return 0;
- long double r = x - y;
+ ldouble_t r = x - y;
if (isinf (r) && !isinf (x) && !isinf (y))
__set_errno (ERANGE);
@@ -18,10 +18,11 @@
<http://www.gnu.org/licenses/>. */
#include <math.h>
+#include <math_private.h>
-long double
-__fmaxl (long double x, long double y)
+ldouble_t
+__fmaxl (ldouble_t x, ldouble_t y)
{
return (isgreaterequal (x, y) || isnan (y)) ? x : y;
}
@@ -18,10 +18,11 @@
<http://www.gnu.org/licenses/>. */
#include <math.h>
+#include <math_private.h>
-long double
-__fminl (long double x, long double y)
+ldouble_t
+__fminl (ldouble_t x, ldouble_t y)
{
return (islessequal (x, y) || isnan (y)) ? x : y;
}
@@ -22,7 +22,8 @@ static char rcsid[] = "$NetBSD: $";
#include <math_private.h>
#include <errno.h>
-long double __ldexpl(long double value, int exp)
+ldouble_t
+__ldexpl(ldouble_t value, int exp)
{
if(!isfinite(value)||value==0.0) return value + value;
value = __scalbnl(value,exp);
@@ -20,8 +20,8 @@
#include <math_private.h>
/* Return the greatest floating-point number less than X. */
-long double
-__nextdownl (long double x)
+ldouble_t
+__nextdownl (ldouble_t x)
{
return -__nextupl (-x);
}