feat(libSceIcu): implement C string conversion helpers #12294

Merged
Ninot1Quyi merged 1 commit from upstream-pr/12294 into main 2026-10-28 11:31:49 +00:00
Ninot1Quyi commented 2026-10-28 07:57:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ninot1Quyi on 2026-10-28T07:57:44Z.


What

The five ICU C-string helpers currently resolve to inventory stubs and throw. Implement their integer formatting/parsing and in-place ASCII case conversion, with canonical public declarations and runtime coverage.

Export NID
T_CString_int64ToString 2m4vg20UoXI
T_CString_integerToString wwOr3NA7FRc
T_CString_stringToInteger RGVOIIycuyA
T_CString_toLowerCase 9duJwhiYGCE
T_CString_toUpperCase wuiJZ6Iy6Mc

Names/NIDs come from the PS5 3.20 inventory; signatures and semantics follow ICU 78.1 cstring.h and cstring.cpp. The implementation is independently written.

Formatting preserves 32/64-bit width, supports bases 2–16 and treats negative values as signed only in decimal. Parsing uses guest LP64 strtoul, preserving its errno behavior before taking the low 32 bits. Case conversion changes ASCII letters only and accepts null pointers. Unsigned arithmetic and caller storage avoid upstream signed-minimum and temporary-buffer undefined behavior. Invalid formatting arguments and a null parse source throw; native invalid-input behavior and firmware availability remain unverified in the library debt.

The existing progress tool reports libSceIcu 6/120 → 11/120, replacing five inventory stubs without changing the total.

Tested

Ubuntu 24.04 x86-64, GCC 13.3, Release, full CMake configuration with BUILD_TESTING=ON and bundled dependencies; based on main 660a0b306d.

  • Built libSceIcu, its real libc/libkernel dependencies, nid_patcher, and all three ICU test executables.
  • ctest --test-dir build -R '^guest_icu_(cstring|version|unescape)$' --output-on-failure: 3/3 passed, 0.08 seconds, including after rebasing.
  • The new test checks 30,720 deterministic randomized formatting cases against std::to_chars, all formatting bases and signed extrema, length/NUL/canaries, parsing bases 2–36, LP64 overflow and errno, and all 256 byte values for ASCII conversion.
  • Recompiled the complete ICU provider and new test with -fsanitize=undefined -fno-sanitize-recover=undefined, linked to the real runtime libraries: passed without UBSan reports.
  • Separate behavior probe through all five NIDs after the real nid_patcher: baseline ICU sources at b99bbebacd (unchanged in 660a0b306d) threw in 5/5 cases; this implementation passed 5/5. The probe exercises values and output buffers, not only symbol presence.
  • python3 core/libs/tests/test_public_headers.py --audit-only, python3 tools/check_conventions.py --base origin/main, and git diff --check: passed.
  • Ran the unchanged tools/pr_overlap.py --branch codex/system-libraries against 1,374 applicable open PR heads using a read-only adapter for the GitHub-plugin PR listing. No confirmed overlaps or duplicate exports. Manually checked #11088, #11115, #11118, #11122, #11132 and #11136, which already conflict with main: their exports are disjoint, and this change adds no shared-file merge conflicts.

