feat(libSceLibcInternal): implement the _Atan and _Tan families for Dinkumware's arguments #21716
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/21716"
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 Krille2004zzz on 2026-11-16T16:37:01Z.
What
Implements
_Atan,_FAtan,_LAtan,_Tan,_FTanand_LTanin libSceLibcInternal (newQuadrantTrig.cpp), replacing the parameterless stubs. Only the arguments Dinkumware's own callers pass are implemented; every other argument still throws throughNotImplemented_nid_no_patch. Because of that,tools/progress.pystill counts all six as pending._Atan(double, int),_FAtan(float, int)and_LAtan(long double, int)come from Dinkumware's public xmath.h._Tan(x, int quads)comes from the declaration in Dinkumware V6.50's xxtan.h.xatan.c,xxxatan.h,xtan.c,xxxtan.h) is ported or used._Atan(x, flags):atan,atan2,asinandacos(xxatan.h, xxatan2.h,xxasin.h,xxacos.h) pass x in [0, 1] and flags built from 0x2, 0x4 and 0x8, and return the result as their own. Those callers only make sense if flags 0, 0x2, 0x4 and 0x6 give atan(x), pi/2 - atan(x), pi/2 + atan(x) and pi - atan(x), and 0x8 negates the result. That is what is implemented. An x outside [0, 1], NaN, infinity, the 0x1 bit or bits above 0x8 throw._Tan(x, quads): Dinkumware'stan(x)is_Tan(x, 0), so quads 0 returns libc'stan,tanfortanl. Any other quads value throws, because no caller in that library shows what it does.atan/atanl/tan/tanf/tanl. For flags 0x2, 0x4 and 0x6 the double version adds a two-part pi/2, as msun'satan2does.quadswould let the throwing paths be implemented._Atanlist entry appears twice word for word, so a fragment cannot change it, and the_LAtanentry is the one #21704 changes. The functions also still throw for every other argument.Tested
Linux x86-64 (Debian, GCC 14.2.0), Release,
BUILD_TESTING=ON, rebased on currentmain. No title tested.guest_libc_internal_quadrant_trigpasses. It checks:_Atan(0, 0x2) == pi/2,_Atan(0, 0x6) == pi,_Atan(0, 0xe) == -pi,_Atan(0, 0x8) == -0_Atan(z, 0) == atan(z)atan2within 2 ulp on 8 samplesacosrelation Dinkumware'sacosrelies on, within 4 ulp_Tan(x, 0) == tan(x)bit for bit, including NaN and infinity_Atan 0x4 is pi/2 + atan, and the same for_LAtan).ctest -R "libc_internal|dinkumware|public_headers": 159/159 pass.tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.py --branchreports no shared exports. The one conflict is with #21704: line 38 (_LAtan) ofinclude/MathInternals.hppsits next to that PR's line 37 (_Hypot). Whichever merges second needs a one-line rebase.main, so they could not be compared automatically. I compared their hunks by hand: none touches these functions or the changed lines.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-16T16:43:24Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
61ff86a672:tools/check_conventions.pypassed;git diff --checkclean.guest_libc_internal_quadrant_trig_testsbuilt cleanly.guest_libc_internal_quadrant_trig):core/libs/prx/libSceLibcInternal/Export.cpp,core/libs/prx/libSceLibcInternal/InventoryExports2.cpp,core/libs/prx/libSceLibcInternal/include/InventoryExports2.hpp,core/libs/prx/libSceLibcInternal/include/MathInternals.hppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me