feat(libc): implement fabs, sqrt, trunc and fma #2167
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2167"
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-09T10:33:35Z.
What
Exports the
doubleversions offabs,sqrt,truncandfma. Each one forwards to the C++ standard library, likeroundandfmodnext to them. All four are exact or correctly rounded in IEEE 754, so the host result matches the console's.Titles: open-source homebrew from the #1578 catalog audit imports them from
libSceLibcInternal(resolved throughlibc.prx):fabs: PPSA74126 Stremio Plus, PPSA99003 ProsperoTV, PPSA99169 RetroArchsqrt: PPSA99001 ProsperoRadio, PPSA99003 ProsperoTV, PPSA99169 RetroArchtrunc: PPSA99001 ProsperoRadio, PPSA99003 ProsperoTVfma: PPSA99169 RetroArch, PPSA99764 PorpoiseI haven't run any of these titles.
Tested
Windows 11, WinLibs GCC 15.2.0 r7, Release,
-DBUILD_TESTING=ON:CheckExactOperationsinguest_math_tests:trunc: signed zero (trunc(-0.5)is-0), 2^52+1,-1e300, infinities and NaN;fabs: clears the sign of-0and of a negative NaN;sqrt: correctly rounded (sqrt(2) == 1.4142135623730951),sqrt(-0) == -0,sqrt(denorm_min), NaN for negatives;fma: single rounding (fma(0.1, 10, -1) == 0x1p-54, where0.1 * 10 - 1gives 0), no intermediate overflow (fma(2^1023, 2, -2^1023) == 2^1023), andfma(inf, 0, 1)is NaN.x * y + zforfma,pow(x, 0.5)forsqrt, along longround trip fortruncandx < 0 ? -x : xforfabseach makeguest_mathfail.cmake --build build --target libs: the patchedlibc.prxexports all 4 NIDs.tools/check_conventions.pypasses, andtools/pr_overlap.py --branchreports no overlap. This branch also merges cleanly with my #2158 and #2166.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-09T10:33:56Z.
Progress report (
51f69aa→da7feb0)📈 System libraries: 84.71% (+0.02%, +4 implemented functions)
✅ 4 implemented
fabs_nid_postfixfma_nid_postfixsqrt_nid_postfixtrunc_nid_postfixImported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-09T11:24:37Z.
Full Linux and Windows builds and tests for this head (
da7feb06), using the project's Build workflow. I can't start the upstream manual run, so I ran the samebuild.ymlin my fork through a mirror PR. Like the upstream run, the jobs check out the PR head merged into currentmain(d70b8998):ctest: 516/516 passedctest: 507/507 passedRun: https://github.com/AchrafReyani/AnyPS5/actions/runs/37920409715
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T20:09:23Z.
Closing: these four come from the #1578 import list, and none of the titles named is shown stopping at them on main (they weren't run). Library functions go in when a title reaches them; please reopen with the title ID and the log line when one does.
Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-11T06:38:13Z.
@AchrafReyani
fabsis now a title's next stop onmain52ce9b8a. Withpthread_set_name_np(#3031) merged, PSBox Cloud Gaming (PPSA99810) reports this on Linux (catalog build,sce_module/libc.prxunwrapped as #2605 requires):app.elf: symbol lookup error: app.elf: undefined symbol: 388LcMWHRCAsqrtfrom this PR is already in through #3233, and the head now conflicts withmaininGuestMath.cpp. With this PR'sfabs,truncandfmalines added tomain, PSBox goes on to_umtx_op(#1482).Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-11T07:10:03Z.
Thanks @babyhuey! Redone on current
mainas #3314:fabs,truncandfmaonly, sincesqrtis in through #3233.Pull request closed