feat(libc): export the std::__sce_v2 resetiosflags, setiosflags, setbase and setprecision manipulators #15809
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15809"
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 Danigamer05 on 2026-11-04T16:40:55Z.
What
Export the versioned
std::__sce_v2resetiosflags,setiosflags,setbaseandsetprecisionmanipulators from libc._ZNSt8__sce_v213resetiosflagsEiHeqRSMqwwwY0xCFB80_ZNSt8__sce_v211setiosflagsEilztvX9nXnR80xCFBB0_ZNSt8__sce_v27setbaseEiIqXrM0jIFDw0xCFBD0_ZNSt8__sce_v212setprecisionEx3EDeSsnqsYc0xCFC20The behavior comes from the
libc.prxbundled with PPSA03671 v01.001.005 (J03848509, SHA-256483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6).Each one returns a function and its argument in two registers, as
SceV2StreamManipulator. Theintargument is returned zero-extended to 64 bits and thelong longone as is. The function changes the versionedios_baseas the module's does:resetiosflagsclears the given bits of the 32-bit flags at 0x18;setiosflagsstores(flags & ~mask) | (mask & 0xFFFF), so it also clears the high bits of the mask, which it does not set;setbasereplaces the base field (bits 9 to 11) with0x400for 8,0x200for 10,0x800for 16 and 0 for any other base;setprecisionstores the 64-bit precision at 0x20.They sit in
LocaleSupport.cppafter the versionedios_basecalls and use main'sSceV2IosBase, reading and writing the flags and precision at their offsets. This libc exports no versioned stream class, so they only suit streams laid out by a title's ownlibc.prx. The debt entry records that, and that a null stream throwsstd::invalid_argumentwhere the console faults. #9526 adds the versionedsetwin the same file; these four are not part of it.Tested
Windows x86-64, WinLibs GCC 15.2.0, Release,
BUILD_TESTING=ON, mainb11c7bf84f5. Exact tested commit:dfbb31ac9ac. The head35ac394278bonly renames the four helpers with the_nid_no_patchsuffix; it was rebuilt and passed the new CTest,guest_locale,guest_sce_v2_locale, code conventions and 1,000,000 more side-by-side calls with no difference.Built libc, libkernel, their NID-patched production libraries and the related tests. The new
guest_sce_v2_iomanippasses, along withguest_locale,guest_sce_v2_locale,guest_sce_v2_exceptionsandpublic_headers.The new test checks 19 calls: masks with low, high, all and no bits, bases 8, 10, 16, 0, 2, -8 and 24, and precisions 6, 0, -1 and one above 32 bits. Each applies the returned function to a guarded 72-byte object and checks the returned argument, the flags, the precision, that no other byte changes, and that a null stream throws. Every expected value was taken from the original module, not from this implementation.
The original functions were loaded from the bundled module with their relocations applied. Their imports were bound by NID to this branch's libc and libkernel, with
__stack_chk_guardpointing at a local value.Side by side with the patched production library, the returned argument, all 96 bytes around the stream,
errno, MXCSR and the x87 control and status words agree in all 10,000,000 calls over two seeds. The arguments mixed edge values, random 32- and 64-bit values and small bases; the starting stream bytes were random, with all-zero and all-one flags.Negative control: four lines were altered one at a time:
setiosflagskept the high bits;setbaseswapped the octal and decimal fields;resetiosflagskept the mask instead of clearing it;setprecisionstored 32 bits.The new CTest failed on each, and the side-by-side run reported differences for each altered function. The source was then restored byte for byte (SHA-256 checked) and rebuilt, and the test and side-by-side run passed again.
Code conventions and
git diff --checkpass.tools/pr_overlap.pyread 1,876 open PRs at the tested commit and reports no overlap. It keeps exit 2 for 25 branches that already conflict with main. Merging each of the 25 with this branch and with main usinggit merge-treegives the same conflict blocks. Only #13486 names a related symbol: it lists the unversionedstd::resetiosflagsandstd::setbasein a table, not these four. The branch also merges cleanly with #15336, #15471, #15484, #15490, #15501, #15519, #15552, #15561, #15602, #15614, #15667, #15683, #15791 and #15796.Not tested: Linux, macOS, another SDK, a game, GPU or console. No game compatibility claim. No original module, extracted bytes, harness or log is committed or uploaded.
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