feat(libc): implement C99 numeric helpers #2280
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2280"
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:29:21Z.
What
Add 24 missing C99 numeric exports to libc in a separate translation unit:
sqrtf,fabsf,ceilf,truncf,nearbyint.remquo,remquof,copysign,copysignf.nan,nanf,nanl.nextafter,nexttoward,nexttowardf.fdim,fdimf,fmax,fmaxf,fmin,fminf,fmaf.scalbln,scalblnf.Min/max implement FreeBSD's signed-zero ordering and NaN handling directly, including no new exceptions when selecting the numeric operand against a signaling NaN. Bit classification avoids arithmetic on the NaN operand.
nexttowardretains the extended-precision target rather than narrowing it to the result type. Neighbor operations normalize missing MinGW overflow/underflow flags andERANGEat representation boundaries.Guest
longexponents are 64-bit on Windows too.scalblnbounds the exponent before calling the native int-exponent operation; the bounds exceed the full float/double exponent range. Compile only the new implementation and fixture with-frounding-math.Contracts and signatures follow FreeBSD math(3), fmax(3), and scalbn(3). All 24 names occur in the shadPS4 aerolib table.
Checked current open PR descriptions, existing exports across libraries, and relevant libc patches in #2193, #2192 and #2167. #2192 implements
nextafterf; this branch addsnextafterandnexttoward*. This branch is independent of #2235 and #2271 and excludes their exports. Shared CMake insertion points may need both independent registrations preserved when rebasing.The progress scanner changes from 2578/3044 (84.69%) to 2602/3068 (84.81%). Both counts grow because these are newly declared exports.
Tested
libstarget passed.guest_video_out_wqhd_detection_no_vulkan), zero failures; 41.04 seconds total.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T14:34:53Z.
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:17Z.
Same as #2271: closing until a title is shown to reach these on main.
Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-11T06:39:17Z.
@obojeoboje
nanffrom this PR is now a title's next stop onmain52ce9b8a. Withstrsep(#3192) merged, VLC (PPSA85300) reports this on Linux (catalog build,sce_module/libc.prxunwrapped as #2605 requires):app.elf: symbol lookup error: app.elf: undefined symbol: DZU+K1wozGIWith
nanfadded tomain, VLC goes on todaemon(Wn6I3wVATUE, #2842), which is also where Windows stops first.Since functions go in when a title reaches them, a resubmission would carry the
nanfamily from here (nan,nanf,nanl) and leave the rest for later;sqrtfis already in through #3233. Intake needs 10 merged PRs to open a new one. If you'd like, I can open it as a carry that keeps your authorship. I'll wait for your yes.Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-11T09:43:41Z.
Additional fminf validation target (2026-10-11, e22af772)
Controlled PPSA99902 launches with validated unlocked-I/O and localeconv prerequisites now reproduce missing fminf/uVRcM2yFdP4 before guest entry in10/10 runs. Exact procedure, hashes, limits and comparison candidates. This PR
bdf94e0eand #1770c5107d50are identified alternatives; neither implementation has been tested by us yet. FP signed-zero/NaN/exception validation and another title replay are next. No new PR; AI-assisted investigation: Codex.Independent original Linux fixture and min/max validation (2026-10-11,
bdf94e0e)I fetched and Git-blob-verified the original NumericHelpers.cpp and full GuestNumericHelpers.cpp at this PR's
bdf94e0ehead. Native standalone Ubuntu24.04 WSL/GCC13.3/glibc2.39, -O2 -frounding-math: the complete original fixture passes5/5. The original four min/max functions additionally pass18,432 source-checked bit-result/FP-flag/rounding cases on each of5 runs. This is not a full Linux AnyPS5 system-runtime/GPU build; the broader20 exports are covered only by your original fixture, not by the min/max matrix.The matrix matches separately compiled unmodified FreeBSD11.4 d1060029 function bodies (build adapters disclosed), and demonstrates Linux glibc divergences in #1770's host wrappers for signed zero and signaling NaNs; its default Windows build passes the same matrix. Exact counts, examples, provenance and limits. Your explicit IsNan/Extremum logic has been carried unchanged for the four focused min/max exports into current maina73 Math/GuestMath; relevant Windows and Linux probes pass, six mutants caught. Full build and PPSA99902 replay still pending. Other parts of this24-function PR have not been integrated or tested on Windows by us.
Credit to this original PR. No new PR; AI-assisted tests/adaptation/report: Codex. No PS5 console-equivalence claim.
Original Windows fixture and focused fork validation (2026-10-11, a73)
Additional validation: the complete original
bdf94e0eGuestNumericHelpers fixture, linked to its Git-blob-verified original production file, passes five native standalone Windows runs using WinLibs GCC15.2 r7,-O2 -frounding-math -fno-asynchronous-unwind-tables. This extends the earlier Linux standalone fixture result. It is not full integration of this24-export PR, and the extended18,432-case oracle still targets only four min/max exports; it does not establish complete behavior for the other20 functions.The focused four-function adaptation is on our fork59c6d5e, preserving your helper logic. Full Windows build/all122 libraries pass; full suite823 tests:810 pass/5 skip/8 fail, and math+locale integration811/5/7. Relevant tests/native minmax probes pass repeatedly. Failure controls and the newer-runtime title limitation: both before/after title profiles stop earlier at missing sceKernelGetCpuTemperature, so no minmax startup improvement is claimed yet. No new PR. Credit to this PR; AI-assisted tests/adaptation/report: Codex.
Controlled title milestone after prerequisite restoration (2026-10-11)
Fork experimental integration5cd5ea carries the focused four min/max exports, locale and validated kernel prerequisites onto maina73. The no-minmax libc control stops at missing fminf; replacing only libc in the same122-library profile reaches guest entry 5/5, then the independently retraced0x1a color-target guard tracked by #2970. Full control hashes, exact counts, source/termination limits and final812/824 full-suite result. No full integration of the other20 exports, console equivalence or gameplay claim; no new PR. Your explicit selection logic remains credited in focused59c6d5e. AI-assisted report: Codex.
Pull request closed