feat(libSceLibcInternal): implement locale::facet _Incref and _Decref #23858
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/23858"
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 GiannisG1 on 2026-11-19T19:49:53Z.
What
std::locale::facet::_Increfand_Decref(inventory 076 and 075, NIDs-EgSegeAKl4andAgxEl+HeWRQ) were parameterless placeholders that threw. In the Dinkumware/Microsoft STL design they override_Facet_base's virtuals, so the vtable of a facet a title defines itself (a customcodecvtornumpunct, say) points at these exports. Installing such a facet in a locale, or copying and destroying that locale, called a throwing stub.They now follow Microsoft STL's
locale::facet(stl/inc/xlocale):_Increfatomically adds one to the reference count;_Decrefatomically subtracts one and returns the facet when the count reaches zero (the caller deletes it), otherwise null.The count is the 32-bit field at 0x08 that the retain and release entries of the facet vtables in libc (
RetainFacet/ReleaseFacetinLocaleSupport.cpp) already use the same way. A null facet throwsstd::invalid_argument. The mangled names hash to the inventory NIDs (tools/nid_names.py), so the exports are named and the two placeholders are gone. The new header is included by the library umbrella. The debt fragment removes the two table rows and adds a Functional entry: not verified on a console.Tested
Linux Mint 22.3, GCC 13.3.0, Release, head on
maine4cee4952b.guest_libc_internal_facet_references:_Increfcalls make the count 2 and leave the vtable pointer and the next field alone;_Decrefreturns null at 2→1 and the facet at 1→0;_Increfcalls reach 160000, and the same number of concurrent_Decrefcalls brings it back to 0 with exactly one of them returning the facet;std::invalid_argument.main: the test does not link, because neither export exists there (the NIDs reach the throwing placeholders). This PR: passes 3/3.tools/suite.py) on this branch: GPU tests on a GTX 1050 Ti (NVIDIA 580.178.04), an HD 630 (Mesa 25.2.8 ANV) and llvmpipe 25.2.8, everything else once. The results are identical to themaine4cee4952bbaseline: GTX none failed, HD 630 the same 10, llvmpipe the same 3.guest_libc_internal_facet_referencesandpublic_headerspass.progress.py --module libSceLibcInternallists neither export as pending.check_conventions.py,check_test_registration.py,check_main_sync.py(merges cleanly),check_compile.pyanddebt_fold.py --checkare clean.pr_overlap.py --branch: #17300 (rename-only) names the same two aliases. #13778, #14834, #17300, #18135 and #21704 could not be compared because they conflict withmain. A trial merge with each adds no conflicting file beyond those it already has. It merges cleanly with #23809, #23837 and #23846.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
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-19T20:04:08Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
1215eadb2c:tools/check_conventions.pypassed.guest_libc_internal_facet_references_testsbuilt cleanly.guest_libc_internal_facet_references):core/libs/prx/libSceLibcInternal/InventoryExports.cpp,core/libs/prx/libSceLibcInternal/include/InventoryExports.hpp,core/libs/prx/libSceLibcInternal/libSceLibcInternal.hpp,core/libs/prx/libSceLibcInternal/FacetReferences.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me