Skip to content

test(libc): cover the exact long double and float rounding exports - #9769

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
DavidSamir:test/libc-mathexact-rounding
Oct 25, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
DavidSamir:test/libc-mathexact-rounding

Conversation

@DavidSamir

Copy link
Copy Markdown
Contributor

What

Line coverage of libc and libkernel over the CPU-side test suite (gcov, Windows) showed these exact-math exports never running: copysignl, sqrtl, lrintl, llrintl, lrintf, llrintf, scalbf, scalblnf and __isinfl.

How:

  • tests/GuestMathExact.cpp: a new CheckRoundingAndScaling() checks:
    • copysignl, including signed zeros;
    • sqrtl at 6.25, at -1 (NaN) and at -0 (stays -0);
    • lrintl, llrintl, lrintf and llrintf at ±2.5 under each of the four rounding modes, which pins round-half-even under FE_TONEAREST. The functions use an ErrnoGuard, so the check also confirms errno is left alone;
    • scalbf with integral, fractional (NaN), NaN and ±infinite exponents;
    • scalblnf with exponents of ±10 and the 64-bit limits (clamped);
    • __isinfl for ±infinity, a finite value, zero and NaN.
  • It leaves out _FDclass/_LDclass, which feat(libc): add Dinkumware float bit helpers from firmware #8397 changes, and logbl, lroundl and finitef, which other tests name. The declarations, function and call sit apart from the existing checks.

Tested

  • Windows 11 Pro 26200, WinLibs GCC 15.2.0, Release, no GPU involved: guest_math_exact passes.
  • Negative control: with lrintf using llround (which ignores the rounding mode), the test fails. Restored, it passes.
  • tools/check_conventions.py passes.

Overlap (tools/pr_overlap.py --branch plus git merge-tree):

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
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

guest_math_exact did not reach copysignl, sqrtl, lrintl, llrintl, lrintf,
llrintf, scalbf, scalblnf or __isinfl. It now checks copysignl with signed
zeros, sqrtl at -1 and -0, the four lrint forms at +-2.5 under each
rounding mode with errno untouched, scalbf with fractional, infinite and
NaN exponents, scalblnf clamping 64-bit exponents, and __isinfl.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test exercises signed-zero copy, long-double square root cases, all four active rounding modes for the lrint* family, scalbf/scalblnf edge exponents, and __isinfl. It also leaves the unrelated _FDclass/_LDclass coverage to #8397 as described. I found no duplicate implementation or overlap with #9771; this PR adds a separate test source only.

Current-main merge-tree, diff-check and conventions pass. The hosted Linux/Windows product tests are skipped for this test-only change, so the Windows guest_math_exact result and negative control are the author’s reported run; I did not run the target locally because this checkout has no configured build and less than 1 GB free disk.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approved test-only change still has no code or overlap issue. Current-main diff-check and merge-tree pass, and the hosted register-context/relinker/ASan/write-watch checks pass; product builds are skipped. The branch is based on 8b3e39832a, 32 commits behind current main (11f976b27c16ed91633f00039dba5dfd97dd7cc1). Please rebase and rerun guest_math_exact before merge. I did not rerun locally.

@oneandonlydean oneandonlydean self-assigned this Oct 23, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 24, 2026
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 25, 2026
@oneandonlydean
oneandonlydean merged commit 390e44c into boykopovar:main Oct 25, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants