feat(libc): implement llroundf #2189

Closed
reyani-dev wants to merge 1 commit from upstream-pr/2189 into main
reyani-dev commented 2026-10-09 11:10:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-09T11:10:49Z.


What

Exports llroundf next to lroundf and llround, which round the same way: halfway cases away from zero, into a 64-bit result.

Title: PPSA99169 RetroArch imports it from libSceLibcInternal (resolved through libc.prx), per the #1578 audit. I haven't run the title.

Tested

Windows 11, WinLibs GCC 15.2.0 r7, Release, -DBUILD_TESTING=ON:

  • New checks in guest_math_tests, next to the llround case:
    • halfway cases away from zero (±2.5f);
    • -0.4f → 0;
    • results beyond 32 bits (2^33, -2^62);
    • 0.49999997f → 0, which floor(x + 0.5f) gets wrong because the sum rounds up to 1;
    • 16777215.f.
  • Mutation check: floor(x + 0.5f) and the host lround (32-bit long on Windows) each make guest_math fail.
  • cmake --build build --target libs: the patched libc.prx exports eQhBFnTOp40.
  • tools/check_conventions.py passes, and tools/pr_overlap.py --branch reports no overlap.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4799614632 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2189). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-09T11:10:49Z. --- ### What Exports `llroundf` next to `lroundf` and `llround`, which round the same way: halfway cases away from zero, into a 64-bit result. Title: PPSA99169 RetroArch imports it from `libSceLibcInternal` (resolved through `libc.prx`), per the #1578 audit. I haven't run the title. ### Tested Windows 11, WinLibs GCC 15.2.0 r7, Release, `-DBUILD_TESTING=ON`: - New checks in `guest_math_tests`, next to the `llround` case: - halfway cases away from zero (`±2.5f`); - `-0.4f` → 0; - results beyond 32 bits (`2^33`, `-2^62`); - `0.49999997f` → 0, which `floor(x + 0.5f)` gets wrong because the sum rounds up to 1; - `16777215.f`. - Mutation check: `floor(x + 0.5f)` and the host `lround` (32-bit `long` on Windows) each make `guest_math` fail. - `cmake --build build --target libs`: the patched `libc.prx` exports `eQhBFnTOp40`. - `tools/check_conventions.py` passes, and `tools/pr_overlap.py --branch` reports no overlap. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-09 11:11:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T11:11:11Z.


Progress report (d70b899 → babc53f)

📈 System libraries: 84.7% (+0.01%, +1 implemented functions)

✅ 1 implemented
Library Name
libc llroundf_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6079709365 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2189#issuecomment-6079709365). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T11:11:11Z. --- <!-- progress-report --> ### Progress report (d70b899 → babc53f) 📈 **System libraries**: 84.7% (+0.01%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libc | `llroundf_nid_postfix` | </details>
reyani-dev commented 2026-10-09 11:34:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-09T11:34:18Z.


Full Linux and Windows builds and tests for this head (babc53fb), using the project's Build workflow. I can't start the upstream manual run, so I ran the same build.yml in my fork through a mirror PR. Like the upstream run, the jobs check out the PR head merged into current main (d70b8998):

Job Result
linux success; full build, ctest: 516/516 passed
windows success; full build, ctest: 507/507 passed
relinker (Linux, Windows, macOS) success

Run: https://github.com/AchrafReyani/AnyPS5/actions/runs/37922143613

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6080041080 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2189#issuecomment-6080041080). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-09T11:34:18Z. --- Full Linux and Windows builds and tests for this head (`babc53fb`), using the project's Build workflow. I can't start the upstream manual run, so I ran the same `build.yml` in my fork through a mirror PR. Like the upstream run, the jobs check out the PR head merged into current `main` (`d70b8998`): | Job | Result | |---|---| | [linux](https://github.com/AchrafReyani/AnyPS5/actions/runs/37922143613/job/113792399170) | success; full build, `ctest`: 516/516 passed | | [windows](https://github.com/AchrafReyani/AnyPS5/actions/runs/37922143613/job/113792399276) | success; full build, `ctest`: 507/507 passed | | relinker (Linux, Windows, macOS) | success | Run: https://github.com/AchrafReyani/AnyPS5/actions/runs/37922143613
oneandonlydean commented 2026-10-09 20:09:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T20:09:57Z.


