test(libc): read only the five standard exception flags in two Dinkumware tests #20503

Merged
kali113 merged 1 commit from upstream-pr/20503 into main 2026-11-15 08:03:01 +00:00
kali113 commented 2026-11-15 07:33:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by kali113 on 2026-11-15T07:33:02Z.


What

On macOS FE_ALL_EXCEPT (0x3f) includes FE_DENORMAL (0x2), which x86 raises when an operation reads a subnormal operand. Two Dinkumware tests compare fetestexcept(FE_ALL_EXCEPT) with the five standard flags the guest expects, so they fail whenever the host sets the denormal-operand flag even though the result bits, errno and the MXCSR value are right:

  • GuestDinkumwareDivision.cpp: fetestexcept(FE_ALL_EXCEPT) gives 0x2a where 0x28 is expected (case 69, result 7ff0000000000000, MXCSR 0x9faa both).
  • GuestDinkumwareInternals.cpp: the _Exp and _FExp checks (_Exp subnormal result: result subnormal, errno 0, flags 0x2).

Both now read only FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT (the internals test already has this as FloatingExceptions). On Linux and Windows the five-flag mask is what the checks meant already; no production code changes.

Tested

macOS (Apple M5 Pro, macOS 27.3, x86_64 build under Rosetta), CMake, Ninja, Release, BUILD_TESTING=ON, CMAKE_OSX_ARCHITECTURES=x86_64, on main 6350d99363 with #17425 merged locally (libcurl.prx does not link on this machine without it), ctest -R dinkumware:

  • guest_dinkumware_division: failed before (it fails in my full-suite runs on main + #17425), passes now.
  • guest_dinkumware_internals: failed before, still fails, but past the _Exp checks: it now stops at _LLog of a zero mantissa, a separate problem (an x87 long double argument passed to _LLog_nid_postfix from the test) that this PR does not touch.
  • The other 28 guest_dinkumware_* tests pass as before.

tools/check_conventions.py passes. Not run on Linux or Windows.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none (#20395 also edits GuestDinkumwareInternals.cpp, other lines)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5320591197 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20503). Originally posted by [kali113](https://github.com/kali113) on 2026-11-15T07:33:02Z. --- ### What On macOS `FE_ALL_EXCEPT` (0x3f) includes `FE_DENORMAL` (0x2), which x86 raises when an operation reads a subnormal operand. Two Dinkumware tests compare `fetestexcept(FE_ALL_EXCEPT)` with the five standard flags the guest expects, so they fail whenever the host sets the denormal-operand flag even though the result bits, `errno` and the MXCSR value are right: - `GuestDinkumwareDivision.cpp`: `fetestexcept(FE_ALL_EXCEPT)` gives `0x2a` where `0x28` is expected (case 69, result `7ff0000000000000`, MXCSR `0x9faa` both). - `GuestDinkumwareInternals.cpp`: the `_Exp` and `_FExp` checks (`_Exp` subnormal result: result subnormal, `errno` 0, flags `0x2`). Both now read only `FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT` (the internals test already has this as `FloatingExceptions`). On Linux and Windows the five-flag mask is what the checks meant already; no production code changes. ### Tested macOS (Apple M5 Pro, macOS 27.3, x86_64 build under Rosetta), CMake, Ninja, Release, `BUILD_TESTING=ON`, `CMAKE_OSX_ARCHITECTURES=x86_64`, on `main` `6350d99363` with #17425 merged locally (`libcurl.prx` does not link on this machine without it), `ctest -R dinkumware`: - `guest_dinkumware_division`: failed before (it fails in my full-suite runs on `main` + #17425), passes now. - `guest_dinkumware_internals`: failed before, still fails, but past the `_Exp` checks: it now stops at `_LLog of a zero mantissa`, a separate problem (an x87 `long double` argument passed to `_LLog_nid_postfix` from the test) that this PR does not touch. - The other 28 `guest_dinkumware_*` tests pass as before. `tools/check_conventions.py` passes. Not run on Linux or Windows. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none (#20395 also edits `GuestDinkumwareInternals.cpp`, other lines) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes (Claude Code)
copilot-pull-request-reviewer[bot] commented 2026-11-15 07:33:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-15T07:33:09Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5909653263 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20503#pullrequestreview-5909653263). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-15T07:33:09Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
PrivacyOnion commented 2026-11-15 07:46:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-15T07:46:23Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 20dc5a8aa1:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_dinkumware_division_tests, guest_dinkumware_internals_tests built cleanly.
  • CTest (guest_dinkumware_division, guest_dinkumware_internals):
    1/2 Test #1171: guest_dinkumware_division ........   Passed    0.01 sec
    2/2 Test #1172: guest_dinkumware_internals .......   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 2
    
  • Code reading:
    • GuestDinkumwareDivision.cpp:179: Verified that querying std::fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT) directly aligns with StandardFlags(test.flags | sticky), which translates only bits 0, 2, 3, 4, and 5 into standard exceptions and excludes non-standard host flags such as FE_DENORMAL (0x2).
    • GuestDinkumwareInternals.cpp:174,183: Verified that CheckExp and CheckFExp pass FloatingExceptions (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT) into std::fetestexcept, ensuring uniform exception querying across Linux, macOS, and Windows.
    • GuestDinkumwareInternals.cpp:494,498,585,589: Verified that subnormal classification tests for _Exp_nid_postfix and _FExp_nid_postfix checking std::fetestexcept(FloatingExceptions) == 0 correctly ignore the hardware denormal-operand flag raised by x86 for denorm_min() while preserving errno == 0 and FP_SUBNORMAL verifications.
    • GuestDinkumwareInternals.cpp:502-520,593-611: Verified that overflow, underflow, and finite boundary checks for _Exp_nid_postfix and _FExp_nid_postfix accurately evaluate the standard exception bitmasks without interference from platform-specific bits in FE_ALL_EXCEPT.
    • AGENTS.md compliance: Verified that no comments were added to modified files, no production code or headers were changed, and all floating-point exception macros used are standard identifiers.
  • Note: the AI-assisted checkbox can stay.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5909691297 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20503#pullrequestreview-5909691297). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-15T07:46:23Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `20dc5a8aa1`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_dinkumware_division_tests`, `guest_dinkumware_internals_tests` built cleanly. - **CTest** (`guest_dinkumware_division`, `guest_dinkumware_internals`): ``` 1/2 Test #1171: guest_dinkumware_division ........ Passed 0.01 sec 2/2 Test #1172: guest_dinkumware_internals ....... Passed 0.01 sec 100% tests passed, 0 tests failed out of 2 ``` - **Code reading**: - GuestDinkumwareDivision.cpp:179: Verified that querying std::fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT) directly aligns with StandardFlags(test.flags | sticky), which translates only bits 0, 2, 3, 4, and 5 into standard exceptions and excludes non-standard host flags such as FE_DENORMAL (0x2). - GuestDinkumwareInternals.cpp:174,183: Verified that CheckExp and CheckFExp pass FloatingExceptions (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT) into std::fetestexcept, ensuring uniform exception querying across Linux, macOS, and Windows. - GuestDinkumwareInternals.cpp:494,498,585,589: Verified that subnormal classification tests for _Exp_nid_postfix and _FExp_nid_postfix checking std::fetestexcept(FloatingExceptions) == 0 correctly ignore the hardware denormal-operand flag raised by x86 for denorm_min() while preserving errno == 0 and FP_SUBNORMAL verifications. - GuestDinkumwareInternals.cpp:502-520,593-611: Verified that overflow, underflow, and finite boundary checks for _Exp_nid_postfix and _FExp_nid_postfix accurately evaluate the standard exception bitmasks without interference from platform-specific bits in FE_ALL_EXCEPT. - AGENTS.md compliance: Verified that no comments were added to modified files, no production code or headers were changed, and all floating-point exception macros used are standard <cfenv> identifiers. - Note: the AI-assisted checkbox can stay. Looks Good To Me
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!20503
No description provided.