Repository navigation
feat(libSceLibcInternal): implement significand exports - #25706
Conversation
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against c59f863545:
- Conventions:
tools/check_conventions.pypassed. - Build:
guest_libc_internal_significand_testsbuilt cleanly. - CTest (
guest_libc_internal_significand):1/1 Test #4544: guest_libc_internal_significand ... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 - Negative control: with
core/libs/prx/libSceLibcInternal/include/MathInternals.hpp,core/libs/prx/libSceLibcInternal/Significand.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass. - Code reading:
- Verified sceLibcInternalSignificand_nid_no_patch and sceLibcInternalSignificandF_nid_no_patch implementations in Significand.cpp follow PS5 firmware 13.60 assembly by delegating scalbn(x, -ilogb(x)) with NegateExponent handling INT_MIN safely without signed overflow UB
- Verified special floating-point edge cases (normal numbers, subnormals, +/-0.0, +/-inf, NaN) produce correct IEEE-754 results matching BSD/FreeBSD significand semantics
- Verified CMakeLists.txt target definition, test registration, target linking against libSceLibcInternal, libc, libkernel, and Windows unwind setup
- Verified debt fragment formatting in docs/dev/debt/changes/feat-libSceLibcInternal-significand.md adheres to TechnicalDebt.md rules and documents known side-effect gaps
- Verified AGENTS.md rules: no code comments, valid Conventional Commit PR metadata, no banned or untracked files
Looks Good To Me
throny
left a comment
There was a problem hiding this comment.
Review: ✅ correct, significand = scalbn(x, -ilogb(x)) for every input class
Basis: host check: the PR's formula vs the existing libc significand on 14 edge bit patterns and 2M random doubles (gcc) · head c59f863545
Checked
Az3tTyAy380/L2YaHYQdmHware new (no hits on main).- ±0 keeps its sign (the INT_MIN negate wraps instead of UB), ±inf stays ±inf, quiet NaN bits unchanged, subnormals correct (
ilogbreads bits, so DAZ doesn't matter: least subnormal → ±1.0), errno untouched (scalbnrestores it). No differences from the libc implementation on non-NaN inputs. - Follows the 13.60
ilogb→ negate →scalbnchain cited in the fragment.
Findings
- Minor: for a signalling NaN this raises FE_INVALID and returns the quieted NaN, while libc's
significandreturns the sNaN unchanged; the PR's behaviour is the one the firmware call chain implies. The test checks NaN withisnanonly, so payload/sign aren't pinned.
Suggested action: merge
AI-assisted review (Claude Code) · head c59f863545 · base main 2c08875217
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
Nothing blocks this change; the implementation follows the stated exponent-scaling approach, and the inspected code supports merging.
What I ran
Reviewed head c59f8635456134d1e774a4c2b4005c69f33efb89. I did not run build or test commands; the Windows and WSL results in the PR description are author-reported.
repo_read.py: review/description.md, review/commits.md, review/manifest.json, review/diff.patch
repo_read.py: targeted source reads and searches
Results
| Check | Result | Note |
|---|---|---|
| Diff and source review | passed | All five changed files read |
| Build and tests | not run | Results reported by author only |
| Negative control | not run | Reported by author only |
Findings
Blocking
None.
Non-blocking
None.
Sources
- The added wrappers use the existing
ilogb/ilogbfandscalbn/scalbnfproviders; the providers returnINT_MINfor zero andINT_MAXfor infinities and NaNs, andNegateExponentpreservesINT_MINas described. - The new test covers normal and subnormal inputs, signed zero, infinities, and NaNs for both precisions.
Not verified
No commands were run, and no console execution or title import was verified. The author-reported Windows and WSL test runs and export-table checks were not independently confirmed. No files were excluded from the prepared changed-file bundle.
To get this to a good state
Nothing is required.
Progress report (719516a → c59f863)📈 System libraries: 45.6% (+0.01%, +2 implemented functions) ✅ 2 implemented
Changed libraries (implemented exports)
|
What
Implements
libSceLibcInternalsignificand(Az3tTyAy380) andsignificandf(L2YaHYQdmHw). Both followlibSceLibcInternal.sprxfirmware 13.60 at0x59b40and0x59b70: callilogb, apply the 32-bit exponent negation including theINT_MINwraparound, then callscalbnwith the original input. The implementation reuses the existing libc providers and binds unique helpers withAPS5_EXPORT, so the libc export-preservation rule does not leave unpatched names.Coverage for this module:
tools/progress.pyon current main144d41ab69f: 676 done / 448 TODO / 1124 total -> 678 / 448 / 1126 (+2 implemented and +2 declared).Tested
libSceLibcInternal,guest_libc_internal_significand_tests,guest_math_tests,nid_patcherand the patched module;guest_libc_internal_significandandguest_mathpassed 2/2.guest_libc_internal_significandandguest_mathpassed 2/2.significand_nid_postfix not implemented(0xc0000409); the implemented body passes normal, subnormal, signed-zero, infinity and NaN checks in both precisions.Az3tTyAy380andL2YaHYQdmHwin the freshly patched PE export table.check_conventions.py --base origin/main,debt_fold.py --check,check_test_registration.py,git diff --checkand the 1406-header public include-graph validation passed.significand/significandf, and there is no semantic dependency.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)