fix(libc): format wide %a, %e, %f and %g with the narrow console rules #9927
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9927"
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 JJenkx on 2026-10-22T22:11:59Z.
What
The wide printf family (
swprintf,vswprintfand the rest) still formats%a,%e,%fand%gthrough the host. Thelibc.prxthat titles ship givesswprintfthe same text assnprintf. On 199,948 random formats, the copy bundled with PPSA07923 printed identical narrow and wide output. This build's wide output differed from it on 23,893, including 1,631 with no more than 17 significant digits. Examples, console thenmain:%.0fof 2.5 gives3vs2, and%aof0x1p-1074gives0x1p-1074vs0x0.0000000000001p-1022.The wide float branch now uses #9916's
DecimalFloatand #9699'sHexFloatfor finite values. Infinities, NaN, andlong doublewith%astill use the host, as in the narrow family.Tested
Refreshed exact head, 2026-10-25:
2def057898f2d0d857bed1579e14b6930adf4cd2. Two linear topic commits directly on main49d1f9b07ec7f6f989ace1c504bbe9dd6748dcbb; #9699 and #9916 are already merged. No merge commits or duplicated merged prerequisites. All added/removed line multisets for this topic's code, tests and debt match the former public patch. Conventions and whitespace pass. Both stack heads merge cleanly with newer mainb76f08cf33ea280d6155f16a84c1555701c3b2af, which changes only libSceNet export/tests/debt since the tested base; that is a merge preview, not another build.Fresh Linux GCC 16.2.1 Release: rebuilt libc and all 12 selected CPU test executables. Exact main, candidate and restored candidate each pass 12 groups × 3 repetitions (36 passes per arm), zero skips. This includes complete
guest_formatting,guest_wide_formattingandguest_stdio_variadicexecutables, plus wide strings/conversion/stream scanning, scan counts, strings, allocating strings, allocator failures, multibyte locale and character checks.Restoring only main's
FormattingWide.cppwhile keeping candidate tests failsguest_wide_formattingat the decimal rounding/cap check andguest_stdio_variadicat the formatted stream contents. Those parent-production controls fail both expected groups. Restoring this exact head passes all 36 executions again and reproduces identical hashes for libc and all 12 tested executables.Both pinned heads, full source-preservation checks, patches, build/test logs, parent controls and restoration hashes. SHA-256:
7da9766761e33dbc0bd05a7462cda802cb6b2d9a096516324133055079f9e151; downloaded copy verified.These are CPU regression results, not a fresh Windows run, converted title-libc differential, physical-console measurement, game/performance run or full-suite build. Earlier evidence below retains its original revisions and platforms.
Historical pinned validation
Earlier Linux refresh:
8f2f8a0e3fd494d4930198112cf558569811f534on main637220db112a3daf4960984290a82fcf65ba7061. The stack is rebuilt linearly in the order #9699 → #9916 → #9927 → #9958 → #10379, with no merge commits or duplicated prerequisite commits. This PR adds the wide-formatting commit plus its stream-expectation correction. Fresh Release libc/fixture build andguest_formatting,guest_wide_formatting,guest_stdio_variadicpass (3/3) on this exact head; conventions against the tested main and whitespace checks pass. Final-stack conventions against origin/main have zero errors (six inherited debt-length warnings). All five heads also merge cleanly with newer mainc8d34aa8f4d8058d57169cc1e423ba6db00faaf0; that merge preview is not an additional runtime test. The stream expectation correction is retained together with the wide finite paths. All five pinned heads, patches, checks and control logs (SHA-2569cda806ab2a54a4a0ce012517eafb7db0441ab2665d2e49884c3d1fc5b9e0c8a). No fresh Windows, title-library comparison, physical-console, game or performance result is claimed; Windows testing remains paused. The requested fresh Windows validation on #9699 is still outstanding.Historical validation on previous public head
6ff9b7d58ace9c651630593c511875b67224e222is retained below with its original scope; references there to ‘exact head’ refer to that historical run.Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Ninja, Release,
BUILD_TESTING=ON. Head 8359f9ef3a, on #9916's head b5e461750e.Differential run: a scratch loader runs a title's decrypted
libc.prxnatively. It calls that copy'ssnprintfandswprintf(nJz16JE1txM) and this build'sswprintf_nid_postfixon 199,948 random formats: random flags, width, precision 0–29,a/A/e/E/f/F/g/G, and values from random bits or binary fractions. The copies of PPSA07923, PPSA05916 and PPSA13934 all give the same results:mainit differed on 23,893.guest_wide_formatting: the newCheckFloatcovers ties (2.5,0.25,2025with#), a large tie that rounds down (67108865.5), zero padding (%.20fof 0.1),%aof a subnormal and a carried%.3a, and along doubletie. All of them are console results. The libc formatting, scanning, stream, wide-character and string tests (34) pass in three runs out of three. With #9916'sFormattingWide.cppand this test,guest_wide_formattingaborts.python tools/check_conventions.py --base origin/mainandgit diff --checkpass.Overlap: the code merges cleanly with #9596, #9527 and #5303, which also edit
FormattingWide.cpp. The last two have a neighbouring-line conflict indocs/dev/debt/libc.md. The overlap bot also flags #8855 and #9552 in the debt file. At their reviewed heads (a37f8c630aand314c7c4b9c), #8855 changes the narrow printf locale wording and #9552 raises its argument-position limit; retain those changes alongside this PR's float-formatting entries when resolving the debt text. #8855 also changesCheckWcsftimeinGuestWideFormatting.cpp, separately from this PR'sCheckFloatcases. These are patch-review findings, not a combined build/test result or additional dependencies.Not tested: a console. The original Windows report above used the earlier head; the exact-head Linux result is recorded below.
Linux (reviewer run): MarcZX10 ran a focused Linux check in an existing configured Release build with GCC 12:
guest_formattingandguest_wide_formattingpassed 2/2 with the formatting and test sources of #9958, which contains this PR. That reused an older configured tree with the PR's sources overlaid, so it is a focused Linux run, not a clean CI build.Linux (Codex, fresh exact-head build): Recorded result for
72e9e54e1591ab826269db01c2f936cdaa881691: Linux 7.2.9-arch1-1, GCC 16.2.1 20260810, glibc 2.44, Ninja Release,BUILD_TESTING=ON.ctest -R '^guest_(wide_)?formatting$' -V --no-tests=error --timeout 120passes both complete executables in all three repetitions, with no skipped cases. This is two CTest cases, not the Windows 34-test selection or a full CI/title/performance result. The broader Linux run reproduced a staleguest_stdio_variadicexpectation:vfwprintfof2.25with%5.1fnow correctly writes2.3under this PR’s rounding rule, while the test expected2.2. Commitf51e62745581c846487cdc00415e2bde681b1bb4corrects only that expected string; production code is unchanged. All 19 selected libc formatting, allocation, scanning, stream, wide-character, string, conversion and locale tests then passed in each of three repetitions (19/19 ×3, no skips). This is a focused Linux result, not a Windows rerun, full CI build or title test.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-10-23T05:12:55Z.
Review: DISMISSED
Reviewed exact head f51e62745581c846487cdc00415e2bde681b1bb4. The implementation and test report describe a focused wide floating-formatting change, preserve the stated extended-precision debt, and include a correction to the dependent
guest_stdio_variadicexpectation. The PR reports repeated focused Linux tests and Windows differential/build results; I have not independently rerun these on this head in this session. Local diff check, conventions, and registration checks pass. I cannot approve this branch as based on currentmain:tools/check_main_sync.py --base upstream/main --head <head>reports 6 commits ahead / 396 behind, with a clean merge. CONTRIBUTING requires one topic branch based on currentmainand kept up to date. Please merge currentmain, preserve the agreed overlap/debt edits, and rerun the focused formatting tests plus conventions on the resulting head. This request is only for repository freshness; it is not an intake or queue-size objection.