feat(libc): implement atol #1868

Closed
TheAggie wants to merge 1 commit from upstream-pr/1868 into main
TheAggie commented 2026-10-08 22:27:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-08T22:27:41Z.


What

atol was not exported. The homebrew Puzzles collection (PPSA99006) calls it before reaching its main menu.

The guest's long is 64-bit, but the host's long is 32-bit on Windows, so atol parses with strtoll instead of the host atol. Base 10, leading whitespace and a sign, stopping at the first non-digit, as C requires.

  • core/libs/prx/libc/src/Strings.cpp: atol.
  • guest_math test: a value below INT32_MIN with leading whitespace and trailing text, INT64_MAX with a plus sign, 0x10 (0, since it is base 10), and an empty string.

Related: #1852 implements atoll in libSceLibcInternal; this is atol in libc, so the two don't overlap.

Tested

Windows 11 Pro (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release.

  • The full suite (485 tests) passes on current main with this PR and four other small libc/libkernel PRs of mine merged together (atol, getprogname, dup2, ctime/rewind, pthread_set_name_np). It was run from the generated CTestTestfile.cmake commands because antivirus blocks ctest.exe on this machine.
  • tools/check_conventions.py --base origin/main passes on this branch alone.

Not tested on Linux or macOS.

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:4793542097 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1868). Originally posted by [TheAggie](https://github.com/TheAggie) on 2026-10-08T22:27:41Z. --- ### What `atol` was not exported. The homebrew Puzzles collection (PPSA99006) calls it before reaching its main menu. The guest's `long` is 64-bit, but the host's `long` is 32-bit on Windows, so `atol` parses with `strtoll` instead of the host `atol`. Base 10, leading whitespace and a sign, stopping at the first non-digit, as C requires. - `core/libs/prx/libc/src/Strings.cpp`: `atol`. - `guest_math` test: a value below `INT32_MIN` with leading whitespace and trailing text, `INT64_MAX` with a plus sign, `0x10` (0, since it is base 10), and an empty string. Related: #1852 implements `atoll` in libSceLibcInternal; this is `atol` in libc, so the two don't overlap. ### Tested Windows 11 Pro (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. - The full suite (485 tests) passes on current `main` with this PR and four other small libc/libkernel PRs of mine merged together (atol, getprogname, dup2, ctime/rewind, pthread_set_name_np). It was run from the generated `CTestTestfile.cmake` commands because antivirus blocks `ctest.exe` on this machine. - `tools/check_conventions.py --base origin/main` passes on this branch alone. Not tested on Linux or macOS. ### 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-08 22:29:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-08T22:29:13Z.


Progress report (ce64d8e → 0074362)

➖ System libraries: 84.76% (+0.0%, +1 implemented functions)

✅ 1 implemented
Library Name
libc atol_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6070334430 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1868#issuecomment-6070334430). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-08T22:29:13Z. --- <!-- progress-report --> ### Progress report (ce64d8e → 0074362) ➖ **System libraries**: 84.76% (+0.0%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libc | `atol_nid_postfix` | </details>
Dextroid17 commented 2026-10-09 02:46:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-09T02:46:39Z.

Review: COMMENTED


Verified on Linux — the differential holds, which is the half the "Tested" line could not cover.

  • Arm A (this PR): cmake --build build --target guest_math_tests --parallel 16 → clean; the binary runs and passes, exit 0.
  • Arm B (control): the implementation file back at main with the new test kept → the target fails to link:
GuestMath.cpp:(.text+0x23c): undefined reference to `atol_nid_postfix'

So the test cannot even run without the export, and its behavioural assertions are what carry the rest.

Claim cross-check: atol is std::strtoll(str, nullptr, 10) (Strings.cpp:154) — base 10, with strtoll's sign, leading-whitespace and first-non-digit behaviour, and 64-bit regardless of the host's long width. That last part is the reason the body gives for not handing this to the host atol, and it is the right call on a platform whose long is 32 bits.

The titles are named (Puzzles PPSA99006) — that is exactly the part reviewers ask for, and it is here.

Not verified: Windows (the author's platform), and behaviour beyond what this test asserts.

Written with AI assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5465145272 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1868#pullrequestreview-5465145272). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-09T02:46:39Z. **Review:** COMMENTED --- Verified on Linux — the differential holds, which is the half the "Tested" line could not cover. - **Arm A (this PR)**: `cmake --build build --target guest_math_tests --parallel 16` → clean; the binary runs and passes, **exit 0**. - **Arm B (control)**: the implementation file back at `main` with the new test kept → the target **fails to link**: ``` GuestMath.cpp:(.text+0x23c): undefined reference to `atol_nid_postfix' ``` So the test cannot even run without the export, and its behavioural assertions are what carry the rest. **Claim cross-check**: `atol` is `std::strtoll(str, nullptr, 10)` (`Strings.cpp:154`) — base 10, with `strtoll`'s sign, leading-whitespace and first-non-digit behaviour, and 64-bit regardless of the host's `long` width. That last part is the reason the body gives for not handing this to the host `atol`, and it is the right call on a platform whose `long` is 32 bits. The titles are named (Puzzles PPSA99006) — that is exactly the part reviewers ask for, and it is here. Not verified: Windows (the author's platform), and behaviour beyond what this test asserts. Written with AI assistance.
oneandonlydean commented 2026-10-09 09:30:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:30:13Z.


Closing: Puzzles (PPSA99006) stops at mkstemp on main (#1613), before atol. Reopen when atol is a title's next stop on main, with the log line.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6078237961 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1868#issuecomment-6078237961). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T09:30:13Z. --- Closing: Puzzles (PPSA99006) stops at `mkstemp` on main (#1613), before `atol`. Reopen when `atol` is a title's next stop on main, with the log line.
TheAggie commented 2026-10-10 04:49:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-10T04:49:15Z.


ProsperoPuzzles (PPSA99006) and PSBox (PPSA99810) now stop at atol on main (per @babyhuey's runs on #2186). #2186 by @AchrafReyani implements both atol and atoll with that evidence, so it covers more than this PR. I'll leave this one closed in favour of #2186.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6093921795 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1868#issuecomment-6093921795). Originally posted by [TheAggie](https://github.com/TheAggie) on 2026-10-10T04:49:15Z. --- ProsperoPuzzles (PPSA99006) and PSBox (PPSA99810) now stop at `atol` on `main` (per @babyhuey's runs on #2186). #2186 by @AchrafReyani implements both `atol` and `atoll` with that evidence, so it covers more than this PR. I'll leave this one closed in favour of #2186. AI-assisted (Claude Code).

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