fix(libc): compute expl, sinhl, coshl and tanhl with FreeBSD msun's ld80 code #18525
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18525"
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 AlfaRojo on 2026-11-11T20:08:53Z.
What
expl,sinhl,coshlandtanhlreturned the host'sstd::exp,std::sinh,std::coshandstd::tanh, so their low bits depended on the host math library (WinLibs differs from msun on about 22%, 32%, 32% and 4% of random arguments; e.g.expl(19.1947635596975747091)is off by one ulp, and msun'ssinhlis within 0.5 ulp where WinLibs' is up to 0.74). They now port FreeBSD release/11.4.0lib/msun/ld80/s_expl.cwith itsk_expl.hkernel (128-entry Tang table, shared),lib/msun/src/e_sinhl.c,e_coshl.cands_tanhl.c: https://github.com/freebsd/freebsd-src/blob/release/11.4.0/lib/msun/ld80/s_expl.c. Both licence notices (Kargl BSD and Sun) are kept.expm1lfrom the same file is not ported. The debt entry indocs/dev/debt/libc.mdis split out of the host-computed list and records that console equivalence is unverified, that errno is untouched, and the x87 precision behaviour.Tested
65351c2931.guest_math3/3 runs pass: C99 Annex F specials (expl(-inf)= +0,expl(+inf), NaN,expl(0)= 1, signed-zerosinhl/tanhl,tanhl(+-inf)= +-1,coshl(+-inf)), the exact overflow and underflow thresholds ofexpl(the threshold value itself is finite, the next value is +inf with FE_OVERFLOW; the underflow threshold gives the smallest denormal, the next value +0 with FE_UNDERFLOW),sinhl/coshloverflow past the threshold,tanhl(+-100)= +-1 with FE_INEXACT, errno left unchanged, and 82 regular values bit for bit (small, near 1, 40 and 64, near overflow and underflow, denormal results, the host-differing ones) plus one value per function at 53-bit x87 precision. The expected bits come from the port and were cross-checked against mpmath at 300 bits: every case is within 0.51 ulp.std::calls restored the test aborts at theexplunderflow-threshold check (host gives 0, msun the smallest denormal); pinned values of all four functions differ from the host.tools/check_conventions.py --base upstream/mainpasses;tools/check_test_registration.pypasses.powl) only indocs/dev/debt/libc.md; #18513 (sinl,cosl,tanl) in the adjacent fourMath.cppexport lines, the test call list and the same debt line.tools/pr_overlap.pyfailed closed (output attached; 1981 open PRs, 118 share files, 31 not compared because they conflict with main). No open PR implements these four functions. #18122 forwardsexpl,sinhl,coshlandtanhlof libSceLibcInternal to*_nid_no_patch, which call*_nid_postfix, so it composes with this change. #11262, #11266, #18110 and #18481 edit the samedocs/dev/debt/libc.mdlist entry this PR splits, and #11266 and #18513 the neighbouringMath.cpplines; whichever merges second needs a trivial rebase. #11266 (exp2l) has its own tables and does not addk_expl.h. I grepped the diffs of the uncompared PRs for the four names: the only hits are the wordexplicitin unrelated libkernel and relinker PRs, and a reformat of the debt files in #14212; #6295, #7544 and #11109 (not compared, touchMath.cpp) do not mention them.f74693e6f7(merged with upstream/main including #11266'sexp2l):guest_math,guest_math_elementaryandguest_math_exact, all three test executables rebuilt, pass in 3/3 runs;check_conventions.py --base upstream/mainreports no errors.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-12T06:08:54Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
331e064441:tools/check_conventions.pypassed;git diff --checkclean.guest_math_testsbuilt cleanly.guest_math,guest_math_elementary,guest_math_exact):core/libs/prx/libc/src/Math.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me