feat(libc): implement extended-precision math exports #2271
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2271"
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 obojeoboje on 2026-10-09T14:06:04Z.
What
Add 43 missing libc
long doublemath exports in a dedicated translation unit, preserving the guest x87 extended format rather than narrowing inputs, outputs or pointer results todouble.Trigonometric and hyperbolic:
acosl,asinl,atanl,atan2l,tanl,acoshl,asinhl,atanhl,coshl,sinhl,tanhl.Exponentials, logarithms and roots:
expl,exp2l,expm1l,log10l,log1pl,log2l,logbl,sqrtl,cbrtl,hypotl.Arithmetic and rounding:
fabsl,copysignl,fdiml,fmaxl,fminl,fmal,ceill,floorl,roundl,lroundl,llroundl,nearbyintl.Remainders, neighbors and decomposition:
fmodl,remainderl,remquol,nextafterl,nexttowardl,frexpl,ldexpl,modfl,scalbnl,scalblnl.Guest
lroundlreturns 64 bits on Windows through the hostllroundoverload.scalblnlaccepts a 64-bit guest exponent and bounds it before using the native int-exponent operation, avoiding Windowslongtruncation. Bounds exceed the entire representable x87 exponent range.Normalize native runtime differences found by the tests: signed-zero fractional results for infinite
modflinputs; domain/pole exception flags and errno foracoshl,atanhlandsqrtl; and missing overflow/zero-underflow flags for finite exponential/hyperbolic inputs. Preserve FreeBSD signed-zero ordering forfmaxl/fminl, and normalize neighbor-operation underflow/overflow flags andERANGE. Use-frounding-mathonly for the new implementation and test translation units.Contracts and signatures follow FreeBSD fmax(3), math(3), modf(3), and ldexp(3). All 43 export names are present in the shadPS4 aerolib table. Transcendental results use native extended-precision math; bit-identical results across host runtimes are not claimed.
Checked open PR descriptions and the relevant libc patches in #2193, #2213, #2166, #2167, #2173, #2192 and #2037. This branch excludes their functions and the rounding exports in #2235. Shared CMake insertion points may need both independent source/test additions preserved when rebasing.
The progress scanner changes from 2578/3044 (84.69%) to 2621/3087 (84.90%). Both counts grow because these are newly declared exports.
Tested
Windows, WinLibs GCC 15.2, Release with testing enabled: full default build and
libstarget passed.Full CTest run, four workers, 30-second per-test limit: 507 passed, one skipped (
guest_video_out_wqhd_detection_no_vulkan), zero failures; 39.68 seconds total on the final head91f4371b.New runtime fixture exercises all 43 exports using fixed numerical expectations, extended precision beyond double, exponents beyond the double range, subnormal decomposition/scaling, all four rounding modes, signed zero, NaNs/infinities, exception flags, fused rounding, quotient bits and 64-bit integer boundaries/exponents.
Linux, Ubuntu 24.04 under WSL, GCC 13.3: built
ExtendedMath.cppas a separate optimized shared library and linked/ran the same complete fixture with UndefinedBehaviorSanitizer successfully on the final head91f4371b. This was a focused runtime check, not a full Linux project build or NID-patched library run.Test registration, conventions and whitespace checks passed. No game tested.
Full Linux/Windows Build and the relinker matrix still require a collaborator to dispatch the workflow for this PR head.
Checklist
Based on current
main; no other open PR implements the same functionsOne topic per PR; follow-ups go in a new PR
No comments in code except technical debt
Unimplemented paths throw (
NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebtNo notes, investigation
.mdfiles or images added to the repository (attach them to this PR)New third-party code is a submodule built from source: none added
Generic behaviour, not specific to one title
Depends on: none
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T14:34:47Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libc/CMakeLists.txtL48Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T20:11:07Z.
Closing: none of these 43 functions is shown to be reached by a title on main; the list comes from the aerolib table, and library functions go in when a title needs them. Reopen with the title ID and the log line where it stops if you find one.
Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-10T22:36:22Z.
@obojeoboje PokeMMO (PPSA98001) now stops at
frexplonmainf38a036e(catalog build,sce_module/libc.prxunwrapped, with #1529 in):app.elf: symbol lookup error: app.elf: undefined symbol: YZk9sHO0yNg. The intake check needs 10 merged PRs; if you can't open PRs yet, would you like me to open thefrexplpart of this from my fork with your commits and authorship kept, after a Linux and Windows run? The rest of the long double set has no title stopping on it yet, so it would likely need to wait.Pull request closed