feat(libc): implement nextafterf #2192

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

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


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:4799631978 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2192). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-09T11:12:40Z. --- ### 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)
github-actions[bot] commented 2026-10-09 11:13:03 +00:00 (Migrated from github.com)

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


Progress report (d70b899 → a9d3dd2)

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

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

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


Full Linux and Windows builds and tests for this head (a9d3dd2e), 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/37922331579

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6080142280 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2192#issuecomment-6080142280). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-09T11:41:15Z. --- Full Linux and Windows builds and tests for this head (`a9d3dd2e`), 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/37922331579/job/113793018493) | success; full build, `ctest`: 516/516 passed | | [windows](https://github.com/AchrafReyani/AnyPS5/actions/runs/37922331579/job/113793018422) | success; full build, `ctest`: 507/507 passed | | relinker (Linux, Windows, macOS) | success | Run: https://github.com/AchrafReyani/AnyPS5/actions/runs/37922331579
oneandonlydean commented 2026-10-09 20:10:01 +00:00 (Migrated from github.com)

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


Same as #2167, for nextafterf.

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

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


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 a9d3dd2e 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)
Stremio Plus (PPSA74126) undefined symbol: 3m2ro+Di+Ck (nextafterf) 17Mfe1B3X6U (_fstatfs)

Example lines for Stremio Plus (PPSA74126): main Windows FAIL: unresolved ELF import 3m2ro+Di+Ck (nextafterf) from libSceLibcInternal.prx; with this branch, Linux app.elf: symbol lookup error: app.elf: undefined symbol: 17Mfe1B3X6U, Windows FAIL: unresolved ELF import 17Mfe1B3X6U from libkernel.prx.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6092622333 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2192#issuecomment-6092622333). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-10T02:16:36Z. --- 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 a9d3dd2e 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) | |---|---|---| | Stremio Plus (PPSA74126) | `undefined symbol: 3m2ro+Di+Ck` (`nextafterf`) | `17Mfe1B3X6U` (`_fstatfs`) | Example lines for Stremio Plus (PPSA74126): `main` Windows `FAIL: unresolved ELF import 3m2ro+Di+Ck (nextafterf) from libSceLibcInternal.prx`; with this branch, Linux `app.elf: symbol lookup error: app.elf: undefined symbol: 17Mfe1B3X6U`, Windows `FAIL: unresolved ELF import 17Mfe1B3X6U from libkernel.prx`.
reyani-dev commented 2026-10-10 02:25:27 +00:00 (Migrated from github.com)

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


@oneandonlydean this now has the evidence the close note asked for, thanks to @babyhuey's run above: Stremio Plus (PPSA74126) stops at nextafterf (3m2ro+Di+Ck) on current main and moves on to _fstatfs 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:6092704237 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2192#issuecomment-6092704237). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-10T02:25:27Z. --- @oneandonlydean this now has the evidence the close note asked for, thanks to @babyhuey's run above: Stremio Plus (PPSA74126) stops at `nextafterf` (`3m2ro+Di+Ck`) on current `main` and moves on to `_fstatfs` 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:36 +00:00 (Migrated from github.com)

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


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

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6100848310 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2192#issuecomment-6100848310). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-10T18:34:36Z. --- Resubmitted as #2934 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!2192
No description provided.