feat(libc): implement atol and atoll #2186

Closed
reyani-dev wants to merge 1 commit from upstream-pr/2186 into main
reyani-dev commented 2026-10-09 11:07:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-09T11:07:13Z.


What

Exports atol and atoll. FreeBSD defines them as strtol(str, NULL, 10) and strtoll(str, NULL, 10). The guest long is 64 bits (as strtol_nid_postfix already assumes), so atol calls std::strtoll rather than the host atol, whose long is 32 bits on Windows.

Titles: from the #1578 audit, imported from libSceLibcInternal (resolved through libc.prx):

  • atoll (fLcU5G6Qrjs): PPSA99039 EVO Player, which stops on Windows with FAIL: unresolved ELF import fLcU5G6Qrjs from libSceLibcInternal.prx; also Stremio Plus, RetroArch, PS5MC, Porpoise
  • atol: PPSA74126 Stremio Plus, PPSA92280 Capy Mobile, PPSA99169 RetroArch, PPSA99420 PS5MC

I haven't run any of these titles.

Tested

Windows 11, WinLibs GCC 15.2.0 r7, Release, -DBUILD_TESTING=ON:

  • New checks in guest_math_tests, next to the strtol cases:
    • leading white space and sign;
    • values beyond 32 bits (-4294967296, INT64_MAX, INT64_MIN, 4294967297x);
    • base 10 only ("0x10" → 0, "010" → 10);
    • empty and non-numeric input → 0.
  • Mutation check: the host std::atol (32-bit long on Windows) and strtoll(..., 0) each make guest_math fail.
  • cmake --build build --target libs: the patched libc.prx exports +my9jdHCMIQ (atol) and fLcU5G6Qrjs (atoll).
  • tools/check_conventions.py passes, and tools/pr_overlap.py --branch reports no overlap.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4799578168 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2186). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-09T11:07:13Z. --- ### What Exports `atol` and `atoll`. FreeBSD defines them as `strtol(str, NULL, 10)` and `strtoll(str, NULL, 10)`. The guest `long` is 64 bits (as `strtol_nid_postfix` already assumes), so `atol` calls `std::strtoll` rather than the host `atol`, whose `long` is 32 bits on Windows. Titles: from the #1578 audit, imported from `libSceLibcInternal` (resolved through `libc.prx`): - `atoll` (`fLcU5G6Qrjs`): PPSA99039 EVO Player, which stops on Windows with `FAIL: unresolved ELF import fLcU5G6Qrjs from libSceLibcInternal.prx`; also Stremio Plus, RetroArch, PS5MC, Porpoise - `atol`: PPSA74126 Stremio Plus, PPSA92280 Capy Mobile, PPSA99169 RetroArch, PPSA99420 PS5MC I haven't run any of these titles. ### Tested Windows 11, WinLibs GCC 15.2.0 r7, Release, `-DBUILD_TESTING=ON`: - New checks in `guest_math_tests`, next to the `strtol` cases: - leading white space and sign; - values beyond 32 bits (`-4294967296`, `INT64_MAX`, `INT64_MIN`, `4294967297x`); - base 10 only (`"0x10"` → 0, `"010"` → 10); - empty and non-numeric input → 0. - Mutation check: the host `std::atol` (32-bit `long` on Windows) and `strtoll(..., 0)` each make `guest_math` fail. - `cmake --build build --target libs`: the patched `libc.prx` exports `+my9jdHCMIQ` (`atol`) and `fLcU5G6Qrjs` (`atoll`). - `tools/check_conventions.py` passes, and `tools/pr_overlap.py --branch` reports no overlap. ### 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 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-09 11:07:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T11:07:36Z.


Progress report (d70b899 → a6f870a)

📈 System libraries: 84.7% (+0.01%, +2 implemented functions)

✅ 2 implemented
Library Name
libc atol_nid_postfix
libc atoll_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6079657904 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2186#issuecomment-6079657904). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T11:07:36Z. --- <!-- progress-report --> ### Progress report (d70b899 → a6f870a) 📈 **System libraries**: 84.7% (+0.01%, +2 implemented functions) <details> <summary>✅ 2 implemented</summary> | Library | Name | | - | - | | libc | `atol_nid_postfix` | | libc | `atoll_nid_postfix` | </details>
reyani-dev commented 2026-10-09 11:30:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-09T11:30:12Z.


