[PATCH 14/15] math: Fix y0 template for arguments less/equal than 0
Adhemerval Zanella
adhemerval.zanella@linaro.org
Wed Mar 27 16:45:26 GMT 2024
The template is used by some ABI for the static build, and it
fails to correct return if the argument is less/equal than 0
Checked on x86_64-linux-gnu.
---
math/Makefile | 1 +
math/w_j0_template.c | 16 ++++++++++++----
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/math/Makefile b/math/Makefile
index 7391f2bd41..5807e949d7 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -372,6 +372,7 @@ libm-test-funcs-auto-static = \
exp10 \
log2 \
log10 \
+ y0 \
# libm-test-funcs-auto-static
libm-test-funcs-noauto-static = \
copysign \
diff --git a/math/w_j0_template.c b/math/w_j0_template.c
index 1822fc8213..afa2056f96 100644
--- a/math/w_j0_template.c
+++ b/math/w_j0_template.c
@@ -39,11 +39,19 @@ M_DECL_FUNC (__y0) (FLOAT x)
if (__glibc_unlikely (islessequal (x, M_LIT (0.0))))
{
if (x < 0)
- /* Domain error: y0(x<0). */
- __set_errno (EDOM);
+ {
+ /* Domain error: y0(x<0). */
+ __feraiseexcept (FE_INVALID);
+ __set_errno (EDOM);
+ return NAN;
+ }
else if (x == 0)
- /* Pole error: y0(0). */
- __set_errno (ERANGE);
+ {
+ /* Pole error: y0(0). */
+ __feraiseexcept (FE_DIVBYZERO);
+ __set_errno (ERANGE);
+ return -INFINITY;
+ }
}
return M_SUF (__ieee754_y0) (x);
}
--
2.34.1
More information about the Libc-alpha
mailing list