test(libc): cover the untested libm exports #1844

Closed
NahuelGenchi wants to merge 1 commit from upstream-pr/1844 into main
NahuelGenchi commented 2026-10-08 21:26:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by NahuelGenchi on 2026-10-08T21:26:04Z.


What

The same scan for libc exports that no test mentions found 36 in Math.cpp. Almost all of them forward to the host libm, so nothing would notice a swapped argument or a wrong overload. This adds guest_math_basics:

  • Classification: __isfinite, __isnan, __signbit and the float variants, including negative zero, infinities, NaN and the smallest subnormal.
  • Results the standard fixes exactly: fmod (sign follows x, NaN for a zero divisor or infinite x), remainderf (ties to even), roundf (halves away from zero, -0.4 gives negative zero), modf and modff (the integral part keeps the sign, even for -0.5), ldexpf overflowing to infinity, exp2f and log2f on powers of two, powf(NaN, 0), tanh at the infinities, atan2 with a signed zero, acos and asin outside their domain.
  • Results compared within a small relative tolerance: cbrt, log10, tan, the inverse trigonometric functions, sincos and sincosf, expf, logf, sinf, cosf, and _FSinh and _FCosh (which scale by their second argument).

Left out: rand and srand, because checking them would mean copying the generator into the test.

No library code changes.

Tested

Ubuntu 26.04, GCC 15.2. The new test passes, and I flipped one expectation to confirm it aborts when a result is wrong. The convention checks pass. Not run on Windows locally, so the Windows job is the first run there; the exact comparisons are limited to results the standard fixes, but it will show if the Windows runtime disagrees on any of them.

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:4792985766 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1844). Originally posted by [NahuelGenchi](https://github.com/NahuelGenchi) on 2026-10-08T21:26:04Z. --- ### What The same scan for libc exports that no test mentions found 36 in `Math.cpp`. Almost all of them forward to the host libm, so nothing would notice a swapped argument or a wrong overload. This adds `guest_math_basics`: - Classification: `__isfinite`, `__isnan`, `__signbit` and the float variants, including negative zero, infinities, NaN and the smallest subnormal. - Results the standard fixes exactly: `fmod` (sign follows `x`, NaN for a zero divisor or infinite `x`), `remainderf` (ties to even), `roundf` (halves away from zero, `-0.4` gives negative zero), `modf` and `modff` (the integral part keeps the sign, even for `-0.5`), `ldexpf` overflowing to infinity, `exp2f` and `log2f` on powers of two, `powf(NaN, 0)`, `tanh` at the infinities, `atan2` with a signed zero, `acos` and `asin` outside their domain. - Results compared within a small relative tolerance: `cbrt`, `log10`, `tan`, the inverse trigonometric functions, `sincos` and `sincosf`, `expf`, `logf`, `sinf`, `cosf`, and `_FSinh` and `_FCosh` (which scale by their second argument). Left out: `rand` and `srand`, because checking them would mean copying the generator into the test. No library code changes. ### Tested Ubuntu 26.04, GCC 15.2. The new test passes, and I flipped one expectation to confirm it aborts when a result is wrong. The convention checks pass. Not run on Windows locally, so the Windows job is the first run there; the exact comparisons are limited to results the standard fixes, but it will show if the Windows runtime disagrees on any of them. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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
oneandonlydean commented 2026-10-09 08:57:05 +00:00 (Migrated from github.com)

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


Same as #1843, for Math.cpp.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6077739057 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1844#issuecomment-6077739057). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T08:57:05Z. --- Same as #1843, for `Math.cpp`.

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