From 547136b0f9b5eac7dea1e73c617286c073ae5c07 Mon Sep 17 00:00:00 2001 From: "Mikhail R. Gadelha" Date: Tue, 6 May 2025 14:05:44 -0300 Subject: [PATCH 1/3] [libc] Enable exp10m1f on RISC-V Previously, the test was failing due to isnan() and isinf() not being defined. The patch follows other tests in the same dir and call isnan and isinf from the FBits class. --- libc/config/linux/riscv/entrypoints.txt | 2 +- libc/test/src/math/exp10m1f_test.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt index d2fc128b35a3c..30d9d00dfefc9 100644 --- a/libc/config/linux/riscv/entrypoints.txt +++ b/libc/config/linux/riscv/entrypoints.txt @@ -451,7 +451,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.exp libc.src.math.exp10 libc.src.math.exp10f - # libc.src.math.exp10m1f + libc.src.math.exp10m1f libc.src.math.exp2 libc.src.math.exp2f libc.src.math.exp2m1f diff --git a/libc/test/src/math/exp10m1f_test.cpp b/libc/test/src/math/exp10m1f_test.cpp index cc960321175cb..21076ad16268e 100644 --- a/libc/test/src/math/exp10m1f_test.cpp +++ b/libc/test/src/math/exp10m1f_test.cpp @@ -80,7 +80,7 @@ TEST_F(LlvmLibcExp10m1fTest, InFloatRange) { constexpr uint32_t STEP = UINT32_MAX / COUNT; for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) { float x = FPBits(v).get_val(); - if (isnan(x) || isinf(x)) + if (FPBits(v).is_nan() || FPBits(v).is_inf()) continue; LIBC_NAMESPACE::libc_errno = 0; float result = LIBC_NAMESPACE::exp10m1f(x); @@ -89,7 +89,8 @@ TEST_F(LlvmLibcExp10m1fTest, InFloatRange) { // in the single-precision floating point range, then ignore comparing with // MPFR result as MPFR can still produce valid results because of its // wider precision. - if (isnan(result) || isinf(result) || LIBC_NAMESPACE::libc_errno != 0) + if (FPBits(result).is_nan() || FPBits(result).is_inf() || + LIBC_NAMESPACE::libc_errno != 0) continue; ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp10m1, x, LIBC_NAMESPACE::exp10m1f(x), 0.5); From bb5a94020414c32167de264b9d21c1e644d4bbff Mon Sep 17 00:00:00 2001 From: "Mikhail R. Gadelha" Date: Wed, 7 May 2025 12:06:41 -0300 Subject: [PATCH 2/3] Update libc/test/src/math/exp10m1f_test.cpp Co-authored-by: OverMighty --- libc/test/src/math/exp10m1f_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc/test/src/math/exp10m1f_test.cpp b/libc/test/src/math/exp10m1f_test.cpp index 21076ad16268e..b10e10184cd7d 100644 --- a/libc/test/src/math/exp10m1f_test.cpp +++ b/libc/test/src/math/exp10m1f_test.cpp @@ -80,7 +80,7 @@ TEST_F(LlvmLibcExp10m1fTest, InFloatRange) { constexpr uint32_t STEP = UINT32_MAX / COUNT; for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) { float x = FPBits(v).get_val(); - if (FPBits(v).is_nan() || FPBits(v).is_inf()) + if (FPBits(v).is_inf_or_nan()) continue; LIBC_NAMESPACE::libc_errno = 0; float result = LIBC_NAMESPACE::exp10m1f(x); From 7bfb779abd9c7de9623aa0a2e5c2ee3fe4409a02 Mon Sep 17 00:00:00 2001 From: "Mikhail R. Gadelha" Date: Wed, 7 May 2025 12:06:49 -0300 Subject: [PATCH 3/3] Update libc/test/src/math/exp10m1f_test.cpp Co-authored-by: OverMighty --- libc/test/src/math/exp10m1f_test.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libc/test/src/math/exp10m1f_test.cpp b/libc/test/src/math/exp10m1f_test.cpp index b10e10184cd7d..aee273384f1a2 100644 --- a/libc/test/src/math/exp10m1f_test.cpp +++ b/libc/test/src/math/exp10m1f_test.cpp @@ -89,8 +89,7 @@ TEST_F(LlvmLibcExp10m1fTest, InFloatRange) { // in the single-precision floating point range, then ignore comparing with // MPFR result as MPFR can still produce valid results because of its // wider precision. - if (FPBits(result).is_nan() || FPBits(result).is_inf() || - LIBC_NAMESPACE::libc_errno != 0) + if (FPBits(result).is_inf_or_nan() || LIBC_NAMESPACE::libc_errno != 0) continue; ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp10m1, x, LIBC_NAMESPACE::exp10m1f(x), 0.5);