feat(libSceIcu): implement 13 native-backed converter exports #16611

Closed
hyvvs wants to merge 12 commits from upstream-pr/16611 into main
hyvvs commented 2026-11-07 09:29:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hyvvs on 2026-11-07T09:29:53Z.


What

Implement 13 guest-callable libSceIcu converter exports with typed APS5_VABI wrappers around pinned ICU 78.1: ucnv_open, ucnv_close, ucnv_getName, ucnv_reset, ucnv_resetToUnicode, ucnv_resetFromUnicode, ucnv_setFallback, ucnv_setSubstChars, ucnv_toUChars, ucnv_fromUChars, ucnv_toUnicode, ucnv_fromUnicode, and ucnv_convertEx.

Open/close owns a real native ICU converter object. Operations propagate the native UErrorCode through a separate 32-bit guest status; UChar is 16-bit and UBool is 8-bit. Streaming conversions update caller-owned input/output cursor pointers, preserve offsets and partial-state handling, and respect preflights, small buffers, substitution, fallback and resets. ucnv_getName returns a converter-owned borrowed string. Unknown or unavailable encodings return actual ICU errors rather than fake success. No guest callbacks are forwarded across a mismatched native calling convention.

Dependency / stacked diff: #13578 is a separate contributor's pinned-ICU backend; this branch includes its unchanged ICU 78.1 source pin 049e0d6a420629ac7db77256987d083a563287b5, CMake bootstrap and property/case exports so this PR can build standalone. Only the 13 ucnv_* exports above are introduced by this change. The combined compare against current main also includes #13578's proposed exports; do not attribute all scanner delta to the converter or merge the shared infrastructure twice. Coordinate #13578 first. New upstream CharacterDigits implementations remain authoritative (the branch removes its older duplicate definitions).

Scope and limitations: UCONFIG_NO_FILE_IO=1 plus stubdata.cpp means only compiled-in encodings (including UTF-8 and UTF-16LE) are supported; converter alias tables and .cnv data are absent. ucnv_setFromUCallBack, ucnv_setToUCallBack and ucnv_cbFromUWriteBytes are intentionally still throwing until guest SysV callback bridges can be validated. Native/guest ICU converter object mixing across distinct ICU runtime versions is unsupported. C signatures match the checked ICU headers but PS5 console ABI and ICU release have not been measured; guest ICU 68 names do not establish ICU 78 behavior on hardware.

Overlap audit: python tools/pr_overlap.py --branch feat/libSceIcu-encoding-converter --repo boykopovar/AnyPS5 --jobs 1 examined 1,747 open PRs and exited 2 (fail closed) on shared ICU infrastructure, unmergeable old PRs and inherited property/case implementations. Source inspection confirms ucnv_fromUChars, ucnv_resetToUnicode and ucnv_resetFromUnicode in #14340, #14443 and #16605 are still unconditional throwing int(void) stubs, not competing converter implementations; #14144 similarly touches legacy inventory. #16250 and #16605 overlap the stacked #13578 property/case dependency, while #16507 adds script properties and shares the same source/bootstrap. Integration with #16605 is specifically overlapping in cmake/Icu.cmake: both branches contain the icu_common converter source list, including ${ICU_SOURCE_DIR}/common/uenum.cpp, and the dependent core/libs/prx/libSceIcu/CMakeLists.txt setup. When either PR merges, the other must preserve the shared single source list and drop duplicated infrastructure hunks while retaining its own exports and tests. These intersections need coordinated merge resolution; the checker did NOT establish blanket nonoverlap for all shared files. No known open PR has a real implementation of these 13 ucnv_* exports.

