test(libc): cover log and logf special values and domain errors #15142
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15142"
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 Oscar45397 on 2026-11-02T18:23:09Z.
What
logandlogfhave no test.CheckLogSpecialValuesis added toguest_math_exact:log(1) == +0;log(+-0) == -infwitherrno == ERANGE;log(-1)andlog(-inf)are NaN witherrno == EDOM;log(+inf) == +inf;log(NaN)is NaN;log(2)andlog(0.5)within a relative 1e-15 of +-ln 2 (0.6931471805599453),log(2.718281828459045)within 1e-15 of 1;logf, within a relative 1e-6, pluslogf(1.4012985e-45f)(the smallest subnormal, 2^-149) within 1e-6 of -103.27893, which is -149 ln 2.Sources: C11 F.10.3.7 (
log(1)returns +0;log(+-0)returns -inf and raises divide-by-zero;log(x)for x < 0 returns a NaN and raises invalid;log(+inf)returns +inf); POSIXlog: a pole error setserrnotoERANGEand a domain error sets it toEDOM.Changed:
core/libs/tests/GuestMathExact.cpp. Test only, no change to the library.Tested
Windows 11 Home 26200, Ryzen 9 5900X, WinLibs GCC 15.2.0 r7, Release, on
mainb28bb77217plus this test.ctest --test-dir build -R '^guest_math_exact$' --repeat until-fail:3: passes 3 of 3 runs.logreturningstd::log2(x),guest_math_exactfails. Restored, it passes again.python tools/check_conventions.py --base upstream/main: passed.Not run on Linux or macOS: the
errnochecks rely on the hostlogsettingerrno, which POSIX requires.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-02T19:45:30Z.
Review: APPROVED
The
errnorows hold for the console's system libc too, not only for the host math libraries. Firmware 13.42'ssystem/common/lib/libSceLibcInternal.sprx(sha256a01795ab49df639dd40abd6194956ada062244826824ce486c9acab227bf5285), disassembly only:exp,expf,log,logfandpowall report errors through one helper at0x16450, which stores into the location returned by its call at0x16463and picks0x21(EDOM) when bit 0 of its flag argument is set, otherwise0x22(ERANGE) when any of bits0x1cis set:For example
expcalls it with 8 on overflow (4c323). I haven't read every call site's flag, and I haven't checked thelibc.prxthat titles ship, which the debt file says uses FreeBSD msun. Tested on Windows 11, WinLibs GCC 15.2.0, with this head merged ontomain:guest_math_exactpasses.