fix(libc): compute j1f and y1f with FreeBSD msun's algorithm #16847
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/16847"
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-07T18:07:25Z.
What
libc
j1f(NIDuVXcivvVHzU) andy1f(NIDgklG+J87Pq4) returned the host's doublej1/y1rounded to float. The console's libc uses FreeBSD msun's floate_j1f.c, which evaluates its own float rational approximations, so the last bit differs. For example, on glibc 2.43:mainj1f(0x3fa00000)(1.25)0x3f02b8350x3f02b834y1f(0x3fc00000)(1.5)0xbed31a1e0xbed31a1fThis PR ports
e_j1f.cat FreeBSD release/10.0.0 (__ieee754_j1f,__ieee754_y1fand theirponef/qoneftables) into a newcore/libs/prx/libc/src/J1f.cpp. It keeps the upstream notice byte for byte, the coefficients, thresholds, evaluation order and thevolatile hugeread.Bessel.cpp, #7998) and that my #16747 uses forj0f.|x| >= 2, and fory1f's logarithm, it calls this libc's msunsinf,cosf,sqrtfandlogf, not the host's.y1f(±0)keeps the measured −∞, witherrnoand exception flags unchanged, asGuestBessel's existing zero checks require.y1do:y1f(+inf)is +0, andy1f(-inf)andy1f(NaN)go through1 / (x + x * x).errnoor raising invalid, as the measured doubley1does. The float functions' negative domain is unmeasured, and the new debt entry says so.j0f,jnf,y0fandynfare unchanged. The only lines removed fromMath.cppare the two old wrappers.Tested
guest_bessel(core/libs/tests/GuestBessel.cpp) gains exact-bitj1fandy1fcases for both signs of 36 inputs, and every existing assertion is kept. They cover:|x| < 2, the fourponef/qoneftable ranges, they1f2^17 shortcut and thex + xoverflow guard;errnoon every case;y1f, and invalid fory1f(-inf).Expected values come from upstream
e_j1f.ccompiled locally with-O2 -ffp-contract=off -fno-builtin.Linux x86-64 (Ubuntu 26.04, GCC 15, glibc 2.43, Release):
main,guest_besselfails withGuest j1f failed for 3fa00000: 3f02b835, expected 3f02b834;guest_bessel,guest_math,guest_math_elementaryandguest_math_exactpass 4/4.Windows 11: (build 26300, WinLibs MinGW-w64 GCC 15.2.0 UCRT, Release):
main'sMath.cppandCMakeLists.txt,guest_besselfails with the sameGuest j1f failed for 3fa00000: 3f02b835, expected 3f02b834.Mutation check: changing
r00from-0.0625to-0.06fails the new cases (3f03eec5instead of3f02b834).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 (1,439 onmain); this PR only removesj1fandy1ffrom it (1,422), and the newj1f and y1fentry is under the limit.python3 tools/pr_overlap.py --branch fix/libc-j1f-y1f-msun: no open PR changesj1fory1f.j0f) removes the adjacent wrapper line and adds its source and debt entry at the same spots, so it conflicts textually. Whichever merges second rebases; the two are otherwise independent.hypotl) edits the same shared debt line.hypot3lline above the removed wrappers.libc.mdorCMakeLists.txt. I checked them by hand, and none changes these functions.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