feat(libSceLibcInternal): implement the Dinkumware significand scanners and wide _WSto*x conversions #18298
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18298"
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 justdoston on 2026-11-11T04:37:53Z.
What
Implement the last seven string-to-float internals in
libSceLibcInternalthat were still parameterless throwing placeholders inInventoryExports2.cpp:_Stoflt,_Stoxflt: scan a decimal or hexadecimal significand into words plus an exponent.words[0]gets the power-of-ten (decimal) or power-of-two (hexadecimal) exponent, andwords[1..n]the significand in 9 decimal or 7 hexadecimal digits per word, at most 5 words. The return value is the word count, 0 for a failed parse, and*endis rolled back tostartthen. Words are most significant first. The first dropped digit rounds half up with carry, trailing zeros move into the exponent, a zero significand gets exponent 0, thee/pexponent saturates at 999999999, and an incomplete exponent is left unread._WStoflt,_WStoxflt: the same over the guestchar16_ttext. The decimal point is the guestlocaleconv()'s, widened withbtowc._WStodx,_WStofx,_WStoldx: the wide forms of libc's_Stodx,_Stofxand_Stoldx. They parse the text's ASCII prefix through those libc functions, exactly as libc's_WStod,_WStofand_WStoldalready do, but keep the caller'serrorpointer so a range error is reported.The scanner in the new
FloatDigits.cppwas written from the C standard's subject sequence forstrtod(C11 7.22.1.3), not from any implementation. The prototypes are the declarations in Dinkumware V6.00'sxmath.h, withlongasstd::int64_tas in the PS5 ABI. Recorded indocs/dev/debt/libSceLibcInternal.md:maxsigbelow 1 throws.No module was read, no title's trace was used, and nothing was measured on a PS5.
A manual sweep of the diffs of all open pull requests that touch
libSceLibcInternalorlibcfound none that adds, removes or renames any of these seven names. Thepr_overlapsummary will follow in a comment.Tested
Linux (Ubuntu, GCC 13). The full project can't be built on this machine because system dev packages are missing, so I built an ASan+UBSan harness instead:
FloatDigits.cppand the new test, withlocaleconv,btowcandNotImplementedAtstubbed. For the rewritten scanner, libc's_Stodx/_Stofx/_Stoldxwere stubbed with hoststrtod/strtof/strtold. The wide_WSto*xwrappers are unchanged from98cc3c9ab9, where the harness linked libc's realsrc/DinkumwareInternals.cpp.guest_libc_internal_float_digits(new) passes with no sanitizer reports. It checks:_Stoflt: 19 inputs. They cover exponents, a fraction with leading zeros, a 20-digit significand split over three words, rounding up and down at a one-word limit with carry through a run of nines, zeros with and without a fraction or exponent, an incomplete exponent rolled back, exponent saturation, a 50-digit significand cut to 5 words, trailing zeros moved into the exponent, and failed parses that roll*endback tostart._Stoxflt: 10 inputs, with the same coverage plus the hexadecimal-to-binary exponent scale._WStoflt/_WStoxfltand must give the same count, end and words._WStodx/_WStofx/_WStoldx: power-of-ten scaling, stopping at a non-ASCII character, a non-number left unread, and*errorset on overflow (and underflow fordouble).*endnot rolled back, accepting an exponent with no digits, a wrong hexadecimal scale, and applying an exponent to zero.FloatDigits.cppcompiles cleanly withg++ -std=c++20 -Wall -Wextra -Werror.python3 tools/check_conventions.py --base origin/mainandpython3 core/libs/tests/test_public_headers.py --audit-onlypass.tools/nid_names.py'scompute_nidgives the inventory NID for all seven names.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 PrivacyOnion on 2026-11-11T16:27:45Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
98cc3c9ab9:tools/check_conventions.pypassed;git diff --checkclean.guest_libc_internal_float_digits_testsbuilt cleanly.guest_libc_internal_float_digits):core/libs/prx/libSceLibcInternal/InventoryExports2.cpp,core/libs/prx/libSceLibcInternal/include/InventoryExports2.hpp,core/libs/prx/libSceLibcInternal/libSceLibcInternal.hppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Generated withfooter from the description; the AI-assisted checkbox can stay.Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-14T00:06:23Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
bcd0cb07a7:tools/check_conventions.pypassed;git diff --checkclean.guest_libc_internal_float_digits_testsbuilt cleanly.guest_libc_internal_float_digits):core/libs/prx/libSceLibcInternal/InventoryExports2.cpp,core/libs/prx/libSceLibcInternal/include/InventoryExports2.hpp,core/libs/prx/libSceLibcInternal/libSceLibcInternal.hppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me