Skip to content

feat(libc): export std::setw(int) - #6585

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
Mouad-Scriptz-0:feat/libc-setw
Oct 19, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
Mouad-Scriptz-0:feat/libc-setw

Conversation

@Mouad-Scriptz-0

Copy link
Copy Markdown

What

Exports std::setw(int) (_ZSt4setwi) from libc. Sony's libc is Dinkumware, where setw returns a manipulator that holds a function pointer and the width (16 bytes, returned in RAX:RDX); the caller invokes the pointer with the stream's ios_base and the width. The returned function stores the width in the stream's ios_base (GuestLocale::IosBase::width, offset 0x20) and returns the stream, leaving flags and precision alone; a null stream throws. The call convention comes from the title's own call site (mov esi, edx; call rax), and flags at 0x18 in that code matches the existing IosBase layout.

PPSA21402 imports setw and no library exported it: tools/import_audit.py lists it as the title's only absent import, and reports 0 absent with this change.

Tested

Fedora 44 (kernel 7.2.8, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, Intel Arc Meteor Lake, Mesa 26.2.3), worktree on main e16b2bc: guest_locale passes with the new CheckStreamWidth (the pair is returned, the returned function sets the width and returns the same stream, flags and precision and the bytes around the object stay untouched, a null stream throws); without the export the test does not link. The title (PPSA21402) starts and renders with the patched libc.prx. It later stops with null or misaligned index base from the graphics path, which it also does with the previous libc.prx, so it is not related to this change. Not tested on Windows.

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: none
  • Unblocks: PPSA21402 (no Game bring-up discussion yet)
  • GPUs tested: n/a (libc only)
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

Dinkumware's setw returns a manipulator holding a function pointer and the
width, which the caller applies to the stream; the function stores the
width in the stream's ios_base. The export returns that pair in RAX:RDX and
the function writes ios_base::width, leaving flags and precision alone.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Progress report (31cbb55 → 2e86b69)

➖ System libraries: 88.83% (+0.0%, +2 implemented functions)

✅ 2 implemented
Library Name
libc SetStreamWidth
libc _ZSt4setwi_nid_postfix

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 6975 core/libs/prx/libc/src/LocaleSupport.cpp L309
core/libs/tests/GuestLocale.cpp L21, L154, L182

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 6044 core/libs/tests/GuestLocale.cpp
PR 7081 core/libs/prx/libc/src/LocaleSupport.cpp

@johnmaia

Copy link
Copy Markdown
Contributor

Windows run, since Windows is untested. Windows 11, WinLibs GCC 15.2.0 r7 (MinGW), Release, BUILD_TESTING=ON, RTX 4080, ctest -j4 --timeout 300. Head 2e86b69 merged into main 5d9dcc4, plus #6452 so the MinGW test build works.

Not tested: a negative control on Windows.

AI-assisted: yes (Claude Code)

@github-actions github-actions Bot added the libc label Oct 16, 2026
@github-actions github-actions Bot added the unblocks title Names a title ID on the Unblocks line label Oct 18, 2026
@adriadam10 adriadam10 self-assigned this Oct 19, 2026
@adriadam10
adriadam10 merged commit 6b8228b into boykopovar:main Oct 19, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libc unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants