feat(libSceIcu): implement the ICU locale, string hash and data hook exports #23859

Merged
larpsahur333 merged 1 commit from upstream-pr/23859 into main 2026-11-19 22:46:24 +00:00
larpsahur333 commented 2026-11-19 19:52:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by larpsahur333 on 2026-11-19T19:52:20Z.


What

Ten libSceIcu exports that answered NotImplemented_nid_no_patch now call ICU 78.1 through its C entry points:

  • locale availability: uloc_countAvailable, uloc_getAvailable
  • locale names: uloc_getName
  • subtags: uloc_addLikelySubtags, uloc_minimizeSubtags
  • string hashes: ustr_hashUCharsN, ustr_hashCharsN, ustr_hashICharsN
  • data hooks: udata_setCommonData, udata_setFileAccess

This is the part of the ICU work that #18400 (ucnv_*) and #18208 (u_charName/u_charFromName) do not cover, as the review asked. Every other stub this branch touched is back byte for byte: the fourteen ubrk_* entries, ubrk_setUText, ucnv_fromUnicode and uloc_getCharacterOrientation. ures_open, ures_getByKey and ures_getStringByKey are not touched: a host ICU bundle does not match the ICU 68 model the existing ures_close/ures_getUint use. RecoveredInventory.cpp, RecoveredInventory.hpp and Identified.hpp are unchanged from main.

cmake/Icu.cmake gains common/locavailable.cpp and common/errorcode.cpp, because the locale availability entry points live there and the vendored ICU build did not compile them.

tools/progress.py: libraries 17526/39558 (44.3%) before, 17536/39550 (44.34%) after; libSceIcu alone 285/2763 (10.31%) to 291/2759 (10.55%).

Tested

Windows 11 x86-64, MinGW-w64 GCC 15.2.0 (x86_64-ucrt-posix-seh, WinLibs 15.2.0posix-14.0.0-ucrt-r7), CMake 3.29.2, Ninja.

guest_icu_availability (new, core/libs/prx/libSceIcu/tests/Availability.cpp) passes. It checks uloc_countAvailable and uloc_getAvailable(0), canonicalizes EN-us to en_US and checks the required length plus the overflow status for a four-byte buffer, hashes abc and the empty string with all three hash functions (136518 and 0, and the case-insensitive one folding ABC to the same value), runs the subtag functions accepting either the result or the missing-data status ICU reports without icudt, and calls udata_setFileAccess. The whole ICU suite passes on that tree: ctest -R "^guest_icu" reports 100% tests passed, 0 tests failed out of 77.

python core/libs/tests/test_public_headers.py --compiler g++: 413 libraries, 34727 exports: unique declarations and umbrella coverage verified.

python3 tools/debt_fold.py --check and python3 tools/check_conventions.py --base <base> --head <head> pass.

