[PATCH v6 1/3] math: Remove the SVID error handling from lgammaf/lgammaf_r

Wilco Dijkstra Wilco.Dijkstra@arm.com
Tue Nov 4 20:52:13 GMT 2025


Hi Adhemerval,

@@ -161,7 +163,7 @@ __ieee754_lgammaf_r (float x, int *signgamp)
       if (x <= 0.0f)
         {
           *signgamp = asuint (x) >> 31 ? -1 : 1;
-         return 1.0f / 0.0f;
+         return __math_divzerof (0);

OK

@@ -206,10 +208,11 @@ __ieee754_lgammaf_r (float x, int *signgamp)
       if (ax > 0x1.afc1ap+1f)
         {
           if (__glibc_unlikely (x > 0x1.895f1cp+121f))
-           return math_narrow_eval (0x1p127f * 0x1p127f);
+           return __math_oflowf (0);
+

OK

           /* |x|>=2**23, must be -integer */
           if (__glibc_unlikely (x < 0.0f && ax > 0x1p+23f))
-           return ax / 0.0f;
+           return __math_divzerof (1);


That should be __math_divzerof (0);


           double lz = as_ln (z);
           f = (z - 0.5) * (lz - 1) + 0x1.acfe390c97d69p-2;
           if (ax < 0x1.0p+20f)
@@ -271,7 +274,7 @@ __ieee754_lgammaf_r (float x, int *signgamp)
             {
               int ni = floorf (-2 * x);
               if ((ni & 1) == 0 && ni == -2 * x)
-               return 1.0f / 0.0f;
+               return __math_divzerof (1);

Same here: __math_divzerof (0);

 
+++ b/sysdeps/ieee754/flt-32/math_errf.c
@@ -84,6 +84,12 @@ __math_oflowf (uint32_t sign)
   return xflowf (sign, 0x1p97f);
 }
 
+attribute_hidden float
+__math_oflowf_value (float x)
+{
+  return with_errnof (x, ERANGE);
+}

We should name it as __math_erangef like __math_edomf since that makes it
clearer we are setting errno only.

Cheers,
Wilco


More information about the Libc-alpha mailing list