feat(libc): add std::__sce_v2::_Random_device, _Fiopen and setw #9526
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9526"
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 AlxcBTW on 2026-10-22T00:14:23Z.
What
Adds three
std::__sce_v2exports next to their unversioned counterparts, each written from the console'slibc.prxdisassembly (a title's copy, read only):std::__sce_v2::_Random_device()(MQ8-UG0KYnQ)RuntimeSupport.cpp_ZSt14_Random_devicev(Nmtr628eA3A): both call one routine, so it returns the unversioned call's valuestd::__sce_v2::_Fiopen(const char*, int, int)(lEeJadNvMbo)FileAndHeap.cpp_Fiopenhere uses 0x80, 0x20 and 0x40 for them. A mode with any other bit set, or outside the console's table of twenty combinations, returns null; no-create reads asin,appas `outstd::__sce_v2::setw(long long)(I0vuMo7qix8)LocaleSupport.cppINT_MAXis kept wholeThe disassembly for
_Fiopenwas decoded to its mode table (jump table and string table, with relocations applied) and checked against the implementation for every mode below 0x10000 and for -1: the same string, or null, in all of them.Not in this PR:
std::__sce_v2::_Xregex_error(regex_constants::error_type)(luv6hxzFAhY) is left out. The console's body throws astd::__sce_v2::regex_error(0x18 bytes, message chosen from a table of fifteen texts by the error code, its own typeinfo and destructor), not the unversionedstd::regex_error(0x38 bytes) that_ZSt13_Xregex_errorthrows. That type belongs to the versioned exception hierarchy of #8901, which does not defineregex_error, so a thrower written now would throw the wrong type. A debt entry says so; it can follow #8901 as its own PR._Stolx,_Stoulx,_Stollxand_Stoullxv2 forwards wait for #8384.Known differences, in
docs/dev/debt/libc.md: this libc exports no versionedios_base, so the v2setwmanipulator only suits streams built by a title's ownlibc.prx, and a null stream throws where the console faults.Titles that import these: Minecraft Dungeons II (PPSA16064) imports all four of the listed functions, including the one left out.
Tested
1da5b7cd5plus the CI scaffolding commit; run 39690062746, the test filterguest_locale|guest_fiopen|guest_crt): 3 of 3 passed. Not run on Windows, and not run on a console or with a title.guest_locale(GuestLocale.cpp,CheckStreamWidthV2):setwwith 12, withINT_MAX + 5, with0x123456789abcdef0, with -1 and with 0 through the returned function on a guarded 64-byte buffer: the 8 bytes at offset 0x28 hold the value each time and no other byte changes; a null stream throws; the unversioned manipulator still writes the 4 bytes at 0x20 of anios_base.guest_fiopen(GuestFiopen.cpp): thirteen modes with no table entry (0,ate,trunc, binary alone, no-replace alone,in|trunc,in|no-replace, bits above 0xff, -1) return null and create nothing; read modes and no-create modes on a missing file return null; the file modes are exercised by writing and reading back a temp file (all buta+b,rb-with-ateand a few duplicates of the same string) (out|binarycreates,appandin|appappend,in|ateandno-create|ateend at offset 6,out|no-createandin|outoverwrite from the start,trunctruncates,no-replacecreates a missing file and returns null for an existing one); the 0x20 and 0x40 bits mean binary and no-create here, not what they mean in the unversioned call.guest_crt(GuestCrt.cpp):_Random_devicereturns values that are not all equal in 64 calls.python3 tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.py --branchlists no PR with the same exports; textual overlaps only:docs/dev/debt/libc.mdline 136 (#6565, #8872, #8880, #9001, #9133, #9170, #9447) andcore/libs/tests/GuestFiopen.cpplines 154-155 (#8658). Neighbours: #8901 (the versioned exceptions that_Xregex_errorwaits for) and #9416 (its_ZSt4setwi_nid_postfixis the unversioned call).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)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-22T00:15:14Z.
Progress report (
a6dcea9→1da5b7c)📈 System libraries: 42.35% (+0.02%, +4 implemented functions)
✅ 4 implemented
SetStreamWidthV2_ZNSt8__sce_v214_Random_deviceEv_nid_postfix_ZNSt8__sce_v24setwEx_nid_postfix_ZNSt8__sce_v27_FiopenEPKcii_nid_postfixImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T00:30:05Z.
Review: CHANGES_REQUESTED
The three added mangled exports independently recompute to the PR's NIDs (
lEeJadNvMbo,I0vuMo7qix8,MQ8-UG0KYnQ). The reported mode-table comparison, focused tests, and CI provide useful evidence; I found no additional implementation defect in this pass. These results are author-reported where specified; I did not run a local build or tests. Current eligibility, conventions, intake, labels, report, relinker matrix/ASan, register-context and write-watch checks pass; product Linux/Windows jobs were skipped.There is a concrete shared-file conflict with #9527: a direct three-way merge conflicts in
docs/dev/debt/libc.md. The overlap scan for #9527 also lists this PR. Please choose the landing order, record the agreed prerequisite in the second PR'sDepends online, and rebase/resolve the debt entries before merge. The currentDepends on: nonedoes not reflect that conflict.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T11:39:43Z.
A fresh pairwise merge check found two current debt-file ordering conflicts: #9527 (also your PR) and #9669 both add entries at the same insertion point in
docs/dev/debt/libc.md;git merge-tree --write-treereports content conflicts with each. The #9527 pair also has a cleanly auto-mergedFileAndHeap.cpphunk. Please coordinate the order across these three PRs, setDepends onon each branch that must follow another, and make sure all debt entries survive the final rebases. I also confirmed this head is 4 ahead / 119 behind currentmain, while its individual merge withmainis clean.Pull request closed