From fcc3145abf5581badc4379f512687d9f7febe234 Mon Sep 17 00:00:00 2001 From: MarcZX100 Date: Sat, 10 Oct 2026 21:32:08 +0000 Subject: [PATCH] fix(libc): apply range handling to llroundf The original fix predates llroundf, which was added in #2933. Use the same guest range and exception behavior for the fourth wrapper and include it in the edge-case checks. --- core/libs/prx/libc/src/Math.cpp | 2 +- core/libs/tests/GuestMath.cpp | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/core/libs/prx/libc/src/Math.cpp b/core/libs/prx/libc/src/Math.cpp index 807d6116b..7d5fc2161 100644 --- a/core/libs/prx/libc/src/Math.cpp +++ b/core/libs/prx/libc/src/Math.cpp @@ -52,7 +52,7 @@ float APS5_VABI frexpf_nid_postfix(float x, int* exponent) { return std::frexp(x std::int64_t APS5_VABI lround_nid_postfix(double x) { return RoundToInt64(x); } std::int64_t APS5_VABI lroundf_nid_postfix(float x) { return RoundToInt64(x); } std::int64_t APS5_VABI llround_nid_postfix(double x) { return RoundToInt64(x); } -std::int64_t APS5_VABI llroundf_nid_postfix(float x) { return std::llround(x); } +std::int64_t APS5_VABI llroundf_nid_postfix(float x) { return RoundToInt64(x); } int APS5_VABI __isfinitef_nid_postfix(float x) { return std::isfinite(x) ? 1 : 0; } int APS5_VABI __isnormal_nid_postfix(double x) { return std::isnormal(x) ? 1 : 0; } int APS5_VABI __isnormalf_nid_postfix(float x) { return std::isnormal(x) ? 1 : 0; } diff --git a/core/libs/tests/GuestMath.cpp b/core/libs/tests/GuestMath.cpp index 69fa3c362..ec8080d0a 100644 --- a/core/libs/tests/GuestMath.cpp +++ b/core/libs/tests/GuestMath.cpp @@ -273,12 +273,14 @@ static void CheckDoubleRounding(double value, std::int64_t expected, bool invali } static void CheckFloatRounding(float value, std::int64_t expected, bool invalid) { - std::feclearexcept(FE_ALL_EXCEPT); - errno = 12345; - const std::int64_t result = lroundf_nid_postfix(value); - Require(result == expected); - Require((std::fetestexcept(FE_INVALID) != 0) == invalid); - Require(errno == 12345); + for (const bool useLlround : {false, true}) { + std::feclearexcept(FE_ALL_EXCEPT); + errno = 12345; + const std::int64_t result = useLlround ? llroundf_nid_postfix(value) : lroundf_nid_postfix(value); + Require(result == expected); + Require((std::fetestexcept(FE_INVALID) != 0) == invalid); + Require(errno == 12345); + } } int main() {