fix(libc): accept the full llroundl integer range #4942
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4942"
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 QRMOE on 2026-10-13T05:49:09Z.
What
Accept the complete signed 64-bit result range in
llroundl. On main,llroundl(9223372036854775807.0L)returnsINT64_MINand raisesFE_INVALID, although the input is exactly representable in the guest's x87 extended format and the correct rounded result isINT64_MAX.The shared rounding helper uses an exclusive upper bound of
static_cast<TFloat>(INT64_MAX). That bound becomes 2^63 for float and double but staysINT64_MAXfor long double, excluding the largest valid integer. Use the exactly representable 2^63 bound in every specialization. The existing float/double range checks and invalid-input handling retain their behavior.The valid result agrees with FreeBSD's
s_llroundl.cand itss_lround.c, which includes the maximum integer within the long-double input range.Tested
Windows, MinGW GCC 15.2, Release,
BUILD_TESTING=ON; negative control on main7e181fcc3, final branch rebased onto88107b7de:expected 9223372036854775807, got -9223372036854775808.FE_INVALIDand preserves the caller's errno. Existing float/double boundary cases also pass.guest_sce_net,guest_poll,guest_socket_read_write,guest_tcp,guest_socket_pair,guest_dup,guest_socket_eventsandguest_fstatfs). Avast's log records automatic sandboxing of the test programs. The local full-build limitation remains; local full-build success is not claimed.Review validation
Ready for maintainer review. Full Linux/Windows CI requires a maintainer's manual dispatch; marking this PR ready does not claim those jobs passed.
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 repositoryImported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T07:05:51Z.
Windows test of this PR.
Environment: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release,
BUILD_TESTING=ON,-j2,libusb-cmakefrom a local checkout. Built frommainea2bbefb2with this PR and six other open PRs (#4958, #4956, #4954, #4953, #4946, #4942, #4927) merged together; the merges had no conflict.Result: guest_math (1 of 1; the test file is shared with #4946, both merged together) pass.
Not checked: whether the test fails without the change in the library code; the PR was not tested alone, only in the combined merge (the tests of the other PRs in the batch also pass); no title run; Linux not tested.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by nicolasfalesy on 2026-10-13T07:22:31Z.
Linux test (Arch, GCC 16.2.1, glibc, Release), this PR merged onto
main7e181fcc3together with #4963, #4953, #4946 and #4942 (no conflicts):guest_mathpasses. With this PR'sMath.cppchange reverted it fails on Linux too, so the check guards the change on both systems.