feat(libSceNKWebKit): implement PAL::fileSizeDescription #19460
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/19460"
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 MatteoSid on 2026-11-13T11:04:57Z.
What
Implements
PAL::fileSizeDescription(unsigned long)(_ZN3PAL19fileSizeDescriptionEm, NIDPbp5FkR35mI) in libSceNKWebKit. Before this PR it threw throughNotImplemented_nid_no_patch.The code follows the non-Cocoa branch of pinned WebKit
FileSizeFormatter.cpplines 35-46 atc55364d53f97, the revision the other libSceNKWebKit WTF and WebCore entries pin:bytes;size / 1000.to one decimal place andKB;size / 1000000.andMB;size / 1000000000.andGB.Upstream formats the number with
FormattedNumber::fixedWidth(value, 1), which isnumberToFixedWidthString, that isdouble-conversion'sToFixedwith the EcmaScript converter.ToFixedworks on the exact binary value and rounds up when the first discarded bit is set (fixed-dtoa.cclines 264-268). The PR reuses the mergedNKWebKit::WtfAbi::NumberToFixedWidthStringfromsrc/WtfNumberFormat.cpp, whichTextStreamalready uses for the sameToFixedbehaviour. It builds the result with the mergedWTF::StringImpl::create(const LChar*, unsigned)export, as the color serialization exports inWebCoreColorSpaces.cppdo. No new String layout or allocator is added.The code is in the new
src/PalFileSizeFormatter.cpp, which starts with aDerived fromline and the upstream Apple notice, byte-identical to lines 1-24 of the pinned file. The stub leavesExport.cppandInventoryExports.hpp, and the declaration goes intoWtfExports.hppbeside the otherPALexports. Indocs/dev/debt/libSceNKWebKit.md, the table row is removed and the throwing count goes from 5949 (main) to 5948. A new gap entry records that the code was not compared with a console module. It also records that the PS5 11.x tree returns anAtomStringbuilt bymakeAtomString, while this PR returns a plain 8-bitStringthat is not in the atom table. The export name does not encode the return type, so the two cannot be told apart from the symbol.Reachability: the only argument is a plain
uint64_t. The function reads no object, global or earlier state, so any caller reaches the whole implementation, including WebCore code in the same module. The result is an ordinary 8-bitWTF::String, the same as the other implemented String-returning exports in this library return.Tested
Linux,
anyps5-dev:24.04container (Ubuntu 24.04, GCC 13.3), Release,-DBUILD_TESTING=ON. Head65e48e8917. It mergesmainatb33b901eab(merge commit5bfaa3278c). The PR was first based onmaind134f4c8ea.The merge had no textual conflict, but git kept both "N of the 8703" count lines, 5948 from this branch and 5940 from
main.65e48e8917keeps one line, set to 5939:main's 5940 minus the one stub this PR removes, with no recount.On head
65e48e8917I built all 77 libSceNKWebKit test targets and the NID-patchedlibSceNKWebKit.prxwith no errors.ctest -R "nkwebkit|^public_headers$"passes 78 of 78: the 77 libSceNKWebKit tests, includingnkwebkit_palfilesizeformatter, andpublic_headers.git diff --check origin/main HEADis clean.nkwebkit_palfilesizeformatterchecks the exact strings. It also checks that each result is a non-null 8-bitStringImplwith one reference. Expected values were worked out from the exactdoublequotients with Python'sDecimalandROUND_HALF_UP:0 bytes,1 bytes,999 bytes;1.0 KB, 10491.0 KB, 10501.1 KB, 11501.1 KB, 12501.3 KB, 13501.4 KB, 999949999.9 KB, 9999501000.0 KB, 9999991000.0 KB;1.0 MB, 12500001.3 MB, 15000001.5 MB, 999949999999.9 MB, 9999999991000.0 MB;1.0 GB, 12500000001.3 GB, 123456789012123.5 GB,UINT64_MAX18446744073.7 GB.Two of these cases separate the rounding rules. 1150/1000. is just below 1.15, so it gives
1.1. 1250/1000. is exactly 1.25, a tie thatToFixedrounds up to1.3, whereprintf's round-half-even would give1.2.Mutation check, run on the earlier head
fd430701b2(the code is unchanged since then), one change at a time: 17 of 17 make the test fail at run time (none by a build error). The mutations:<changed to<=at each of the three thresholds;printf("%.1f")(ties to even) instead of theToFixedformatter;nm -D --defined-onlyon the patchedlibSceNKWebKit.prxbuilt from65e48e8917listsPbp5FkR35mI(T).tools/nid_names.py's NID of_ZN3PAL19fileSizeDescriptionEmisPbp5FkR35mI.python3 tools/check_conventions.py --base origin/main --head HEADpasses.Overlap:
090b3a1ff7,tools/pr_overlap.py --branchinanyps5-dev-gh:24.04merged the 95 open PRs that share files and found no shared export. It could not compare 25 PRs that conflict withmain. I read their diffs by hand: none adds or removesfileSizeDescriptionor edits the lines next to my hunks. They share only the "N of the 8703" count line, which every libSceNKWebKit PR edits. #18377 and #18395 also conflict withmainalone, inExport.cppandLegacyExports.hpp, and merge-tree shows the same conflicts with this branch; their debt entries merge cleanly.PAL::CryptoDigest) removes the stubs just above this one. On head090b3a1ff7,git merge-tree --write-treemerged it, #19302 and #18951 with this branch cleanly. On65e48e8917it merges #19302 (77928b987d) andmainb33b901eabcleanly.fileSizeDescription,Pbp5FkR35mIandFileSizeFormatterfind no other PR.Windows: JJenkx ran
nkwebkit_palfilesizeformatteron head65e48e8917merged ontomain(Windows 11, WinLibs GCC 15.2 UCRT, Release); it passes in 3 of 3 runs (comment).Not run: macOS, a console, 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)