[libc-commits] [libc] [llvm] [libc] Remove direct math.h includes from src (PR #85324)

via libc-commits libc-commits at lists.llvm.org
Thu Mar 14 15:18:22 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Michael Jones (michaelrj-google)

<details>
<summary>Changes</summary>

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.



---

Patch is 72.79 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/85324.diff


126 Files Affected:

- (modified) libc/fuzzing/math/RemQuoDiff.h (+1-1) 
- (modified) libc/fuzzing/math/SingleInputSingleOutputDiff.h (-2) 
- (modified) libc/fuzzing/math/TwoInputSingleOutputDiff.h (-2) 
- (modified) libc/fuzzing/stdlib/strtofloat_fuzz.cpp (+1-1) 
- (modified) libc/src/__support/FPUtil/FEnvImpl.h (+1-2) 
- (modified) libc/src/__support/FPUtil/ManipulationFunctions.h (+1-2) 
- (modified) libc/src/__support/FPUtil/NearestIntegerOperations.h (+1-2) 
- (modified) libc/src/math/generic/math_utils.h (+1-2) 
- (modified) libc/test/UnitTest/FPMatcher.h (+1-1) 
- (modified) libc/test/src/__support/uint_test.cpp (+1-1) 
- (modified) libc/test/src/math/CMakeLists.txt (+2) 
- (modified) libc/test/src/math/CeilTest.h (+1-1) 
- (modified) libc/test/src/math/CopySignTest.h (+1-1) 
- (modified) libc/test/src/math/FAbsTest.h (+1-1) 
- (modified) libc/test/src/math/FDimTest.h (+1-1) 
- (modified) libc/test/src/math/FMaxTest.h (+1-1) 
- (modified) libc/test/src/math/FMinTest.h (+1-1) 
- (modified) libc/test/src/math/FModTest.h (+1-1) 
- (modified) libc/test/src/math/FloorTest.h (+1-1) 
- (modified) libc/test/src/math/FrexpTest.h (+1-1) 
- (modified) libc/test/src/math/HypotTest.h (+1-1) 
- (modified) libc/test/src/math/ILogbTest.h (+1-1) 
- (modified) libc/test/src/math/LdExpTest.h (+1-1) 
- (modified) libc/test/src/math/LogbTest.h (+1-1) 
- (modified) libc/test/src/math/ModfTest.h (+1-1) 
- (modified) libc/test/src/math/NextAfterTest.h (+1-1) 
- (modified) libc/test/src/math/RIntTest.h (+1-1) 
- (modified) libc/test/src/math/RemQuoTest.h (+1-1) 
- (modified) libc/test/src/math/RoundTest.h (+1-1) 
- (modified) libc/test/src/math/RoundToIntegerTest.h (+1-1) 
- (modified) libc/test/src/math/SqrtTest.h (+1-1) 
- (modified) libc/test/src/math/TruncTest.h (+1-1) 
- (modified) libc/test/src/math/acosf_test.cpp (+1-1) 
- (modified) libc/test/src/math/acoshf_test.cpp (+1-1) 
- (modified) libc/test/src/math/asinf_test.cpp (+1-1) 
- (modified) libc/test/src/math/asinhf_test.cpp (+1-1) 
- (modified) libc/test/src/math/atanf_test.cpp (+1-1) 
- (modified) libc/test/src/math/atanhf_test.cpp (+1-1) 
- (modified) libc/test/src/math/cos_test.cpp (+1-1) 
- (modified) libc/test/src/math/cosf_test.cpp (+1-1) 
- (modified) libc/test/src/math/coshf_test.cpp (+1-1) 
- (modified) libc/test/src/math/erff_test.cpp (+1-1) 
- (modified) libc/test/src/math/exhaustive/fmod_generic_impl_test.cpp (+3-1) 
- (modified) libc/test/src/math/exp10_test.cpp (+1-1) 
- (modified) libc/test/src/math/exp10f_test.cpp (+1-1) 
- (modified) libc/test/src/math/exp2_test.cpp (+1-1) 
- (modified) libc/test/src/math/exp2f_test.cpp (+1-1) 
- (modified) libc/test/src/math/exp_test.cpp (+1-1) 
- (modified) libc/test/src/math/expf_test.cpp (+1-1) 
- (modified) libc/test/src/math/explogxf_test.cpp (+6-4) 
- (modified) libc/test/src/math/expm1_test.cpp (+1-1) 
- (modified) libc/test/src/math/expm1f_test.cpp (+1-1) 
- (modified) libc/test/src/math/fdim_test.cpp (+1-1) 
- (modified) libc/test/src/math/fdimf_test.cpp (+1-1) 
- (modified) libc/test/src/math/fdiml_test.cpp (+1-1) 
- (modified) libc/test/src/math/ilogb_test.cpp (+1-1) 
- (modified) libc/test/src/math/ilogbf_test.cpp (+1-1) 
- (modified) libc/test/src/math/ilogbl_test.cpp (+1-1) 
- (modified) libc/test/src/math/inv_trigf_utils_test.cpp (+1-1) 
- (modified) libc/test/src/math/log10_test.cpp (+1-1) 
- (modified) libc/test/src/math/log10f_test.cpp (+1-1) 
- (modified) libc/test/src/math/log1p_test.cpp (+1-1) 
- (modified) libc/test/src/math/log1pf_test.cpp (+1-1) 
- (modified) libc/test/src/math/log2_test.cpp (+1-1) 
- (modified) libc/test/src/math/log2f_test.cpp (+1-1) 
- (modified) libc/test/src/math/log_test.cpp (+1-1) 
- (modified) libc/test/src/math/logf_test.cpp (+1-1) 
- (modified) libc/test/src/math/powf_test.cpp (+1-1) 
- (modified) libc/test/src/math/sin_test.cpp (+1-1) 
- (modified) libc/test/src/math/sincosf_test.cpp (+1-1) 
- (modified) libc/test/src/math/sinf_test.cpp (+1-1) 
- (modified) libc/test/src/math/sinhf_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/CeilTest.h (+1-1) 
- (modified) libc/test/src/math/smoke/CopySignTest.h (+1-1) 
- (modified) libc/test/src/math/smoke/FAbsTest.h (+1-1) 
- (modified) libc/test/src/math/smoke/FModTest.h (+1-1) 
- (modified) libc/test/src/math/smoke/FloorTest.h (+1-1) 
- (modified) libc/test/src/math/smoke/HypotTest.h (+1-1) 
- (modified) libc/test/src/math/smoke/ModfTest.h (+1-1) 
- (modified) libc/test/src/math/smoke/NextAfterTest.h (+1-1) 
- (modified) libc/test/src/math/smoke/NextTowardTest.h (+1-1) 
- (modified) libc/test/src/math/smoke/RIntTest.h (+1-1) 
- (modified) libc/test/src/math/smoke/RemQuoTest.h (+1-1) 
- (modified) libc/test/src/math/smoke/RoundTest.h (+1-1) 
- (modified) libc/test/src/math/smoke/RoundToIntegerTest.h (+1-1) 
- (modified) libc/test/src/math/smoke/SqrtTest.h (+1-1) 
- (modified) libc/test/src/math/smoke/TruncTest.h (+1-1) 
- (modified) libc/test/src/math/smoke/acosf_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/acoshf_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/asinf_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/asinhf_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/atanf_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/atanhf_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/cosf_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/coshf_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/erff_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/exp10_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/exp10f_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/exp2_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/exp2f_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/exp_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/expf_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/expm1_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/expm1f_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/log10_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/log10f_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/log1p_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/log1pf_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/log2_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/log2f_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/log_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/logf_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/powf_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/sincosf_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/sinf_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/sinhf_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/tanf_test.cpp (+1-1) 
- (modified) libc/test/src/math/smoke/tanhf_test.cpp (+1-1) 
- (modified) libc/test/src/math/tan_test.cpp (+1-1) 
- (modified) libc/test/src/math/tanf_test.cpp (+1-1) 
- (modified) libc/test/src/math/tanhf_test.cpp (+1-1) 
- (modified) libc/test/utils/FPUtil/x86_long_double_test.cpp (+1-1) 
- (modified) libc/utils/MPFRWrapper/MPFRUtils.cpp (+1-1) 
- (modified) utils/bazel/llvm-project-overlay/libc/BUILD.bazel (+15-1) 
- (modified) utils/bazel/llvm-project-overlay/libc/test/src/__support/BUILD.bazel (+1) 
- (modified) utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel (+1) 


``````````diff
diff --git a/libc/fuzzing/math/RemQuoDiff.h b/libc/fuzzing/math/RemQuoDiff.h
index 2a962249617673..95a9866f29dbbe 100644
--- a/libc/fuzzing/math/RemQuoDiff.h
+++ b/libc/fuzzing/math/RemQuoDiff.h
@@ -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>
 
diff --git a/libc/fuzzing/math/SingleInputSingleOutputDiff.h b/libc/fuzzing/math/SingleInputSingleOutputDiff.h
index 8c1e4b0d0290ed..bdf54ee9af6c4f 100644
--- a/libc/fuzzing/math/SingleInputSingleOutputDiff.h
+++ b/libc/fuzzing/math/SingleInputSingleOutputDiff.h
@@ -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>
 
diff --git a/libc/fuzzing/math/TwoInputSingleOutputDiff.h b/libc/fuzzing/math/TwoInputSingleOutputDiff.h
index e3e3fe703b139e..f017dbd63f4af5 100644
--- a/libc/fuzzing/math/TwoInputSingleOutputDiff.h
+++ b/libc/fuzzing/math/TwoInputSingleOutputDiff.h
@@ -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>
 
diff --git a/libc/fuzzing/stdlib/strtofloat_fuzz.cpp b/libc/fuzzing/stdlib/strtofloat_fuzz.cpp
index b773043bda67d8..b000321854d16d 100644
--- a/libc/fuzzing/stdlib/strtofloat_fuzz.cpp
+++ b/libc/fuzzing/stdlib/strtofloat_fuzz.cpp
@@ -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>
 
diff --git a/libc/src/__support/FPUtil/FEnvImpl.h b/libc/src/__support/FPUtil/FEnvImpl.h
index 6810659733de2c..a6a533dcfdf4aa 100644
--- a/libc/src/__support/FPUtil/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/FEnvImpl.h
@@ -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__)
diff --git a/libc/src/__support/FPUtil/ManipulationFunctions.h b/libc/src/__support/FPUtil/ManipulationFunctions.h
index f148d984f5f35c..e9ca6dc33acc77 100644
--- a/libc/src/__support/FPUtil/ManipulationFunctions.h
+++ b/libc/src/__support/FPUtil/ManipulationFunctions.h
@@ -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 {
 
diff --git a/libc/src/__support/FPUtil/NearestIntegerOperations.h b/libc/src/__support/FPUtil/NearestIntegerOperations.h
index 19ae75ea788912..e890e38ba4ae7d 100644
--- a/libc/src/__support/FPUtil/NearestIntegerOperations.h
+++ b/libc/src/__support/FPUtil/NearestIntegerOperations.h
@@ -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 {
 
diff --git a/libc/src/math/generic/math_utils.h b/libc/src/math/generic/math_utils.h
index e884fe2deae284..cced761fc8c822 100644
--- a/libc/src/math/generic/math_utils.h
+++ b/libc/src/math/generic/math_utils.h
@@ -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.
diff --git a/libc/test/UnitTest/FPMatcher.h b/libc/test/UnitTest/FPMatcher.h
index 4525b9e830195e..01a83c9a0f948f 100644
--- a/libc/test/UnitTest/FPMatcher.h
+++ b/libc/test/UnitTest/FPMatcher.h
@@ -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 {
diff --git a/libc/test/src/__support/uint_test.cpp b/libc/test/src/__support/uint_test.cpp
index 851656e9fcbbb0..5764324ca28815 100644
--- a/libc/test/src/__support/uint_test.cpp
+++ b/libc/test/src/__support/uint_test.cpp
@@ -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 {
 
diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index b8a4aafcd97aa2..20d97666f50899 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -1503,6 +1503,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
 )
 
diff --git a/libc/test/src/math/CeilTest.h b/libc/test/src/math/CeilTest.h
index 5ea4f349d008b3..74cc90614dfc2a 100644
--- a/libc/test/src/math/CeilTest.h
+++ b/libc/test/src/math/CeilTest.h
@@ -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;
 
diff --git a/libc/test/src/math/CopySignTest.h b/libc/test/src/math/CopySignTest.h
index 8b81e8d7de2523..206626d66f5806 100644
--- a/libc/test/src/math/CopySignTest.h
+++ b/libc/test/src/math/CopySignTest.h
@@ -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;
 
diff --git a/libc/test/src/math/FAbsTest.h b/libc/test/src/math/FAbsTest.h
index 54f5f87e08e7e3..942991f23be1c6 100644
--- a/libc/test/src/math/FAbsTest.h
+++ b/libc/test/src/math/FAbsTest.h
@@ -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;
 
diff --git a/libc/test/src/math/FDimTest.h b/libc/test/src/math/FDimTest.h
index e00b4fd5c42ec0..76f0f18bbc68d6 100644
--- a/libc/test/src/math/FDimTest.h
+++ b/libc/test/src/math/FDimTest.h
@@ -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 {
diff --git a/libc/test/src/math/FMaxTest.h b/libc/test/src/math/FMaxTest.h
index f8046f380f5fd5..2c7dc3dc13ec5a 100644
--- a/libc/test/src/math/FMaxTest.h
+++ b/libc/test/src/math/FMaxTest.h
@@ -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;
 
diff --git a/libc/test/src/math/FMinTest.h b/libc/test/src/math/FMinTest.h
index 7a6534f320c92a..a986d5240d0da7 100644
--- a/libc/test/src/math/FMinTest.h
+++ b/libc/test/src/math/FMinTest.h
@@ -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;
 
diff --git a/libc/test/src/math/FModTest.h b/libc/test/src/math/FModTest.h
index 2b1442923268d9..96ad299258a176 100644
--- a/libc/test/src/math/FModTest.h
+++ b/libc/test/src/math/FModTest.h
@@ -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));                                             \
diff --git a/libc/test/src/math/FloorTest.h b/libc/test/src/math/FloorTest.h
index 66b37d69d7ba3d..21ae291e61bc7e 100644
--- a/libc/test/src/math/FloorTest.h
+++ b/libc/test/src/math/FloorTest.h
@@ -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;
 
diff --git a/libc/test/src/math/FrexpTest.h b/libc/test/src/math/FrexpTest.h
index f3a64ce4aac31f..f971b45628f09f 100644
--- a/libc/test/src/math/FrexpTest.h
+++ b/libc/test/src/math/FrexpTest.h
@@ -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;
 
diff --git a/libc/test/src/math/HypotTest.h b/libc/test/src/math/HypotTest.h
index 8f84024a6ee117..46fcc462a2793a 100644
--- a/libc/test/src/math/HypotTest.h
+++ b/libc/test/src/math/HypotTest.h
@@ -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;
 
diff --git a/libc/test/src/math/ILogbTest.h b/libc/test/src/math/ILogbTest.h
index 3e2db33e2c0524..dcc9d554eb3c28 100644
--- a/libc/test/src/math/ILogbTest.h
+++ b/libc/test/src/math/ILogbTest.h
@@ -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:
diff --git a/libc/test/src/math/LdExpTest.h b/libc/test/src/math/LdExpTest.h
index fe84b5f4c192a4..738135d6afe27e 100644
--- a/libc/test/src/math/LdExpTest.h
+++ b/libc/test/src/math/LdExpTest.h
@@ -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>
diff --git a/libc/test/src/math/LogbTest.h b/libc/test/src/math/LogbTest.h
index d64c5c44e4281a..3859b56582e5e4 100644
--- a/libc/test/src/math/LogbTest.h
+++ b/libc/test/src/math/LogbTest.h
@@ -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;
 
diff --git a/libc/test/src/math/ModfTest.h b/libc/test/src/math/ModfTest.h
index a7e5e8810611b1..84e26db49695d5 100644
--- a/libc/test/src/math/ModfTest.h
+++ b/libc/test/src/math/ModfTest.h
@@ -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;
 
diff --git a/libc/test/src/math/NextAfterTest.h b/libc/test/src/math/NextAfterTest.h
index 2f1450a16fd1e5..d45d819bfdb6cd 100644
--- a/libc/test/src/math/NextAfterTest.h
+++ b/libc/test/src/math/NextAfterTest.h
@@ -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 {
diff --git a/libc/test/src/math/RIntTest.h b/libc/test/src/math/RIntTest.h
index 3b16b902bcf5d3..d392d4fb14a2e2 100644
--- a/libc/test/src/math/RIntTest.h
+++ b/libc/test/src/math/RIntTest.h
@@ -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;
diff --git a/libc/test/src/math/RemQuoTest.h b/libc/test/src/math/RemQuoTest.h
index 7b3011d23055d9..d61b97554199e7 100644
--- a/libc/test/src/math/RemQuoTest.h
+++ b/libc/test/src/math/RemQuoTest.h
@@ -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;
 
diff --git a/libc/test/src/math/RoundTest.h b/libc/test/src/math/RoundTest.h
index b255ecc4fa84e8..17da00f869d3b3 100644
--- a/libc/test/src/math/RoundTest.h
+++ b/libc/test/src/math/RoundTest.h
@@ -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;
 
diff --git a/libc/test/src/math/RoundToIntegerTest.h b/libc/test/src/math/RoundToIntegerTest.h
index 9bd4ba52f61ba8..017f5867fc8de7 100644
--- a/libc/test/src/math/RoundToIntegerTest.h
+++ b/libc/test/src/math/RoundToIntegerTest.h
@@ -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;
 
diff --git a/libc/test/src/math/SqrtTest.h b/libc/test/src/math/SqrtTest.h
index 75eb411810f5ee..9811b2767ee337 100644
--- a/libc/test/src/math/SqrtTest.h
+++ b/libc/test/src/math/SqrtTest.h
@@ -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;
 
diff --git a/libc/test/src/math/TruncTest.h b/libc/test/src/math/TruncTest.h
index 6d0ea1182ec11b..c3a89dbb837b52 100644
--- a/libc/test/src/math/TruncTest.h
+++ b/libc/test/src/math/TruncTest.h
@@ -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;
 
diff --git a/libc/test/src/math/acosf_test.cpp b/libc/test/src/math/acosf_test.cpp
index c273184d58f3e6..6f8321bd7182ae 100644
--- a/libc/test/src/math/acosf_test.cpp
+++ b/libc/test/src/math/acosf_test.cpp
@@ -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>
diff --git a/libc/test/src/math/acoshf_test.cpp b/libc/test/src/math/acoshf_test.cpp
index a0e845b2b247ee..41d1166fb430db 100644
--- a/libc/test/src/math/acoshf_test.cpp
+++ b/libc/test/src/math/acoshf_test.cpp
@@ -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>
diff --git a/libc/test/src/math/asinf_test.cpp b/libc/test/src/math/asinf_test.cpp
index a24fdcc36e140a..4e36f03f489551 100644
--- a/libc/test/src/math/asinf_test.cpp
+++ b/libc/test/src/math/asinf_test.cpp
@@ -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>
diff --git a/libc/test/src/math/asinhf_test.cpp b/libc/test/src/math/asinhf_test.cpp
index 3127861c9a1be5..9a3bfbed1068d8 100644
--- a/libc/test/src/math/asinhf_test.cpp
+++ b/libc/test/src/math/asinhf_test.cpp
@@ -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>
diff --git a/libc/test/src/math/atanf_test.cpp b/libc/test/src/math/atanf_test.cpp
index 1fa7165805c7d1..fdd69d3dc7914f 100644
--- a/libc/test/src/math/atanf_test.cpp
+++ b/libc/test/src/math/atanf_test.cpp
@@ -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>
diff --git a/libc/test/src/math/atanhf_test.cpp b/libc/test/src/math/atanhf_test.cpp
index 1b45436094da44..39c067f3e764c2 100644
--- a/libc/test/src/math/atanhf_test.cpp
+++ b/libc/test/src/math/atanhf_test.cpp
@@ -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>
diff --git a/libc/test/src/math/cos_test.cpp b/libc/test/src/math/cos_test.cpp
index 1f55e9e9a14959..6a1122997c51a2 100644
--- a/libc/test/src/math/cos_test.cpp
+++ b/libc/test/src/math/cos_test.cpp
@@ -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>;
 
diff --git a/libc/test/src/math/cosf_test.cpp b/libc/test/src/math/cosf_test.cpp
index 93ab06dc80b261..8a5eb17fdcea50 100644
--- a/libc/test/src/math/cosf_test.cpp
+++ b/libc/test/src/math/cosf_test.cpp
@@ -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/MPFRW...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/85324


More information about the libc-commits mailing list