feat(libSceLibcInternal): implement _Hypot, _FHypot and _LHypot #21704
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/21704"
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:20:11Z.
What
Implements
_Hypot,_FHypotand_LHypotin libSceLibcInternal (newScaledHypot.cpp), replacing the parameterless stubs.(x, y, int* exponent)come from Dinkumware's public xmath.h declarations. No Dinkumware code is ported; the body is written from the measured behaviour.libSceLibcInternal.sprxmeasurements that @BunnyFl posted in #12363 (module run natively on a PC, not a console). Thanks for those:exponentbefore anything elsefrexpexponent of the larger magnitude, divided by 4 (truncated), times 2, or 2 when that is 0, and the result ishypot/hypotf/hypotlof the arguments scaled by 2^-exponentstd::invalid_argumentwhere the module faults.Tested
Linux x86-64 (Debian, GCC 14.2.0), Release,
BUILD_TESTING=ON, on this branch rebased on currentmain. No title tested.guest_libc_internal_scaled_hypotpasses. It checks every #12363 measured case: (3, 4), (-5, 12), (0, 0), (1e300, 1e300) giving1.7281329749791539e150and 498, (1e-310, 1e-310) giving7.584601526487318e-156and -514, (0.1, 0.2), (inf, NaN), (NaN, 1), plus (inf, 1), the float/long double (3, 4) and (inf, NaN) cases,result * 2^exponent == hypoton extra pairs, and the null exponent. Removing the NaN check makes it fail at_Hypot nan 1.ctest -R "libc_internal|dinkumware|public_headers": 159/159 pass.ctest -j8(before the rebase): 5846/5847 pass. The failure isguest_http2_transport, which also fails on unmodifiedmainon this machine. GPU tests were skipped (no Vulkan device).tools/check_conventions.py --base origin/main: all checks pass.tools/pr_overlap.py --branch: no shared exports. Six PRs that already conflict withmain(#13778, #17300, #18135, #19602, #20059, #21255) 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:22:54Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
d3e41cb996:tools/check_conventions.pypassed;git diff --checkclean.guest_libc_internal_scaled_hypot_testsbuilt cleanly.guest_libc_internal_scaled_hypot):core/libs/prx/libSceLibcInternal/Export.cpp,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
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T11:34:44Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; its scaled result logic and exponent handling are consistent with the documented behavior, with remaining firmware-specific differences recorded as technical debt.
What I ran
d3e41cb996e228e19d9125fb7fad67ac8c081282usingrepo_read.py.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The reported test runs and platform behavior were not independently verified. The firmware comparison was measured by the author on a PC, not a console; firmware-specific bit-level behavior, signalling NaNs, directed rounding, and exception flags remain unconfirmed. No excluded changed files were listed in the manifest.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T09:54:06Z.
Review: COMMENTED
Reviewed — no blocking findings
The implementation follows the documented measured exponent and special-value rules, while the firmware comparison remains incomplete and the reported tests were not run by this review.
What I ran
24405258b9d014f4339a8034ff60bf214d8ee1aa.GuestCopyOut_nid_no_patchdeclarations and the existinghypot_nid_postfiximplementation for targeted context.Results
Findings
Blocking
None.
Non-blocking
core/libs/dev/debt/changes/feat-libsce-libcinternal-hypot.md:5documents that_Hypot,_FHypotand_LHypotmay differ from firmware in last-bit results, with only limited float and long-double measurements. The implementation’s generic use of the host hypot routines is consistent with that stated limitation. Consider adding more firmware comparisons when available, especially for float and long double.Not verified
files.jsonwas not available through the reader; the manifest lists eight changed files, and all eight were read. No files were marked excluded in the manifest.To get this to a good state
Nothing is required. Optional: expand the firmware comparisons for float and long double when measurements are available.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T21:55:06Z.
Review: COMMENTED
Reviewed — comments
The implementation follows the stated scaling and special-value rules, but I could not run the reported checks in this review, so a formal approval is not justified.
What I ran
Reviewed head
d3773c67a0872c44cf21487e1549de74e02f56a4. I read the prepared description, commits, manifest, and diff; usedrepo_read.pyto inspect the changed implementation, declarations, build wiring, tests, and debt entries. No test or build command was run here. The author reports Linux x86-64 Debian/GCC 14.2 results; those were not independently verified.Results
Negative control
Could not run the reported mutation check that removes the NaN check.
Findings
Blocking
None.
Non-blocking
(0.1, 0.2), while_FHypotand_LHypotwere measured only for(3, 4)and(inf, NaN). The debt entry records these limits. Additional firmware comparisons would strengthen confidence in the edge cases and rounding behavior.Sources
ScaledHypot.cppat the reviewed headNot verified
No build, test, negative control, Windows or macOS run, title test, or physical-console behavior was verified here. I read the changed files listed in the manifest:
core/libs/prx/libSceLibcInternal/CMakeLists.txt,core/libs/prx/libSceLibcInternal/Export.cpp(relevant changed hunks),core/libs/prx/libSceLibcInternal/ScaledHypot.cpp,core/libs/prx/libSceLibcInternal/include/MathInternals.hpp,core/libs/tests/GuestLibcInternalScaledHypot.cpp, and the three changed debt fragments. No changed file was excluded by the manifest.To get this to a good state
Nothing is required. Optional: add broader firmware comparisons for float and long-double edge cases and rounding behavior.