feat(libc): implement nextafterf #2934

Merged
reyani-dev merged 1 commit from upstream-pr/2934 into main 2026-10-10 20:09:09 +00:00
reyani-dev commented 2026-10-10 18:33:56 +00:00 (Migrated from github.com)

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


Resubmission of #2192, which was closed because no title was shown stopping on it. The title evidence has since been posted there by @babyhuey (run):

On main c963432d, Stremio Plus (PPSA74126) stops at nextafterf (3m2ro+Di+Ck): Windows FAIL: unresolved ELF import 3m2ro+Di+Ck (nextafterf) from libSceLibcInternal.prx, Linux undefined symbol: 3m2ro+Di+Ck. With this change it moves on to _fstatfs.

The function is still absent on current main, and no open PR implements it. The branch is rebased onto current main. Windows 11 (WinLibs GCC 15.2.0), Release: guest_math passes 3/3, check_conventions.py passes, and pr_overlap.py reports no overlap.


What

Exports nextafterf next to remainderf. It forwards to std::nextafter on float, so it steps by one float ULP toward the second argument.

Title: PPSA74126 Stremio Plus 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 scalbnf:
    • both neighbours of 1 (0x1.000002p0f, 0x1.fffffep-1f);
    • ±denorm_min from 0, and back to 0;
    • x == y returns y, so nextafterf(-0, +0) is +0;
    • FLT_MAX toward infinity gives infinity;
    • NaN in either argument.
  • Mutation check: computing in double and casting back (which returns x unchanged), or returning x when x == y, each make guest_math fail.
  • cmake --build build --target libs: the patched libc.prx exports 3m2ro+Di+Ck.
  • 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:4813521651 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2934). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-10T18:33:56Z. --- Resubmission of #2192, which was closed because no title was shown stopping on it. The title evidence has since been posted there by @babyhuey ([run](https://github.com/boykopovar/AnyPS5/pull/2192#issuecomment-6092622333)): On `main` c963432d, Stremio Plus (PPSA74126) stops at `nextafterf` (`3m2ro+Di+Ck`): Windows `FAIL: unresolved ELF import 3m2ro+Di+Ck (nextafterf) from libSceLibcInternal.prx`, Linux `undefined symbol: 3m2ro+Di+Ck`. With this change it moves on to `_fstatfs`. The function is still absent on current `main`, and no open PR implements it. The branch is rebased onto current `main`. Windows 11 (WinLibs GCC 15.2.0), Release: `guest_math` passes 3/3, `check_conventions.py` passes, and `pr_overlap.py` reports no overlap. --- ### What Exports `nextafterf` next to `remainderf`. It forwards to `std::nextafter` on `float`, so it steps by one `float` ULP toward the second argument. Title: PPSA74126 Stremio Plus 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 `scalbnf`: - both neighbours of 1 (`0x1.000002p0f`, `0x1.fffffep-1f`); - ±`denorm_min` from 0, and back to 0; - `x == y` returns `y`, so `nextafterf(-0, +0)` is `+0`; - `FLT_MAX` toward infinity gives infinity; - NaN in either argument. - Mutation check: computing in `double` and casting back (which returns `x` unchanged), or returning `x` when `x == y`, each make `guest_math` fail. - `cmake --build build --target libs`: the patched `libc.prx` exports `3m2ro+Di+Ck`. - `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)
reyani-dev commented 2026-10-10 18:57:16 +00:00 (Migrated from github.com)

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


Full Linux and Windows builds and tests for this head (fc828e19), 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 (bf6e25a1):

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

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

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6101048916 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2934#issuecomment-6101048916). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-10T18:57:16Z. --- Full Linux and Windows builds and tests for this head (`fc828e19`), 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` (`bf6e25a1`): | Job | Result | |---|---| | [linux](https://github.com/AchrafReyani/AnyPS5/actions/runs/38076406934/job/114284395385) | success; full build, `ctest`: 703/703 passed | | [windows](https://github.com/AchrafReyani/AnyPS5/actions/runs/38076406934/job/114284395409) | success; full build, `ctest`: 711/711 passed | | relinker (Linux, Windows, macOS) | success | Run: https://github.com/AchrafReyani/AnyPS5/actions/runs/38076406934
github-actions[bot] commented 2026-10-10 19:01:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T19:01:22Z.


Progress report (1476f76 → fc828e1)

➖ System libraries: 84.56% (+0.0%, +1 implemented functions)

✅ 1 implemented
Library Name
libc nextafterf_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6101086355 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2934#issuecomment-6101086355). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-10T19:01:22Z. --- <!-- progress-report --> ### Progress report (1476f76 → fc828e1) ➖ **System libraries**: 84.56% (+0.0%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libc | `nextafterf_nid_postfix` | </details>
babyhuey commented 2026-10-10 19:09:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-10T19:09:34Z.


Heads-up so the evidence here isn't read against the wrong layout: the runs of mine linked in the description are from main c963432d, before #2605. Since #2605 each title's sce_module/libc.prx has to be unwrapped, and that module is the SDK shim whose exports point 1872 libc functions at one return-0 stub (#2652). So on current main (9c5d67fb, catalog run with the module unwrapped) Stremio Plus (PPSA74126) stopped at _fstatfs (now merged in #2858) instead of nextafterf. The stop comes back once the shim's return-0 exports are left out, which is what the closed #2705 did; its table lists Stremio Plus at nextafterf (3m2ro+Di+Ck).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6101159973 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2934#issuecomment-6101159973). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-10T19:09:34Z. --- Heads-up so the evidence here isn't read against the wrong layout: the runs of mine linked in the description are from `main` c963432d, before #2605. Since #2605 each title's `sce_module/libc.prx` has to be unwrapped, and that module is the SDK shim whose exports point 1872 libc functions at one return-0 stub (#2652). So on current `main` (9c5d67fb, catalog run with the module unwrapped) Stremio Plus (PPSA74126) stopped at `_fstatfs` (now merged in #2858) instead of `nextafterf`. The stop comes back once the shim's return-0 exports are left out, which is what the closed #2705 did; its table lists Stremio Plus at `nextafterf` (`3m2ro+Di+Ck`).
reyani-dev commented 2026-10-10 19:17:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-10T19:17:32Z.


Thanks @babyhuey, that's an important caveat. These titles' imports declare libSceLibcInternal, so on current main they bind to the bundled SDK shim's return-0 export (#1497/#2652) instead of failing at load, which hides the stop. Once #1529 keeps libSceLibcInternal-declared imports host-bound, the stop comes back, as the closed #2705 table showed. Either way, these titles call the real function, so on main they currently get 0 from it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6101231787 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2934#issuecomment-6101231787). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-10T19:17:32Z. --- Thanks @babyhuey, that's an important caveat. These titles' imports declare `libSceLibcInternal`, so on current `main` they bind to the bundled SDK shim's return-0 export (#1497/#2652) instead of failing at load, which hides the stop. Once #1529 keeps `libSceLibcInternal`-declared imports host-bound, the stop comes back, as the closed #2705 table showed. Either way, these titles call the real function, so on `main` they currently get 0 from it.
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!2934
No description provided.