feat(libc): export nextafter double math function #7874

Merged
ErenYeager1836 merged 1 commit from upstream-pr/7874 into main 2026-10-19 16:52:01 +00:00
ErenYeager1836 commented 2026-10-19 11:56:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ErenYeager1836 on 2026-10-19T11:56:00Z.


What

Export nextafter_nid_postfix(double x, double y) in core/libs/prx/libc/src/Math.cpp delegating directly to std::nextafter(double, double).

Fixes part of #7624, unblocking unresolved import h+J60RRlfnk in PPSA26578 (Unity/IL2CPP).

Tested

  • Added unit test assertions in core/libs/tests/GuestMath.cpp:
    • Stepping towards +0.0 and -0.0
    • Stepping across zero
    • Subnormal smallest step from 0.0
    • Stepping to/from \pm\infty
    • NaN propagation
  • python tools/check_conventions.py passes 100%.

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 under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: part of #7624
  • Unblocks: PPSA26578
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4920527481 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7874). Originally posted by [ErenYeager1836](https://github.com/ErenYeager1836) on 2026-10-19T11:56:00Z. --- ### What Export `nextafter_nid_postfix(double x, double y)` in `core/libs/prx/libc/src/Math.cpp` delegating directly to `std::nextafter(double, double)`. Fixes part of #7624, unblocking unresolved import `h+J60RRlfnk` in PPSA26578 (Unity/IL2CPP). ### Tested - Added unit test assertions in `core/libs/tests/GuestMath.cpp`: - Stepping towards $+0.0$ and $-0.0$ - Stepping across zero - Subnormal smallest step from $0.0$ - Stepping to/from $\pm\infty$ - NaN propagation - `python tools/check_conventions.py` passes 100%. ### 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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical debt file - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: part of #7624 - [x] Unblocks: PPSA26578 - [x] GPUs tested: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-19 11:56:45 +00:00 (Migrated from github.com)

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


Progress report (6762694 → 6487d5e)

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

✅ 1 implemented
Library Name
libc nextafter_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6266636042 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7874#issuecomment-6266636042). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T11:56:45Z. --- <!-- progress-report --> ### Progress report (6762694 → 6487d5e) ➖ **System libraries**: 82.17% (+0.0%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libc | `nextafter_nid_postfix` | </details>
github-actions[bot] commented 2026-10-19 12:10:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T12:10:02Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 6295 core/libs/prx/libc/src/Math.cpp L530
core/libs/tests/GuestMath.cpp L109, L1145
nextafter_nid_postfix

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 6044 core/libs/tests/GuestMath.cpp
PR 6158 core/libs/prx/libc/src/Math.cpp
core/libs/tests/GuestMath.cpp
PR 6879 core/libs/prx/libc/src/Math.cpp
PR 7201 core/libs/prx/libc/src/Math.cpp
PR 7332 core/libs/prx/libc/src/Math.cpp
core/libs/tests/GuestMath.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6266868920 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7874#issuecomment-6266868920). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T12:10:02Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 6295](https://www.github.com/boykopovar/AnyPS5/pull/6295) | `core/libs/prx/libc/src/Math.cpp` [L530](https://github.com/boykopovar/AnyPS5/blob/95d901b9371f2c623b8894b2ace401132d36256a/core/libs/prx/libc/src/Math.cpp#L530)<br>`core/libs/tests/GuestMath.cpp` [L109](https://github.com/boykopovar/AnyPS5/blob/95d901b9371f2c623b8894b2ace401132d36256a/core/libs/tests/GuestMath.cpp#L109), [L1145](https://github.com/boykopovar/AnyPS5/blob/95d901b9371f2c623b8894b2ace401132d36256a/core/libs/tests/GuestMath.cpp#L1145) | `nextafter_nid_postfix` | | Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestMath.cpp` | | [PR 6158](https://www.github.com/boykopovar/AnyPS5/pull/6158) | `core/libs/prx/libc/src/Math.cpp`<br>`core/libs/tests/GuestMath.cpp` | | [PR 6879](https://www.github.com/boykopovar/AnyPS5/pull/6879) | `core/libs/prx/libc/src/Math.cpp` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libc/src/Math.cpp` | | [PR 7332](https://www.github.com/boykopovar/AnyPS5/pull/7332) | `core/libs/prx/libc/src/Math.cpp`<br>`core/libs/tests/GuestMath.cpp` |
fogydes commented 2026-10-19 12:25:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fogydes on 2026-10-19T12:25:06Z.

Review: COMMENTED


The implementation in core/libs/prx/libc/src/Math.cpp and unit test assertions in core/libs/tests/GuestMath.cpp are clean and correct:

  • nextafter_nid_postfix maps directly to std::nextafter(double, double).
  • Normal steps, denormals, infinities, quiet NaNs, and negative zero are covered in GuestMath.cpp.
  • Built guest_math_tests.exe locally with MinGW-w64 GCC 15.2.0 (Release) and verified guest_math CTest passes in 0.05s.

The CI conventions workflow failed because the PR description omitted the template sections from .github/pull_request_template.md. Adding ### Tested and ### Checklist to the PR description will clear the failure:

### What

PPSA26578 (issue #7624) imports `nextafter` (NID `h+J60RRlfnk`) from `libc`, and its bundled `libc.prx` does not export it, causing the process to exit at start-up on `main` with:

```text
0xC0000139 (GetLastError: 127)
unresolved ELF import h+J60RRlfnk from libc.prx

Currently, core/libs/prx/libc/src/Math.cpp implements nextafterf (float). This exports the double-precision variant nextafter:

  • double APS5_VABI nextafter_nid_postfix(double x, double y) delegating to std::nextafter(double, double).
  • Unit test coverage in GuestMath.cpp verifying normal steps, denormals, infinities, quiet NaNs, and negative zero behavior.

Fixes part of #7624.

Tested

Windows 11, MinGW-w64 GCC 15.2.0 (Release). Built guest_math_tests and verified guest_math CTest passes.

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 under Silent stubs in their library's technical debt file
  • 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
  • Fixes: none
  • Unblocks: PPSA26578 #7624
  • GPUs tested: n/a
  • AI-assisted: no
*(If AI assistance was used, adjust `AI-assisted` to `yes`)*.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5571487857 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7874#pullrequestreview-5571487857). Originally posted by [fogydes](https://github.com/fogydes) on 2026-10-19T12:25:06Z. **Review:** COMMENTED --- The implementation in `core/libs/prx/libc/src/Math.cpp` and unit test assertions in `core/libs/tests/GuestMath.cpp` are clean and correct: - `nextafter_nid_postfix` maps directly to `std::nextafter(double, double)`. - Normal steps, denormals, infinities, quiet NaNs, and negative zero are covered in `GuestMath.cpp`. - Built `guest_math_tests.exe` locally with MinGW-w64 GCC 15.2.0 (Release) and verified `guest_math` CTest passes in 0.05s. The CI `conventions` workflow failed because the PR description omitted the template sections from `.github/pull_request_template.md`. Adding `### Tested` and `### Checklist` to the PR description will clear the failure: ```markdown ### What PPSA26578 (issue #7624) imports `nextafter` (NID `h+J60RRlfnk`) from `libc`, and its bundled `libc.prx` does not export it, causing the process to exit at start-up on `main` with: ```text 0xC0000139 (GetLastError: 127) unresolved ELF import h+J60RRlfnk from libc.prx ``` Currently, `core/libs/prx/libc/src/Math.cpp` implements `nextafterf` (float). This exports the double-precision variant `nextafter`: - `double APS5_VABI nextafter_nid_postfix(double x, double y)` delegating to `std::nextafter(double, double)`. - Unit test coverage in `GuestMath.cpp` verifying normal steps, denormals, infinities, quiet NaNs, and negative zero behavior. Fixes part of #7624. ### Tested Windows 11, MinGW-w64 GCC 15.2.0 (Release). Built `guest_math_tests` and verified `guest_math` CTest passes. ### 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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical debt file - [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] Fixes: none - [x] Unblocks: PPSA26578 #7624 - [x] GPUs tested: n/a - [x] AI-assisted: no ``` *(If AI assistance was used, adjust `AI-assisted` to `yes`)*.
ErenYeager1836 commented 2026-10-19 13:44:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ErenYeager1836 on 2026-10-19T13:44:20Z.


Thanks for the verification @fogydes! Updated the PR description with the required ### Checklist and ### Tested sections. Conventions CI is now passing green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6268696609 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7874#issuecomment-6268696609). Originally posted by [ErenYeager1836](https://github.com/ErenYeager1836) on 2026-10-19T13:44:20Z. --- Thanks for the verification @fogydes! Updated the PR description with the required `### Checklist` and `### Tested` sections. Conventions CI is now passing green.
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!7874
No description provided.