Skip to content

feat(libc): export std::setprecision(int) - #11233

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
edubox:feat/libc-setprecision
Oct 26, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
edubox:feat/libc-setprecision

Conversation

@edubox

@edubox edubox commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

What

Export std::setprecision(int) (_ZSt12setprecisioni, NID 1h8hFQghR7w). Dinkumware's setprecision returns the same 16-byte manipulator as setw: the setter goes in RAX and the 32-bit precision in RDX. The setter writes ios_base::precision at offset 0x1c, leaving flags and width alone.

Evidence: disassembled the libc.prx bundled in PPSA02530's sce_module. 1h8hFQghR7w is a 10-byte export that returns mov %esi,0x1c(%rdi); ret in RAX and the argument in EDX. _ZSt4setwi has the same shape and writes 0x20 (width); both offsets are now pinned with static_assert in GuestLocale.hpp.

Tested

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
  • Fixes: none
  • Unblocks: none (removes one of the libc imports PPSA05510 needs; it still stops on the next one)
  • GPUs tested: n/a (libc locale manipulation only)
  • AI-assisted: yes

Dinkumware's setprecision returns the same two-register manipulator as setw: the function pointer in RAX and the precision value in RDX. The function stores the argument at ios_base offset 0x1c, leaving flags and width alone.

Disassembled from the libc.prx bundled in PPSA02530's sce_module, where _ZSt12setprecisioni (NID 1h8hFQghR7w) returns a pointer to 'mov %esi,0x1c(%rdi); ret' and has the same 10-byte export shape as _ZSt4setwi. Negative and zero values are stored unchanged; a null stream throws.
@github-actions

Copy link
Copy Markdown

Progress report (b90d009 → 93b0c59)

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

✅ 2 implemented
Library Name
libc SetStreamPrecision
libc _ZSt12setprecisioni_nid_postfix

Changed libraries (implemented exports)

Library Before After Change
libc 1348/1358 (99.26%) 1350/1360 (99.26%) +0.00 pp

@MarcZX10 MarcZX10 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.

Reviewed exact head 93b0c598706ac58645f7db2c7558859c70aaf19f. The new export follows the existing setw manipulator representation and updates only the measured IosBase::precision field; the focused test covers preservation of adjacent state, guard bytes, zero/negative inputs, and null-stream failure. git diff --check and current-main conventions pass; Linux register-context and relinker/ASan checks pass, with macOS and Windows jobs still pending. I could not run the full product target locally: the available build is relinker-only, and the repository rejected the manual full-build dispatch with HTTP 403. The author reports the focused guest_locale test passing on Linux; I did not independently rerun it.

@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

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 7081 core/libs/prx/libc/src/LocaleSupport.cpp
PR 7851 core/libs/prx/libc/include/Api.hpp
PR 9526 core/libs/prx/libc/src/LocaleSupport.cpp
core/libs/tests/GuestLocale.cpp
PR 9772 core/libs/prx/libc/include/Api.hpp

@github-actions github-actions Bot added the libc label Oct 26, 2026
@oneandonlydean oneandonlydean self-assigned this Oct 26, 2026
@babyhuey

Copy link
Copy Markdown
Contributor

Windows run of this head 93b0c598706, merged onto main 204c6747d0a (clean merge, local only), with the selection CI's skipped Windows product job uses: Windows 11, Ryzen 7 5800X, RTX 3080, WinLibs GCC 15.2, Release, BUILD_TESTING=ON. The tree was configured fresh after the merge, then select_tests.py select / ninja -f select.ninja selected / --target libs / select_tests.py ctest --parallel 4 --timeout 120, with check_skips.py --job windows (all skips expected).

AI-assisted: yes (Claude Code)

@oneandonlydean
oneandonlydean merged commit e95e81d into boykopovar:main Oct 26, 2026
18 checks passed
@edubox
edubox deleted the feat/libc-setprecision branch October 26, 2026 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants