fix(libc): asin(|x| > 1) returns the x86 default NaN and leaves errno unchanged #3605
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3605"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by CouchRiv on 2026-10-11T14:09:52Z.
What
asin(x)for|x| > 1(including +-inf) returns0x7ff8000000000000and sets errno to 33 onmain; FreeBSD msun returns0xfff8000000000000and never sets errno (e_asin.c#L81-L85;math_errhandlingisMATH_ERREXCEPT, math.h#L67-L69). Example:asin(2.0).asinnow handles|x| > 1itself: it raisesFE_INVALID, returns0xfff8000000000000and leaves errno as the caller set it. For|x| <= 1and for NaN it still calls the host function, with the same result and flags as onmain.Also changes: errno (
asin(|x| > 1)no longer sets errno to 33, as in msun).Tested
CachyOS Linux, RTX 4070 Ti (NVIDIA) and Radeon 610M (RADV), lavapipe for CI parity.
asin(2.0)returns0xfff8000000000000with errno unchanged andFE_INVALIDraised;asin(NaN)raises nothing. The new checks fail onmainand pass with the change. 1/1 (CPU-only test, so the three drivers run the same code).mainon 767 inputs (finite, subnormal, +-inf, quiet and signalling NaNs): only the 488 inputs with|x| > 1change (the sign of the NaN, and errno from 33 to 0); every other input, NaN included, gives the same result, errno and flags as onmain.tools/check_conventions.py --base origin/mainandgit diff --check: clean.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-11T15:20:08Z.
Independent pre-review on Linux (full CI runs only happen on manual trigger, so recording one): CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
BUILD_TESTING=ON.tools/check_conventions.py --base origin/mainpasses.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T16:32:04Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/tests/GuestMath.cppL284Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T21:43:41Z.
Checked build +
guest_mathon current main (passes; fails with the Math.cpp change reverted), result matches FreeBSD msune_asin.c(default x86 NaN, sign set, FE_INVALID, errno untouched), plus @blawesom's independent full run; merging.