feat(libc): implement floating-point rounding and exception flags #6985
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6985"
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 Lorkydey on 2026-10-17T01:48:17Z.
What
Adds six missing
libSceLibcInternalexports to libc:fegetround,fesetround,fetestexcept,feclearexcept,fegetexceptflagandfesetexceptflag.Rounding changes apply to both x87 and SSE. Exception queries combine both units, and masked flag updates preserve unrelated flags and control bits. The implementation follows the FreeBSD 11.4 amd64 contract used by the existing
fegetenv, including the denormal flag and the 16-bitfexcept_t; the unverified console ABI and null-pointer behavior are recorded in libc's technical debt.A dedicated test checks actual x87/SSE conversions in all four rounding modes, invalid-mode rejection without state changes, flag save/restore/clear, two-byte writes with canaries, preservation of exception masks and isolation between threads. No title-unblocking or performance claim.
Tested
Windows x86-64, WinLibs MinGW-w64 GCC 15.2, Ninja, Release,
BUILD_TESTING=ON, rebased ontoe1ac3300d(baseline check onfd9e577d; focused tests rerun after rebase).undefined reference); adding the implementation makes the same test link and pass.cmake --build build --target guest_floating_point_tests guest_math_tests --parallel 2: passed.ctest --test-dir build -R '^guest_(floating_point|math)$' --output-on-failure: 2/2 passed; the new test takes about 0.04 s.nid_patcher, patched the resultinglibc.prx, and verified all six NIDs in its export table.python tools/check_conventions.py --base origin/mainandgit diff --check: passed.tools/progress.py: libraries 3318/3712 (89.39%) on main, 3324/3718 (89.40%) with this change.Linux execution, a full-project build and title runs have not been performed locally. Automatic PR checks do not replace the project's manually dispatched full Linux/Windows builds.
Overlap review: ran
tools/pr_overlap.py --branch feat/libc-floating-point-controlsand rechecked the final documentation placement against all 36 PRs changing that file. No duplicate exports, new files or confirmed line conflicts remain. The stale branches #5021, #5303, #5668, #6044, #6222 and #6565 share build/debt files and cannot be fully compared automatically; their available diffs were reviewed manually. They do not implement these exports. #6044 reorganizes existing tests, so this new test may need the same organization when that work lands. None is a prerequisite for this implementation.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 github-actions[bot] on 2026-10-17T01:48:59Z.
Progress report (
e1ac330→4e7e8ac)📈 System libraries: 89.4% (+0.01%, +6 implemented functions)
✅ 6 implemented
feclearexcept_nid_postfixfegetexceptflag_nid_postfixfegetround_nid_postfixfesetexceptflag_nid_postfixfesetround_nid_postfixfetestexcept_nid_postfixImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T02:11:40Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libc/CMakeLists.txtdocs/dev/debt/libc.mdcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtdocs/dev/debt/libc.mddocs/dev/debt/libc.mdcore/libs/prx/libc/CMakeLists.txtdocs/dev/debt/libc.mdcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtdocs/dev/debt/libc.mdcore/libs/prx/libc/CMakeLists.txtdocs/dev/debt/libc.mddocs/dev/debt/libc.mdcore/libs/prx/libc/CMakeLists.txtdocs/dev/debt/libc.mdcore/libs/prx/libc/CMakeLists.txtdocs/dev/debt/libc.mdImported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-17T15:16:39Z.
Review: COMMENTED
Linux run, since the description notes Linux execution has not been performed.
Machine: Linux x86_64, i7-8700, Ubuntu 26.04, GCC 15.2, Release,
BUILD_TESTING=ON, full build.Head
4e7e8ac1amerged ontomain40315fcf8(clean merge; the branch is based one1ac3300d).guest_floating_pointandguest_mathpass with the PR.ctest -E "^agc|gpu|vulkan|video_out"): 683/683, the 682 tests ofmainplusguest_floating_point.I did not repeat the test-only check on
main: the test needs the new exports to link, which the description already covers.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T15:55:31Z.
Checked against FreeBSD
x86/fenv.handamd64/fenv.c(rounding bits,FE_ALL_EXCEPTwith denormals, 16-bitfexcept_t,fesetroundrejection, x87+MXCSR handling), the new test (it needs the exports to link, covers all four modes on x87 and SSE, state preservation, threads) and the TechnicalDebt entry; Linux run by @jotitadev; merged.