Full Linux and Windows builds and tests for this head (a6f870ae), using the project's Build workflow. I can't start the upstream manual run, so I ran the same build.yml in my fork through a mirror PR. Like the upstream run, the jobs check out the PR head merged into current main (d70b8998):

Job Result
linux success; full build, ctest: 516/516 passed
windows success; full build, ctest: 507/507 passed
relinker (Linux, Windows, macOS) success

Run: https://github.com/AchrafReyani/AnyPS5/actions/runs/37921793157

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6079983745 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2186#issuecomment-6079983745). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-09T11:30:12Z. --- Full Linux and Windows builds and tests for this head (`a6f870ae`), using the project's Build workflow. I can't start the upstream manual run, so I ran the same `build.yml` in my fork through a mirror PR. Like the upstream run, the jobs check out the PR head merged into current `main` (`d70b8998`): | Job | Result | |---|---| | [linux](https://github.com/AchrafReyani/AnyPS5/actions/runs/37921793157/job/113791247280) | success; full build, `ctest`: 516/516 passed | | [windows](https://github.com/AchrafReyani/AnyPS5/actions/runs/37921793157/job/113791247155) | success; full build, `ctest`: 507/507 passed | | relinker (Linux, Windows, macOS) | success | Run: https://github.com/AchrafReyani/AnyPS5/actions/runs/37921793157
oneandonlydean commented 2026-10-09 20:09:51 +00:00 (Migrated from github.com)

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


Closing: the EVO Player atoll stop is from an older main; on current main it stops at other imports first, same as #1852. Reopen when atol or atoll is a title's next stop on main, with the log line.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6088440139 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2186#issuecomment-6088440139). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T20:09:51Z. --- Closing: the EVO Player `atoll` stop is from an older main; on current main it stops at other imports first, same as #1852. Reopen when `atol` or `atoll` is a title's next stop on main, with the log line.
babyhuey commented 2026-10-10 02:16:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-10T02:16:33Z.


This is now a title's next stop on current main, so here is the log line the close note asked for, plus a check of this branch.

