[libc] Remove direct math.h includes (#85324)

Reland of #84991

A downstream overlay mode user ran into issues with the isnan macro not
working in our sources with a specific libc configuration. This patch
replaces the last direct includes of math.h with our internal
math_macros.h, along with the necessary build system changes.
This commit is contained in:
Michael Jones
2024-03-18 14:19:33 -07:00
committed by GitHub
parent d0d9839b14
commit 5d56b34807
129 changed files with 166 additions and 149 deletions

View File

@@ -1,7 +1,8 @@
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
add_custom_target(libc-fuzzer)
add_subdirectory(math)
# TODO(#85680): Re-enable math fuzzing after headers are sorted out
# add_subdirectory(math)
add_subdirectory(stdlib)
add_subdirectory(stdio)
add_subdirectory(string)

View File

@@ -11,7 +11,7 @@
#include "src/__support/FPUtil/FPBits.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
#include <stddef.h>
#include <stdint.h>

View File

@@ -10,9 +10,7 @@
#define LLVM_LIBC_FUZZING_MATH_SINGLE_INPUT_SINGLE_OUTPUT_DIFF_H
#include "fuzzing/math/Compare.h"
#include "src/__support/FPUtil/FPBits.h"
#include <math.h>
#include <stddef.h>
#include <stdint.h>

View File

@@ -10,9 +10,7 @@
#define LLVM_LIBC_FUZZING_MATH_TWO_INPUT_SINGLE_OUTPUT_DIFF_H
#include "fuzzing/math/Compare.h"
#include "src/__support/FPUtil/FPBits.h"
#include <math.h>
#include <stddef.h>
#include <stdint.h>

View File

@@ -16,7 +16,7 @@
#include "src/__support/FPUtil/FPBits.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
#include <stddef.h>
#include <stdint.h>

View File

@@ -9,13 +9,12 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_FENVIMPL_H
#define LLVM_LIBC_SRC___SUPPORT_FPUTIL_FENVIMPL_H
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/macros/attributes.h" // LIBC_INLINE
#include "src/__support/macros/config.h" // LIBC_HAS_BUILTIN
#include "src/__support/macros/properties/architectures.h"
#include "src/errno/libc_errno.h"
#include <fenv.h>
#include <math.h>
#if defined(LIBC_TARGET_ARCH_IS_AARCH64)
#if defined(__APPLE__)

View File

@@ -15,6 +15,7 @@
#include "dyadic_float.h"
#include "rounding_mode.h"
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/CPP/bit.h"
#include "src/__support/CPP/limits.h" // INT_MAX, INT_MIN
#include "src/__support/CPP/type_traits.h"
@@ -22,8 +23,6 @@
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
#include <math.h>
namespace LIBC_NAMESPACE {
namespace fputil {

View File

@@ -13,11 +13,10 @@
#include "FPBits.h"
#include "rounding_mode.h"
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/CPP/type_traits.h"
#include "src/__support/common.h"
#include <math.h>
namespace LIBC_NAMESPACE {
namespace fputil {

View File

@@ -9,13 +9,12 @@
#ifndef LLVM_LIBC_SRC_MATH_GENERIC_MATH_UTILS_H
#define LLVM_LIBC_SRC_MATH_GENERIC_MATH_UTILS_H
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/CPP/bit.h"
#include "src/__support/CPP/type_traits.h"
#include "src/__support/common.h"
#include "src/errno/libc_errno.h"
#include <math.h>
#include <stdint.h>
// TODO: evaluate which functions from this file are actually used.

View File

@@ -17,7 +17,7 @@
#include "test/UnitTest/StringUtils.h"
#include "test/UnitTest/Test.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
namespace LIBC_NAMESPACE {
namespace testing {

View File

@@ -10,8 +10,8 @@
#include "src/__support/UInt.h"
#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128
#include "include/llvm-libc-macros/math-macros.h" // HUGE_VALF, HUGE_VALF
#include "test/UnitTest/Test.h"
#include <math.h> // HUGE_VALF, HUGE_VALF
namespace LIBC_NAMESPACE {

View File

@@ -1518,6 +1518,8 @@ add_fp_unittest(
DEPENDS
libc.include.math
libc.src.math.generic.explogxf
libc.src.math.fabs
libc.src.math.fabsf
libc.src.__support.FPUtil.fp_bits
)

View File

@@ -10,7 +10,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

View File

@@ -10,7 +10,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

View File

@@ -13,7 +13,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

View File

@@ -6,11 +6,11 @@
//
//===---------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
template <typename T>
class FDimTestTemplate : public LIBC_NAMESPACE::testing::Test {

View File

@@ -13,7 +13,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

View File

@@ -13,7 +13,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

View File

@@ -14,7 +14,7 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
#define TEST_SPECIAL(x, y, expected, dom_err, expected_exception) \
EXPECT_FP_EQ(expected, f(x, y)); \

View File

@@ -13,7 +13,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

View File

@@ -11,7 +11,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

View File

@@ -14,7 +14,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

View File

@@ -9,11 +9,11 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_ILOGBTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_ILOGBTEST_H
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/CPP/limits.h" // INT_MAX
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/ManipulationFunctions.h"
#include "test/UnitTest/Test.h"
#include <math.h>
class LlvmLibcILogbTest : public LIBC_NAMESPACE::testing::Test {
public:

View File

@@ -15,7 +15,7 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
#include <stdint.h>
template <typename T>

View File

@@ -11,7 +11,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

View File

@@ -12,7 +12,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

View File

@@ -9,13 +9,13 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_NEXTAFTERTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_NEXTAFTERTEST_H
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/CPP/bit.h"
#include "src/__support/CPP/type_traits.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
template <typename T>
class NextAfterTestTemplate : public LIBC_NAMESPACE::testing::Test {

View File

@@ -15,8 +15,8 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include "include/llvm-libc-macros/math-macros.h"
#include <fenv.h>
#include <math.h>
#include <stdio.h>
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

View File

@@ -9,12 +9,12 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_REMQUOTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_REMQUOTEST_H
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

View File

@@ -13,7 +13,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

View File

@@ -15,8 +15,8 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include "include/llvm-libc-macros/math-macros.h"
#include <errno.h>
#include <math.h>
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

View File

@@ -11,7 +11,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

View File

@@ -13,7 +13,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

View File

@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/acosf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/acoshf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -7,13 +7,13 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/asinf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/asinhf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/atanf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/atanhf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -11,7 +11,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
using LlvmLibcCosTest = LIBC_NAMESPACE::testing::FPTest<double>;

View File

@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/cosf.h"
@@ -13,7 +14,6 @@
#include "test/UnitTest/Test.h"
#include "test/src/math/sdcomp26094.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/CPP/array.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
@@ -13,7 +14,6 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/math/erff.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -273,6 +273,7 @@ add_fp_unittest(
fmod_generic_impl_test.cpp
DEPENDS
libc.src.__support.FPUtil.fp_bits
libc.src.__support.FPUtil.manipulation_functions
libc.src.__support.FPUtil.generic.fmod
)

View File

@@ -6,53 +6,55 @@
//
//===----------------------------------------------------------------------===//
#include "src/__support/CPP/type_traits.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/ManipulationFunctions.h" // ldexp
#include "src/__support/FPUtil/generic/FMod.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <array>
#include <limits>
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
template <typename T, bool InverseMultiplication>
class LlvmLibcFModTest : public LIBC_NAMESPACE::testing::Test {
using U = typename LIBC_NAMESPACE::fputil::FPBits<T>::StorageType;
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
using U = typename FPBits::StorageType;
using DivisionHelper = LIBC_NAMESPACE::cpp::conditional_t<
InverseMultiplication,
LIBC_NAMESPACE::fputil::generic::FModDivisionInvMultHelper<U>,
LIBC_NAMESPACE::fputil::generic::FModDivisionSimpleHelper<U>>;
static constexpr std::array<T, 11> test_bases = {
static constexpr std::array<T, 11> TEST_BASES = {
T(0.0),
T(1.0),
T(3.0),
T(27.0),
T(11.0 / 8.0),
T(2.764443),
T(1.0) - std::numeric_limits<T>::epsilon(),
T(1.0) + std::numeric_limits<T>::epsilon(),
T(M_PI),
T(M_SQRT2),
T(M_E)};
T(1.0) - T(0x1.0p-23) - T(0x1.0p-52) - T(0x1.0p-112),
T(1.0) + T(0x1.0p-23) + T(0x1.0p-52) + T(0x1.0p-112),
T(3.14159265),
T(1.41421356),
T(2.71828183)};
public:
void testExtensive() {
using FMod = LIBC_NAMESPACE::fputil::generic::FMod<T, U, DivisionHelper>;
using nl = std::numeric_limits<T>;
int min2 = nl::min_exponent - nl::digits - 5;
int max2 = nl::max_exponent + 3;
for (T by : test_bases) {
int min2 = -(FPBits::MAX_BIASED_EXPONENT + FPBits::SIG_LEN) / 2;
int max2 = 3 + FPBits::MAX_BIASED_EXPONENT / 2;
for (T by : TEST_BASES) {
for (int iy = min2; iy < max2; iy++) {
T y = by * std::ldexp(2, iy);
if (y == 0 || !std::isfinite(y))
T y = by * LIBC_NAMESPACE::fputil::ldexp(2.0, iy);
FPBits y_bits(y);
if (y_bits.is_zero() || !y_bits.is_finite())
continue;
for (T bx : test_bases) {
for (T bx : TEST_BASES) {
for (int ix = min2; ix < max2; ix++) {
T x = bx * std::ldexp(2, ix);
if (!std::isfinite(x))
T x = bx * LIBC_NAMESPACE::fputil::ldexp(2.0, ix);
if (!FPBits(x).is_finite())
continue;
T result = FMod::eval(x, y);
mpfr::BinaryInput<T> input{x, y};

View File

@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/exp10.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/exp10f.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <stdint.h>

View File

@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/exp2.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
#include "src/errno/libc_errno.h"
@@ -13,7 +14,6 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <stdint.h>

View File

@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/exp.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/expf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <stdint.h>

View File

@@ -7,12 +7,14 @@
//===----------------------------------------------------------------------===//
#include "in_float_range_test_helper.h"
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/math/fabs.h"
#include "src/math/fabsf.h"
#include "src/math/generic/explogxf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
using LlvmLibcExplogfTest = LIBC_NAMESPACE::testing::FPTest<float>;
@@ -22,7 +24,7 @@ constexpr int def_count = 100003;
constexpr float def_prec = 0.500001f;
auto f_normal = [](float x) -> bool {
return !(isnan(x) || isinf(x) || fabs(x) < 2E-38);
return !(isnan(x) || isinf(x) || LIBC_NAMESPACE::fabs(x) < 2E-38);
};
TEST_F(LlvmLibcExplogfTest, ExpInFloatRange) {
@@ -32,8 +34,8 @@ 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 || fabsf(x) < 0x1.0p-10));
return !((isnan(x) || isinf(x) || 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,
def_prec);

View File

@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/expm1.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/expm1f.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <stdint.h>

View File

@@ -8,11 +8,11 @@
#include "FDimTest.h"
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/math/fdim.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
using LlvmLibcFDimTest = FDimTestTemplate<double>;

View File

@@ -8,11 +8,11 @@
#include "FDimTest.h"
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/math/fdimf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
using LlvmLibcFDimTest = FDimTestTemplate<float>;

View File

@@ -8,11 +8,11 @@
#include "FDimTest.h"
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/math/fdiml.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
using LlvmLibcFDimTest = FDimTestTemplate<long double>;

View File

@@ -8,12 +8,12 @@
#include "ILogbTest.h"
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/ManipulationFunctions.h"
#include "src/math/ilogb.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
TEST_F(LlvmLibcILogbTest, SpecialNumbers_ilogb) {
test_special_numbers<double>(&LIBC_NAMESPACE::ilogb);

View File

@@ -8,12 +8,12 @@
#include "ILogbTest.h"
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/ManipulationFunctions.h"
#include "src/math/ilogbf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
TEST_F(LlvmLibcILogbTest, SpecialNumbers_ilogbf) {
test_special_numbers<float>(&LIBC_NAMESPACE::ilogbf);

View File

@@ -8,12 +8,12 @@
#include "ILogbTest.h"
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/ManipulationFunctions.h"
#include "src/math/ilogbl.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
TEST_F(LlvmLibcILogbTest, SpecialNumbers_ilogbl) {
test_special_numbers<long double>(&LIBC_NAMESPACE::ilogbl);

View File

@@ -7,12 +7,12 @@
//===----------------------------------------------------------------------===//
#include "in_float_range_test_helper.h"
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/math/generic/inv_trigf_utils.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
using LlvmLibcAtanfTest = LIBC_NAMESPACE::testing::FPTest<float>;

View File

@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/log10.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/math/log10f.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/log1p.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/log1pf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/log2.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/log2f.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <stdint.h>

View File

@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/log.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/math/logf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <stdint.h>

View File

@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/math/powf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -12,7 +12,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
using LlvmLibcSinTest = LIBC_NAMESPACE::testing::FPTest<double>;

View File

@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/sincosf.h"
@@ -13,7 +14,6 @@
#include "test/UnitTest/Test.h"
#include "test/src/math/sdcomp26094.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/sinf.h"
@@ -13,7 +14,6 @@
#include "test/UnitTest/Test.h"
#include "test/src/math/sdcomp26094.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/CPP/array.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
@@ -13,7 +14,6 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -12,7 +12,7 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
template <typename T> class CeilTest : public LIBC_NAMESPACE::testing::Test {

View File

@@ -12,7 +12,7 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
template <typename T>
class CopySignTest : public LIBC_NAMESPACE::testing::Test {

View File

@@ -12,7 +12,7 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
template <typename T> class FAbsTest : public LIBC_NAMESPACE::testing::Test {

View File

@@ -14,7 +14,7 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
#define TEST_SPECIAL(x, y, expected, dom_err, expected_exception) \
EXPECT_FP_EQ(expected, f(x, y)); \

View File

@@ -12,7 +12,7 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
template <typename T> class FloorTest : public LIBC_NAMESPACE::testing::Test {

View File

@@ -13,7 +13,7 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
template <typename T>
class HypotTestTemplate : public LIBC_NAMESPACE::testing::Test {

View File

@@ -11,7 +11,7 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
template <typename T> class ModfTest : public LIBC_NAMESPACE::testing::Test {

View File

@@ -9,13 +9,13 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_NEXTAFTERTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_NEXTAFTERTEST_H
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/CPP/bit.h"
#include "src/__support/CPP/type_traits.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
#define ASSERT_FP_EQ_WITH_EXCEPTION(result, expected, expected_exception) \
ASSERT_FP_EQ(result, expected); \

View File

@@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_NEXTTOWARDTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_NEXTTOWARDTEST_H
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/CPP/bit.h"
#include "src/__support/CPP/type_traits.h"
#include "src/__support/FPUtil/BasicOperations.h"
@@ -16,7 +17,6 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <fenv.h>
#include <math.h>
#define ASSERT_FP_EQ_WITH_EXCEPTION(result, expected, expected_exception) \
ASSERT_FP_EQ(result, expected); \

View File

@@ -14,8 +14,8 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "include/llvm-libc-macros/math-macros.h"
#include <fenv.h>
#include <math.h>
#include <stdio.h>
static constexpr int ROUNDING_MODES[4] = {FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO,

View File

@@ -9,11 +9,11 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_REMQUOTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_REMQUOTEST_H
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
template <typename T>
class RemQuoTestTemplate : public LIBC_NAMESPACE::testing::Test {

View File

@@ -12,7 +12,7 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
template <typename T> class RoundTest : public LIBC_NAMESPACE::testing::Test {

View File

@@ -14,8 +14,8 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "include/llvm-libc-macros/math-macros.h"
#include <errno.h>
#include <math.h>
static constexpr int ROUNDING_MODES[4] = {FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO,
FE_TONEAREST};

View File

@@ -10,7 +10,7 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
template <typename T> class SqrtTest : public LIBC_NAMESPACE::testing::Test {

View File

@@ -12,7 +12,7 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
#include "include/llvm-libc-macros/math-macros.h"
template <typename T> class TruncTest : public LIBC_NAMESPACE::testing::Test {

View File

@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/acosf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/acoshf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/asinf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/asinhf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/atanf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/atanhf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/cosf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/CPP/array.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/coshf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -6,11 +6,11 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/math/erff.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/exp10.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
#include <errno.h>
#include <stdint.h>

View File

@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/exp10f.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <math.h>
#include <stdint.h>

Some files were not shown because too many files have changed in this diff Show More