feat(libc): implement logb, sinhf, nearbyintf and __powisf2 #2037
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2037"
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 Aryansh1520 on 2026-10-09T05:36:51Z.
What
PPSA28997 (God of War Sons of Sparta) imports these four functions, and none of them is exported yet.
logb,sinhfandnearbyintfforward to the C++ standard library, like their existing neighbours (logbf,sinf).__powisf2, the compiler-rt helper forpowion floats, uses compiler-rt's algorithm: repeated squaring infloat, then the reciprocal for a negative exponent.Tested
tools/check_conventions.py --base origin/mainandtools/pr_overlap.py --branchpass.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 MarcZX10 on 2026-10-09T05:57:50Z.
Please add focused tests to guest_math for logb, sinhf, nearbyintf and powisf2, including exponents 0, -1 and INT_MIN, plus special values. The for-loop increment squares base after remaining has become zero; exponent 1 therefore computes an unused FLT_MAX * FLT_MAX, which can raise overflow. LLVM compiler-rt stops before that final square (reference: https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/builtins/powisf2.c). I built exact head
23c84b2don Linux with GCC 12; the existing guest_math passed 1/1 in 0.02 s and conventions passed, but that test does not cover these new exports. No GitHub checks are reported for this head.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:22:52Z.
Which of these does PPSA28997 stop at on main? Please add that log line; with it and the tests MarcZX100 asked for, this can go in.
Imported from boykopovar/AnyPS5. Originally posted by Aryansh1520 on 2026-10-09T10:36:51Z.
Updated in
a046106a.__powisf2now follows compiler-rt exactly: it halves the exponent and stops before squaring once it reaches zero, so exponent 1 no longer computes the unusedFLT_MAX * FLT_MAX. With GCC 12+ at -O2 the old dead square was already optimized away (the new overflow-flag check passed on both versions here), but the code no longer depends on that.guest_mathnow coverslogb(powers of two, negatives, denormal min, max, ±0, -inf, NaN),sinhf(±0 sign, known values, overflow to ±inf, ±inf, NaN),nearbyintf(ties to even, -0 sign, large values, noFE_INEXACT, upward and toward-zero rounding modes) and__powisf2(exponents 0, 1, -1, 10, 127, 128, -126, INT_MAX, INT_MIN; zero, infinity and NaN bases; noFE_OVERFLOWforFLT_MAX^1andFLT_MAX^-1).On where PPSA28997 stops: I don't have a log line for these four. I found them statically, among the unresolved imports of the title's modules (
logbfromIl2cppUserAssemblies.prx,nearbyintffromeboot.elf,sinhfand__powisf2in the libc import table), and implemented them before any run reached them. So no recorded run stopped at one of them, and I won't claim a line I didn't see. On main (as of Oct 8) the title stops earlier, atLTov9gMEqCU(std::ios_base::_Addstd, covered by #545).The build workflows on this head are waiting for approval to run (fork PR).
Imported from boykopovar/AnyPS5. Originally posted by Aryansh1520 on 2026-10-09T10:53:14Z.
To avoid the
GuestMath.cppoverlap with #1818 and #2038, the new checks now live in their own test,GuestFloatMath.cpp(guest_float_math), in7550255d. The checks are unchanged, and this PR no longer editsGuestMath.cpp.Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T15:46:26Z.
Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head
7550255d, merged ontomaind70b8998in one build with 38 other PRs that had no Windows run.guest_float_math. None of them reported skipping a case.No title was run.
🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T20:08:29Z.
Closing: on main PPSA28997 stops at
LTov9gMEqCU(#545) before it reaches any of these, and library functions go in when a title stops on them. Please reopen with the log line once one of them is the stop.Pull request closed