[PATCH] math: Fix errno setting for narrowing sqrt functions on underflow [BZ #33393]
Wilco Dijkstra
Wilco.Dijkstra@arm.com
Mon Oct 20 18:26:19 GMT 2025
Hi Osama,
> Thanks for the feedback, that is actually my first contribution to glibc attempt,
> will try to find something simpler.
Yes it's unfortunate that errno is so problematic. I was thinking of suggesting the
ilogb issue as a simpler one. However there are several target implementations
that would need to be fixed too, and then there is the question what to do with
targets that inline the function without setting errno...
If you're looking for something small in terms of math, one option would be to
look at rewriting some of the ancient math functions. There are many smallish
functions that could be optimized by doing basic tricks. Eg. the frexp() fast path
should be as trivial as:
if (__glibc_likely ((ex - 1) < 0x7fe)
{
ex -= 1022;
*eptr = ex;
return asdouble (ix - ex << 53);
}
Cheers,
Wilco
More information about the Libc-alpha
mailing list