Repository navigation
test(libc): compare the C exception flags in the scaled hyperbolic checks - #10907
oneandonlydean merged 1 commit into
Conversation
…ecks The _FSinh and _FCosh special-value checks read the raised flags with fetestexcept(FE_ALL_EXCEPT). On macOS FE_ALL_EXCEPT also holds the x86 denormal-operand flag, which an SSE operation on a subnormal input such as 0x1p-149 raises, so the check saw 0x2e where it expects 0x2c. glibc and FreeBSD leave that flag out of FE_ALL_EXCEPT. The checks now read the five C exception flags.
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed head 476b63d. 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.
|
Clarification to my approval: GitHub's review body lost several inline-code terms to shell quoting. The intended statements are that the explicit five-flag mask equals |
|
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.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Windows check of Not run: a title. AI-assisted: yes (Claude Code) |
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)