feat(libSceLibcInternal): implement the msun trigonometric kernels #13778
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13778"
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 croumegous on 2026-10-31T05:48:09Z.
What
libSceLibcInternalexports FreeBSD msun's four trigonometric kernels, and all four were parameterless placeholders that threw throughNotImplemented_nid_no_patch:__kernel_cos-m7FIvSBbMMlibSceLibcInternalInventory_263_nid_no_patch__kernel_cosdf7ruwcMCJVGIlibSceLibcInternalInventory_264_nid_no_patch__kernel_sindf2Lvc7KWtErslibSceLibcInternalInventory_265_nid_no_patch__kernel_sinzpy7LnTL5p0sceLibcInternalUnknown6_109_zpy7LnTL5p0_nid_no_patchThey are now the FreeBSD 11.4 sources (
k_cos.c,k_sin.c,k_cosf.c,k_sinf.c) with their real prototypes, inTrigKernels.cpp, exported as<name>_nid_postfix. The four placeholders, their header declarations and their inventory rows are removed, so each NID has one definition. The libcsinf/cosfkeep their own private copies (TrigfKernelSin/TrigfKernelCos), unchanged.These are what a FreeBSD-derived libm's
sin,cos,tan,sinfandcosfcall after range reduction; a title or bundled module importing them fromlibSceLibcInternalstopped on the first call.The debt entry states what is unverified: the NIDs hash from these names, but the console module was not read, so that it runs this code with these signatures is an assumption (the module is FreeBSD-derived, and libc's
sinf/cosfhere already are msun'sk_sinf.c/k_cosf.c).Tested
guest_trig_kernels(core/libs/tests/GuestTrigKernels.cpp, built withTrigKernels.cpp): 9 inputs from2^-30toπ/4, both signs, with and without a taily. All five results (__kernel_cos,__kernel_sinwithiy0 and 1,__kernel_cosdf,__kernel_sindf) are compared bit for bit with the unmodified FreeBSD 11.4 sources compiled by GCC for x86-64 (vectors generated from them; identical at-O0and-O2). It also checks them against hostcos/sinwithin2^-52, and the signed zeros FreeBSD returns (__kernel_sin(-0, 0, 0)is+0; withiy = 1it is-0).-O0,-O2and-O3 -march=x86-64-v3: passes. Negative control: changing one__kernel_coscoefficient fails row 4.compute_nid(tools/nid_names.py) gives exactly the four NIDs above for the four names.g++ -fsyntax-only -Wall -WextraonTrigKernels.cpp,InventoryExports.cpp,InventoryExports6.cpp: clean.python3 tools/progress.py --module libSceLibcInternal: 73/652 → 77/652.python3 tools/check_conventions.py --base origin/main: passed.python3 tools/pr_overlap.py --branch feat/libcinternal-trig-kernels: no shared exports or new files with any of the 1,580 open PRs. It exits 2 because PRs 5021, 11750 and 11751 conflict withmainand could not be merged: I compared their diffs by hand, and none of them contains these names, NIDs orTrigKernels. Its first run also flagged a textual conflict with #12924 and #13724 on the same debt line; the entry was moved, and both now merge cleanly with this branchlibSceLibcInternalshared library and its other tests (the full tree with submodules does not fit this machine), Windows, macOS. Not run on a PS5 or with a title.Checklist
main; no other open PR implements the same functionslibc/src/Math.cpp)NotImplemented_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 jotitadev on 2026-10-31T09:36:44Z.
Review: COMMENTED
Linux run of head
f66ce2078, merged (--no-commit) ontomain809c7fa2df, in the full tree (not a standalone executable). Ubuntu 26.04 (kernel 7.0), GCC 15.2.0, CMake 4.2.3, Ninja, Release,BUILD_TESTING=ON, i7-8700.guest_trig_kernelsbuilds through thelibSceLibcInternalCMake block and passes 3/3.libSceLibcInternalincluded.public_headers: 65/65 (the PR touchesApi.hppandInventoryExports.hpp). Related subsetguest_math|guest_float|guest_floating|libc_internal|LibcInternal|guest_trig|guest_libc: 16/16.C2in__kernel_cosfrome-03toe-02makes it abort withfailed: __kernel_cos (row 2)3/3; athrowat the top of each of the five exports also aborts it 3/3.main+ #13778 + #13782 + #13835 (the three openlibSceLibcInternalPRs; #13778/#13782 shareCMakeLists.txt) merge cleanly; full build ok, the same subset 17/17 three times,public_headers65/65.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T06:43:33Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change; the implementation follows the stated FreeBSD kernels and adds host tests, while console imports and signatures remain unverified.
What I ran
Reviewed head
f66ce2078ec7044c30f57d7d925c5413f0bc6ad9using the prepared diff andrepo_read.pyto inspect changed code at the pinned head. I did not run build or test commands.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Console module imports and the assumed signatures/NID-to-function mapping were not confirmed. No build or tests were run by this review; the reported host test results are author-reported. The reviewed files were
CMakeLists.txt,InventoryExports.cpp,InventoryExports6.cpp,TrigKernels.cpp,include/Api.hpp,include/InventoryExports.hpp,GuestTrigKernels.cpp, anddocs/dev/debt/libSceLibcInternal.md.files.jsonwas not available in the reader, so excluded files and the completereviewedset could not be confirmed.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T13:16:48Z.
Review: COMMENTED
Checked the branch sources and built the focused tests against the existing Linux runtime.
GuestTrigKernelspassed.AI-assisted: yes.
Pull request closed