diff options
| author | Joseph Myers <joseph@codesourcery.com> | 2018-09-14 13:10:39 +0000 |
|---|---|---|
| committer | Joseph Myers <joseph@codesourcery.com> | 2018-09-14 13:10:39 +0000 |
| commit | f29b6f17e4e80de9761479c7d377b765095baa67 (patch) | |
| tree | 8fc16963ffd4e087f0bde8c7fe081cefbcf30103 | |
| parent | e44acb20633ab079da00ff0b29d7a5fe624525bc (diff) | |
| download | glibc-f29b6f17e4e80de9761479c7d377b765095baa67.tar.xz glibc-f29b6f17e4e80de9761479c7d377b765095baa67.zip | |
Use rint functions not __rint functions in glibc libm.
Continuing the move to use, within libm, public names for libm
functions that can be inlined as built-in functions on many
architectures, this patch moves calls to __rint functions to call the
corresponding rint names instead, with asm redirection to __rint when
the calls are not inlined. The x86_64 math_private.h is removed as no
longer useful after this patch.
This patch is relative to a tree with my floor patch
<https://sourceware.org/ml/libc-alpha/2018-09/msg00148.html> applied,
and much the same considerations arise regarding possibly replacing an
IFUNC call with a direct inline expansion.
Tested for x86_64, and with build-many-glibcs.py.
* include/math.h [!_ISOMAC && !(__FINITE_MATH_ONLY__ &&
__FINITE_MATH_ONLY__ > 0) && !NO_MATH_REDIRECT] (rint): Redirect
using MATH_REDIRECT.
* sysdeps/aarch64/fpu/s_rint.c: Define NO_MATH_REDIRECT before
header inclusion.
* sysdeps/aarch64/fpu/s_rintf.c: Likewise.
* sysdeps/alpha/fpu/s_rint.c: Likewise.
* sysdeps/alpha/fpu/s_rintf.c: Likewise.
* sysdeps/i386/fpu/s_rintl.c: Likewise.
* sysdeps/ieee754/dbl-64/s_rint.c: Likewise.
* sysdeps/ieee754/dbl-64/wordsize-64/s_rint.c: Likewise.
* sysdeps/ieee754/float128/s_rintf128.c: Likewise.
* sysdeps/ieee754/flt-32/s_rintf.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_rintl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_rintl.c: Likewise.
* sysdeps/m68k/coldfire/fpu/s_rint.c: Likewise.
* sysdeps/m68k/coldfire/fpu/s_rintf.c: Likewise.
* sysdeps/m68k/m680x0/fpu/s_rint.c: Likewise.
* sysdeps/m68k/m680x0/fpu/s_rintf.c: Likewise.
* sysdeps/m68k/m680x0/fpu/s_rintl.c: Likewise.
* sysdeps/powerpc/fpu/s_rint.c: Likewise.
* sysdeps/powerpc/fpu/s_rintf.c: Likewise.
* sysdeps/riscv/rv64/rvd/s_rint.c: Likewise.
* sysdeps/riscv/rvf/s_rintf.c: Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_rint.c: Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_rintf.c: Likewise.
* sysdeps/sparc/sparc64/fpu/multiarch/s_rint.c: Likewise.
* sysdeps/sparc/sparc64/fpu/multiarch/s_rintf.c: Likewise.
* sysdeps/x86_64/fpu/multiarch/s_rint.c: Likewise.
* sysdeps/x86_64/fpu/multiarch/s_rintf.c: Likewise.
* sysdeps/x86_64/fpu/math_private.h: Remove file.
* math/e_scalb.c (invalid_fn): Use rint functions instead of
__rint variants.
* math/e_scalbf.c (invalid_fn): Likewise.
* math/e_scalbl.c (invalid_fn): Likewise.
* sysdeps/ieee754/dbl-64/e_gamma_r.c (__ieee754_gamma_r):
Likewise.
* sysdeps/ieee754/flt-32/e_gammaf_r.c (__ieee754_gammaf_r):
Likewise.
* sysdeps/ieee754/k_standard.c (__kernel_standard): Likewise.
* sysdeps/ieee754/k_standardl.c (__kernel_standard_l): Likewise.
* sysdeps/ieee754/ldbl-128/e_gammal_r.c (__ieee754_gammal_r):
Likewise.
* sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c (__ieee754_gammal_r):
Likewise.
* sysdeps/ieee754/ldbl-96/e_gammal_r.c (__ieee754_gammal_r):
Likewise.
* sysdeps/powerpc/powerpc32/fpu/s_llrint.c (__llrint): Likewise.
* sysdeps/powerpc/powerpc32/fpu/s_llrintf.c (__llrintf): Likewise.
41 files changed, 93 insertions, 48 deletions
@@ -1,6 +1,56 @@ 2018-09-14 Joseph Myers <joseph@codesourcery.com> * include/math.h [!_ISOMAC && !(__FINITE_MATH_ONLY__ && + __FINITE_MATH_ONLY__ > 0) && !NO_MATH_REDIRECT] (rint): Redirect + using MATH_REDIRECT. + * sysdeps/aarch64/fpu/s_rint.c: Define NO_MATH_REDIRECT before + header inclusion. + * sysdeps/aarch64/fpu/s_rintf.c: Likewise. + * sysdeps/alpha/fpu/s_rint.c: Likewise. + * sysdeps/alpha/fpu/s_rintf.c: Likewise. + * sysdeps/i386/fpu/s_rintl.c: Likewise. + * sysdeps/ieee754/dbl-64/s_rint.c: Likewise. + * sysdeps/ieee754/dbl-64/wordsize-64/s_rint.c: Likewise. + * sysdeps/ieee754/float128/s_rintf128.c: Likewise. + * sysdeps/ieee754/flt-32/s_rintf.c: Likewise. + * sysdeps/ieee754/ldbl-128/s_rintl.c: Likewise. + * sysdeps/ieee754/ldbl-128ibm/s_rintl.c: Likewise. + * sysdeps/m68k/coldfire/fpu/s_rint.c: Likewise. + * sysdeps/m68k/coldfire/fpu/s_rintf.c: Likewise. + * sysdeps/m68k/m680x0/fpu/s_rint.c: Likewise. + * sysdeps/m68k/m680x0/fpu/s_rintf.c: Likewise. + * sysdeps/m68k/m680x0/fpu/s_rintl.c: Likewise. + * sysdeps/powerpc/fpu/s_rint.c: Likewise. + * sysdeps/powerpc/fpu/s_rintf.c: Likewise. + * sysdeps/riscv/rv64/rvd/s_rint.c: Likewise. + * sysdeps/riscv/rvf/s_rintf.c: Likewise. + * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_rint.c: Likewise. + * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_rintf.c: Likewise. + * sysdeps/sparc/sparc64/fpu/multiarch/s_rint.c: Likewise. + * sysdeps/sparc/sparc64/fpu/multiarch/s_rintf.c: Likewise. + * sysdeps/x86_64/fpu/multiarch/s_rint.c: Likewise. + * sysdeps/x86_64/fpu/multiarch/s_rintf.c: Likewise. + * sysdeps/x86_64/fpu/math_private.h: Remove file. + * math/e_scalb.c (invalid_fn): Use rint functions instead of + __rint variants. + * math/e_scalbf.c (invalid_fn): Likewise. + * math/e_scalbl.c (invalid_fn): Likewise. + * sysdeps/ieee754/dbl-64/e_gamma_r.c (__ieee754_gamma_r): + Likewise. + * sysdeps/ieee754/flt-32/e_gammaf_r.c (__ieee754_gammaf_r): + Likewise. + * sysdeps/ieee754/k_standard.c (__kernel_standard): Likewise. + * sysdeps/ieee754/k_standardl.c (__kernel_standard_l): Likewise. + * sysdeps/ieee754/ldbl-128/e_gammal_r.c (__ieee754_gammal_r): + Likewise. + * sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c (__ieee754_gammal_r): + Likewise. + * sysdeps/ieee754/ldbl-96/e_gammal_r.c (__ieee754_gammal_r): + Likewise. + * sysdeps/powerpc/powerpc32/fpu/s_llrint.c (__llrint): Likewise. + * sysdeps/powerpc/powerpc32/fpu/s_llrintf.c (__llrintf): Likewise. + + * include/math.h [!_ISOMAC && !(__FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0) && !NO_MATH_REDIRECT] (MATH_REDIRECT): New macro. [!_ISOMAC && !(__FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0) diff --git a/include/math.h b/include/math.h index eed953072b..f93ecaf6e6 100644 --- a/include/math.h +++ b/include/math.h @@ -102,6 +102,7 @@ fabsf128 (_Float128 x) # define MATH_REDIRECT_UNARY_ARGS(TYPE) TYPE MATH_REDIRECT (sqrt, "__ieee754_", MATH_REDIRECT_UNARY_ARGS) MATH_REDIRECT (floor, "__", MATH_REDIRECT_UNARY_ARGS) +MATH_REDIRECT (rint, "__", MATH_REDIRECT_UNARY_ARGS) # endif # endif diff --git a/math/e_scalb.c b/math/e_scalb.c index 96c3579aad..7f795c40d2 100644 --- a/math/e_scalb.c +++ b/math/e_scalb.c @@ -24,7 +24,7 @@ static double __attribute__ ((noinline)) invalid_fn (double x, double fn) { - if (__rint (fn) != fn) + if (rint (fn) != fn) return (fn - fn) / (fn - fn); else if (fn > 65000.0) return __scalbn (x, 65000); diff --git a/math/e_scalbf.c b/math/e_scalbf.c index 23b38a95de..aa08b9a81d 100644 --- a/math/e_scalbf.c +++ b/math/e_scalbf.c @@ -24,7 +24,7 @@ static float __attribute__ ((noinline)) invalid_fn (float x, float fn) { - if (__rintf (fn) != fn) + if (rintf (fn) != fn) return (fn - fn) / (fn - fn); else if (fn > 65000.0f) return __scalbnf (x, 65000); diff --git a/math/e_scalbl.c b/math/e_scalbl.c index a677d06b9f..f0c0bceb3a 100644 --- a/math/e_scalbl.c +++ b/math/e_scalbl.c @@ -24,7 +24,7 @@ static long double __attribute__ ((noinline)) invalid_fn (long double x, long double fn) { - if (__rintl (fn) != fn) + if (rintl (fn) != fn) return (fn - fn) / (fn - fn); else if (fn > 65000.0L) return __scalbnl (x, 65000); diff --git a/sysdeps/aarch64/fpu/s_rint.c b/sysdeps/aarch64/fpu/s_rint.c index eb4232af00..ec7d63d549 100644 --- a/sysdeps/aarch64/fpu/s_rint.c +++ b/sysdeps/aarch64/fpu/s_rint.c @@ -16,6 +16,7 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ +#define NO_MATH_REDIRECT #include <math.h> #include <libm-alias-double.h> diff --git a/sysdeps/aarch64/fpu/s_rintf.c b/sysdeps/aarch64/fpu/s_rintf.c index 9ebfcb45b4..96fb57b982 100644 --- a/sysdeps/aarch64/fpu/s_rintf.c +++ b/sysdeps/aarch64/fpu/s_rintf.c @@ -16,6 +16,7 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ +#define NO_MATH_REDIRECT #include <math.h> #include <libm-alias-float.h> diff --git a/sysdeps/alpha/fpu/s_rint.c b/sysdeps/alpha/fpu/s_rint.c index d3bcf1829a..0f4a7467e4 100644 --- a/sysdeps/alpha/fpu/s_rint.c +++ b/sysdeps/alpha/fpu/s_rint.c @@ -16,6 +16,7 @@ License along with the GNU C Library. If not, see <http://www.gnu.org/licenses/>. */ +#define NO_MATH_REDIRECT #include <math.h> #include <math_ldbl_opt.h> #include <libm-alias-double.h> diff --git a/sysdeps/alpha/fpu/s_rintf.c b/sysdeps/alpha/fpu/s_rintf.c index 0cc912d843..f8bf5e4ab1 100644 --- a/sysdeps/alpha/fpu/s_rintf.c +++ b/sysdeps/alpha/fpu/s_rintf.c @@ -16,6 +16,7 @@ License along with the GNU C Library. If not, see <http://www.gnu.org/licenses/>. */ +#define NO_MATH_REDIRECT #include <math.h> #include <libm-alias-float.h> diff --git a/sysdeps/i386/fpu/s_rintl.c b/sysdeps/i386/fpu/s_rintl.c index 5900435af9..6946f611c3 100644 --- a/sysdeps/i386/fpu/s_rintl.c +++ b/sysdeps/i386/fpu/s_rintl.c @@ -4,6 +4,7 @@ * Public domain. */ +#define NO_MATH_REDIRECT #include <libm-alias-ldouble.h> #include <math_private.h> diff --git a/sysdeps/ieee754/dbl-64/e_gamma_r.c b/sysdeps/ieee754/dbl-64/e_gamma_r.c index e7b6dfecd7..9f7af6f0c9 100644 --- a/sysdeps/ieee754/dbl-64/e_gamma_r.c +++ b/sysdeps/ieee754/dbl-64/e_gamma_r.c @@ -129,7 +129,7 @@ __ieee754_gamma_r (double x, int *signgamp) return 1.0 / x; } if (__builtin_expect (hx < 0, 0) - && (uint32_t) hx < 0xfff00000 && __rint (x) == x) + && (uint32_t) hx < 0xfff00000 && rint (x) == x) { /* Return value for integer x < 0 is NaN with invalid exception. */ *signgamp = 0; diff --git a/sysdeps/ieee754/dbl-64/s_rint.c b/sysdeps/ieee754/dbl-64/s_rint.c index cb0f5ca298..dd01a84176 100644 --- a/sysdeps/ieee754/dbl-64/s_rint.c +++ b/sysdeps/ieee754/dbl-64/s_rint.c @@ -20,6 +20,7 @@ * Inexact flag raised if x not equal to rint(x). */ +#define NO_MATH_REDIRECT #include <math.h> #include <math_private.h> #include <libm-alias-double.h> diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_rint.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_rint.c index 622e479c5f..378b73a544 100644 --- a/sysdeps/ieee754/dbl-64/wordsize-64/s_rint.c +++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_rint.c @@ -19,6 +19,7 @@ * Inexact flag raised if x not equal to rint(x). */ +#define NO_MATH_REDIRECT #include <math.h> #include <math_private.h> #include <libm-alias-double.h> diff --git a/sysdeps/ieee754/float128/s_rintf128.c b/sysdeps/ieee754/float128/s_rintf128.c index 2adb95f360..73c53776d9 100644 --- a/sysdeps/ieee754/float128/s_rintf128.c +++ b/sysdeps/ieee754/float128/s_rintf128.c @@ -1,2 +1,3 @@ +#define NO_MATH_REDIRECT #include <float128_private.h> #include "../ldbl-128/s_rintl.c" diff --git a/sysdeps/ieee754/flt-32/e_gammaf_r.c b/sysdeps/ieee754/flt-32/e_gammaf_r.c index ddc268e8fc..28da9c46d2 100644 --- a/sysdeps/ieee754/flt-32/e_gammaf_r.c +++ b/sysdeps/ieee754/flt-32/e_gammaf_r.c @@ -121,7 +121,7 @@ __ieee754_gammaf_r (float x, int *signgamp) return 1.0 / x; } if (__builtin_expect (hx < 0, 0) - && (uint32_t) hx < 0xff800000 && __rintf (x) == x) + && (uint32_t) hx < 0xff800000 && rintf (x) == x) { /* Return value for integer x < 0 is NaN with invalid exception. */ *signgamp = 0; diff --git a/sysdeps/ieee754/flt-32/s_rintf.c b/sysdeps/ieee754/flt-32/s_rintf.c index db6f260a0b..0306dc21f4 100644 --- a/sysdeps/ieee754/flt-32/s_rintf.c +++ b/sysdeps/ieee754/flt-32/s_rintf.c @@ -13,6 +13,7 @@ * ==================================================== */ +#define NO_MATH_REDIRECT #include <math.h> #include <math_private.h> #include <libm-alias-float.h> diff --git a/sysdeps/ieee754/k_standard.c b/sysdeps/ieee754/k_standard.c index f74f9c712e..f71a837980 100644 --- a/sysdeps/ieee754/k_standard.c +++ b/sysdeps/ieee754/k_standard.c @@ -471,11 +471,11 @@ __kernel_standard(double x, double y, int type) if (_LIB_VERSION == _SVID_) { exc.retval = HUGE; y *= 0.5; - if(x<zero&&__rint(y)!=y) exc.retval = -HUGE; + if(x<zero&&rint(y)!=y) exc.retval = -HUGE; } else { exc.retval = HUGE_VAL; y *= 0.5; - if(x<zero&&__rint(y)!=y) exc.retval = -HUGE_VAL; + if(x<zero&&rint(y)!=y) exc.retval = -HUGE_VAL; } if (_LIB_VERSION == _POSIX_) __set_errno (ERANGE); @@ -491,7 +491,7 @@ __kernel_standard(double x, double y, int type) exc.name = CSTR ("pow"); exc.retval = zero; y *= 0.5; - if (x < zero && __rint (y) != y) + if (x < zero && rint (y) != y) exc.retval = -zero; if (_LIB_VERSION == _POSIX_) __set_errno (ERANGE); diff --git a/sysdeps/ieee754/k_standardl.c b/sysdeps/ieee754/k_standardl.c index 58abc22b6e..618abb28f4 100644 --- a/sysdeps/ieee754/k_standardl.c +++ b/sysdeps/ieee754/k_standardl.c @@ -73,14 +73,14 @@ __kernel_standard_l (long double x, long double y, int type) { exc.retval = HUGE; y *= 0.5; - if (x < zero && __rintl (y) != y) + if (x < zero && rintl (y) != y) exc.retval = -HUGE; } else { exc.retval = HUGE_VAL; y *= 0.5; - if (x < zero && __rintl |
