[libc] Create a separate proxy header for math-function-macros.h (#98430)
Fix #98393
diff --git a/libc/hdr/CMakeLists.txt b/libc/hdr/CMakeLists.txt
index da640e8..a2fad9b 100644
--- a/libc/hdr/CMakeLists.txt
+++ b/libc/hdr/CMakeLists.txt
@@ -33,6 +33,15 @@
)
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
errno_macros.h
diff --git a/libc/hdr/math_function_macros.h b/libc/hdr/math_function_macros.h
new file mode 100644
index 0000000..48dec82
--- /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 <math.h>
+
+#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 d5a8237..8634511 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 c66f914..8db4f69 100644
--- a/libc/test/src/math/CopySignTest.h
+++ b/libc/test/src/math/CopySignTest.h
@@ -39,7 +39,7 @@
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 92b589b..7b4ea93 100644
--- a/libc/test/src/math/FAbsTest.h
+++ b/libc/test/src/math/FAbsTest.h
@@ -41,7 +41,7 @@
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 fefcefe..20c63e7 100644
--- a/libc/test/src/math/FDimTest.h
+++ b/libc/test/src/math/FDimTest.h
@@ -67,9 +67,9 @@
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 405642c..43904a4 100644
--- a/libc/test/src/math/FMaxTest.h
+++ b/libc/test/src/math/FMaxTest.h
@@ -65,9 +65,9 @@
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 eae0008..51c21ae 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 @@
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 3ba64af..74a2d60 100644
--- a/libc/test/src/math/FrexpTest.h
+++ b/libc/test/src/math/FrexpTest.h
@@ -99,7 +99,7 @@
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<T> result;
diff --git a/libc/test/src/math/ILogbTest.h b/libc/test/src/math/ILogbTest.h
index c2d5a13..ccb92eb 100644
--- a/libc/test/src/math/ILogbTest.h
+++ b/libc/test/src/math/ILogbTest.h
@@ -82,7 +82,7 @@
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 @@
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 d6042e3..5ef3b26 100644
--- a/libc/test/src/math/LogbTest.h
+++ b/libc/test/src/math/LogbTest.h
@@ -78,7 +78,7 @@
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 d6c6f27..3377290 100644
--- a/libc/test/src/math/ModfTest.h
+++ b/libc/test/src/math/ModfTest.h
@@ -90,7 +90,7 @@
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 c39f239..a35a6ee 100644
--- a/libc/test/src/math/RemQuoTest.h
+++ b/libc/test/src/math/RemQuoTest.h
@@ -127,7 +127,7 @@
// 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 0d25a80..4880582 100644
--- a/libc/test/src/math/acosf_test.cpp
+++ b/libc/test/src/math/acosf_test.cpp
@@ -48,7 +48,7 @@
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 32761e2..5d7f597 100644
--- a/libc/test/src/math/acoshf_test.cpp
+++ b/libc/test/src/math/acoshf_test.cpp
@@ -45,7 +45,7 @@
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 91e6108..09dc3c9 100644
--- a/libc/test/src/math/asinf_test.cpp
+++ b/libc/test/src/math/asinf_test.cpp
@@ -46,7 +46,7 @@
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 b19e26e..3e55a56 100644
--- a/libc/test/src/math/asinhf_test.cpp
+++ b/libc/test/src/math/asinhf_test.cpp
@@ -45,7 +45,7 @@
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 1242b7e..331f428 100644
--- a/libc/test/src/math/atan2f_test.cpp
+++ b/libc/test/src/math/atan2f_test.cpp
@@ -73,18 +73,18 @@
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 e12e9a8..484d47f 100644
--- a/libc/test/src/math/cos_test.cpp
+++ b/libc/test/src/math/cos_test.cpp
@@ -81,12 +81,12 @@
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 dab35fa..82790e3 100644
--- a/libc/test/src/math/cosf_test.cpp
+++ b/libc/test/src/math/cosf_test.cpp
@@ -47,7 +47,7 @@
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 7c5d663..00bbf4b 100644
--- a/libc/test/src/math/coshf_test.cpp
+++ b/libc/test/src/math/coshf_test.cpp
@@ -61,7 +61,7 @@
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 5c848d7..851eda4 100644
--- a/libc/test/src/math/erff_test.cpp
+++ b/libc/test/src/math/erff_test.cpp
@@ -64,12 +64,12 @@
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 4cbdd16..61ae33e 100644
--- a/libc/test/src/math/exp10_test.cpp
+++ b/libc/test/src/math/exp10_test.cpp
@@ -104,12 +104,12 @@
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 e9b2786..001b378 100644
--- a/libc/test/src/math/exp10f_test.cpp
+++ b/libc/test/src/math/exp10f_test.cpp
@@ -111,7 +111,7 @@
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 @@
// 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 73232ed..f218eea 100644
--- a/libc/test/src/math/exp2_test.cpp
+++ b/libc/test/src/math/exp2_test.cpp
@@ -79,12 +79,12 @@
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 8ff0ce6..7caf148 100644
--- a/libc/test/src/math/exp2f_test.cpp
+++ b/libc/test/src/math/exp2f_test.cpp
@@ -107,7 +107,7 @@
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 @@
// 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 cb94828..793cf0c 100644
--- a/libc/test/src/math/exp2m1f_test.cpp
+++ b/libc/test/src/math/exp2m1f_test.cpp
@@ -49,7 +49,7 @@
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 @@
// 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 64d8198..ee674c5 100644
--- a/libc/test/src/math/exp_test.cpp
+++ b/libc/test/src/math/exp_test.cpp
@@ -77,12 +77,12 @@
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 1dce381..26a0bca 100644
--- a/libc/test/src/math/expf_test.cpp
+++ b/libc/test/src/math/expf_test.cpp
@@ -108,7 +108,7 @@
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 @@
// 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 bcca87f..01197b8 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<float>;
+using FPBits = LIBC_NAMESPACE::fputil::FPBits<float>;
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -24,7 +25,8 @@
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 @@
return static_cast<float>(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 df5c088..9720773 100644
--- a/libc/test/src/math/expm1_test.cpp
+++ b/libc/test/src/math/expm1_test.cpp
@@ -62,12 +62,12 @@
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 515f988..274fe3b 100644
--- a/libc/test/src/math/expm1f_test.cpp
+++ b/libc/test/src/math/expm1f_test.cpp
@@ -117,7 +117,7 @@
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 @@
// 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 fd9a615..32b8468 100644
--- a/libc/test/src/math/log10_test.cpp
+++ b/libc/test/src/math/log10_test.cpp
@@ -100,12 +100,12 @@
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 47dfa40..98486de 100644
--- a/libc/test/src/math/log1p_test.cpp
+++ b/libc/test/src/math/log1p_test.cpp
@@ -101,12 +101,12 @@
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 db0772d..b42cf3b 100644
--- a/libc/test/src/math/log1pf_test.cpp
+++ b/libc/test/src/math/log1pf_test.cpp
@@ -74,7 +74,7 @@
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 9992c13..f9bd93d 100644
--- a/libc/test/src/math/log2_test.cpp
+++ b/libc/test/src/math/log2_test.cpp
@@ -99,12 +99,12 @@
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 24b51ad..83691fb 100644
--- a/libc/test/src/math/log2f_test.cpp
+++ b/libc/test/src/math/log2f_test.cpp
@@ -50,7 +50,7 @@
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 @@
// 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 de1e595..c0f9edf 100644
--- a/libc/test/src/math/log_test.cpp
+++ b/libc/test/src/math/log_test.cpp
@@ -98,12 +98,12 @@
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 28a171d..79d8275 100644
--- a/libc/test/src/math/logf_test.cpp
+++ b/libc/test/src/math/logf_test.cpp
@@ -82,7 +82,7 @@
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 797913e..c13231f 100644
--- a/libc/test/src/math/powf_test.cpp
+++ b/libc/test/src/math/powf_test.cpp
@@ -71,18 +71,18 @@
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 89534ae..60f6ef5 100644
--- a/libc/test/src/math/sin_test.cpp
+++ b/libc/test/src/math/sin_test.cpp
@@ -67,12 +67,12 @@
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 7e06456..09c8715 100644
--- a/libc/test/src/math/sincos_test.cpp
+++ b/libc/test/src/math/sincos_test.cpp
@@ -110,7 +110,7 @@
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 7c359b3..7254c3b 100644
--- a/libc/test/src/math/sincosf_test.cpp
+++ b/libc/test/src/math/sincosf_test.cpp
@@ -101,7 +101,7 @@
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 6a8f8f4..3703626 100644
--- a/libc/test/src/math/sinf_test.cpp
+++ b/libc/test/src/math/sinf_test.cpp
@@ -48,7 +48,7 @@
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 cc0552f..400df2f 100644
--- a/libc/test/src/math/sinhf_test.cpp
+++ b/libc/test/src/math/sinhf_test.cpp
@@ -46,7 +46,7 @@
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 80d5793..1ca67af 100644
--- a/libc/test/src/math/tan_test.cpp
+++ b/libc/test/src/math/tan_test.cpp
@@ -75,12 +75,12 @@
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 e624d30..9b9e127 100644
--- a/libc/test/src/math/tanf_test.cpp
+++ b/libc/test/src/math/tanf_test.cpp
@@ -48,7 +48,7 @@
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 c34efe8..2e74984 100644
--- a/libc/test/src/math/tanhf_test.cpp
+++ b/libc/test/src/math/tanhf_test.cpp
@@ -45,7 +45,7 @@
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);