Same as #2167, for llroundf.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6088441711 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2189#issuecomment-6088441711). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T20:09:57Z. --- Same as #2167, for `llroundf`.
babyhuey commented 2026-10-10 02:16:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-10T02:16:35Z.


This is now a title's next stop on current main, so here is the log line the close note asked for, plus a check of this branch.

Checked babc53fb merged onto main c963432d (clean), Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC from WinLibs), Release.

  • guest_math passes 5/5 on both (--repeat until-fail:5); no CRT assertion dialog on Windows.
  • On main (catalog runs on 2edaf7f4 Linux and 0c0dc1e9 Windows) and with this branch:
Title main with this branch (Linux and Windows)
OpenRCT2 Native Port (PPSA99728) undefined symbol: eQhBFnTOp40 (llroundf) +my9jdHCMIQ (atol)

Example lines for OpenRCT2 Native Port (PPSA99728): main Windows FAIL: unresolved ELF import eQhBFnTOp40 (llroundf) from libSceLibcInternal.prx; with this branch, Linux app.elf: symbol lookup error: app.elf: undefined symbol: +my9jdHCMIQ, Windows FAIL: unresolved ELF import +my9jdHCMIQ from libSceLibcInternal.prx.

The next stop, atol, is #2186.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6092622141 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2189#issuecomment-6092622141). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-10T02:16:35Z. --- This is now a title's next stop on current `main`, so here is the log line the close note asked for, plus a check of this branch. Checked babc53fb merged onto `main` c963432d (clean), Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC from WinLibs), Release. - `guest_math` passes 5/5 on both (`--repeat until-fail:5`); no CRT assertion dialog on Windows. - On `main` (catalog runs on 2edaf7f4 Linux and 0c0dc1e9 Windows) and with this branch: | Title | `main` | with this branch (Linux and Windows) | |---|---|---| | OpenRCT2 Native Port (PPSA99728) | `undefined symbol: eQhBFnTOp40` (`llroundf`) | `+my9jdHCMIQ` (`atol`) | Example lines for OpenRCT2 Native Port (PPSA99728): `main` Windows `FAIL: unresolved ELF import eQhBFnTOp40 (llroundf) from libSceLibcInternal.prx`; with this branch, Linux `app.elf: symbol lookup error: app.elf: undefined symbol: +my9jdHCMIQ`, Windows `FAIL: unresolved ELF import +my9jdHCMIQ from libSceLibcInternal.prx`. The next stop, `atol`, is #2186.
reyani-dev commented 2026-10-10 02:25:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-10T02:25:28Z.


@oneandonlydean this now has the evidence the close note asked for, thanks to @babyhuey's run above: OpenRCT2 Native Port (PPSA99728) stops at llroundf (eQhBFnTOp40) on current main and moves on to atol (#2186) with this branch. Could you reopen it? GitHub doesn't let me reopen a PR a maintainer closed. I also rechecked this branch merged onto current main on Windows: guest_math passes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6092704419 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2189#issuecomment-6092704419). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-10T02:25:28Z. --- @oneandonlydean this now has the evidence the close note asked for, thanks to @babyhuey's run above: OpenRCT2 Native Port (PPSA99728) stops at `llroundf` (`eQhBFnTOp40`) on current `main` and moves on to `atol` (#2186) with this branch. Could you reopen it? GitHub doesn't let me reopen a PR a maintainer closed. I also rechecked this branch merged onto current `main` on Windows: `guest_math` passes.
reyani-dev commented 2026-10-10 18:34:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-10T18:34:35Z.


Resubmitted as #2933 now that intake allows it, rebased onto current main with the title evidence above.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6100848109 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2189#issuecomment-6100848109). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-10T18:34:35Z. --- Resubmitted as #2933 now that intake allows it, rebased onto current `main` with the title evidence above.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!2189
No description provided.