feat(libc): implement fabs, trunc and fma #3314
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3314"
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 reyani-dev on 2026-10-11T07:10:01Z.
What
fabs(388LcMWHRCA),truncandfmafromlibSceLibcInternal, redone on currentmainfrom the closed #2167.sqrtfrom that PR has since landed in #3233.@babyhuey reported on #2167 that PSBox Cloud Gaming (PPSA99810) now stops at
fabsonmain52ce9b8a(Linux, catalog build withsce_module/libc.prxunwrapped as #2605 requires):With
fabs,truncandfmaadded, PSBox goes on to_umtx_op(#1482).The three are direct
std::fabs,std::truncandstd::fma, all exact operations with no rounding choice. They sit next tosqrt/sqrtfinMath.cpp.guest_mathgainsCheckExactOperations:fabsclears the sign of-0(bit pattern 0) and of a negative NaN.trunckeeps the sign of-0.5(result-0), keeps2^52 + 1and-1e300exact, and passes infinity and NaN through.fma(0.1, 10, -1)is2^-54, which a separate multiply and add would round to 0;fma(2^1023, 2, -2^1023)doesn't overflow in the intermediate.Tested
Windows 11 (10.0.26200), WinLibs GCC 15.2.0 r7, Release, full build with
BUILD_TESTING=ON, onmain1690db9a:guest_mathpasses 5/5 (--repeat until-fail:5). Without the change it doesn't link, and withfmareplaced by a separate multiply and add it fails.ctest -E "^agc_|video_out": 414/414.tools/import_audit.pyon PSBox Cloud Gaming's registry:388LcMWHRCA(fabs) is no longer absent, and no new absent import appears.check_conventions.pypasses, andpr_overlap.pyreports no overlap.The title stop is babyhuey's Linux run on #2167; I don't run the catalog titles.
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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T07:10:21Z.
Progress report (
bae9962→ffeb263)📈 System libraries: 85.81% (+0.01%, +3 implemented functions)
✅ 3 implemented
fabs_nid_postfixfma_nid_postfixtrunc_nid_postfixImported from boykopovar/AnyPS5. Originally posted by Mouhand-Kaddo on 2026-10-11T07:18:36Z.
Additional platform validation of standalone PR head
ffeb26365474436638f56e2f3351560c686e7595(2026-10-11):Linux: passed — Arch Linux in WSL2 (kernel 6.6.87.2), GCC 16.2.1 20260810; CMake 4.3.1 / Ninja; Release,
BUILD_TESTING=ON.1 checks, 0 failures, 0 CTest skips. Built the selected targets and dependencies; this is focused validation, not a full build or full-suite run.
Checks:
guest_math.Command after building:
ctest --test-dir <build> --verbose --no-tests=error --timeout 30 -R "^guest_math$".No title/gameplay validation. These results cover the standalone head, not a merge with current main.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T07:28:22Z.
Checked on Linux: scoped build + ctest green,
guest_mathpasses, and it fails to link without the change.fabs/trunc/fmaare exact IEEE operations and the test pins the edge cases (-0, NaN sign, 2^52+1, fma without intermediate rounding or overflow). No overlap with other open PRs; merging.