Skip to content

[libc] Remove direct math.h includes #85324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion libc/fuzzing/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion libc/fuzzing/math/RemQuoDiff.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
2 changes: 0 additions & 2 deletions libc/fuzzing/math/SingleInputSingleOutputDiff.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
2 changes: 0 additions & 2 deletions libc/fuzzing/math/TwoInputSingleOutputDiff.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
2 changes: 1 addition & 1 deletion libc/fuzzing/stdlib/strtofloat_fuzz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
3 changes: 1 addition & 2 deletions libc/src/__support/FPUtil/FEnvImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
3 changes: 1 addition & 2 deletions libc/src/__support/FPUtil/ManipulationFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@
#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"
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY

#include <math.h>

namespace LIBC_NAMESPACE {
namespace fputil {

Expand Down
3 changes: 1 addition & 2 deletions libc/src/__support/FPUtil/NearestIntegerOperations.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
3 changes: 1 addition & 2 deletions libc/src/math/generic/math_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion libc/test/UnitTest/FPMatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/__support/uint_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
2 changes: 2 additions & 0 deletions libc/test/src/math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/CeilTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/CopySignTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/FAbsTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/FDimTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/FMaxTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/FMinTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/FModTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)); \
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/FloorTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/FrexpTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/HypotTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/ILogbTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/LdExpTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/LogbTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/ModfTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/NextAfterTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/RIntTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/RemQuoTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/RoundTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/RoundToIntegerTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/SqrtTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/TruncTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/acosf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/acoshf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/math/asinf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Loading