feat(libc): implement acosl and frexpl #3221

Merged
adriadam10 merged 1 commit from upstream-pr/3221 into main 2026-10-11 02:06:59 +00:00
adriadam10 commented 2026-10-11 01:59:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T01:59:07Z.


What

acosl (iH4YAIRcecA) and frexpl (YZk9sHO0yNg), both imported from libSceLibcInternal, aren't exported. Since #1529, Linux binds those imports to the system libraries, so each is the stop of a catalog homebrew title on main:

Title Stop on main f1ae427b6
RetroArch (PPSA99169) ./app.elf: symbol lookup error: ./app.elf: undefined symbol: iH4YAIRcecA (acosl)
PokeMMO Prospero (PPSA98001) ./app.elf: symbol lookup error: ./app.elf: undefined symbol: YZk9sHO0yNg (frexpl)

long double is the x87 80-bit format, as in Sony's own libc.prx (the one Astro's Playroom ships). There, frexpl loads its argument with fldt 0x8(%rsp) and returns in st(0), which is what APS5_VABI already does for strtold here.

  • acosl uses the host's math library, like acos and the other libc math functions here.
  • frexpl follows Sony's frexpl, which is FreeBSD's s_frexpl.c: for infinity and NaN it returns the argument without writing *exp. glibc's frexpl writes 0 there, so that case is handled before calling std::frexp, which is exact for every finite value.

TechnicalDebt records that acosl comes from the host library rather than the console's msun: the last bit can differ, and glibc sets EDOM where msun only raises the exception. asinh (Porpoise, PPSA99764) is left to #3190, which implements it.

Tested

Linux (CachyOS), GCC 16, Release.

  • guest_math passes. Expected values were computed independently with Python decimal at 80 digits and are compared bit for bit:
    • acosl(-1) is π in 80-bit (0x4000:c90fdaa22168c235), acosl(0) is π/2 and acosl(1) is +0; ±1.5 and -2 give NaN;
    • frexpl over 8, -3, 0.375 and the smallest subnormal (0x3ffe:8000000000000000, exponent -16444);
    • frexpl(-0) gives -0 with exponent 0;
    • frexpl of ±infinity and NaN returns the argument and leaves the exponent untouched.
  • On main the test doesn't link.
  • Negative checks, each one makes the test fail: acosl through double, frexpl writing the exponent for infinity or NaN, and frexpl through double.
  • Title stops: catalog releases (sha256-checked) relinked for Linux with main's relinker and launched. Each stops at load with the line above.
  • tools/check_conventions.py 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 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:4815902019 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3221). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T01:59:07Z. --- ### What `acosl` (`iH4YAIRcecA`) and `frexpl` (`YZk9sHO0yNg`), both imported from `libSceLibcInternal`, aren't exported. Since #1529, Linux binds those imports to the system libraries, so each is the stop of a catalog homebrew title on `main`: | Title | Stop on `main` f1ae427b6 | |---|---| | RetroArch (PPSA99169) | `./app.elf: symbol lookup error: ./app.elf: undefined symbol: iH4YAIRcecA` (`acosl`) | | PokeMMO Prospero (PPSA98001) | `./app.elf: symbol lookup error: ./app.elf: undefined symbol: YZk9sHO0yNg` (`frexpl`) | `long double` is the x87 80-bit format, as in Sony's own `libc.prx` (the one Astro's Playroom ships). There, `frexpl` loads its argument with `fldt 0x8(%rsp)` and returns in `st(0)`, which is what `APS5_VABI` already does for `strtold` here. - **`acosl`** uses the host's math library, like `acos` and the other libc math functions here. - **`frexpl`** follows Sony's `frexpl`, which is FreeBSD's `s_frexpl.c`: for infinity and NaN it returns the argument without writing `*exp`. glibc's `frexpl` writes 0 there, so that case is handled before calling `std::frexp`, which is exact for every finite value. TechnicalDebt records that `acosl` comes from the host library rather than the console's msun: the last bit can differ, and glibc sets `EDOM` where msun only raises the exception. `asinh` (Porpoise, PPSA99764) is left to #3190, which implements it. ### Tested Linux (CachyOS), GCC 16, Release. - `guest_math` passes. Expected values were computed independently with Python `decimal` at 80 digits and are compared bit for bit: - `acosl(-1)` is π in 80-bit (`0x4000:c90fdaa22168c235`), `acosl(0)` is π/2 and `acosl(1)` is +0; ±1.5 and -2 give NaN; - `frexpl` over 8, -3, 0.375 and the smallest subnormal (`0x3ffe:8000000000000000`, exponent -16444); - `frexpl(-0)` gives -0 with exponent 0; - `frexpl` of ±infinity and NaN returns the argument and leaves the exponent untouched. - On `main` the test doesn't link. - Negative checks, each one makes the test fail: `acosl` through `double`, `frexpl` writing the exponent for infinity or NaN, and `frexpl` through `double`. - Title stops: catalog releases (sha256-checked) relinked for Linux with `main`'s relinker and launched. Each stops at load with the line above. - `tools/check_conventions.py` 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](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
github-actions[bot] commented 2026-10-11 01:59:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T01:59:27Z.


Progress report (6040a96 → 3cd36b0)

➖ System libraries: 85.97% (+0.0%, +2 implemented functions)

✅ 2 implemented
Library Name
libc acosl_nid_postfix
libc frexpl_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6104414992 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3221#issuecomment-6104414992). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T01:59:27Z. --- <!-- progress-report --> ### Progress report (6040a96 → 3cd36b0) ➖ **System libraries**: 85.97% (+0.0%, +2 implemented functions) <details> <summary>✅ 2 implemented</summary> | Library | Name | | - | - | | libc | `acosl_nid_postfix` | | libc | `frexpl_nid_postfix` | </details>
adriadam10 commented 2026-10-11 02:07:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T02:07:18Z.


Merged: Linux CI is red only on agc_unit_shadow, which main has failed since #2864 (reported in #3215). Windows passed, and guest_math passed on both.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6104472317 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3221#issuecomment-6104472317). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T02:07:18Z. --- Merged: Linux CI is red only on `agc_unit_shadow`, which main has failed since #2864 (reported in #3215). Windows passed, and `guest_math` passed on both.
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!3221
No description provided.