fix(libc): compute logl, log10l and log2l with _LLog #18110

Merged
AasishDairelSahayaGrinspan merged 1 commit from upstream-pr/18110 into main 2026-11-12 21:45:08 +00:00
AasishDairelSahayaGrinspan commented 2026-11-10 13:24:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AasishDairelSahayaGrinspan on 2026-11-10T13:24:38Z.


What

The libc.prx bundled with PPSA21564 computes logl, log10l and log2l by calling _LLog with the bases 0, 1 and -1, as the _LLog entry records. The _LLog implementation ported from that binary already lives in this libc and gives the same bits, errno and floating-point flags on four million random arguments at 64-, 53- and 24-bit precision, but the three exports still called the host library — whose results differed on 869,197, 2,000,696 and 306,649 of those arguments at 64 bits.

The three exports now forward to _LLog: log10l(1000) is exactly 3, logl(0) raises FE_DIVBYZERO and sets ERANGE, and logl of a negative argument raises FE_INVALID and sets EDOM, as the module does. The _XLgamma long double path inherits the improvement through its logl call. The debt entry drops the closed clause, and the host-computed ld80 list loses logl and log10l.

The focused test pins the recorded behavior: the exact-3 results, the measured-fraction bits from the _LLog table, positive zero for logl(1), and the errno/flag pairs for zero and negative arguments.

Tested

macOS 15 (arm64 host, x86_64 target via Rosetta), Apple Clang, Release:

  • All six new TestLongLogExports assertions pass (verified by hoisting the call ahead of a pre-existing, unrelated _Exp subnormal result classification failure that clean main already shows on this host — that failure exists without this change and is not touched here).
  • python3 tools/check_conventions.py --base origin/main: passed.

Linux and Windows run the full suite in CI; the change is three forwarding calls over the already-tested _LLog.

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: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5242053359 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18110). Originally posted by [AasishDairelSahayaGrinspan](https://github.com/AasishDairelSahayaGrinspan) on 2026-11-10T13:24:38Z. --- ### What The `libc.prx` bundled with PPSA21564 computes `logl`, `log10l` and `log2l` by calling `_LLog` with the bases 0, 1 and -1, as the [_LLog entry](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/debt/libc.md) records. The `_LLog` implementation ported from that binary already lives in this libc and gives the same bits, `errno` and floating-point flags on four million random arguments at 64-, 53- and 24-bit precision, but the three exports still called the host library — whose results differed on 869,197, 2,000,696 and 306,649 of those arguments at 64 bits. The three exports now forward to `_LLog`: `log10l(1000)` is exactly 3, `logl(0)` raises `FE_DIVBYZERO` and sets `ERANGE`, and `logl` of a negative argument raises `FE_INVALID` and sets `EDOM`, as the module does. The `_XLgamma` long double path inherits the improvement through its `logl` call. The debt entry drops the closed clause, and the host-computed ld80 list loses `logl` and `log10l`. The focused test pins the recorded behavior: the exact-3 results, the measured-fraction bits from the `_LLog` table, positive zero for `logl(1)`, and the errno/flag pairs for zero and negative arguments. ### Tested macOS 15 (arm64 host, x86_64 target via Rosetta), Apple Clang, Release: - All six new `TestLongLogExports` assertions pass (verified by hoisting the call ahead of a pre-existing, unrelated `_Exp subnormal result classification` failure that clean `main` already shows on this host — that failure exists without this change and is not touched here). - `python3 tools/check_conventions.py --base origin/main`: passed. Linux and Windows run the full suite in CI; the change is three forwarding calls over the already-tested `_LLog`. ### 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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/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 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
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!18110
No description provided.