feat(libSceLibcInternal): implement the _Quad and _Quadph families #24583
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/24583"
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 Bladureau on 2026-11-20T20:27:16Z.
What
Implements
_Quad,_FQuad,_LQuad,_Quadph,_FQuadphand_LQuadphin libSceLibcInternal. They were no-parameterNotImplementedstubs._Atan/_Tan:unsigned int _Quad(T* px, int retcode)andunsigned int _Quadph(T* px, T phase). Dinkumware's_Sin,_Sincosand_Tancall_Quad(xxxsin.h).retcode & 1(argument in units of pi): the source's steps in the argument's type, including the unmasked quadrant (for example0xfffffffcfor -1.9).huge_rad(2/pi·2^12, 2/pi·2^27 and 2/pi·2^32 for float, double and long double), the quadrant is Dinkumware'sx * 2/pirounded half away from zero in the argument's type, so it can be the neighbour of the nearest one. Abovehuge_radit is the nearest one. The remainderx - q·pi/2comes from the existing msun__kernel_rem_pio2(prec 3), summed with error-free additions and rounded once. Dinkumware's tables are not copied._Quadphfollows the source, including the x86 result of the out-of-rangelongconversion (INT64_MIN).NotImplemented_nid_no_patch, because Dinkumware's callers filter them before calling. A null pointer throwsstd::invalid_argument._Quad*names are removed from three "Additional imported names" entries._FQuadstays in the_FHypot… entry becauselibcinternal-erfc-tail-kernels.md(and #21704) already change that entry.No title ID: I have no console or dumps.
Tested
Linux only, in Docker (ubuntu:24.04, GCC 13.3,
-O2 -ffp-contract=off -Wall -Wextra, no warnings).Quad.cpp,RemPio2.cppand the new test were built standalone, not through the full CMake build.guest_libc_internal_quad: passes. It checks 111 cases bit for bit (all three types, both modes,_Quadph, ±pi/4, the double worst case 6381956970095103·2^797, signed zero, subnormals) plus the NaN/infinity/null rejections. The expected values come from the reference below, not from this code.xxxquad.h, with exact rational arithmetic, each operation rounded to the type, and pi to 17,000 bits. Against it, 84,600 inputs match exactly, with no mismatch in quadrant or remainder. They include 1,262 medium inputs where Dinkumware's quadrant is not the nearest one, and 6,000 inputs that are roundings of k·pi/2 (heavy cancellation).<=athuge_rad, where both paths pick the same quadrant for all three types, and prec 1 instead of 3.python tools/check_conventions.py --base upstream/mainandpython tools/debt_fold.py --checkpass.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
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-20T20:27:29Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T20:30:46Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change based on the code reviewed; the reported standalone checks are author-reported, and I did not run checks.
What I ran
Reviewed head
0831525f42d15373ff9786d6db59321c3b13719eusing the prepared diff and the repository readerrepo_read.py. No commands or tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No changed files were excluded according to the manifest, and all six changed files were read:
core/libs/prx/libSceLibcInternal/CMakeLists.txt,core/libs/prx/libSceLibcInternal/Export.cpp,core/libs/prx/libSceLibcInternal/Quad.cpp,core/libs/prx/libSceLibcInternal/include/MathInternals.hpp,core/libs/tests/GuestLibcInternalQuad.cpp, anddocs/dev/debt/changes/feat-libscelibcinternal-quad.md. I did not run the reported tests or check conventions, the full build, Windows/MinGW, or console behavior.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-21T00:09:47Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
0831525f42:tools/check_conventions.pypassed.guest_libc_internal_quad_testsbuilt cleanly.guest_libc_internal_quad):core/libs/prx/libSceLibcInternal/Export.cpp,core/libs/prx/libSceLibcInternal/include/MathInternals.hpp,core/libs/prx/libSceLibcInternal/Quad.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T04:27:05Z.
Review: DISMISSED
Reviewed — changes requested
Changes are required before merge: make the extended precision test safe on Windows, where the test is explicitly enabled.
What I ran
Inspected the prepared diff and source at head
fbc62e8c6a23194158b6aca0eb35373f62c28e49usingrepo_read.pyreader tools. No build or tests were run.Results
Findings
Blocking
core/libs/tests/GuestLibcInternalQuad.cpp:70:Extendedwrites the exponent at byte offset 8 of along double. On Windows ABIs wherelong doubleis 8 bytes, this writes two bytes beyond the object;SameExtendedsimilarly reads beyond it at line 78. CMake adds and enables this test onWIN32(core/libs/prx/libSceLibcInternal/CMakeLists.txt:969-978), so the test has undefined behavior on that configuration. Guard the x87-specific cases or use a representation-aware implementation for Windows.Non-blocking
None.
Sources
The finding is based on the changed test and its CMake registration in the prepared diff, plus the corresponding source at the pinned head.
Not verified
No tests or builds were run. The full text of
core/libs/tests/GuestLibcInternalQuad.cpp,core/libs/prx/libSceLibcInternal/CMakeLists.txt, andcore/libs/prx/libSceLibcInternal/Export.cppwas not read; only relevant ranges or the diff were inspected.Quad.cpp,MathInternals.hpp, and both changed debt documents were read. The manifest lists all changed files as included; no separatefiles.jsonwas available.To get this to a good state
Make the extended precision test safe for Windows, then run the test on Windows and the relevant build checks on the new head.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T12:46:38Z.
Review: COMMENTED
Built the branch’s changed sources and ran
GuestLibcInternalQuadon Linux against the existing runtime libraries. The test run passed and covered the fixture’s numeric vectors for the _Quad and _Quadph families.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-04T12:02:37Z.
Review: COMMENTED
Actionable comments
e1f0f72c-90d6-4449-896f-7531fe541c70Reviewing files that changed from the base of the PR and between
63b98e5bf8andc283e2f642.core/libs/prx/libSceLibcInternal/CMakeLists.txtcore/libs/prx/libSceLibcInternal/Export.cppcore/libs/prx/libSceLibcInternal/Quad.cppcore/libs/prx/libSceLibcInternal/include/MathInternals.hppcore/libs/tests/GuestLibcInternalQuad.cppdocs/dev/debt/changes/feat-libscelibcinternal-quad.mddocs/dev/debt/changes/libsce-libcinternal-rint.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-04T12:25:44Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head
c283e2f64218d1a972538a54ac92a1083ea75556. I read all seven files listed underreviewedinfiles.json; no files were excluded. I did not run tests or builds. The only successful reader search was:Further reader searches could not run because the reader could not write its log in the read-only review folder.
Results
Findings
Blocking
None.
Non-blocking
long doublehas double precision.Not verified
I did not independently verify the author-reported test and reference results, Windows/MinGW behavior, console behavior, or the cited Dinkumware implementation. All files listed as reviewed were read;
files.jsonlists no excluded files.To get this to a good state
Nothing is required. Optional: verify behavior on Windows/MinGW and on the target module when those environments are available.