feat(libc): implement atanhf #5036
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5036"
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 0xRickx on 2026-10-13T09:07:15Z.
What
Dusklight (PPSA99305) imports
atanhf(cPGyc5FGjy0) fromlibSceLibcInternal.prx. Thelibc.prxit bundles only has a zero-return stub for it, and no AnyPS5 library exports it. With #3651 (posix_spawn, its current stop onmain) applied, Dusklight stops here:atanhffollows the one in thelibc.prxbundled with PPSA28319, read from its disassembly, assinhfandasinlalready do. That is FreeBSD msun'se_atanhf.ccalling msun'ss_log1pf.c, both at 59bc2f09, the revision #3725 tookexpm1fandexpffrom. Thelog1pfpaths for the positive argumentsatanhfpasses are inlined (AtanhfLog1p), because libc's exportedlog1pfis the host's; with the host's, 4.7% of the arguments in [0, 1) give different bits. For |x| > 1, the infinities and NaN, Sony's error helper raisesFE_INVALIDand setserrnotoEDOM. For |x| = 1 it setserrnotoERANGEand returns ±inf. The technical-debt entry records that the systemlibSceLibcInternalis assumed to have the same code.Tested
Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, on
main4bb2c7f3:atanhfcode of thelibc.prxbundled with PPSA28319 on the Windows host. For all 2^32 arguments it gives the same bits,errnoand floating-point exceptions as this implementation. msun's owne_atanhf.cands_log1pf.cbuilt with the host compiler give the same bits.guest_mathgainsCheckAtanhf: bit patterns for every branch reachable fromatanhf, both signs, and theerrnoand exception behaviour. It fails with the hostlog1pfin place of the msun one, at input3dcccccd.main's relinker:mainit stops atposix_spawnattr_init(44hlATrd47U, #3651);cPGyc5FGjy0(atanhf);patched_libraries, ismain'slibkernel_sys.prxload failure on Windows, fixed by #5025.tools/check_conventions.py --base upstream/mainpasses.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 github-actions[bot] on 2026-10-13T09:07:45Z.
Progress report (
2a2a3dc→3fe04d4)➖ System libraries: 88.38% (+0.0%, +1 implemented functions)
✅ 1 implemented
atanhf_nid_postfixImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T09:14:15Z.
Checked the
atanhf+ inlinedlog1pfpaths against msune_atanhf.c/s_log1pf.cat 59bc2f09 over all 2^32 float arguments on Linux (GCC,-ffp-contract=off): identical bits.guest_mathpasses with the newCheckAtanhf; conventions and the debt entry are fine. Merging once the full Build is green.Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-13T09:24:44Z.
Windows check with both titles that stop here. Windows 11 (26300), Radeon 860M, WinLibs GCC 15.2.0, Release. Build:
main2a2a3dc65+ #3651 (7bb59f73b) + this PR (3fe04d4b7), titles relinked with--windows --trap-sdk-syscall-stubs.guest_math: 3/3.atanhfand runs the full 60 s (Dusklight | FPS: 23.18). With #3651 alone it stops atunresolved ELF import cPGyc5FGjy0.atanhftoo, then faults after 2 s inside the title:0xc0000005, ripPPSA99309.exe+0xddad12, read of0x98. That's a separate stop, after this PR's point.AI-assisted: yes (Claude Code)