mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-22 21:10:07 +00:00
58307649fb
TS 18661-1 generally defines libm functions taking sNaN arguments to return qNaN and raise "invalid", even for the cases where a corresponding qNaN argument would not result in a qNaN return. This includes hypot with one argument being an infinity and the other being an sNaN. This patch duly fixes hypot implementatations in glibc (generic and powerpc) to ensure qNaN, computed by arithmetic on the arguments, is returned in that case. Various implementations do their checks for infinities and NaNs inline by manipulating the representations of the arguments. For simplicity, this patch just uses issignaling to check for sNaN arguments. This could be inlined like the existing code (with due care about reversed quiet NaN conventions, for implementations where that is relevant), but given that all these checks are in cases where it's already known at least one argument is not finite, which should be the uncommon case, that doesn't seem worthwhile unless performance issues are observed in practice. Tested for x86_64, x86, mips64 and powerpc. [BZ #20940] * sysdeps/ieee754/dbl-64/e_hypot.c (__ieee754_hypot): Do not return Inf for arguments Inf and sNaN. * sysdeps/ieee754/flt-32/e_hypotf.c (__ieee754_hypotf): Likewise. * sysdeps/ieee754/ldbl-128/e_hypotl.c (__ieee754_hypotl): Likewise. * sysdeps/ieee754/ldbl-128ibm/e_hypotl.c (__ieee754_hypotl): Likewise. * sysdeps/ieee754/ldbl-96/e_hypotl.c (__ieee754_hypotl): Likewise. * sysdeps/powerpc/fpu/e_hypot.c (TEST_INF_NAN): Do not return Inf for arguments Inf and sNaN. When returning a NaN, compute it by arithmetic on the arguments. * sysdeps/powerpc/fpu/e_hypotf.c (TEST_INF_NAN): Likewise. * math/libm-test.inc (pow_test_data): Add tests of sNaN arguments. |
||
---|---|---|
.. | ||
e_hypot.c | ||
e_hypotf.c | ||
e_rem_pio2f.c | ||
e_sqrt.c | ||
e_sqrtf.c | ||
fclrexcpt.c | ||
fe_mask.c | ||
fe_nomask.c | ||
fedisblxcpt.c | ||
feenablxcpt.c | ||
fegetenv.c | ||
fegetexcept.c | ||
fegetmode.c | ||
fegetround.c | ||
feholdexcpt.c | ||
fenv_const.c | ||
fenv_libc.h | ||
fenv_private.h | ||
fesetenv.c | ||
fesetexcept.c | ||
fesetmode.c | ||
fesetround.c | ||
feupdateenv.c | ||
fgetexcptflg.c | ||
fix-fp-int-compare-invalid.h | ||
fraiseexcpt.c | ||
fsetexcptflg.c | ||
ftestexcept.c | ||
k_cosf.c | ||
k_rem_pio2f.c | ||
k_sinf.c | ||
libm-test-ulps | ||
libm-test-ulps-name | ||
Makefile | ||
math_ldbl.h | ||
math_private.h | ||
s_cosf.c | ||
s_fabs.S | ||
s_fabsf.S | ||
s_float_bitwise.h | ||
s_fma.S | ||
s_fmaf.S | ||
s_fmax.S | ||
s_fmaxf.S | ||
s_fmin.S | ||
s_fminf.S | ||
s_isnan.c | ||
s_isnanf.S | ||
s_lrintf.S | ||
s_rint.c | ||
s_rintf.c | ||
s_sinf.c | ||
t_sqrt.c | ||
tst-setcontext-fpscr.c |