Skip to content

feat(libSceLibcInternal): implement the remaining collate<char> constructor forms and D0 - #23885

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
GiannisG1:feat/libcinternal-collate-ctor-aliases
Nov 19, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
GiannisG1:feat/libcinternal-collate-ctor-aliases

Conversation

@GiannisG1

Copy link
Copy Markdown
Contributor

What

#22428 implemented the complete-object collate<char> constructors, and its D1 and D2 are implemented too. Three NIDs of the same class were still inventory placeholders that threw:

Export Inventory NID
collate<char>::collate(const _Locinfo&, size_t), base object (C2) 099 L71JAnoQees
collate<char>::collate(size_t), C2 100 tkqNipin1EI
collate<char>::~collate(), deleting destructor (D0) 101 Lt4407UMs2o

The Itanium C++ ABI emits identical complete- and base-object constructors for a class without virtual bases, so the C2 forms do what their C1 siblings in Collate.cpp do. D0 runs the complete destructor, which has nothing to release here (D1 and D2 are empty), and frees the object with operator delete, as the delete entry of the facet vtable in libc (DeleteCollate) does. A null object throws std::invalid_argument.

The mangled names hash to the inventory NIDs (tools/nid_names.py), so the exports are named and the three placeholders are gone. The debt fragment removes the three table rows and adds a Functional entry: not verified on a console.

Tested

Linux Mint 22.3, GCC 13.3.0, Release, head on main e4cee4952b.

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 (see AGENTS.md)
  • 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

🤖 Generated with Claude Code

…ructor forms and D0

collate<char>'s base-object (const _Locinfo&, size_t) and (size_t)
constructors and its deleting destructor were inventory placeholders
that threw while the complete-object constructors and D1/D2 were
implemented. The Itanium C++ ABI emits identical complete- and
base-object constructors for a class without virtual bases, so the C2
forms do what their C1 siblings do. D0 runs the (empty) complete
destructor and frees the object with operator delete, as the facet
vtable's delete entry in libc does. Their mangled names hash to the
inventory NIDs, so the exports are named.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@PrivacyOnion PrivacyOnion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libc_internal_collate_tests built cleanly.
  • CTest (guest_libc_internal_collate):
    1/1 Test #4389: guest_libc_internal_collate ......   Passed    0.03 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceLibcInternal/Collate.cpp, core/libs/prx/libSceLibcInternal/InventoryExports.cpp, core/libs/prx/libSceLibcInternal/include/Api.hpp, core/libs/prx/libSceLibcInternal/include/InventoryExports.hpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified _ZNSt7collateIcEC2Em_nid_postfix correctly delegates to ConstructNamedCollate(self, 'C', references) matching its C1 counterpart and throwing std::invalid_argument on nullptr self.
    • Verified _ZNSt7collateIcEC2ERKSt8_Locinfom_nid_postfix correctly delegates to _ZNSt7collateIcEC1ERKSt8_Locinfom_nid_postfix, validating both self and locinfo for nullptr.
    • Verified _ZNSt7collateIcED0Ev_nid_postfix null check throws std::invalid_argument before invoking _ZdlPv_nid_postfix(self) without leaking or double freeing.
    • Verified removal of InventoryExports 099, 100, and 101 from InventoryExports.cpp and InventoryExports.hpp cleanly corresponds to the newly exported functions.
    • Verified Technical debt fragment docs/dev/debt/changes/feat-libcinternal-collate-ctor-aliases.md properly records the removed inventory placeholders and adds the Functional entry.
    • Verified test coverage in GuestLibcInternalCollate.cpp exercises layout, references count, borrowed _Locinfo immutability, allocating/deleting destructor behavior, and null pointer error rejection.

Looks Good To Me

@github-actions

Copy link
Copy Markdown

Progress report (fa0b7e3 → 26479cb)

📈 System libraries: 44.6% (+0.0076%, +3 implemented, -3 removed functions)

✅ 3 implemented
Library Name
libSceLibcInternal _ZNSt7collateIcEC2ERKSt8_Locinfom_nid_postfix
libSceLibcInternal _ZNSt7collateIcEC2Em_nid_postfix
libSceLibcInternal _ZNSt7collateIcED0Ev_nid_postfix
🗑️ 3 removed
Library Name
libSceLibcInternal libSceLibcInternalInventory_099_nid_no_patch
libSceLibcInternal libSceLibcInternalInventory_100_nid_no_patch
libSceLibcInternal libSceLibcInternalInventory_101_nid_no_patch

Changed libraries (implemented exports)

Library Before After Change
libSceLibcInternal 587/1131 (51.90%) 590/1131 (52.17%) +0.27%

@oneandonlydean
oneandonlydean merged commit 69b345d into boykopovar:main Nov 19, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants