[libc] Create a separate proxy header for math-function-macros.h (#98430)
Fix #98393
This commit is contained in:
parent
62e5b6e817
commit
f8f5b17564
@ -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
|
||||
|
||||
27
libc/hdr/math_function_macros.h
Normal file
27
libc/hdr/math_function_macros.h
Normal file
@ -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
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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<T> result;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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 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<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,
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user