fix(libc): compute y0f with FreeBSD msun's algorithm #16866
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/16866"
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 AlexWhitehouse on 2026-11-07T19:20:32Z.
What
libc
y0f(NID+tfKv1vt0QQ) returned the host's doubley0rounded to float. The console's libc uses FreeBSD msun's floate_j0f.c, which defines bothj0fandy0f, so the last bit differs. For example,y0f(1.0f)is0x3db4c011onmainand0x3db4c010in msun. Herelogf(1)is exactly 0, so the logarithm can't explain the difference.This PR adds the
y0fhalf ofe_j0f.cat FreeBSD release/10.0.0 to theJ0f.cppthat #16747 creates. That means__ieee754_y0fwith itsu00-u06andv01-v04coefficients, reusing that file'spzerof/qzeroftables andj0f.Bessel.cpp, #7998) follows. It calls this libc's msunlogf,sinf,cosfandsqrtf.y0f(±0)keeps the measured −∞, witherrnoand exception flags unchanged.y0do:y0f(+inf)is +0, andy0f(-inf)andy0f(NaN)go through1 / (x + x * x).errnoor raising invalid, as the measured doubley0does.main: on Linux,mainsetEDOMfor negative arguments because glibc'sy0does. That came from the host, not from a console measurement. The float negative domain is unmeasured, and the new debt entry says so.y1fin my #16847 follows the same rule.y0fwrapper line is removed fromMath.cpp.Tested
guest_bessel(core/libs/tests/GuestBessel.cpp) gains 81 exact-bity0fcases, each also checking thaterrnois unchanged. They cover:|x| < 2ranges, the fourpzerof/qzeroftable ranges, thex + xoverflow guard andFLT_MAX;Further checks cover no invalid or divide-by-zero for finite negatives, and invalid for
-inf. Every existing assertion is kept. Expected values come from upstreame_j0f.ccompiled locally with-O2 -ffp-contract=off -fno-builtin.Linux x86-64 (Ubuntu 26.04, GCC 15, glibc 2.43, Release):
guest_besselfails withGuest y0f failed for 3f800000: 3db4c011, expected 3db4c010;guest_bessel,guest_math,guest_math_elementaryandguest_math_exactpass 4/4;main750815131d, which has #16747 and #16847, the same four tests pass 4/4 at75fa632dac.Windows 11: (build 26300, WinLibs MinGW-w64 GCC 15.2.0 UCRT, Release):
J0f.cppandMath.cpp,guest_besselfails with the sameGuest y0f failed for 3f800000: 3db4c011, expected 3db4c010.Mutation check: flipping the sign of
u01fails the new cases (be856e6dfor 1.0), before and after the rebase.python3 tools/check_conventions.py --base origin/main: no errors. The one warning is about the shared host-results entry, which was already over 1,000 characters onmain; this PR only removesy0ffrom it.python3 tools/pr_overlap.py --branch fix/libc-y0f-msun: no other PR implementsy0f.libc.mdentries.Math.cpplines next to the removed wrapper.j1f/y1f) added tests next to the new ones inGuestBessel.cppand edited the same debt line. It has merged, and this branch is rebased onto it with both sets of tests and entries kept.libSceLibcInternalforwarders with thej0fandy0fNIDs that call libc's functions; it merges cleanly with this branch.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)main)🤖 Generated with Claude Code