feat(libc): export the std::__sce_v2 float classification, integer-part and normalization helpers #14955
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14955"
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 Danigamer05 on 2026-11-02T04:30:00Z.
What
Export eight
std::__sce_v2Dinkumware floating-point helpers from libc, each forwarding to the unversioned helper already inMathExact.cppandMath.cpp:_ZNSt8__sce_v26_DtestEPdQ4jbwEbIBkU_Dtest_ZNSt8__sce_v27_FDtestEPfN1UVzJiqJcw_FDtest_ZNSt8__sce_v27_LDtestEPeJWcsTyLhh4E_Dtest_ZNSt8__sce_v25_DintEPdsLk4tA4JXn6w_Dint_ZNSt8__sce_v26_FDintEPfsEZGGXQTe+O4_FDint_ZNSt8__sce_v26_LDintEPesPtChgopsIV0_Dint_ZNSt8__sce_v26_DnormEPNS_5_DvalEyUpZZbVLg-w_Dnorm_ZNSt8__sce_v27_FDnormEPNS_5_FvalEeMWrDzXms5E_FDnormThe behaviour comes from the
libc.prxbundled with PPSA03671 v01.001.005 (J03848509, SHA-256483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6), which exports all eight at RVAs0xCB580,0xCF280,0x10C100,0xCB230,0xCF040,0x10C0F0,0xCA2B0and0xCA150. Its__sce_v2long doubleforms take an 8-bytedouble:_LDtestcalls the unversioned_Dtest, and_LDintcallsstd::__sce_v2::_Dint. The declarations here usedouble*for them. In that module the two_Dtestand the two_FDtestare byte-identical across namespaces; the other forms are separate compilations, so all eight were compared by running them.Other
__sce_v2math helpers in the same module (_Dscale,_Dunscale,_Exp,_Cosh,_Sinh,_Feraiseand their float forms) differ from the unversioned helpers here for subnormal inputs, NaN signs,errnoor exception flags. They need their own implementations and are not part of this change.Tested
Windows x86-64, WinLibs GCC 15.2.0, Release,
BUILD_TESTING=ON, main926f7dd492b0b432d9287f4d6faaaf1c9d3c86c5.Built libc, libkernel, their NID-patched production libraries and the
guest_sce_v2_float_helpers,guest_dinkumware_float_bitsandguest_math_exacttests. All three pass, as doespublic_headers.The new test checks 56 double and 48 float classification inputs, 84 double and 60 float integer-part cases and 18 normalization cases. Each expected code and output was taken from the original module, not from this implementation.
The original functions were loaded from the bundled module with its relocations applied. Its
__errorimport was bound to this libc and__stack_chk_guardto a local value;__stack_chk_failand every other import would have stopped the run, and none was called. They then ran side by side with the patched production library, called by NID, on 32,269,675 vectors:Return code, output bits,
errno, and MXCSR and x87 exception flags agree for all eight exports. Thelong doubleforms were run on 8-byte doubles.Negative control: three forwarders were temporarily altered (
_Dintand_LDintwith an off-by-one scale,_LDtestnegating the code,_FDnormadding one). The new CTest failed, and the side-by-side run flagged exactly those four exports while the other four still agreed. The source was then restored byte for byte (SHA-256 checked), rebuilt, and all four tests and all 32,269,675 vectors passed again.Code conventions and
git diff --checkpass. All tests and the side-by-side run were repeated at the submitted commita99455ab20bfc4dd5f57a6509cf910838dea81ef.tools/pr_overlap.pyread 1,895 open PRs and reports no confirmed overlap. It keeps exit 2 for 18 branches that already conflict with main (#5021, #7081, #7386, #7447, #7715, #8150, #8965, #9340, #9371, #9447, #9526, #9929, #10405, #10987, #11332, #11831, #12560, #14212). None of their added lines contains the eight names, their NIDs or the new test. Each was merged with this branch and with main usinggit merge-tree. This branch adds no conflict block to any of them. Only #14212, which re-spaces every debt file, already conflicts with main at thenearbyintentry next to the new debt line. The debt entry was moved there from an earlier place, where it would have added a conflict with #11332. Merging the 155 open PRs that editdocs/dev/debt/libc.mdagainst this placement adds no conflict.Not tested: Linux, macOS, another SDK, a game, GPU or console. No game compatibility claim. No original module, extracted bytes, oracle or log is committed or uploaded.
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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-02T16:08:31Z.
Review: APPROVED
Cross-checked against firmware 13.42's system
libSceLibcInternal.sprx(sha256a01795ab49df639dd40abd6194956ada062244826824ce486c9acab227bf5285) as well as the title's bundledlibc.prx. Read from disassembly only, not measured on a console:_LDtest(0x11cf30) iscall 0x4ee10, the unversioned_Dtest._LDint(0x11cf20) iscall 0xdc380, which isstd::__sce_v2::_Dint.So the
long double-takes-doubleforwarding in the PR matches the system module as well. The versioned_Dtest,_FDtestand_FDnormbodies are byte-identical to the unversioned ones in this module. The_Dintand_FDintpairs differ in bytes, so the run-based comparison in the PR is what settles those two. I didn't re-run that comparison against the system module.Build and test on Windows (WinLibs GCC,
BUILD_TESTING=ON), PR merged into currentmain:guest_sce_v2_float_helpersandguest_math_exactpass. Onmainthe exports don't exist, and the test doesn't link.