feat(libc): implement rint and lrint families #2235

Closed
obojeoboje wants to merge 1 commit from upstream-pr/2235 into main
obojeoboje commented 2026-10-09 12:38:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by obojeoboje on 2026-10-09T12:38:34Z.


What

Implement nine libc exports: rint, rintf, rintl, lrint, lrintf, lrintl, llrint, llrintf, and llrintl.

The functions honor the active floating-point rounding mode and preserve floating-point exception behavior. Guest long results use the host llrint overloads to retain 64-bit values on Windows. Extended-precision overloads retain the guest x87 long double representation. Compile only this translation unit with -frounding-math; without it GCC's optimized rint gives incorrect negative results under directed rounding.

Behavior references: FreeBSD rint(3) and lrint(3). Export names are present in the shadPS4 aerolib table.

The progress scanner changes from 2578/3044 (84.69%) to 2587/3053 (84.74%). These are newly declared exports, so both counts grow.

Tested

Windows, WinLibs GCC 15.2, Release build with testing enabled. No game tested.

  • Full default build and libs target passed.
  • Full CTest run with four workers and a 30-second per-test limit: 507 passed, one skipped (guest_video_out_wqhd_detection_no_vulkan), zero failures; 37.64 seconds total.
  • New runtime tests cover all nine exports under all four rounding modes, ties, signed zero, infinities, NaN, FE_INEXACT, invalid integer conversions (FE_INVALID), results beyond 32 bits, integer boundaries, and extended precision beyond double. Invalid-conversion return values are deliberately not asserted because they are unspecified.
  • Test registration and conventions checks passed.
  • Full Linux/Windows CI and the relinker matrix still require a collaborator to dispatch the Build workflow for this PR head.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4800513122 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2235). Originally posted by [obojeoboje](https://github.com/obojeoboje) on 2026-10-09T12:38:34Z. --- ### What Implement nine libc exports: `rint`, `rintf`, `rintl`, `lrint`, `lrintf`, `lrintl`, `llrint`, `llrintf`, and `llrintl`. The functions honor the active floating-point rounding mode and preserve floating-point exception behavior. Guest `long` results use the host `llrint` overloads to retain 64-bit values on Windows. Extended-precision overloads retain the guest x87 `long double` representation. Compile only this translation unit with `-frounding-math`; without it GCC's optimized `rint` gives incorrect negative results under directed rounding. Behavior references: FreeBSD [rint(3)](https://man.freebsd.org/cgi/man.cgi?manpath=FreeBSD+15.0-RELEASE&query=rint&sektion=3) and [lrint(3)](https://man.freebsd.org/cgi/man.cgi?manpath=FreeBSD+14.0-RELEASE&query=lrint&sektion=3). Export names are present in the [shadPS4 aerolib table](https://github.com/shadps4-emu/shadPS4/blob/0fe263a4760dfbfa973366890061749b4af0de97/src/core/aerolib/aerolib.inl). The progress scanner changes from 2578/3044 (84.69%) to 2587/3053 (84.74%). These are newly declared exports, so both counts grow. ### Tested Windows, WinLibs GCC 15.2, Release build with testing enabled. No game tested. - Full default build and `libs` target passed. - Full CTest run with four workers and a 30-second per-test limit: 507 passed, one skipped (`guest_video_out_wqhd_detection_no_vulkan`), zero failures; 37.64 seconds total. - New runtime tests cover all nine exports under all four rounding modes, ties, signed zero, infinities, NaN, `FE_INEXACT`, invalid integer conversions (`FE_INVALID`), results beyond 32 bits, integer boundaries, and extended precision beyond double. Invalid-conversion return values are deliberately not asserted because they are unspecified. - Test registration and conventions checks passed. - Full Linux/Windows CI and the relinker matrix still require a collaborator to dispatch the Build workflow for this PR head. ### 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 in TechnicalDebt - [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
github-actions[bot] commented 2026-10-09 13:33:30 +00:00 (Migrated from github.com)

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


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
#2170 core/libs/prx/libc/CMakeLists.txt L48
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6081967577 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2235#issuecomment-6081967577). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T13:33:30Z. --- <!-- 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 | |---|---|---|---| | #2170 | `core/libs/prx/libc/CMakeLists.txt` [L48](https://github.com/boykopovar/AnyPS5/blob/8b393b6e9a8ade9188d4f74a0293e0efd9828597/core/libs/prx/libc/CMakeLists.txt#L48) | | |
oneandonlydean commented 2026-10-09 20:10:43 +00:00 (Migrated from github.com)

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


Same as #2217, for the rint/lrint family.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6088452934 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2235#issuecomment-6088452934). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T20:10:43Z. --- Same as #2217, for the `rint`/`lrint` family.

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