Checked a6f870ae merged onto main c963432d (the only conflict is in GuestMath.cpp, where main added strtoll/_Stoul checks next to this PR's; keeping both resolves it), Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC from WinLibs), Release.

  • guest_math passes 5/5 on both (--repeat until-fail:5); no CRT assertion dialog on Windows.
  • On main (catalog runs on 2edaf7f4 Linux and 0c0dc1e9 Windows) and with this branch:
Title main with this branch (Linux and Windows)
PSXS5 (PPSA97510) undefined symbol: fLcU5G6Qrjs (atoll) 1nTKA7pN1jw (utime)
SwanStationPS5 (PPSA98510) undefined symbol: fLcU5G6Qrjs (atoll) 1nTKA7pN1jw (utime)
EVO Player (PPSA99039) undefined symbol: fLcU5G6Qrjs (atoll) 3QIPIh-GDjw (rewind)
Nuvio PS5 (PPSA99997) undefined symbol: fLcU5G6Qrjs (atoll) 3QIPIh-GDjw (rewind)
ProsperoPuzzles (PPSA99006) undefined symbol: +my9jdHCMIQ (atol) 04AjkP0jO9U (_umtx_op)
PSBox Cloud Gaming (PPSA99810) undefined symbol: +my9jdHCMIQ (atol) j-gWL6wDros (getifaddrs)

Example lines for PSXS5 (PPSA97510): main Windows FAIL: unresolved ELF import fLcU5G6Qrjs (atoll) from libSceLibcInternal.prx; with this branch, Linux app.elf: symbol lookup error: app.elf: undefined symbol: 1nTKA7pN1jw, Windows FAIL: unresolved ELF import 1nTKA7pN1jw from libSceLibcInternal.prx.

OpenRCT2 (PPSA99728) also reaches atol once llroundf exists (#2189).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6092621656 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2186#issuecomment-6092621656). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-10T02:16:33Z. --- This is now a title's next stop on current `main`, so here is the log line the close note asked for, plus a check of this branch. Checked a6f870ae merged onto `main` c963432d (the only conflict is in `GuestMath.cpp`, where `main` added `strtoll`/`_Stoul` checks next to this PR's; keeping both resolves it), Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC from WinLibs), Release. - `guest_math` passes 5/5 on both (`--repeat until-fail:5`); no CRT assertion dialog on Windows. - On `main` (catalog runs on 2edaf7f4 Linux and 0c0dc1e9 Windows) and with this branch: | Title | `main` | with this branch (Linux and Windows) | |---|---|---| | PSXS5 (PPSA97510) | `undefined symbol: fLcU5G6Qrjs` (`atoll`) | `1nTKA7pN1jw` (`utime`) | | SwanStationPS5 (PPSA98510) | `undefined symbol: fLcU5G6Qrjs` (`atoll`) | `1nTKA7pN1jw` (`utime`) | | EVO Player (PPSA99039) | `undefined symbol: fLcU5G6Qrjs` (`atoll`) | `3QIPIh-GDjw` (`rewind`) | | Nuvio PS5 (PPSA99997) | `undefined symbol: fLcU5G6Qrjs` (`atoll`) | `3QIPIh-GDjw` (`rewind`) | | ProsperoPuzzles (PPSA99006) | `undefined symbol: +my9jdHCMIQ` (`atol`) | `04AjkP0jO9U` (`_umtx_op`) | | PSBox Cloud Gaming (PPSA99810) | `undefined symbol: +my9jdHCMIQ` (`atol`) | `j-gWL6wDros` (`getifaddrs`) | Example lines for PSXS5 (PPSA97510): `main` Windows `FAIL: unresolved ELF import fLcU5G6Qrjs (atoll) from libSceLibcInternal.prx`; with this branch, Linux `app.elf: symbol lookup error: app.elf: undefined symbol: 1nTKA7pN1jw`, Windows `FAIL: unresolved ELF import 1nTKA7pN1jw from libSceLibcInternal.prx`. OpenRCT2 (PPSA99728) also reaches `atol` once `llroundf` exists (#2189).
reyani-dev commented 2026-10-10 02:25:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-10T02:25:30Z.


@oneandonlydean this now has the evidence the close note asked for, thanks to @babyhuey's run above. On current main, PSXS5 (PPSA97510), SwanStationPS5, EVO Player and Nuvio stop at atoll, and ProsperoPuzzles and PSBox stop at atol; with this branch each moves on to its next import. OpenRCT2 reaches atol after #2189. Could you reopen it? GitHub doesn't let me reopen a PR a maintainer closed.

I rebased the branch onto current main (96494337). The only conflict was GuestMath.cpp, where main added the strtoll/_Stoul checks next to these; both sets are kept. guest_math passes on Windows.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6092704683 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2186#issuecomment-6092704683). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-10T02:25:30Z. --- @oneandonlydean this now has the evidence the close note asked for, thanks to @babyhuey's run above. On current `main`, PSXS5 (PPSA97510), SwanStationPS5, EVO Player and Nuvio stop at `atoll`, and ProsperoPuzzles and PSBox stop at `atol`; with this branch each moves on to its next import. OpenRCT2 reaches `atol` after #2189. Could you reopen it? GitHub doesn't let me reopen a PR a maintainer closed. I rebased the branch onto current `main` (96494337). The only conflict was `GuestMath.cpp`, where `main` added the `strtoll`/`_Stoul` checks next to these; both sets are kept. `guest_math` passes on Windows.
reyani-dev commented 2026-10-10 18:34:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-10T18:34:33Z.


Resubmitted as #2932 now that intake allows it, rebased onto current main with the title evidence above.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6100847910 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2186#issuecomment-6100847910). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-10T18:34:33Z. --- Resubmitted as #2932 now that intake allows it, rebased onto current `main` with the title evidence above.

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