feat(libc): export the Dinkumware _Mbrtowc and _Wcrtomb helpers #14610
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14610"
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 edubox on 2026-11-01T16:22:10Z.
What
libc.prxexports the Dinkumware multibyte helpers_Mbrtowc(olQf-vTaj2Q) and_Wcrtomb(6pa-Aa4kTHk); PPSA01341 imports both from it and neither was exported here. PPSA28416's relinker registry references neither NID, so this body no longer claims it.The disassembly of PPSA28416's
libc.prx(build J03848509) shows 21-byte thunks at0xc9660and0xc9630that take(wchar_t*, const char*, size_t, mbstate_t*)and(char*, wchar_t, mbstate_t*), use the C-locale conversion vector when the state is null, and forward to the same internal routines asmbrtowcandwcrtomb. This library already has guestmbrtowcandwcrtomb, so the two exports delegate to them and share their UTF-8 conversion, guest 16-bitwchar_tandthread_localstate when the caller passes null. The console's_Cvtvectables are not modelled; the debt entry records it.This removes two of PPSA01341's eleven missing
libc.prximports (the six streams are covered by #14585,_Getctype/_Getcvtby #9466, andNeed_sceLibcis not a real export).Review evidence
On
main, PPSA01341's relinker registry has both imports fromlibc.prxasR_X86_64_JUMP_SLOT:olQf-vTaj2Q#u#s(_Mbrtowc)0x1E742500x279E1D00x26D28386pa-Aa4kTHk#u#s(_Wcrtomb)0x1E742600x279E1E80x26D2840nm -Donmain'sunpatched/libc.prxhas neither symbol; this branch's has_Mbrtowc_nid_postfixand_Wcrtomb_nid_postfix. The other 29 dump registries have no entry for either NID. In the tested main build PPSA01341 runs past both imports (Demon's Souls reaches the tutorial), so there is noNotImplementedstop line for them: they are missing library exports, not the point where that title stops.Tested
Linux x86-64 (CachyOS), GCC 16.2.1, Release:
ctest --test-dir build -R '^guest_multibyte_locale$'passes. The test now checks_Mbrtowcagainstmbrtowcfor a complete form, an incomplete form and a null string/state, and_Wcrtombagainstwcrtombfor a three-byte character and a null destination.nid_patcher libcon the rebuiltunpatched/libc.prxexportsolQf-vTaj2Qand6pa-Aa4kTHk.tools/check_conventions.py --base origin/mainandgit diff --checkare clean;tools/pr_overlap.py --branch feat/libc-mbrtowc-helpersreports no overlap with open pull requests.Not run on Windows or macOS, and not exercised by a title.
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 MarcZX10 on 2026-11-01T16:44:24Z.
Review: COMMENTED
Reviewed — looks good
The two new helpers delegate to the existing multibyte conversions; I found no blocker in the changed files, but hosted checks are queued, so this is a comment rather than an approval.
What I ran
Reviewed head
30046dcc3f2c15932d69b4e351cb21e22ca40316against basef2d874c1fdccf781c0fa5d86619bb5dd8894b958; the merge preview is clean. Environment: Linux x86_64, Python 3.11.2, GCC 12.2.0. No build or C++ test was run.Results
Precheck and focused-check output
Negative control
Not run: the changed C++ test needs a built executable, which was outside this no-build review.
Findings
Blocking: None found in the changed implementation, declarations, test, or debt entry.
Non-blocking: The PR description reports Linux test and NID-patcher results; I did not independently rerun those build-dependent checks. The new test compares wrappers against the existing functions they delegate to, which checks forwarding behavior but is not an independent console-behavior oracle.
Sources
Not verified
The reported Linux CTest run, rebuilt PRX/NID output, other operating systems, console behavior, full build, and queued hosted checks were not verified here.
To get this to a good state
No change is needed from this review. Once hosted checks finish, I will re-check their results; if the head changes, I will rerun the applicable checks on the new head.
Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T19:48:54Z.
Review: COMMENTED
Withdrawn. There is no
NotImplementedstop line at these imports: onmainPPSA01341 runs past them. They are missing exports, not the point where the title stops.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T10:03:26Z.
Review: APPROVED
Reviewed — approved
_Mbrtowcand_Wcrtombforward directly to this library'smbrtowcandwcrtomb. The merged tree builds, the focused tests pass, and the changed test fails to link without the production change.What I ran
Head
b1f186162fa3cee1cddc967235ee4a4f78a65c6d,main4f41f4c375f5abb487dbd184fbc150f31994d762, merged with--no-ff(tree982f09119533ed9f5adc34c991ca53ab22dc67aa). Debian 13 VM, GCC 14.2.0, Release, Ninja,BUILD_TESTING=ON.Results
git diff --checkcheck_conventions.pymain.guest_net_ctlis skipped onmaintoo.guest_multibyte_locale,guest_wide_conversion,guest_localepublic_headersgit status --porcelainempty)Negative control
I restored
core/libs/prx/libc/src/Multibyte.cppfrommainand rebuiltguest_multibyte_locale_tests. The test executable no longer links:Link output
After I restored the merged file, it rebuilds and passes. This confirms the link failure B-Howell reported on Windows/WSL. Because the new functions only forward to existing ones, a link failure is the only failure a revert can produce.
Findings
Blocking
None.
Non-blocking
docs/dev/debt/libc.md:312). CONTRIBUTING asks an entry to "state the gap first". Right now the entry first lists the console signatures and the 21-byte thunks, and only ends with what is not modelled (_Cvtvectables, non-C locales). I suggest starting with that gap. B-Howell's PPSA08329 disassembly shows that in that build_Mbrtowc/_Wcrtombcallmbrtowc/wcrtombdirectly. If you add that, the entry can be cut to what is still unverified, namely the PPSA28416 thunks' C-locale_Cvtvecpath.core/libs/tests/GuestMultibyteLocale.cpp:136-157). It compares each wrapper with the function it calls, as MarcZX10 already noted. This is acceptable for a pure delegation. It is not an independent check of console behaviour.Not verified
libc.prxdisassembly or registries, so the NIDs, the thunk addresses and the PPSA08329 findings come from the description and the discussion.nid_patcheron the rebuiltlibc.prx.