feat(libSceLibcInternal): implement collate<char> compare, hash and do_* members #15711
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15711"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by B-Howell on 2026-11-04T09:07:26Z.
What
Implements five
std::collate<char>members in libSceLibcInternal that used to throw throughNotImplemented_nid_no_patch(sceLibcInternalPending3_043..047inErr.cpp):_ZNKSt7collateIcE10do_compareEPKcS2_S2_S2_1eEXfeW6wrIcollate<char>vtable slot 6 (libcCollateCompare)_ZNKSt7collateIcE12do_transformEPKcS2_gYlF567r3-ACollateTransform)_ZNKSt7collateIcE7do_hashEPKcS2_GSAXi4F1SlMCollateHash)_ZNKSt7collateIcE7compareEPKcS2_S2_S2_Q-8lQCGMj4gdo_comparethrough the facet's vtable (offset 0x20)_ZNKSt7collateIcE4hashEPKcS2_6vYXzFD-mrkdo_hashthrough the facet's vtable (offset 0x30)These are the C++ standard members. [locale.collate.members] says
compare"Returns:do_compare(low1, high1, low2, high2)" andhash"Returns:do_hash(low, high)". libc's_ZNKSt7collateIcE9transformEPKcS2_already does the same thing fortransform, throughGuestLocale::CollateVtable(static_assert(offsetof(CollateVtable, compare) == 0x20)andhash == 0x30inGuestLocale.hpp). Thedo_*members are thecollate<char>base implementations. They call the functions held in slots 6 to 8 of libc's exported_ZTVSt7collateIcE, which are the sameCollateCompare,CollateTransformandCollateHashthatg_collateVtableuses. Because they never look at the facet's vtable, a derived facet that overridesdo_comparestill reaches the base member here. Their rules and known gaps come from libc unchanged: C-locale byte order, the FNV-1a hash, anddo_transformthrowing on embedded nulls. A null facet or a facet with no vtable makescompareandhashthrow.Changes:
core/libs/prx/libSceLibcInternal/Collate.cpp. The five stubs are removed fromErr.cpp._ZTVSt7collateIcE_nid_postfixis declared inprx/libc/include/Api.hpp, and the five entry points inprx/libSceLibcInternal/include/Api.hpp.guest_libc_internal_collate(core/libs/tests/GuestLibcInternalCollate.cpp). It covers ordering, prefix and unsigned-byte cases, embedded nulls, null empty ranges, rejection of reversed ranges, the hash value and its offset basis, inline and heapdo_transformresults, virtual dispatch to an overriding facet, and the basedo_*members ignoring that override.docs/dev/debt/libSceLibcInternal.md: the five "prototype and behavior are unverified" lines are removed and a Functional entry is added.tools/progress.pycollect_libraries(): origin/main has 9913 done of 37146 (libSceLibcInternal 92 done, 1045 todo). This branch has 9918 done (libSceLibcInternal 97 done, 1040 todo), so done goes up by 5 and no new todo appears.Tested
Only the focused test target and the library were built. No title was run.
ctest -R '^(guest_libc_internal_collate|conventions_unknown_nids|conventions_debt_length|conventions_doc_links|debt_split)$'ran 3 times, and each run passed 5 of 5 tests with 0 failures.guest_libc_internal_collateis the new guest test.conventions_unknown_nids,conventions_debt_length,conventions_doc_linksanddebt_splitare the repository's checker self-tests for the conventions and the debt-file split, and were run because the debt file changed.Err.cppplus the new test, with no collate implementation, fails to linkguest_libc_internal_collate_tests. The undefined references are tosceLibcInternalCollateDoCompare_nid_no_patch,DoTransform,DoHash,CompareandHash.python3 tools/check_conventions.py --base origin/mainprinted "All conventions checks passed."python3 tools/pr_overlap.py --branch feat/r2-collate-charfound no PR exporting the same functions and no PR adding the same new files. Its only matches are neighbouring lines inlibSceLibcInternal/CMakeLists.txtand the debt file (#10749, #14158, #15692). I grepped the diffs of every PR it could not compare (#5021, #10780, #11831, #13486, #13778, #13782, #13881, #14085, #14212, #14401, #14837, #14936) and none of them contains these NIDs or files.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code