diff mbox series

[15/15] math: Fix y1 template for arguments less/equal than 0

Message ID 20240327164527.3717523-16-adhemerval.zanella@linaro.org
State Superseded
Headers show
Series Fix some libm static issues | expand

Commit Message

Adhemerval Zanella Netto March 27, 2024, 4:45 p.m. UTC
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_j1_template.c | 16 ++++++++++++----
 2 files changed, 13 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/math/Makefile b/math/Makefile
index 5807e949d7..b58fca85e4 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -373,6 +373,7 @@  libm-test-funcs-auto-static = \
   log2 \
   log10 \
   y0 \
+  y1 \
   # libm-test-funcs-auto-static
 libm-test-funcs-noauto-static = \
   copysign \
diff --git a/math/w_j1_template.c b/math/w_j1_template.c
index 0a97cf9219..addcf4fac9 100644
--- a/math/w_j1_template.c
+++ b/math/w_j1_template.c
@@ -39,11 +39,19 @@  M_DECL_FUNC (__y1) (FLOAT x)
   if (__glibc_unlikely (islessequal (x, M_LIT (0.0))))
     {
       if (x < 0)
-	/* Domain error: y1(x<0).  */
-	__set_errno (EDOM);
+	{
+	  /* Domain error: y1(x<0).  */
+	  __feraiseexcept (FE_INVALID);
+	  __set_errno (EDOM);
+	  return NAN;
+	}
       else if (x == 0)
-	/* Pole error: y1(0).  */
-	__set_errno (ERANGE);
+	{
+	  /* Pole error: y1(0).  */
+	  __feraiseexcept (FE_DIVBYZERO);
+	  __set_errno (ERANGE);
+	  return -INFINITY;
+	}
     }
   return M_SUF (__ieee754_y1) (x);
 }