No Windows, macOS, console or game run is claimed; the full repository test suite was not run.

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:5047144135 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12294). Originally posted by [Ninot1Quyi](https://github.com/Ninot1Quyi) on 2026-10-28T07:57:44Z. --- ### What The five ICU C-string helpers currently resolve to inventory stubs and throw. Implement their integer formatting/parsing and in-place ASCII case conversion, with canonical public declarations and runtime coverage. | Export | NID | | --- | --- | | `T_CString_int64ToString` | `2m4vg20UoXI` | | `T_CString_integerToString` | `wwOr3NA7FRc` | | `T_CString_stringToInteger` | `RGVOIIycuyA` | | `T_CString_toLowerCase` | `9duJwhiYGCE` | | `T_CString_toUpperCase` | `wuiJZ6Iy6Mc` | Names/NIDs come from the [PS5 3.20 inventory](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceIcu.c); signatures and semantics follow ICU 78.1 [cstring.h](https://github.com/unicode-org/icu/blob/049e0d6a420629ac7db77256987d083a563287b5/icu4c/source/common/cstring.h) and [cstring.cpp](https://github.com/unicode-org/icu/blob/049e0d6a420629ac7db77256987d083a563287b5/icu4c/source/common/cstring.cpp). The implementation is independently written. Formatting preserves 32/64-bit width, supports bases 2–16 and treats negative values as signed only in decimal. Parsing uses guest LP64 `strtoul`, preserving its errno behavior before taking the low 32 bits. Case conversion changes ASCII letters only and accepts null pointers. Unsigned arithmetic and caller storage avoid upstream signed-minimum and temporary-buffer undefined behavior. Invalid formatting arguments and a null parse source throw; native invalid-input behavior and firmware availability remain unverified in the library debt. The existing progress tool reports libSceIcu **6/120 → 11/120**, replacing five inventory stubs without changing the total. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Ubuntu 24.04 x86-64, GCC 13.3, Release, full CMake configuration with `BUILD_TESTING=ON` and bundled dependencies; based on main `660a0b306d`. - Built `libSceIcu`, its real `libc`/`libkernel` dependencies, `nid_patcher`, and all three ICU test executables. - `ctest --test-dir build -R '^guest_icu_(cstring|version|unescape)$' --output-on-failure`: **3/3 passed**, 0.08 seconds, including after rebasing. - The new test checks 30,720 deterministic randomized formatting cases against `std::to_chars`, all formatting bases and signed extrema, length/NUL/canaries, parsing bases 2–36, LP64 overflow and errno, and all 256 byte values for ASCII conversion. - Recompiled the complete ICU provider and new test with `-fsanitize=undefined -fno-sanitize-recover=undefined`, linked to the real runtime libraries: passed without UBSan reports. - Separate behavior probe through all five NIDs after the real `nid_patcher`: baseline ICU sources at `b99bbebacd` (unchanged in `660a0b306d`) threw in **5/5** cases; this implementation passed **5/5**. The probe exercises values and output buffers, not only symbol presence. - `python3 core/libs/tests/test_public_headers.py --audit-only`, `python3 tools/check_conventions.py --base origin/main`, and `git diff --check`: passed. - Ran the unchanged `tools/pr_overlap.py --branch codex/system-libraries` against 1,374 applicable open PR heads using a read-only adapter for the GitHub-plugin PR listing. No confirmed overlaps or duplicate exports. Manually checked #11088, #11115, #11118, #11122, #11132 and #11136, which already conflict with main: their exports are disjoint, and this change adds no shared-file merge conflicts. No Windows, macOS, console or game run is claimed; the full repository test suite was not run. ### 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 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 -->
MarcZX10 commented 2026-10-28 08:46:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T08:46:02Z.

Review: APPROVED


Reviewed the five exports against the pinned ICU 78.1 C-string implementation and the test coverage. The formatting paths preserve signed decimal and unsigned non-decimal behavior, including safe handling of minimum signed values; the parse wrapper delegates to the project’s guest strtoul; and case conversion is limited to ASCII bytes as ICU’s configured path is for this target. Tests cover the NIDs through the provider, formatting bases/extrema/canaries, parse overflow/errno, and all byte values. Hosted Windows and conventions checks pass; Linux focused runs and UBSan are reported by the author, while macOS and console runs are explicitly not claimed. I found no blocking issue.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5679943411 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12294#pullrequestreview-5679943411). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-28T08:46:02Z. **Review:** APPROVED --- Reviewed the five exports against the pinned ICU 78.1 C-string implementation and the test coverage. The formatting paths preserve signed decimal and unsigned non-decimal behavior, including safe handling of minimum signed values; the parse wrapper delegates to the project’s guest `strtoul`; and case conversion is limited to ASCII bytes as ICU’s configured path is for this target. Tests cover the NIDs through the provider, formatting bases/extrema/canaries, parse overflow/errno, and all byte values. Hosted Windows and conventions checks pass; Linux focused runs and UBSan are reported by the author, while macOS and console runs are explicitly not claimed. I found no blocking issue.
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!12294
No description provided.