Tested

  • Windows MinGW GCC 15.2 Release, actual repository CMake libSceIcu.prx and guest_icu_converter_native_tests.exe build: PASS; ctest -R '^guest_icu_converter_native$': 1/1 PASS after latest upstream merge db6c3468.
  • WSL Ubuntu GCC 13.3 with ASan+UBSan and ASAN_OPTIONS=detect_leaks=1:halt_on_error=1 UBSAN_OPTIONS=halt_on_error=1: actual libSceIcu.prx/guest test build and CTest 1/1 PASS after latest merge.
  • Differential guest vs pinned native ICU 78.1 checks for whole-buffer UTF-8/UTF-16LE conversion, streaming short-buffer cursors/offsets, preflight/error propagation, substitution/fallback, resets and convertEx: PASS.
  • Public-header audit: 407 libraries / 30,870 unique declarations PASS. tools/check_conventions.py --base upstream/main --head HEAD: PASS. Branch-scoped git diff upstream/main...HEAD --check: PASS.
  • PS5 console / firmware: not tested. GPU paths: not changed.
  • After merge of current main d03beaf110 on November 9, 2026, Windows MinGW GCC 15.2 Release rebuilt the ICU native converter, properties, case mapping, UnicodeData and upstream converter-helper tests; CTest 5/5 passed. WSL Ubuntu GCC 13.3 ASan/UBSan built the same five targets and CTest 5/5 passed with ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=halt_on_error=1 (leak detection disabled). Conventions against upstream/main and diff whitespace checks passed. This merge preserves upstream ConverterHelpers.cpp and its regression test alongside the branch's converter and Unicode tests. Updated commit f6b9dc7f4f720387f53e16ecf78a2e49e623efef.

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: #13578
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5200291712 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16611). Originally posted by [hyvvs](https://github.com/hyvvs) on 2026-11-07T09:29:53Z. --- ### What Implement 13 guest-callable `libSceIcu` converter exports with typed `APS5_VABI` wrappers around pinned ICU 78.1: `ucnv_open`, `ucnv_close`, `ucnv_getName`, `ucnv_reset`, `ucnv_resetToUnicode`, `ucnv_resetFromUnicode`, `ucnv_setFallback`, `ucnv_setSubstChars`, `ucnv_toUChars`, `ucnv_fromUChars`, `ucnv_toUnicode`, `ucnv_fromUnicode`, and `ucnv_convertEx`. Open/close owns a real native ICU converter object. Operations propagate the native `UErrorCode` through a separate 32-bit guest status; `UChar` is 16-bit and `UBool` is 8-bit. Streaming conversions update caller-owned input/output cursor pointers, preserve offsets and partial-state handling, and respect preflights, small buffers, substitution, fallback and resets. `ucnv_getName` returns a converter-owned borrowed string. Unknown or unavailable encodings return actual ICU errors rather than fake success. No guest callbacks are forwarded across a mismatched native calling convention. **Dependency / stacked diff:** #13578 is a separate contributor's pinned-ICU backend; this branch includes its unchanged ICU 78.1 source pin `049e0d6a420629ac7db77256987d083a563287b5`, CMake bootstrap and property/case exports so this PR can build standalone. **Only the 13 `ucnv_*` exports above are introduced by this change.** The combined compare against current main also includes #13578's proposed exports; do not attribute all scanner delta to the converter or merge the shared infrastructure twice. Coordinate #13578 first. New upstream CharacterDigits implementations remain authoritative (the branch removes its older duplicate definitions). **Scope and limitations:** `UCONFIG_NO_FILE_IO=1` plus `stubdata.cpp` means only compiled-in encodings (including UTF-8 and UTF-16LE) are supported; converter alias tables and `.cnv` data are absent. `ucnv_setFromUCallBack`, `ucnv_setToUCallBack` and `ucnv_cbFromUWriteBytes` are intentionally still throwing until guest SysV callback bridges can be validated. Native/guest ICU converter object mixing across distinct ICU runtime versions is unsupported. C signatures match the checked ICU headers but PS5 console ABI and ICU release have not been measured; guest ICU 68 names do not establish ICU 78 behavior on hardware. **Overlap audit:** `python tools/pr_overlap.py --branch feat/libSceIcu-encoding-converter --repo boykopovar/AnyPS5 --jobs 1` examined 1,747 open PRs and **exited 2 (fail closed)** on shared ICU infrastructure, unmergeable old PRs and inherited property/case implementations. Source inspection confirms `ucnv_fromUChars`, `ucnv_resetToUnicode` and `ucnv_resetFromUnicode` in #14340, #14443 and #16605 are still unconditional throwing `int(void)` stubs, not competing converter implementations; #14144 similarly touches legacy inventory. #16250 and #16605 overlap the stacked #13578 property/case dependency, while #16507 adds script properties and shares the same source/bootstrap. Integration with #16605 is specifically overlapping in `cmake/Icu.cmake`: both branches contain the `icu_common` converter source list, including `${ICU_SOURCE_DIR}/common/uenum.cpp`, and the dependent `core/libs/prx/libSceIcu/CMakeLists.txt` setup. When either PR merges, the other must preserve the shared single source list and drop duplicated infrastructure hunks while retaining its own exports and tests. These intersections need coordinated merge resolution; the checker did NOT establish blanket nonoverlap for all shared files. No known open PR has a real implementation of these 13 `ucnv_*` exports. ### 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. --> - Windows MinGW GCC 15.2 **Release**, actual repository CMake `libSceIcu.prx` and `guest_icu_converter_native_tests.exe` build: PASS; `ctest -R '^guest_icu_converter_native$'`: **1/1 PASS** after latest upstream merge `db6c3468`. - WSL Ubuntu GCC 13.3 with ASan+UBSan and `ASAN_OPTIONS=detect_leaks=1:halt_on_error=1 UBSAN_OPTIONS=halt_on_error=1`: actual `libSceIcu.prx`/guest test build and CTest **1/1 PASS** after latest merge. - Differential guest vs pinned native ICU 78.1 checks for whole-buffer UTF-8/UTF-16LE conversion, streaming short-buffer cursors/offsets, preflight/error propagation, substitution/fallback, resets and `convertEx`: PASS. - Public-header audit: **407 libraries / 30,870 unique declarations PASS**. `tools/check_conventions.py --base upstream/main --head HEAD`: PASS. Branch-scoped `git diff upstream/main...HEAD --check`: PASS. - PS5 console / firmware: **not tested**. GPU paths: not changed. - After merge of current `main` `d03beaf110` on November 9, 2026, Windows MinGW GCC 15.2 Release rebuilt the ICU native converter, properties, case mapping, UnicodeData and upstream converter-helper tests; **CTest 5/5 passed**. WSL Ubuntu GCC 13.3 ASan/UBSan built the same five targets and **CTest 5/5 passed** with `ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=halt_on_error=1` (leak detection disabled). Conventions against `upstream/main` and diff whitespace checks passed. This merge preserves upstream `ConverterHelpers.cpp` and its regression test alongside the branch's converter and Unicode tests. Updated commit `f6b9dc7f4f720387f53e16ecf78a2e49e623efef`. ### 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: #13578 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes

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