feat(libc): implement nextafter and tgammaf exports #1806

Closed
Prophet069 wants to merge 1 commit from upstream-pr/1806 into main
Prophet069 commented 2026-10-08 19:52:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Prophet069 on 2026-10-08T19:52:57Z.


What

Add the missing nextafterf, nextafter and tgammaf libc exports. Titles importing these functions currently fail import resolution because their NIDs are absent from the built library.

The exports delegate to the matching float/double overloads of std::nextafter and std::tgamma, following the existing Math.cpp convention. Each uses extern "C", APS5_VABI and the _nid_postfix naming mechanism. No fallback values, title-specific behavior or new dependencies are introduced.

Add guest_math_exports, a CTest regression test for neighboring IEEE-754 values, equal arguments, signed zeros, subnormals, NaNs, infinities, gamma values, poles, domain errors and overflow/underflow. Floating-point exception and errno checks follow the host's advertised math_errhandling capabilities.

This PR contains only the three exports, their behavior test and its CMake registration. It is independent of the subsequent local developments.

Tested

Windows x86-64, MinGW-w64 GCC 15.2.0 UCRT, Release, CMake/Ninja. Built the full libc target, guest_math_exports_tests, guest_math_tests and nid_patcher from this PR's separate worktree, using at most four parallel jobs. Both guest_math_exports and guest_math passed; individual test durations were 0.12 s and 0.03 s.

Patched the freshly built libc.prx with the project's NID patcher and independently verified all three PE exports:

  • nextafterf: 3m2ro+Di+Ck
  • nextafter: h+J60RRlfnk
  • tgammaf: B2ZbqV9geCM

Reviewed ABI declarations: Windows uses the existing System-V APS5_VABI bridge; Linux uses its native System-V ABI. The implementation and regression test use portable C++20 facilities. Linux compilation and runtime tests were not performed because no usable Linux environment is available on this host; Linux CI validation remains outstanding. No converted title was started for this PR validation.

The official tools/check_conventions.py --base origin/main check was run with the planned title and this description supplied through --title and --body. It passed. The complete three-file diff was reviewed and git diff --check origin/main...HEAD passed.

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, OpenAI Codex. The submitting author is responsible for reviewing and validating every line.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4792049062 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1806). Originally posted by [Prophet069](https://github.com/Prophet069) on 2026-10-08T19:52:57Z. --- ### What Add the missing `nextafterf`, `nextafter` and `tgammaf` libc exports. Titles importing these functions currently fail import resolution because their NIDs are absent from the built library. The exports delegate to the matching float/double overloads of `std::nextafter` and `std::tgamma`, following the existing `Math.cpp` convention. Each uses `extern "C"`, `APS5_VABI` and the `_nid_postfix` naming mechanism. No fallback values, title-specific behavior or new dependencies are introduced. Add `guest_math_exports`, a CTest regression test for neighboring IEEE-754 values, equal arguments, signed zeros, subnormals, NaNs, infinities, gamma values, poles, domain errors and overflow/underflow. Floating-point exception and errno checks follow the host's advertised `math_errhandling` capabilities. This PR contains only the three exports, their behavior test and its CMake registration. It is independent of the subsequent local developments. ### Tested Windows x86-64, MinGW-w64 GCC 15.2.0 UCRT, Release, CMake/Ninja. Built the full `libc` target, `guest_math_exports_tests`, `guest_math_tests` and `nid_patcher` from this PR's separate worktree, using at most four parallel jobs. Both `guest_math_exports` and `guest_math` passed; individual test durations were 0.12 s and 0.03 s. Patched the freshly built `libc.prx` with the project's NID patcher and independently verified all three PE exports: - `nextafterf`: `3m2ro+Di+Ck` - `nextafter`: `h+J60RRlfnk` - `tgammaf`: `B2ZbqV9geCM` Reviewed ABI declarations: Windows uses the existing System-V `APS5_VABI` bridge; Linux uses its native System-V ABI. The implementation and regression test use portable C++20 facilities. Linux compilation and runtime tests were not performed because no usable Linux environment is available on this host; Linux CI validation remains outstanding. No converted title was started for this PR validation. The official `tools/check_conventions.py --base origin/main` check was run with the planned title and this description supplied through `--title` and `--body`. It passed. The complete three-file diff was reviewed and `git diff --check origin/main...HEAD` passed. ### 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, OpenAI Codex. The submitting author is responsible for reviewing and validating every line.
github-actions[bot] commented 2026-10-09 05:32:40 +00:00 (Migrated from github.com)

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


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
#2001 core/libs/prx/libc/CMakeLists.txt L44-77
#2019 core/libs/prx/libc/CMakeLists.txt L48
#2058 core/libs/prx/libc/CMakeLists.txt L48
#2059 core/libs/prx/libc/CMakeLists.txt L48
#2060 core/libs/prx/libc/CMakeLists.txt L48
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6074958836 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1806#issuecomment-6074958836). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T05:32:40Z. --- <!-- 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 | |---|---|---|---| | #2001 | `core/libs/prx/libc/CMakeLists.txt` [L44-77](https://github.com/boykopovar/AnyPS5/blob/f145139676a48306681d3a4d5fabf83938759daf/core/libs/prx/libc/CMakeLists.txt#L44-L77) | | | | #2019 | `core/libs/prx/libc/CMakeLists.txt` [L48](https://github.com/boykopovar/AnyPS5/blob/f145139676a48306681d3a4d5fabf83938759daf/core/libs/prx/libc/CMakeLists.txt#L48) | | | | #2058 | `core/libs/prx/libc/CMakeLists.txt` [L48](https://github.com/boykopovar/AnyPS5/blob/f145139676a48306681d3a4d5fabf83938759daf/core/libs/prx/libc/CMakeLists.txt#L48) | | | | #2059 | `core/libs/prx/libc/CMakeLists.txt` [L48](https://github.com/boykopovar/AnyPS5/blob/f145139676a48306681d3a4d5fabf83938759daf/core/libs/prx/libc/CMakeLists.txt#L48) | | | | #2060 | `core/libs/prx/libc/CMakeLists.txt` [L48](https://github.com/boykopovar/AnyPS5/blob/f145139676a48306681d3a4d5fabf83938759daf/core/libs/prx/libc/CMakeLists.txt#L48) | | |
oneandonlydean commented 2026-10-09 08:55:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T08:55:38Z.


Closing: no title is shown to reach nextafterf, nextafter or tgammaf on main. Reopen with the title ID and the log line where it stops if you find one.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6077718247 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1806#issuecomment-6077718247). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T08:55:38Z. --- Closing: no title is shown to reach `nextafterf`, `nextafter` or `tgammaf` on main. Reopen with the title ID and the log line where it stops if you find one.

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!1806
No description provided.