fix(libc): keep frexp from raising FE_INVALID for a signaling NaN #4946
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4946"
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 ErenYeager1836 on 2026-10-13T05:57:37Z.
What
Under IEEE 754 and FreeBSD's
s_frexp.cands_frexpf.c(libm),frexpandfrexpfstore 0 in*expfor zero, infinity, and NaN and return the argument unchanged without raising theFE_INVALIDfloating-point exception for a signaling NaN.In
core/libs/prx/libc/src/Math.cpp,frexpandfrexpfforwarded directly to hoststd::frexp. On hosts wherestd::frexpevaluates floating-point arguments via FPU operations, passing a signaling NaN can raiseFE_INVALID, and*expis left unspecified by C17 7.12.6.4 for infinity and NaN.This change:
std::memcpyinto integer words) to identify zero, infinity, and NaN without tripping host floating-point exception traps on signaling NaNs.*exponentand returns the argument unchanged for these special values as FreeBSD libm does.GuestMath.cpp(CheckFrexpSpecialValues).docs/dev/debt/libc.md.Tested
GuestMath.cppunit tests.python tools/check_conventions.py --base upstream/mainpasses with no violations.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T07:05:50Z.
Windows test of this PR.
Environment: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release,
BUILD_TESTING=ON,-j2,libusb-cmakefrom a local checkout. Built frommainea2bbefb2with this PR and six other open PRs (#4958, #4956, #4954, #4953, #4946, #4942, #4927) merged together; the merges had no conflict.Result: guest_math (1 of 1; the test file is shared with #4942, both merged together) pass.
Not checked: whether the test fails without the change in the library code; the PR was not tested alone, only in the combined merge (the tests of the other PRs in the batch also pass); no title run; Linux not tested.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by nicolasfalesy on 2026-10-13T07:22:30Z.
Linux test (Arch, GCC 16.2.1, glibc, Release), this PR merged onto
main7e181fcc3together with #4963, #4953, #4946 and #4942 (no conflicts):guest_mathpasses. With this PR'sMath.cppchange reverted it fails on Linux too, so the check guards the change on both systems.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T21:25:33Z.
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)docs/dev/debt/libc.mdL36-37Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:33:07Z.
Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.
Pull request closed