Not tested: no PS5 was involved, so the console's answers are unmeasured; without ICU data the subtag functions only report U_MISSING_RESOURCE_ERROR, and a guest-supplied udata_setCommonData blob is the only path to real data.

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 and the licence notice of code adapted from upstream
  • 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
  • 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:5401888644 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23859). Originally posted by [larpsahur333](https://github.com/larpsahur333) on 2026-11-19T19:52:20Z. --- ### What Ten `libSceIcu` exports that answered `NotImplemented_nid_no_patch` now call ICU 78.1 through its C entry points: - locale availability: `uloc_countAvailable`, `uloc_getAvailable` - locale names: `uloc_getName` - subtags: `uloc_addLikelySubtags`, `uloc_minimizeSubtags` - string hashes: `ustr_hashUCharsN`, `ustr_hashCharsN`, `ustr_hashICharsN` - data hooks: `udata_setCommonData`, `udata_setFileAccess` This is the part of the ICU work that #18400 (`ucnv_*`) and #18208 (`u_charName`/`u_charFromName`) do not cover, as the review asked. Every other stub this branch touched is back byte for byte: the fourteen `ubrk_*` entries, `ubrk_setUText`, `ucnv_fromUnicode` and `uloc_getCharacterOrientation`. `ures_open`, `ures_getByKey` and `ures_getStringByKey` are not touched: a host ICU bundle does not match the ICU 68 model the existing `ures_close`/`ures_getUint` use. `RecoveredInventory.cpp`, `RecoveredInventory.hpp` and `Identified.hpp` are unchanged from `main`. `cmake/Icu.cmake` gains `common/locavailable.cpp` and `common/errorcode.cpp`, because the locale availability entry points live there and the vendored ICU build did not compile them. `tools/progress.py`: `libraries 17526/39558 (44.3%)` before, `17536/39550 (44.34%)` after; `libSceIcu` alone `285/2763 (10.31%)` to `291/2759 (10.55%)`. ### Tested Windows 11 x86-64, MinGW-w64 GCC 15.2.0 (`x86_64-ucrt-posix-seh`, WinLibs `15.2.0posix-14.0.0-ucrt-r7`), CMake 3.29.2, Ninja. `guest_icu_availability` (new, `core/libs/prx/libSceIcu/tests/Availability.cpp`) passes. It checks `uloc_countAvailable` and `uloc_getAvailable(0)`, canonicalizes `EN-us` to `en_US` and checks the required length plus the overflow status for a four-byte buffer, hashes `abc` and the empty string with all three hash functions (`136518` and `0`, and the case-insensitive one folding `ABC` to the same value), runs the subtag functions accepting either the result or the missing-data status ICU reports without `icudt`, and calls `udata_setFileAccess`. The whole ICU suite passes on that tree: `ctest -R "^guest_icu"` reports `100% tests passed, 0 tests failed out of 77`. `python core/libs/tests/test_public_headers.py --compiler g++`: `413 libraries, 34727 exports: unique declarations and umbrella coverage verified`. `python3 tools/debt_fold.py --check` and `python3 tools/check_conventions.py --base <base> --head <head>` pass. Not tested: no PS5 was involved, so the console's answers are unmeasured; without ICU data the subtag functions only report `U_MISSING_RESOURCE_ERROR`, and a guest-supplied `udata_setCommonData` blob is the only path to real data. ### 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 and the licence notice of code adapted from upstream - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical debt file - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-19 20:08:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-19T20:08:02Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against dc985a03e8:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_icu_availability_tests built cleanly.
  • CTest (guest_icu_availability):
    1/1 Test #4008: guest_icu_availability ...........   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceIcu/Export.cpp, core/libs/prx/libSceIcu/Identified.hpp, core/libs/prx/libSceIcu/RecoveredInventory.cpp, core/libs/prx/libSceIcu/include/InventoryExports.hpp, core/libs/prx/libSceIcu/libSceIcu.hpp, core/libs/prx/libSceIcu/Availability.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Availability.cpp: Verified that uloc_countAvailable, uloc_getAvailable, uloc_addLikelySubtags, and uloc_minimizeSubtags wrap upstream ICU correctly and validate guest writable memory via GuestWritable_nid_no_patch.
    • Availability.cpp: Checked ucnv_open, ucnv_close, ucnv_reset, ucnv_setFallback, ucnv_getName, ucnv_setSubstChars, and ucnv_toUChars for null checks, pointer bounds, and proper status reporting.
    • Availability.cpp: Checked ures_open, ures_getByKey, and ures_getStringByKey along with u_charName and u_charFromName for proper parameter validation and return codes.
    • cmake/Icu.cmake: Verified the addition of errorcode.cpp and locavailable.cpp to icu_common static library target.
    • docs/dev/debt/changes/feat-libsceicu-availability-exports.md: Verified technical debt documentation fragment complies with AGENTS.md conventions.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5982480550 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23859#pullrequestreview-5982480550). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-19T20:08:02Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `dc985a03e8`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_icu_availability_tests` built cleanly. - **CTest** (`guest_icu_availability`): ``` 1/1 Test #4008: guest_icu_availability ........... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceIcu/Export.cpp`, `core/libs/prx/libSceIcu/Identified.hpp`, `core/libs/prx/libSceIcu/RecoveredInventory.cpp`, `core/libs/prx/libSceIcu/include/InventoryExports.hpp`, `core/libs/prx/libSceIcu/libSceIcu.hpp`, `core/libs/prx/libSceIcu/Availability.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Availability.cpp: Verified that uloc_countAvailable, uloc_getAvailable, uloc_addLikelySubtags, and uloc_minimizeSubtags wrap upstream ICU correctly and validate guest writable memory via GuestWritable_nid_no_patch. - Availability.cpp: Checked ucnv_open, ucnv_close, ucnv_reset, ucnv_setFallback, ucnv_getName, ucnv_setSubstChars, and ucnv_toUChars for null checks, pointer bounds, and proper status reporting. - Availability.cpp: Checked ures_open, ures_getByKey, and ures_getStringByKey along with u_charName and u_charFromName for proper parameter validation and return codes. - cmake/Icu.cmake: Verified the addition of errorcode.cpp and locavailable.cpp to icu_common static library target. - docs/dev/debt/changes/feat-libsceicu-availability-exports.md: Verified technical debt documentation fragment complies with AGENTS.md conventions. Looks Good To Me
PrivacyOnion commented 2026-11-19 20:41:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-19T20:41:53Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 2c60e60f2e:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_icu_availability_tests built cleanly.
  • CTest (guest_icu_availability):
    1/1 Test #4008: guest_icu_availability ...........   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceIcu/Export.cpp, core/libs/prx/libSceIcu/include/InventoryExports.hpp, core/libs/prx/libSceIcu/libSceIcu.hpp, core/libs/prx/libSceIcu/Availability.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Availability.cpp: Verified that uloc_countAvailable, uloc_getAvailable, uloc_addLikelySubtags, uloc_minimizeSubtags, udata_setCommonData, and udata_setFileAccess correctly forward to upstream C entry points and match declared prototypes in Availability.hpp.
    • Availability.cpp: Confirmed Writable helper correctly performs non-null guest memory validation using GuestWritable_nid_no_patch for out buffers and status pointers without dereferencing invalid memory.
    • Export.cpp: Confirmed all 16 unresolved stubs (14 ubrk_* stubs, ubrk_setUText, ucnv_fromUnicode, uloc_getCharacterOrientation) and ures_* stubs were restored as requested by maintainer oneandonlydean.
    • cmake/Icu.cmake: Checked that common/errorcode.cpp and common/locavailable.cpp are cleanly added to icu_common STATIC target, satisfying symbols required by uloc_countAvailable and subtag APIs.
    • docs/dev/debt/changes/feat-libsceicu-availability-exports.md: Verified debt fragment correctly details the behavior, missing icudt status, and guest unwritable pointer handling in compliance with AGENTS.md conventions.
    • tests/Availability.cpp: Verified unit test coverage exercises uloc_countAvailable, uloc_getAvailable, subtag maximization/minimization error and success branches, and udata_setFileAccess.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5983036139 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23859#pullrequestreview-5983036139). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-19T20:41:53Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `2c60e60f2e`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_icu_availability_tests` built cleanly. - **CTest** (`guest_icu_availability`): ``` 1/1 Test #4008: guest_icu_availability ........... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceIcu/Export.cpp`, `core/libs/prx/libSceIcu/include/InventoryExports.hpp`, `core/libs/prx/libSceIcu/libSceIcu.hpp`, `core/libs/prx/libSceIcu/Availability.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Availability.cpp: Verified that uloc_countAvailable, uloc_getAvailable, uloc_addLikelySubtags, uloc_minimizeSubtags, udata_setCommonData, and udata_setFileAccess correctly forward to upstream C entry points and match declared prototypes in Availability.hpp. - Availability.cpp: Confirmed Writable helper correctly performs non-null guest memory validation using GuestWritable_nid_no_patch for out buffers and status pointers without dereferencing invalid memory. - Export.cpp: Confirmed all 16 unresolved stubs (14 ubrk_* stubs, ubrk_setUText, ucnv_fromUnicode, uloc_getCharacterOrientation) and ures_* stubs were restored as requested by maintainer oneandonlydean. - cmake/Icu.cmake: Checked that common/errorcode.cpp and common/locavailable.cpp are cleanly added to icu_common STATIC target, satisfying symbols required by uloc_countAvailable and subtag APIs. - docs/dev/debt/changes/feat-libsceicu-availability-exports.md: Verified debt fragment correctly details the behavior, missing icudt status, and guest unwritable pointer handling in compliance with AGENTS.md conventions. - tests/Availability.cpp: Verified unit test coverage exercises uloc_countAvailable, uloc_getAvailable, subtag maximization/minimization error and success branches, and udata_setFileAccess. Looks Good To Me
PrivacyOnion commented 2026-11-19 21:11:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-19T21:11:47Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 8f6ac9394a:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_icu_availability_tests built cleanly.
  • CTest (guest_icu_availability):
    1/1 Test #4008: guest_icu_availability ...........   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceIcu/Export.cpp, core/libs/prx/libSceIcu/LegacyExports.cpp, core/libs/prx/libSceIcu/include/InventoryExports.hpp, core/libs/prx/libSceIcu/include/LegacyExports.hpp, core/libs/prx/libSceIcu/libSceIcu.hpp, core/libs/prx/libSceIcu/Availability.cpp, core/libs/prx/libSceIcu/StringHash.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified core/libs/prx/libSceIcu/Availability.cpp: uloc_countAvailable, uloc_getAvailable, uloc_addLikelySubtags, uloc_minimizeSubtags, uloc_getName, udata_setCommonData, and udata_setFileAccess correctly forward to ICU C entry points with proper Writable checks and no null pointer dereferences.
    • Verified core/libs/prx/libSceIcu/StringHash.cpp: ustr_hashUCharsN, ustr_hashCharsN, and ustr_hashICharsN accurately match declared signatures and ICU implementations.
    • Verified core/libs/prx/libSceIcu/Export.cpp and include/InventoryExports.hpp: checked that all 16 unresolved stubs and ures_* stubs requested by the maintainer were preserved byte-for-byte and only the implemented stubs were replaced.
    • Verified cmake/Icu.cmake: locavailable.cpp and errorcode.cpp correctly added to icu_common STATIC target, satisfying symbols for locale availability without leaking internal symbols.
    • Verified docs/dev/debt/changes/feat-libsceicu-availability-exports.md: debt fragment adheres strictly to AGENTS.md conventions, documenting missing icudt data behavior and guest pointer error handling.
    • Verified core/libs/prx/libSceIcu/tests/Availability.cpp: test suite comprehensively covers uloc_countAvailable, uloc_getAvailable, subtag maximization/minimization, canonicalization, overflow checks, string hashing, and data access.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5983475083 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23859#pullrequestreview-5983475083). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-19T21:11:47Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `8f6ac9394a`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_icu_availability_tests` built cleanly. - **CTest** (`guest_icu_availability`): ``` 1/1 Test #4008: guest_icu_availability ........... Passed 0.02 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceIcu/Export.cpp`, `core/libs/prx/libSceIcu/LegacyExports.cpp`, `core/libs/prx/libSceIcu/include/InventoryExports.hpp`, `core/libs/prx/libSceIcu/include/LegacyExports.hpp`, `core/libs/prx/libSceIcu/libSceIcu.hpp`, `core/libs/prx/libSceIcu/Availability.cpp`, `core/libs/prx/libSceIcu/StringHash.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified core/libs/prx/libSceIcu/Availability.cpp: uloc_countAvailable, uloc_getAvailable, uloc_addLikelySubtags, uloc_minimizeSubtags, uloc_getName, udata_setCommonData, and udata_setFileAccess correctly forward to ICU C entry points with proper Writable checks and no null pointer dereferences. - Verified core/libs/prx/libSceIcu/StringHash.cpp: ustr_hashUCharsN, ustr_hashCharsN, and ustr_hashICharsN accurately match declared signatures and ICU implementations. - Verified core/libs/prx/libSceIcu/Export.cpp and include/InventoryExports.hpp: checked that all 16 unresolved stubs and ures_* stubs requested by the maintainer were preserved byte-for-byte and only the implemented stubs were replaced. - Verified cmake/Icu.cmake: locavailable.cpp and errorcode.cpp correctly added to icu_common STATIC target, satisfying symbols for locale availability without leaking internal symbols. - Verified docs/dev/debt/changes/feat-libsceicu-availability-exports.md: debt fragment adheres strictly to AGENTS.md conventions, documenting missing icudt data behavior and guest pointer error handling. - Verified core/libs/prx/libSceIcu/tests/Availability.cpp: test suite comprehensively covers uloc_countAvailable, uloc_getAvailable, subtag maximization/minimization, canonicalization, overflow checks, string hashing, and data access. Looks Good To Me
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!23859
No description provided.