diff --git a/libc/hdr/CMakeLists.txt b/libc/hdr/CMakeLists.txt index da640e8c0f70..a2fad9b473ed 100644 --- a/libc/hdr/CMakeLists.txt +++ b/libc/hdr/CMakeLists.txt @@ -32,6 +32,15 @@ add_proxy_header_library( libc.include.math ) +add_proxy_header_library( + math_function_macros + HDRS + math_function_macros.h + FULL_BUILD_DEPENDS + libc.include.llvm-libc-macros.math_function_macros + libc.include.math +) + add_proxy_header_library( errno_macros HDRS diff --git a/libc/hdr/math_function_macros.h b/libc/hdr/math_function_macros.h new file mode 100644 index 000000000000..48dec8260ef8 --- /dev/null +++ b/libc/hdr/math_function_macros.h @@ -0,0 +1,27 @@ +//===-- Definition of macros from math.h ----------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_HDR_MATH_FUNCTION_MACROS_H +#define LLVM_LIBC_HDR_MATH_FUNCTION_MACROS_H + +#ifdef LIBC_FULL_BUILD + +#include "include/llvm-libc-macros/math-function-macros.h" + +#else // Overlay mode + +// GCC will include CXX headers when __cplusplus is defined. This behavior +// can be suppressed by defining _GLIBCXX_INCLUDE_NEXT_C_HEADERS. +#if defined(__GNUC__) && !defined(__clang__) +#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS +#endif +#include + +#endif // LLVM_LIBC_FULL_BUILD + +#endif // LLVM_LIBC_HDR_MATH_MACROS_H diff --git a/libc/hdr/math_macros.h b/libc/hdr/math_macros.h index d5a823723747..863451123f3f 100644 --- a/libc/hdr/math_macros.h +++ b/libc/hdr/math_macros.h @@ -11,7 +11,6 @@ #ifdef LIBC_FULL_BUILD -#include "include/llvm-libc-macros/math-function-macros.h" #include "include/llvm-libc-macros/math-macros.h" #else // Overlay mode diff --git a/libc/test/src/math/CopySignTest.h b/libc/test/src/math/CopySignTest.h index c66f91477480..8db4f6941e60 100644 --- a/libc/test/src/math/CopySignTest.h +++ b/libc/test/src/math/CopySignTest.h @@ -39,7 +39,7 @@ public: constexpr StorageType STEP = STORAGE_MAX / COUNT; for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) { T x = FPBits(v).get_val(); - if (isnan(x) || isinf(x)) + if (FPBits(v).is_nan() || FPBits(v).is_inf()) continue; double res1 = func(x, -x); diff --git a/libc/test/src/math/FAbsTest.h b/libc/test/src/math/FAbsTest.h index 92b589beeb67..7b4ea93e4db9 100644 --- a/libc/test/src/math/FAbsTest.h +++ b/libc/test/src/math/FAbsTest.h @@ -41,7 +41,7 @@ public: constexpr StorageType STEP = STORAGE_MAX / COUNT; for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) { T x = FPBits(v).get_val(); - if (isnan(x) || isinf(x)) + if (FPBits(v).is_nan() || FPBits(v).is_inf()) continue; ASSERT_MPFR_MATCH(mpfr::Operation::Abs, x, func(x), 0.0); } diff --git a/libc/test/src/math/FDimTest.h b/libc/test/src/math/FDimTest.h index fefcefe5052a..20c63e7d1ab5 100644 --- a/libc/test/src/math/FDimTest.h +++ b/libc/test/src/math/FDimTest.h @@ -67,9 +67,9 @@ public: for (StorageType i = 0, v = 0, w = STORAGE_MAX; i <= COUNT; ++i, v += STEP, w -= STEP) { T x = FPBits(v).get_val(), y = FPBits(w).get_val(); - if (isnan(x) || isinf(x)) + if (FPBits(v).is_nan() || FPBits(v).is_inf()) continue; - if (isnan(y) || isinf(y)) + if (FPBits(w).is_nan() || FPBits(w).is_inf()) continue; if (x > y) { diff --git a/libc/test/src/math/FMaxTest.h b/libc/test/src/math/FMaxTest.h index 405642c6b968..43904a489f76 100644 --- a/libc/test/src/math/FMaxTest.h +++ b/libc/test/src/math/FMaxTest.h @@ -65,9 +65,9 @@ public: for (StorageType i = 0, v = 0, w = STORAGE_MAX; i <= COUNT; ++i, v += STEP, w -= STEP) { T x = FPBits(v).get_val(), y = FPBits(w).get_val(); - if (isnan(x) || isinf(x)) + if (FPBits(v).is_nan() || FPBits(v).is_inf()) continue; - if (isnan(y) || isinf(y)) + if (FPBits(w).is_nan() || FPBits(w).is_inf()) continue; if ((x == 0) && (y == 0)) continue; diff --git a/libc/test/src/math/FMinTest.h b/libc/test/src/math/FMinTest.h index eae0008ddfe3..51c21ae56a77 100644 --- a/libc/test/src/math/FMinTest.h +++ b/libc/test/src/math/FMinTest.h @@ -9,6 +9,7 @@ #ifndef LLVM_LIBC_TEST_SRC_MATH_FMINTEST_H #define LLVM_LIBC_TEST_SRC_MATH_FMINTEST_H +#include "src/__support/FPUtil/FPBits.h" #include "test/UnitTest/FEnvSafeTest.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -65,9 +66,9 @@ public: for (StorageType i = 0, v = 0, w = STORAGE_MAX; i <= COUNT; ++i, v += STEP, w -= STEP) { T x = FPBits(v).get_val(), y = FPBits(w).get_val(); - if (isnan(x) || isinf(x)) + if (FPBits(v).is_nan() || FPBits(v).is_inf()) continue; - if (isnan(y) || isinf(y)) + if (FPBits(w).is_nan() || FPBits(w).is_inf()) continue; if ((x == 0) && (y == 0)) continue; diff --git a/libc/test/src/math/FrexpTest.h b/libc/test/src/math/FrexpTest.h index 3ba64afa3c62..74a2d607b0f9 100644 --- a/libc/test/src/math/FrexpTest.h +++ b/libc/test/src/math/FrexpTest.h @@ -99,7 +99,7 @@ public: constexpr StorageType STEP = STORAGE_MAX / COUNT; for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) { T x = FPBits(v).get_val(); - if (isnan(x) || isinf(x) || x == 0.0l) + if (FPBits(v).is_nan() || FPBits(v).is_inf() || x == 0.0l) continue; mpfr::BinaryOutput result; diff --git a/libc/test/src/math/ILogbTest.h b/libc/test/src/math/ILogbTest.h index c2d5a1326e0e..ccb92eb55230 100644 --- a/libc/test/src/math/ILogbTest.h +++ b/libc/test/src/math/ILogbTest.h @@ -82,7 +82,7 @@ public: constexpr StorageType STEP = (MAX_SUBNORMAL - MIN_SUBNORMAL) / COUNT; for (StorageType v = MIN_SUBNORMAL; v <= MAX_SUBNORMAL; v += STEP) { T x = FPBits(v).get_val(); - if (isnan(x) || isinf(x) || x == 0.0) + if (FPBits(v).is_nan() || FPBits(v).is_inf() || x == 0.0) continue; int exponent; @@ -101,7 +101,7 @@ public: constexpr StorageType STEP = (MAX_NORMAL - MIN_NORMAL) / COUNT; for (StorageType v = MIN_NORMAL; v <= MAX_NORMAL; v += STEP) { T x = FPBits(v).get_val(); - if (isnan(x) || isinf(x) || x == 0.0) + if (FPBits(v).is_nan() || FPBits(v).is_inf() || x == 0.0) continue; int exponent; diff --git a/libc/test/src/math/LogbTest.h b/libc/test/src/math/LogbTest.h index d6042e3c200c..5ef3b2675a49 100644 --- a/libc/test/src/math/LogbTest.h +++ b/libc/test/src/math/LogbTest.h @@ -78,7 +78,7 @@ public: constexpr StorageType STEP = STORAGE_MAX / COUNT; for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) { T x = FPBits(v).get_val(); - if (isnan(x) || isinf(x) || x == 0.0l) + if (FPBits(v).is_nan() || FPBits(v).is_inf() || x == 0.0l) continue; int exponent; diff --git a/libc/test/src/math/ModfTest.h b/libc/test/src/math/ModfTest.h index d6c6f27a5edf..337729016961 100644 --- a/libc/test/src/math/ModfTest.h +++ b/libc/test/src/math/ModfTest.h @@ -90,7 +90,7 @@ public: constexpr StorageType STEP = STORAGE_MAX / COUNT; for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) { T x = FPBits(v).get_val(); - if (isnan(x) || isinf(x) || x == T(0.0)) + if (FPBits(v).is_nan() || FPBits(v).is_inf() || x == T(0.0)) continue; T integral; diff --git a/libc/test/src/math/RemQuoTest.h b/libc/test/src/math/RemQuoTest.h index c39f2394555e..a35a6eee8c2e 100644 --- a/libc/test/src/math/RemQuoTest.h +++ b/libc/test/src/math/RemQuoTest.h @@ -127,7 +127,7 @@ public: // In normal range on x86 platforms, the long double implicit 1 bit can be // zero making the numbers NaN. Hence we test for them separately. - if (isnan(x) || isnan(y)) { + if (FPBits(v).is_nan() || FPBits(w).is_nan()) { ASSERT_FP_EQ(result.f, nan); continue; } diff --git a/libc/test/src/math/acosf_test.cpp b/libc/test/src/math/acosf_test.cpp index 0d25a808e0bf..488058237d19 100644 --- a/libc/test/src/math/acosf_test.cpp +++ b/libc/test/src/math/acosf_test.cpp @@ -48,7 +48,7 @@ TEST_F(LlvmLibcAcosfTest, 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; ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Acos, x, LIBC_NAMESPACE::acosf(x), 0.5); diff --git a/libc/test/src/math/acoshf_test.cpp b/libc/test/src/math/acoshf_test.cpp index 32761e25b5ce..5d7f59792b52 100644 --- a/libc/test/src/math/acoshf_test.cpp +++ b/libc/test/src/math/acoshf_test.cpp @@ -45,7 +45,7 @@ TEST_F(LlvmLibcAcoshfTest, 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; ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Acosh, x, LIBC_NAMESPACE::acoshf(x), 0.5); diff --git a/libc/test/src/math/asinf_test.cpp b/libc/test/src/math/asinf_test.cpp index 91e61085e91b..09dc3c960ed9 100644 --- a/libc/test/src/math/asinf_test.cpp +++ b/libc/test/src/math/asinf_test.cpp @@ -46,7 +46,7 @@ TEST_F(LlvmLibcAsinfTest, 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; ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Asin, x, LIBC_NAMESPACE::asinf(x), 0.5); diff --git a/libc/test/src/math/asinhf_test.cpp b/libc/test/src/math/asinhf_test.cpp index b19e26efd07b..3e55a563879d 100644 --- a/libc/test/src/math/asinhf_test.cpp +++ b/libc/test/src/math/asinhf_test.cpp @@ -45,7 +45,7 @@ TEST_F(LlvmLibcAsinhfTest, 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; ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Asinh, x, LIBC_NAMESPACE::asinhf(x), 0.5); diff --git a/libc/test/src/math/atan2f_test.cpp b/libc/test/src/math/atan2f_test.cpp index 1242b7e66528..331f4281af83 100644 --- a/libc/test/src/math/atan2f_test.cpp +++ b/libc/test/src/math/atan2f_test.cpp @@ -73,18 +73,18 @@ TEST_F(LlvmLibcAtan2fTest, InFloatRange) { for (uint32_t i = 0, v = X_START; i <= X_COUNT; ++i, v += X_STEP) { float x = FPBits(v).get_val(); - if (isnan(x) || isinf(x) || x < 0.0) + if (FPBits(v).is_nan() || FPBits(v).is_inf() || x < 0.0) continue; for (uint32_t j = 0, w = Y_START; j <= Y_COUNT; ++j, w += Y_STEP) { float y = FPBits(w).get_val(); - if (isnan(y) || isinf(y)) + if (FPBits(w).is_nan() || FPBits(w).is_inf()) continue; LIBC_NAMESPACE::libc_errno = 0; float result = LIBC_NAMESPACE::atan2f(x, y); ++total_count; - if (isnan(result) || isinf(result)) + if (FPBits(result).is_nan() || FPBits(result).is_inf()) continue; ++finite_count; diff --git a/libc/test/src/math/cos_test.cpp b/libc/test/src/math/cos_test.cpp index e12e9a827469..484d47fd3e96 100644 --- a/libc/test/src/math/cos_test.cpp +++ b/libc/test/src/math/cos_test.cpp @@ -81,12 +81,12 @@ TEST_F(LlvmLibcCosTest, InDoubleRange) { for (uint64_t i = 0, v = START; i <= COUNT; ++i, v += STEP) { double x = FPBits(v).get_val(); - if (isnan(x) || isinf(x)) + if (FPBits(v).is_nan() || FPBits(v).is_inf()) continue; double result = LIBC_NAMESPACE::cos(x); ++total; - if (isnan(result) || isinf(result)) + if (FPBits(result).is_nan() || FPBits(result).is_inf()) continue; ++tested; diff --git a/libc/test/src/math/cosf_test.cpp b/libc/test/src/math/cosf_test.cpp index dab35fa1a9fe..82790e3a9d48 100644 --- a/libc/test/src/math/cosf_test.cpp +++ b/libc/test/src/math/cosf_test.cpp @@ -47,7 +47,7 @@ TEST_F(LlvmLibcCosfTest, 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; ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Cos, x, LIBC_NAMESPACE::cosf(x), 0.5); diff --git a/libc/test/src/math/coshf_test.cpp b/libc/test/src/math/coshf_test.cpp index 7c5d6630e109..00bbf4b0bd94 100644 --- a/libc/test/src/math/coshf_test.cpp +++ b/libc/test/src/math/coshf_test.cpp @@ -61,7 +61,7 @@ TEST_F(LlvmLibcCoshfTest, 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; ASSERT_MPFR_MATCH(mpfr::Operation::Cosh, x, LIBC_NAMESPACE::coshf(x), 0.5); } diff --git a/libc/test/src/math/erff_test.cpp b/libc/test/src/math/erff_test.cpp index 5c848d7d5bf7..851eda4b1542 100644 --- a/libc/test/src/math/erff_test.cpp +++ b/libc/test/src/math/erff_test.cpp @@ -64,12 +64,12 @@ TEST_F(LlvmLibcErffTest, InFloatRange) { for (uint32_t i = 0, v = START; i <= COUNT; ++i, v += STEP) { float x = FPBits(v).get_val(); - if (isnan(x)) + if (FPBits(v).is_nan()) continue; float result = LIBC_NAMESPACE::erff(x); ++cc; - if (isnan(result)) + if (FPBits(result).is_nan()) continue; ++count; diff --git a/libc/test/src/math/exp10_test.cpp b/libc/test/src/math/exp10_test.cpp index 4cbdd169d803..61ae33ecae52 100644 --- a/libc/test/src/math/exp10_test.cpp +++ b/libc/test/src/math/exp10_test.cpp @@ -104,12 +104,12 @@ TEST_F(LlvmLibcExp10Test, InDoubleRange) { for (uint64_t i = 0, v = START; i <= COUNT; ++i, v += STEP) { double x = FPBits(v).get_val(); - if (isnan(x) || isinf(x) || x < 0.0) + if (FPBits(v).is_nan() || FPBits(v).is_inf() || x < 0.0) continue; LIBC_NAMESPACE::libc_errno = 0; double result = LIBC_NAMESPACE::exp10(x); ++cc; - if (isnan(result) || isinf(result)) + if (FPBits(result).is_nan() || FPBits(result).is_inf()) continue; ++count; diff --git a/libc/test/src/math/exp10f_test.cpp b/libc/test/src/math/exp10f_test.cpp index e9b278668104..001b37809d93 100644 --- a/libc/test/src/math/exp10f_test.cpp +++ b/libc/test/src/math/exp10f_test.cpp @@ -111,7 +111,7 @@ TEST_F(LlvmLibcExp10fTest, 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::exp10f(x); @@ -120,7 +120,8 @@ TEST_F(LlvmLibcExp10fTest, 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::Exp10, x, LIBC_NAMESPACE::exp10f(x), 0.5); diff --git a/libc/test/src/math/exp2_test.cpp b/libc/test/src/math/exp2_test.cpp index 73232ed36077..f218eea0b358 100644 --- a/libc/test/src/math/exp2_test.cpp +++ b/libc/test/src/math/exp2_test.cpp @@ -79,12 +79,12 @@ TEST_F(LlvmLibcExp2Test, InDoubleRange) { for (uint64_t i = 0, v = START; i <= COUNT; ++i, v += STEP) { double x = FPBits(v).get_val(); - if (isnan(x) || isinf(x) || x < 0.0) + if (FPBits(v).is_nan() || FPBits(v).is_inf() || x < 0.0) continue; LIBC_NAMESPACE::libc_errno = 0; double result = LIBC_NAMESPACE::exp2(x); ++cc; - if (isnan(result) || isinf(result)) + if (FPBits(result).is_nan() || FPBits(result).is_inf()) continue; ++count; diff --git a/libc/test/src/math/exp2f_test.cpp b/libc/test/src/math/exp2f_test.cpp index 8ff0ce6a6e72..7caf1489d022 100644 --- a/libc/test/src/math/exp2f_test.cpp +++ b/libc/test/src/math/exp2f_test.cpp @@ -107,7 +107,7 @@ TEST_F(LlvmLibcExp2fTest, 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::exp2f(x); @@ -116,7 +116,8 @@ TEST_F(LlvmLibcExp2fTest, 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::Exp2, x, LIBC_NAMESPACE::exp2f(x), 0.5); diff --git a/libc/test/src/math/exp2m1f_test.cpp b/libc/test/src/math/exp2m1f_test.cpp index cb948289b617..793cf0cc2cbb 100644 --- a/libc/test/src/math/exp2m1f_test.cpp +++ b/libc/test/src/math/exp2m1f_test.cpp @@ -49,7 +49,7 @@ TEST_F(LlvmLibcExp2m1fTest, 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::exp2m1f(x); @@ -58,7 +58,8 @@ TEST_F(LlvmLibcExp2m1fTest, 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::Exp2m1, x, LIBC_NAMESPACE::exp2m1f(x), 0.5); diff --git a/libc/test/src/math/exp_test.cpp b/libc/test/src/math/exp_test.cpp index 64d8198e64f2..ee674c5fe6cb 100644 --- a/libc/test/src/math/exp_test.cpp +++ b/libc/test/src/math/exp_test.cpp @@ -77,12 +77,12 @@ TEST_F(LlvmLibcExpTest, InDoubleRange) { for (uint64_t i = 0, v = START; i <= COUNT; ++i, v += STEP) { double x = FPBits(v).get_val(); - if (isnan(x) || isinf(x) || x < 0.0) + if (FPBits(v).is_nan() || FPBits(v).is_inf() || x < 0.0) continue; LIBC_NAMESPACE::libc_errno = 0; double result = LIBC_NAMESPACE::exp(x); ++cc; - if (isnan(result) || isinf(result)) + if (FPBits(result).is_nan() || FPBits(result).is_inf()) continue; ++count; diff --git a/libc/test/src/math/expf_test.cpp b/libc/test/src/math/expf_test.cpp index 1dce381918eb..26a0bca4ce25 100644 --- a/libc/test/src/math/expf_test.cpp +++ b/libc/test/src/math/expf_test.cpp @@ -108,7 +108,7 @@ TEST_F(LlvmLibcExpfTest, 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::expf(x); @@ -117,7 +117,8 @@ TEST_F(LlvmLibcExpfTest, 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; EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp, x, LIBC_NAMESPACE::expf(x), 0.5); diff --git a/libc/test/src/math/explogxf_test.cpp b/libc/test/src/math/explogxf_test.cpp index bcca87f590d7..01197b835433 100644 --- a/libc/test/src/math/explogxf_test.cpp +++ b/libc/test/src/math/explogxf_test.cpp @@ -17,6 +17,7 @@ #include "utils/MPFRWrapper/MPFRUtils.h" using LlvmLibcExplogfTest = LIBC_NAMESPACE::testing::FPTest; +using FPBits = LIBC_NAMESPACE::fputil::FPBits; namespace mpfr = LIBC_NAMESPACE::testing::mpfr; @@ -24,7 +25,8 @@ constexpr int def_count = 100003; constexpr float def_prec = 0.500001f; auto f_normal = [](float x) -> bool { - return !(isnan(x) || isinf(x) || LIBC_NAMESPACE::fabs(x) < 2E-38); + return !(FPBits(x).is_nan() || FPBits(x).is_inf() || + LIBC_NAMESPACE::fabs(x) < 2E-38); }; TEST_F(LlvmLibcExplogfTest, ExpInFloatRange) { @@ -34,7 +36,7 @@ TEST_F(LlvmLibcExplogfTest, ExpInFloatRange) { return static_cast(result.mh * r); }; auto f_check = [](float x) -> bool { - return !((isnan(x) || isinf(x) || x < -70 || x > 70 || + return !((FPBits(x).is_nan() || FPBits(x).is_inf() || x < -70 || x > 70 || LIBC_NAMESPACE::fabsf(x) < 0x1.0p-10)); }; CHECK_DATA(0.0f, neg_inf, mpfr::Operation::Exp, fx, f_check, def_count, diff --git a/libc/test/src/math/expm1_test.cpp b/libc/test/src/math/expm1_test.cpp index df5c08864bb8..9720773d9f96 100644 --- a/libc/test/src/math/expm1_test.cpp +++ b/libc/test/src/math/expm1_test.cpp @@ -62,12 +62,12 @@ TEST_F(LlvmLibcExpm1Test, InDoubleRange) { for (uint64_t i = 0, v = START; i <= COUNT; ++i, v += STEP) { double x = FPBits(v).get_val(); - if (isnan(x) || isinf(x) || x < 0.0) + if (FPBits(v).is_nan() || FPBits(v).is_inf() || x < 0.0) continue; LIBC_NAMESPACE::libc_errno = 0; double result = LIBC_NAMESPACE::expm1(x); ++cc; - if (isnan(result) || isinf(result)) + if (FPBits(result).is_nan() || FPBits(result).is_inf()) continue; ++count; diff --git a/libc/test/src/math/expm1f_test.cpp b/libc/test/src/math/expm1f_test.cpp index 515f988b6264..274fe3bb7afb 100644 --- a/libc/test/src/math/expm1f_test.cpp +++ b/libc/test/src/math/expm1f_test.cpp @@ -117,7 +117,7 @@ TEST_F(LlvmLibcExpm1fTest, 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::expm1f(x); @@ -126,7 +126,8 @@ TEST_F(LlvmLibcExpm1fTest, 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::Expm1, x, LIBC_NAMESPACE::expm1f(x), 0.5); diff --git a/libc/test/src/math/log10_test.cpp b/libc/test/src/math/log10_test.cpp index fd9a615ca87f..32b84686bade 100644 --- a/libc/test/src/math/log10_test.cpp +++ b/libc/test/src/math/log10_test.cpp @@ -100,12 +100,12 @@ TEST_F(LlvmLibcLog10Test, InDoubleRange) { for (uint64_t i = 0, v = START; i <= COUNT; ++i, v += STEP) { double x = FPBits(v).get_val(); - if (isnan(x) || isinf(x) || x < 0.0) + if (FPBits(v).is_nan() || FPBits(v).is_inf() || x < 0.0) continue; LIBC_NAMESPACE::libc_errno = 0; double result = LIBC_NAMESPACE::log10(x); ++cc; - if (isnan(result) || isinf(result)) + if (FPBits(result).is_nan() || FPBits(result).is_inf()) continue; ++count; diff --git a/libc/test/src/math/log1p_test.cpp b/libc/test/src/math/log1p_test.cpp index 47dfa406ec25..98486deb12c7 100644 --- a/libc/test/src/math/log1p_test.cpp +++ b/libc/test/src/math/log1p_test.cpp @@ -101,12 +101,12 @@ TEST_F(LlvmLibcLog1pTest, InDoubleRange) { for (uint64_t i = 0, v = start; i <= COUNT; ++i, v += step) { double x = FPBits(v).get_val(); - if (isnan(x) || isinf(x) || x < 0.0) + if (FPBits(v).is_nan() || FPBits(v).is_inf() || x < 0.0) continue; LIBC_NAMESPACE::libc_errno = 0; double result = LIBC_NAMESPACE::log1p(x); ++cc; - if (isnan(result) || isinf(result)) + if (FPBits(result).is_nan() || FPBits(result).is_inf()) continue; ++count; diff --git a/libc/test/src/math/log1pf_test.cpp b/libc/test/src/math/log1pf_test.cpp index db0772d3c8b8..b42cf3b8681b 100644 --- a/libc/test/src/math/log1pf_test.cpp +++ b/libc/test/src/math/log1pf_test.cpp @@ -74,7 +74,7 @@ TEST_F(LlvmLibcLog1pfTest, 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; ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log1p, x, diff --git a/libc/test/src/math/log2_test.cpp b/libc/test/src/math/log2_test.cpp index 9992c1340e99..f9bd93d44e50 100644 --- a/libc/test/src/math/log2_test.cpp +++ b/libc/test/src/math/log2_test.cpp @@ -99,12 +99,12 @@ TEST_F(LlvmLibcLog2Test, InDoubleRange) { for (uint64_t i = 0, v = START; i <= COUNT; ++i, v += STEP) { double x = FPBits(v).get_val(); - if (isnan(x) || isinf(x) || x < 0.0) + if (FPBits(v).is_nan() || FPBits(v).is_inf() || x < 0.0) continue; LIBC_NAMESPACE::libc_errno = 0; double result = LIBC_NAMESPACE::log2(x); ++cc; - if (isnan(result) || isinf(result)) + if (FPBits(result).is_nan() || FPBits(result).is_inf()) continue; ++count; diff --git a/libc/test/src/math/log2f_test.cpp b/libc/test/src/math/log2f_test.cpp index 24b51adac94d..83691fb75300 100644 --- a/libc/test/src/math/log2f_test.cpp +++ b/libc/test/src/math/log2f_test.cpp @@ -50,7 +50,7 @@ TEST_F(LlvmLibcLog2fTest, 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::log2f(x); @@ -58,7 +58,8 @@ TEST_F(LlvmLibcLog2fTest, 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::Log2, x, LIBC_NAMESPACE::log2f(x), 0.5); diff --git a/libc/test/src/math/log_test.cpp b/libc/test/src/math/log_test.cpp index de1e59579419..c0f9edfc540a 100644 --- a/libc/test/src/math/log_test.cpp +++ b/libc/test/src/math/log_test.cpp @@ -98,12 +98,12 @@ TEST_F(LlvmLibcLogTest, InDoubleRange) { for (uint64_t i = 0, v = START; i <= COUNT; ++i, v += STEP) { double x = FPBits(v).get_val(); - if (isnan(x) || isinf(x) || x < 0.0) + if (FPBits(v).is_nan() || FPBits(v).is_inf() || x < 0.0) continue; LIBC_NAMESPACE::libc_errno = 0; double result = LIBC_NAMESPACE::log(x); ++cc; - if (isnan(result) || isinf(result)) + if (FPBits(result).is_nan() || FPBits(result).is_inf()) continue; ++count; diff --git a/libc/test/src/math/logf_test.cpp b/libc/test/src/math/logf_test.cpp index 28a171d54066..79d8275856b6 100644 --- a/libc/test/src/math/logf_test.cpp +++ b/libc/test/src/math/logf_test.cpp @@ -82,7 +82,7 @@ TEST_F(LlvmLibcLogfTest, 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; ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log, x, LIBC_NAMESPACE::logf(x), 0.5); diff --git a/libc/test/src/math/powf_test.cpp b/libc/test/src/math/powf_test.cpp index 797913e5b7ee..c13231f9d83b 100644 --- a/libc/test/src/math/powf_test.cpp +++ b/libc/test/src/math/powf_test.cpp @@ -71,18 +71,18 @@ TEST_F(LlvmLibcPowfTest, InFloatRange) { for (uint32_t i = 0, v = X_START; i <= X_COUNT; ++i, v += X_STEP) { float x = FPBits(v).get_val(); - if (isnan(x) || isinf(x) || x < 0.0) + if (FPBits(v).is_nan() || FPBits(v).is_inf() || x < 0.0) continue; for (uint32_t j = 0, w = Y_START; j <= Y_COUNT; ++j, w += Y_STEP) { float y = FPBits(w).get_val(); - if (isnan(y) || isinf(y)) + if (FPBits(w).is_nan() || FPBits(w).is_inf()) continue; LIBC_NAMESPACE::libc_errno = 0; float result = LIBC_NAMESPACE::powf(x, y); ++cc; - if (isnan(result) || isinf(result)) + if (FPBits(result).is_nan() || FPBits(result).is_inf()) continue; ++count; diff --git a/libc/test/src/math/sin_test.cpp b/libc/test/src/math/sin_test.cpp index 89534ae82b56..60f6ef5c8446 100644 --- a/libc/test/src/math/sin_test.cpp +++ b/libc/test/src/math/sin_test.cpp @@ -67,12 +67,12 @@ TEST_F(LlvmLibcSinTest, InDoubleRange) { for (uint64_t i = 0, v = START; i <= COUNT; ++i, v += STEP) { double 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; double result = LIBC_NAMESPACE::sin(x); ++cc; - if (isnan(result) || isinf(result)) + if (FPBits(result).is_nan() || FPBits(result).is_inf()) continue; ++count; diff --git a/libc/test/src/math/sincos_test.cpp b/libc/test/src/math/sincos_test.cpp index 7e06456f2e05..09c87153890d 100644 --- a/libc/test/src/math/sincos_test.cpp +++ b/libc/test/src/math/sincos_test.cpp @@ -110,7 +110,7 @@ TEST_F(LlvmLibcSincosTest, InDoubleRange) { for (uint64_t i = 0, v = START; i <= COUNT; ++i, v += STEP) { double x = FPBits(v).get_val(); - if (isnan(x) || isinf(x)) + if (FPBits(v).is_nan() || FPBits(v).is_inf()) continue; ASSERT_SINCOS_MATCH_ALL_ROUNDING(x); diff --git a/libc/test/src/math/sincosf_test.cpp b/libc/test/src/math/sincosf_test.cpp index 7c359b345f4c..7254c3be5b75 100644 --- a/libc/test/src/math/sincosf_test.cpp +++ b/libc/test/src/math/sincosf_test.cpp @@ -101,7 +101,7 @@ TEST_F(LlvmLibcSinCosfTest, 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; EXPECT_SINCOS_MATCH_ALL_ROUNDING(x); diff --git a/libc/test/src/math/sinf_test.cpp b/libc/test/src/math/sinf_test.cpp index 6a8f8f4ee428..370362639490 100644 --- a/libc/test/src/math/sinf_test.cpp +++ b/libc/test/src/math/sinf_test.cpp @@ -48,7 +48,7 @@ TEST_F(LlvmLibcSinfTest, 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; ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sin, x, LIBC_NAMESPACE::sinf(x), 0.5); diff --git a/libc/test/src/math/sinhf_test.cpp b/libc/test/src/math/sinhf_test.cpp index cc0552f72894..400df2f18dab 100644 --- a/libc/test/src/math/sinhf_test.cpp +++ b/libc/test/src/math/sinhf_test.cpp @@ -46,7 +46,7 @@ TEST_F(LlvmLibcSinhfTest, 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; ASSERT_MPFR_MATCH(mpfr::Operation::Sinh, x, LIBC_NAMESPACE::sinhf(x), 0.5); } diff --git a/libc/test/src/math/tan_test.cpp b/libc/test/src/math/tan_test.cpp index 80d57939a4f6..1ca67afdaddf 100644 --- a/libc/test/src/math/tan_test.cpp +++ b/libc/test/src/math/tan_test.cpp @@ -75,12 +75,12 @@ TEST_F(LlvmLibcTanTest, InDoubleRange) { for (uint64_t i = 0, v = START; i <= COUNT; ++i, v += STEP) { double x = FPBits(v).get_val(); - if (isnan(x) || isinf(x)) + if (FPBits(v).is_nan() || FPBits(v).is_inf()) continue; double result = LIBC_NAMESPACE::tan(x); ++total; - if (isnan(result) || isinf(result)) + if (FPBits(result).is_nan() || FPBits(result).is_inf()) continue; ++tested; diff --git a/libc/test/src/math/tanf_test.cpp b/libc/test/src/math/tanf_test.cpp index e624d30f1e00..9b9e1278cf56 100644 --- a/libc/test/src/math/tanf_test.cpp +++ b/libc/test/src/math/tanf_test.cpp @@ -48,7 +48,7 @@ TEST_F(LlvmLibcTanfTest, 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; ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Tan, x, LIBC_NAMESPACE::tanf(x), 0.5); diff --git a/libc/test/src/math/tanhf_test.cpp b/libc/test/src/math/tanhf_test.cpp index c34efe8d733b..2e74984ad954 100644 --- a/libc/test/src/math/tanhf_test.cpp +++ b/libc/test/src/math/tanhf_test.cpp @@ -45,7 +45,7 @@ TEST_F(LlvmLibcTanhfTest, 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; ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Tanh, x, LIBC_NAMESPACE::tanhf(x), 0.5);