test(libc): compare the C exception flags in the scaled hyperbolic checks #10907
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10907"
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 imellag on 2026-10-25T09:19:28Z.
What
The
_FSinhand_FCoshspecial-value checks inguest_mathread the raised flags withfetestexcept(FE_ALL_EXCEPT)and compare them with an exact set. On macOSFE_ALL_EXCEPTis0x3f: besides the five C exception flags it holdsFE_DENORMALOPERAND(0x02), the x86 flag an SSE operation raises when an input is subnormal. glibc's and FreeBSD'sFE_ALL_EXCEPTleave it out (0x3d). So on macOS the check for_FSinh(0x1.fffffep+127, 0x1p-149)sees the denormal flag from its0x1p-149argument and fails:The result,
errnoand the expected flags (FE_DIVBYZERO | FE_OVERFLOW | FE_INEXACT,0x2c) all match. The checks now readFE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT, which isFE_ALL_EXCEPTon Linux and FreeBSD. The failure message prints the same set. Nothing else changes.Tested
Apple M4 Pro, macOS 27.0.1, Apple clang 21, x86-64 Release under Rosetta 2.
mainalone doesn't build the libc tests on macOS, so the tree ismain61fc572ceeplus the open macOS build PRs and the parts of mugurc's series that #7201 also carries.guest_mathstops at the first failing check, and on macOS three things stop it. Two are in the library and already have open PRs:acosf(0.5f)is one ulp off with Apple's x86-64 libm (#9668), andfmodf(1, 0)raises noFE_INVALIDthere (#10345). The third is this one. With #9668 and #10345 applied:_FSinhline above;guest_mathpasses 3 runs out of 3.With only one of the two library PRs, it stops at the other one's check, so all three are needed for the test to pass on macOS. Not run on Linux or Windows. On glibc the new set is exactly
FE_ALL_EXCEPT, so the checks don't change there.check_conventions.py --base upstream/mainpasses.pr_overlap.pyreports no conflicting lines, and none of the pull requests it couldn't compare touches these checks.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T09:23:14Z.
Review: APPROVED
Reviewed head
476b63dd45. The change reads the five standard C floating-point exception flags explicitly in the scaled-hyperbolic special checks and their diagnostic, avoiding macOS's extra x86 denormal flag while retaining the existing exact comparisons for invalid, divide-by-zero, overflow, underflow and inexact. On this Linux host I independently compiled and ran a C++20 static assertion that this mask equals ; and also pass. The reported M4 Pro/macOS Rosetta run exercises three times on a tree with the prerequisite macOS math fixes and passes 3/3; hosted product tests for this test-only diff are skipped. I attempted local CMake configuration in an isolated worktree, but it cannot configure because the SDL2 submodule is uninitialized there and XRandR development support is unavailable, so I did not run the full guest test locally. The diff is narrowly scoped and I found no correctness issue. AI-assisted: yes.