[libc] [llvm] [libc] Add proxy header for fenv.h macro constants. #87863 (PR #87896)

Job Henandez Lara via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 7 14:12:08 PDT 2024


https://github.com/Jobhdez updated https://github.com/llvm/llvm-project/pull/87896

>From e307a31293a68dc5d268a65018516be1231a711b Mon Sep 17 00:00:00 2001
From: Job Hernandez <hj93 at protonmail.com>
Date: Sat, 6 Apr 2024 14:45:12 -0700
Subject: [PATCH 1/7] [libc] Add proxy header for fenv.h macro constants.
 #87863

---
 libc/AOR_v20.02/math/test/mathtest.c          |  2 +-
 libc/AOR_v20.02/math/test/ulp.c               |  2 +-
 libc/config/baremetal/arm/headers.txt         |  2 +-
 libc/config/baremetal/riscv/headers.txt       |  2 +-
 libc/config/darwin/arm/headers.txt            |  2 +-
 libc/config/darwin/x86_64/headers.txt         |  2 +-
 libc/config/gpu/headers.txt                   |  2 +-
 libc/config/linux/aarch64/headers.txt         |  2 +-
 libc/config/linux/arm/headers.txt             |  2 +-
 libc/config/linux/riscv/headers.txt           |  2 +-
 libc/config/linux/x86_64/headers.txt          |  2 +-
 libc/hdr/CMakeLists.txt                       |  9 ++++++
 libc/hdr/fenv_macros.h                        | 22 ++++++++++++++
 libc/src/__support/FPUtil/CMakeLists.txt      |  4 +--
 libc/src/__support/FPUtil/FEnvImpl.h          |  2 +-
 libc/src/__support/FPUtil/aarch64/FEnvImpl.h  |  2 +-
 .../FPUtil/aarch64/fenv_darwin_impl.h         |  2 +-
 libc/src/__support/FPUtil/arm/FEnvImpl.h      |  2 +-
 .../__support/FPUtil/generic/CMakeLists.txt   |  2 +-
 libc/src/__support/FPUtil/riscv/FEnvImpl.h    |  2 +-
 libc/src/__support/FPUtil/rounding_mode.h     |  2 +-
 libc/src/__support/FPUtil/x86_64/FEnvImpl.h   |  2 +-
 libc/src/fenv/CMakeLists.txt                  | 30 +++++++++----------
 libc/src/fenv/fegetenv.h                      |  2 +-
 libc/src/fenv/fegetexceptflag.cpp             |  2 +-
 libc/src/fenv/fegetexceptflag.h               |  2 +-
 libc/src/fenv/feholdexcept.cpp                |  2 +-
 libc/src/fenv/feholdexcept.h                  |  2 +-
 libc/src/fenv/fesetenv.h                      |  2 +-
 libc/src/fenv/fesetexceptflag.cpp             |  2 +-
 libc/src/fenv/fesetexceptflag.h               |  2 +-
 libc/src/fenv/feupdateenv.cpp                 |  2 +-
 libc/src/fenv/feupdateenv.h                   |  2 +-
 libc/test/UnitTest/FPExceptMatcher.cpp        |  2 +-
 libc/test/UnitTest/RoundingModeUtils.cpp      |  2 +-
 .../__support/FPUtil/rounding_mode_test.cpp   |  2 +-
 libc/test/src/fenv/CMakeLists.txt             |  2 +-
 .../test/src/fenv/enabled_exceptions_test.cpp |  2 +-
 libc/test/src/fenv/exception_flags_test.cpp   |  2 +-
 libc/test/src/fenv/exception_status_test.cpp  |  2 +-
 libc/test/src/fenv/feclearexcept_test.cpp     |  2 +-
 libc/test/src/fenv/feenableexcept_test.cpp    |  2 +-
 libc/test/src/fenv/feholdexcept_test.cpp      |  2 +-
 libc/test/src/fenv/feupdateenv_test.cpp       |  2 +-
 libc/test/src/fenv/getenv_and_setenv_test.cpp |  2 +-
 libc/test/src/fenv/rounding_mode_test.cpp     |  2 +-
 libc/test/src/math/RIntTest.h                 |  2 +-
 libc/test/src/math/smoke/NextTowardTest.h     |  2 +-
 libc/test/src/math/smoke/RIntTest.h           |  2 +-
 libc/utils/MPFRWrapper/MPFRUtils.cpp          |  2 +-
 .../llvm-project-overlay/libc/BUILD.bazel     |  6 ++++
 51 files changed, 100 insertions(+), 63 deletions(-)
 create mode 100644 libc/hdr/fenv_macros.h

diff --git a/libc/AOR_v20.02/math/test/mathtest.c b/libc/AOR_v20.02/math/test/mathtest.c
index efe0a8a744bc5c..9ac5e191d2d396 100644
--- a/libc/AOR_v20.02/math/test/mathtest.c
+++ b/libc/AOR_v20.02/math/test/mathtest.c
@@ -15,7 +15,7 @@
 #include <math.h>
 #include <errno.h>
 #include <limits.h>
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 #include "mathlib.h"
 
 #ifndef math_errhandling
diff --git a/libc/AOR_v20.02/math/test/ulp.c b/libc/AOR_v20.02/math/test/ulp.c
index 3821986f7cb485..7a17228698bcf0 100644
--- a/libc/AOR_v20.02/math/test/ulp.c
+++ b/libc/AOR_v20.02/math/test/ulp.c
@@ -7,7 +7,7 @@
  */
 
 #include <ctype.h>
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 #include <float.h>
 #include <math.h>
 #include <stdint.h>
diff --git a/libc/config/baremetal/arm/headers.txt b/libc/config/baremetal/arm/headers.txt
index 3608364e45bdeb..42f3274bc72962 100644
--- a/libc/config/baremetal/arm/headers.txt
+++ b/libc/config/baremetal/arm/headers.txt
@@ -1,7 +1,7 @@
 set(TARGET_PUBLIC_HEADERS
     libc.include.assert
     libc.include.ctype
-    libc.include.fenv
+    libc.hdr.fenv_macros
     libc.include.errno
     libc.include.float
     libc.include.stdint
diff --git a/libc/config/baremetal/riscv/headers.txt b/libc/config/baremetal/riscv/headers.txt
index 3608364e45bdeb..42f3274bc72962 100644
--- a/libc/config/baremetal/riscv/headers.txt
+++ b/libc/config/baremetal/riscv/headers.txt
@@ -1,7 +1,7 @@
 set(TARGET_PUBLIC_HEADERS
     libc.include.assert
     libc.include.ctype
-    libc.include.fenv
+    libc.hdr.fenv_macros
     libc.include.errno
     libc.include.float
     libc.include.stdint
diff --git a/libc/config/darwin/arm/headers.txt b/libc/config/darwin/arm/headers.txt
index 86e7145972324a..29b397edd594d6 100644
--- a/libc/config/darwin/arm/headers.txt
+++ b/libc/config/darwin/arm/headers.txt
@@ -1,7 +1,7 @@
 set(TARGET_PUBLIC_HEADERS
     libc.include.ctype
     libc.include.errno
-    libc.include.fenv
+    libc.hdr.fenv_macros
     libc.include.float
     libc.include.stdint
     libc.include.inttypes
diff --git a/libc/config/darwin/x86_64/headers.txt b/libc/config/darwin/x86_64/headers.txt
index acd24026498774..69f7e88d550448 100644
--- a/libc/config/darwin/x86_64/headers.txt
+++ b/libc/config/darwin/x86_64/headers.txt
@@ -2,7 +2,7 @@ set(TARGET_PUBLIC_HEADERS
     libc.include.ctype
     libc.include.errno
     # Fenv is currently disabled.
-    #libc.include.fenv
+    #libc.hdr.fenv_macros
     libc.include.float
     libc.include.stdint
     libc.include.inttypes
diff --git a/libc/config/gpu/headers.txt b/libc/config/gpu/headers.txt
index dd16938da8a447..bf0b5cfb7b0348 100644
--- a/libc/config/gpu/headers.txt
+++ b/libc/config/gpu/headers.txt
@@ -7,7 +7,7 @@ set(TARGET_PUBLIC_HEADERS
     libc.include.inttypes
     libc.include.limits
     libc.include.math
-    libc.include.fenv
+    libc.hdr.fenv_macros
     libc.include.time
     libc.include.errno
     libc.include.stdlib
diff --git a/libc/config/linux/aarch64/headers.txt b/libc/config/linux/aarch64/headers.txt
index 47db4434b09b33..fd72001965eef9 100644
--- a/libc/config/linux/aarch64/headers.txt
+++ b/libc/config/linux/aarch64/headers.txt
@@ -3,7 +3,7 @@ set(TARGET_PUBLIC_HEADERS
     libc.include.ctype
     libc.include.errno
     libc.include.features
-    libc.include.fenv
+    libc.hdr.fenv_macros
     libc.include.float
     libc.include.stdint
     libc.include.inttypes
diff --git a/libc/config/linux/arm/headers.txt b/libc/config/linux/arm/headers.txt
index 307bb6b146a4cc..f1adb96052ca97 100644
--- a/libc/config/linux/arm/headers.txt
+++ b/libc/config/linux/arm/headers.txt
@@ -1,6 +1,6 @@
 set(TARGET_PUBLIC_HEADERS
     libc.include.ctype
-    libc.include.fenv
+    libc.hdr.fenv_macros
     libc.include.errno
     libc.include.float
     libc.include.stdint
diff --git a/libc/config/linux/riscv/headers.txt b/libc/config/linux/riscv/headers.txt
index c858bcc978d9da..a4fc31bb368c27 100644
--- a/libc/config/linux/riscv/headers.txt
+++ b/libc/config/linux/riscv/headers.txt
@@ -5,7 +5,7 @@ set(TARGET_PUBLIC_HEADERS
     libc.include.errno
     libc.include.fcntl
     libc.include.features
-    libc.include.fenv
+    libc.hdr.fenv_macros
     libc.include.float
     libc.include.stdint
     libc.include.inttypes
diff --git a/libc/config/linux/x86_64/headers.txt b/libc/config/linux/x86_64/headers.txt
index e51c7931942706..74878111621ea5 100644
--- a/libc/config/linux/x86_64/headers.txt
+++ b/libc/config/linux/x86_64/headers.txt
@@ -5,7 +5,7 @@ set(TARGET_PUBLIC_HEADERS
     libc.include.errno
     libc.include.fcntl
     libc.include.features
-    libc.include.fenv
+    libc.hdr.fenv_macros
     libc.include.float
     libc.include.stdint
     libc.include.inttypes
diff --git a/libc/hdr/CMakeLists.txt b/libc/hdr/CMakeLists.txt
index 1d3eb9d5240ab9..ff95a49e29b2f7 100644
--- a/libc/hdr/CMakeLists.txt
+++ b/libc/hdr/CMakeLists.txt
@@ -31,3 +31,12 @@ add_proxy_header_library(
     libc.include.llvm-libc-macros.math_macros
     libc.include.math
 )
+
+add_proxy_header_library(
+  fenv_macros
+  HDRS
+    fenv_macros.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-macros.fenv_macros
+    libc.hdr.fenv_macros
+)
diff --git a/libc/hdr/fenv_macros.h b/libc/hdr/fenv_macros.h
new file mode 100644
index 00000000000000..23b1ebed3c2871
--- /dev/null
+++ b/libc/hdr/fenv_macros.h
@@ -0,0 +1,22 @@
+//===-- Definition of macros from fenv.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_FENV_MACROS_H
+#define LLVM_LIBC_HDR_FENV_MACROS_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "libc/include/llvm-libc-macros/fenv-macros.h"
+
+#else // Overlay mode
+
+#include <fenv.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_FENV_MACROS_H
diff --git a/libc/src/__support/FPUtil/CMakeLists.txt b/libc/src/__support/FPUtil/CMakeLists.txt
index 1af236ed9d6bc1..4c0885ff756ecd 100644
--- a/libc/src/__support/FPUtil/CMakeLists.txt
+++ b/libc/src/__support/FPUtil/CMakeLists.txt
@@ -3,7 +3,7 @@ add_header_library(
   HDRS
     FEnvImpl.h
   DEPENDS
-    libc.include.fenv
+    libc.hdr.fenv_macros
     libc.hdr.math_macros
     libc.src.__support.macros.attributes
     libc.src.errno.errno
@@ -14,7 +14,7 @@ add_header_library(
   HDRS
     rounding_mode.h
   DEPENDS
-    libc.include.fenv
+    libc.hdr.fenv_macros
     libc.src.__support.macros.attributes
     libc.src.__support.macros.properties.architectures
     libc.src.__support.macros.sanitizer
diff --git a/libc/src/__support/FPUtil/FEnvImpl.h b/libc/src/__support/FPUtil/FEnvImpl.h
index 4be1a57f0f4b38..04ab015a9ae6bc 100644
--- a/libc/src/__support/FPUtil/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/FEnvImpl.h
@@ -13,7 +13,7 @@
 #include "src/__support/macros/attributes.h" // LIBC_INLINE
 #include "src/__support/macros/properties/architectures.h"
 #include "src/errno/libc_errno.h"
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 
 #if defined(LIBC_TARGET_ARCH_IS_AARCH64)
 #if defined(__APPLE__)
diff --git a/libc/src/__support/FPUtil/aarch64/FEnvImpl.h b/libc/src/__support/FPUtil/aarch64/FEnvImpl.h
index e0eec17e038c63..05df87a6208e6e 100644
--- a/libc/src/__support/FPUtil/aarch64/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/aarch64/FEnvImpl.h
@@ -17,7 +17,7 @@
 #endif
 
 #include <arm_acle.h>
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 #include <stdint.h>
 
 #include "src/__support/FPUtil/FPBits.h"
diff --git a/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h b/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h
index fd915373020ec9..9e11390c9b60da 100644
--- a/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h
+++ b/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h
@@ -17,7 +17,7 @@
 #endif
 
 #include <arm_acle.h>
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 #include <stdint.h>
 
 #include "src/__support/FPUtil/FPBits.h"
diff --git a/libc/src/__support/FPUtil/arm/FEnvImpl.h b/libc/src/__support/FPUtil/arm/FEnvImpl.h
index ac4673cf20f632..458f4abf278fc3 100644
--- a/libc/src/__support/FPUtil/arm/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/arm/FEnvImpl.h
@@ -12,7 +12,7 @@
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/macros/attributes.h" // For LIBC_INLINE
 
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 #include <stdint.h>
 
 namespace LIBC_NAMESPACE {
diff --git a/libc/src/__support/FPUtil/generic/CMakeLists.txt b/libc/src/__support/FPUtil/generic/CMakeLists.txt
index 0ae62f40dc6163..5c941a6f7e7076 100644
--- a/libc/src/__support/FPUtil/generic/CMakeLists.txt
+++ b/libc/src/__support/FPUtil/generic/CMakeLists.txt
@@ -4,7 +4,7 @@ add_header_library(
     sqrt.h
     sqrt_80_bit_long_double.h
   DEPENDS
-    libc.include.fenv
+    libc.hdr.fenv_macros
     libc.src.__support.common
     libc.src.__support.CPP.bit
     libc.src.__support.CPP.type_traits
diff --git a/libc/src/__support/FPUtil/riscv/FEnvImpl.h b/libc/src/__support/FPUtil/riscv/FEnvImpl.h
index b73c4798b0539a..2a2a18b7e98e45 100644
--- a/libc/src/__support/FPUtil/riscv/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/riscv/FEnvImpl.h
@@ -13,7 +13,7 @@
 #include "src/__support/macros/attributes.h" // For LIBC_INLINE_ASM
 #include "src/__support/macros/config.h"     // For LIBC_INLINE
 
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 #include <stdint.h>
 
 namespace LIBC_NAMESPACE {
diff --git a/libc/src/__support/FPUtil/rounding_mode.h b/libc/src/__support/FPUtil/rounding_mode.h
index 91a5b9c50e7c2b..41f2803e0e8fb5 100644
--- a/libc/src/__support/FPUtil/rounding_mode.h
+++ b/libc/src/__support/FPUtil/rounding_mode.h
@@ -11,7 +11,7 @@
 
 #include "src/__support/macros/attributes.h" // LIBC_INLINE
 
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 
 namespace LIBC_NAMESPACE::fputil {
 
diff --git a/libc/src/__support/FPUtil/x86_64/FEnvImpl.h b/libc/src/__support/FPUtil/x86_64/FEnvImpl.h
index b73b70e907790f..5833d9c8deb50e 100644
--- a/libc/src/__support/FPUtil/x86_64/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/x86_64/FEnvImpl.h
@@ -16,7 +16,7 @@
 #error "Invalid include"
 #endif
 
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 #include <stdint.h>
 
 #include "src/__support/macros/sanitizer.h"
diff --git a/libc/src/fenv/CMakeLists.txt b/libc/src/fenv/CMakeLists.txt
index d2f90d3d007a1b..965a783055add5 100644
--- a/libc/src/fenv/CMakeLists.txt
+++ b/libc/src/fenv/CMakeLists.txt
@@ -5,7 +5,7 @@ add_entrypoint_object(
   HDRS
     fegetround.h
   DEPENDS
-    libc.include.fenv
+    libc.hdr.fenv_macros
     libc.src.__support.FPUtil.fenv_impl
   COMPILE_OPTIONS
     -O2
@@ -18,7 +18,7 @@ add_entrypoint_object(
   HDRS
     fesetround.h
   DEPENDS
-    libc.include.fenv
+    libc.hdr.fenv_macros
     libc.src.__support.FPUtil.fenv_impl
   COMPILE_OPTIONS
     -O2
@@ -31,7 +31,7 @@ add_entrypoint_object(
   HDRS
     feclearexcept.h
   DEPENDS
-    libc.include.fenv
+    libc.hdr.fenv_macros
     libc.src.__support.FPUtil.fenv_impl
   COMPILE_OPTIONS
     -O2
@@ -44,7 +44,7 @@ add_entrypoint_object(
   HDRS
     feraiseexcept.h
   DEPENDS
-    libc.include.fenv
+    libc.hdr.fenv_macros
     libc.src.__support.FPUtil.fenv_impl
   COMPILE_OPTIONS
     -O2
@@ -57,7 +57,7 @@ add_entrypoint_object(
   HDRS
     fetestexcept.h
   DEPENDS
-    libc.include.fenv
+    libc.hdr.fenv_macros
     libc.src.__support.FPUtil.fenv_impl
   COMPILE_OPTIONS
     -O2
@@ -70,7 +70,7 @@ add_entrypoint_object(
   HDRS
     fegetenv.h
   DEPENDS
-    libc.include.fenv
+    libc.hdr.fenv_macros
     libc.src.__support.FPUtil.fenv_impl
   COMPILE_OPTIONS
     -O2
@@ -83,7 +83,7 @@ add_entrypoint_object(
   HDRS
     fesetenv.h
   DEPENDS
-    libc.include.fenv
+    libc.hdr.fenv_macros
     libc.src.__support.FPUtil.fenv_impl
   COMPILE_OPTIONS
     -O2
@@ -96,7 +96,7 @@ add_entrypoint_object(
   HDRS
     fegetexceptflag.h
   DEPENDS
-    libc.include.fenv
+    libc.hdr.fenv_macros
     libc.src.__support.FPUtil.fenv_impl
   COMPILE_OPTIONS
     -O2
@@ -109,7 +109,7 @@ add_entrypoint_object(
   HDRS
     fesetexcept.h
   DEPENDS
-    libc.include.fenv
+    libc.hdr.fenv_macros
     libc.src.__support.FPUtil.fenv_impl
   COMPILE_OPTIONS
     -O2
@@ -122,7 +122,7 @@ add_entrypoint_object(
   HDRS
     fesetexceptflag.h
   DEPENDS
-    libc.include.fenv
+    libc.hdr.fenv_macros
     libc.src.__support.FPUtil.fenv_impl
   COMPILE_OPTIONS
     -O2
@@ -135,7 +135,7 @@ add_entrypoint_object(
   HDRS
     feholdexcept.h
   DEPENDS
-    libc.include.fenv
+    libc.hdr.fenv_macros
     libc.src.__support.FPUtil.fenv_impl
   COMPILE_OPTIONS
     -O2
@@ -148,7 +148,7 @@ add_entrypoint_object(
   HDRS
     feupdateenv.h
   DEPENDS
-    libc.include.fenv
+    libc.hdr.fenv_macros
     libc.src.__support.FPUtil.fenv_impl
   COMPILE_OPTIONS
     -O2
@@ -161,7 +161,7 @@ add_entrypoint_object(
   HDRS
     feenableexcept.h
   DEPENDS
-    libc.include.fenv
+    libc.hdr.fenv_macros
     libc.src.__support.FPUtil.fenv_impl
   COMPILE_OPTIONS
     -O2
@@ -174,7 +174,7 @@ add_entrypoint_object(
   HDRS
     fedisableexcept.h
   DEPENDS
-    libc.include.fenv
+    libc.hdr.fenv_macros
     libc.src.__support.FPUtil.fenv_impl
   COMPILE_OPTIONS
     -O2
@@ -187,7 +187,7 @@ add_entrypoint_object(
   HDRS
     fegetexcept.h
   DEPENDS
-    libc.include.fenv
+    libc.hdr.fenv_macros
     libc.src.__support.FPUtil.fenv_impl
   COMPILE_OPTIONS
     -O2
diff --git a/libc/src/fenv/fegetenv.h b/libc/src/fenv/fegetenv.h
index 658316482984e1..479b87d554fac6 100644
--- a/libc/src/fenv/fegetenv.h
+++ b/libc/src/fenv/fegetenv.h
@@ -9,7 +9,7 @@
 #ifndef LLVM_LIBC_SRC_FENV_FEGETENV_H
 #define LLVM_LIBC_SRC_FENV_FEGETENV_H
 
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 
 namespace LIBC_NAMESPACE {
 
diff --git a/libc/src/fenv/fegetexceptflag.cpp b/libc/src/fenv/fegetexceptflag.cpp
index c6160da7afbde2..035303b079ab22 100644
--- a/libc/src/fenv/fegetexceptflag.cpp
+++ b/libc/src/fenv/fegetexceptflag.cpp
@@ -10,7 +10,7 @@
 #include "src/__support/FPUtil/FEnvImpl.h"
 #include "src/__support/common.h"
 
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 
 namespace LIBC_NAMESPACE {
 
diff --git a/libc/src/fenv/fegetexceptflag.h b/libc/src/fenv/fegetexceptflag.h
index ad72161e536f83..41c77ed7c98a72 100644
--- a/libc/src/fenv/fegetexceptflag.h
+++ b/libc/src/fenv/fegetexceptflag.h
@@ -9,7 +9,7 @@
 #ifndef LLVM_LIBC_SRC_FENV_FEGETEXCEPTFLAG_H
 #define LLVM_LIBC_SRC_FENV_FEGETEXCEPTFLAG_H
 
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 
 namespace LIBC_NAMESPACE {
 
diff --git a/libc/src/fenv/feholdexcept.cpp b/libc/src/fenv/feholdexcept.cpp
index 3c73b1f4217798..5e8b78b295672a 100644
--- a/libc/src/fenv/feholdexcept.cpp
+++ b/libc/src/fenv/feholdexcept.cpp
@@ -10,7 +10,7 @@
 #include "src/__support/FPUtil/FEnvImpl.h"
 #include "src/__support/common.h"
 
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 
 namespace LIBC_NAMESPACE {
 
diff --git a/libc/src/fenv/feholdexcept.h b/libc/src/fenv/feholdexcept.h
index bbefc4ecbd41b2..ef7d145f26e3f5 100644
--- a/libc/src/fenv/feholdexcept.h
+++ b/libc/src/fenv/feholdexcept.h
@@ -9,7 +9,7 @@
 #ifndef LLVM_LIBC_SRC_FENV_FEHOLDEXCEPT_H
 #define LLVM_LIBC_SRC_FENV_FEHOLDEXCEPT_H
 
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 
 namespace LIBC_NAMESPACE {
 
diff --git a/libc/src/fenv/fesetenv.h b/libc/src/fenv/fesetenv.h
index 8b56bebc2e36d4..8591e65d86e15f 100644
--- a/libc/src/fenv/fesetenv.h
+++ b/libc/src/fenv/fesetenv.h
@@ -9,7 +9,7 @@
 #ifndef LLVM_LIBC_SRC_FENV_FESETENV_H
 #define LLVM_LIBC_SRC_FENV_FESETENV_H
 
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 
 namespace LIBC_NAMESPACE {
 
diff --git a/libc/src/fenv/fesetexceptflag.cpp b/libc/src/fenv/fesetexceptflag.cpp
index 2fe7cb571a8ddd..58c10ba97a141b 100644
--- a/libc/src/fenv/fesetexceptflag.cpp
+++ b/libc/src/fenv/fesetexceptflag.cpp
@@ -10,7 +10,7 @@
 #include "src/__support/FPUtil/FEnvImpl.h"
 #include "src/__support/common.h"
 
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 
 namespace LIBC_NAMESPACE {
 
diff --git a/libc/src/fenv/fesetexceptflag.h b/libc/src/fenv/fesetexceptflag.h
index 15e62eda1b840c..a91abe0d6aa7c5 100644
--- a/libc/src/fenv/fesetexceptflag.h
+++ b/libc/src/fenv/fesetexceptflag.h
@@ -9,7 +9,7 @@
 #ifndef LLVM_LIBC_SRC_FENV_FESETEXCEPTFLAG_H
 #define LLVM_LIBC_SRC_FENV_FESETEXCEPTFLAG_H
 
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 
 namespace LIBC_NAMESPACE {
 
diff --git a/libc/src/fenv/feupdateenv.cpp b/libc/src/fenv/feupdateenv.cpp
index 7e81b9476da91b..72bc14bd50a74a 100644
--- a/libc/src/fenv/feupdateenv.cpp
+++ b/libc/src/fenv/feupdateenv.cpp
@@ -10,7 +10,7 @@
 #include "src/__support/FPUtil/FEnvImpl.h"
 #include "src/__support/common.h"
 
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 
 namespace LIBC_NAMESPACE {
 
diff --git a/libc/src/fenv/feupdateenv.h b/libc/src/fenv/feupdateenv.h
index 294c041ddeae79..a925d862f984bb 100644
--- a/libc/src/fenv/feupdateenv.h
+++ b/libc/src/fenv/feupdateenv.h
@@ -9,7 +9,7 @@
 #ifndef LLVM_LIBC_SRC_FENV_FEUPDATEENV_H
 #define LLVM_LIBC_SRC_FENV_FEUPDATEENV_H
 
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 
 namespace LIBC_NAMESPACE {
 
diff --git a/libc/test/UnitTest/FPExceptMatcher.cpp b/libc/test/UnitTest/FPExceptMatcher.cpp
index 1601b7e53f2be1..965059faf7eba0 100644
--- a/libc/test/UnitTest/FPExceptMatcher.cpp
+++ b/libc/test/UnitTest/FPExceptMatcher.cpp
@@ -8,7 +8,7 @@
 
 #include "FPExceptMatcher.h"
 
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 #include <memory>
 #include <setjmp.h>
 #include <signal.h>
diff --git a/libc/test/UnitTest/RoundingModeUtils.cpp b/libc/test/UnitTest/RoundingModeUtils.cpp
index c8f32f81e7134a..cb34c5eab421e2 100644
--- a/libc/test/UnitTest/RoundingModeUtils.cpp
+++ b/libc/test/UnitTest/RoundingModeUtils.cpp
@@ -10,7 +10,7 @@
 #include "src/__support/FPUtil/FEnvImpl.h"
 #include "src/__support/FPUtil/rounding_mode.h"
 
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 
 namespace LIBC_NAMESPACE {
 namespace fputil {
diff --git a/libc/test/src/__support/FPUtil/rounding_mode_test.cpp b/libc/test/src/__support/FPUtil/rounding_mode_test.cpp
index 8077a5aab7afde..5d62bc8c9ae931 100644
--- a/libc/test/src/__support/FPUtil/rounding_mode_test.cpp
+++ b/libc/test/src/__support/FPUtil/rounding_mode_test.cpp
@@ -10,7 +10,7 @@
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 
 using LIBC_NAMESPACE::testing::mpfr::ForceRoundingMode;
 using LIBC_NAMESPACE::testing::mpfr::RoundingMode;
diff --git a/libc/test/src/fenv/CMakeLists.txt b/libc/test/src/fenv/CMakeLists.txt
index 7e456b9a922fb9..577735599dc010 100644
--- a/libc/test/src/fenv/CMakeLists.txt
+++ b/libc/test/src/fenv/CMakeLists.txt
@@ -118,7 +118,7 @@ if (NOT (LLVM_USE_SANITIZER OR (${LIBC_TARGET_OS} STREQUAL "windows")
     SRCS
       feholdexcept_test.cpp
     DEPENDS
-      libc.include.fenv
+      libc.hdr.fenv_macros
       libc.src.fenv.feholdexcept
       libc.src.__support.FPUtil.fenv_impl
     LINK_LIBRARIES
diff --git a/libc/test/src/fenv/enabled_exceptions_test.cpp b/libc/test/src/fenv/enabled_exceptions_test.cpp
index 8bc2454faf9ea8..53440b704ca761 100644
--- a/libc/test/src/fenv/enabled_exceptions_test.cpp
+++ b/libc/test/src/fenv/enabled_exceptions_test.cpp
@@ -15,7 +15,7 @@
 #include "test/UnitTest/FPExceptMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 #include <signal.h>
 
 // This test enables an exception and verifies that raising that exception
diff --git a/libc/test/src/fenv/exception_flags_test.cpp b/libc/test/src/fenv/exception_flags_test.cpp
index 434adc06b1a36a..d62aaa00c26b03 100644
--- a/libc/test/src/fenv/exception_flags_test.cpp
+++ b/libc/test/src/fenv/exception_flags_test.cpp
@@ -12,7 +12,7 @@
 #include "src/__support/FPUtil/FEnvImpl.h"
 #include "test/UnitTest/Test.h"
 
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 
 TEST(LlvmLibcFenvTest, GetExceptFlagAndSetExceptFlag) {
   // We will disable all exceptions to prevent invocation of the exception
diff --git a/libc/test/src/fenv/exception_status_test.cpp b/libc/test/src/fenv/exception_status_test.cpp
index cf0fd1fe1af397..a7000020b1a3c8 100644
--- a/libc/test/src/fenv/exception_status_test.cpp
+++ b/libc/test/src/fenv/exception_status_test.cpp
@@ -15,7 +15,7 @@
 #include "src/__support/FPUtil/FEnvImpl.h"
 #include "test/UnitTest/Test.h"
 
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 
 TEST(LlvmLibcExceptionStatusTest, RaiseAndTest) {
   // This test raises a set of exceptions and checks that the exception
diff --git a/libc/test/src/fenv/feclearexcept_test.cpp b/libc/test/src/fenv/feclearexcept_test.cpp
index fa3e856d1ba200..bb42d9070358ef 100644
--- a/libc/test/src/fenv/feclearexcept_test.cpp
+++ b/libc/test/src/fenv/feclearexcept_test.cpp
@@ -11,7 +11,7 @@
 #include "src/__support/FPUtil/FEnvImpl.h"
 #include "test/UnitTest/Test.h"
 
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 #include <stdint.h>
 
 TEST(LlvmLibcFEnvTest, ClearTest) {
diff --git a/libc/test/src/fenv/feenableexcept_test.cpp b/libc/test/src/fenv/feenableexcept_test.cpp
index 41c1945368ed5a..aeb4f955fd69b6 100644
--- a/libc/test/src/fenv/feenableexcept_test.cpp
+++ b/libc/test/src/fenv/feenableexcept_test.cpp
@@ -13,7 +13,7 @@
 
 #include "test/UnitTest/Test.h"
 
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 
 TEST(LlvmLibcFEnvTest, EnableTest) {
 #if defined(LIBC_TARGET_ARCH_IS_ANY_ARM) ||                                    \
diff --git a/libc/test/src/fenv/feholdexcept_test.cpp b/libc/test/src/fenv/feholdexcept_test.cpp
index 735c7705ff49c6..d1d76bcba78504 100644
--- a/libc/test/src/fenv/feholdexcept_test.cpp
+++ b/libc/test/src/fenv/feholdexcept_test.cpp
@@ -13,7 +13,7 @@
 #include "test/UnitTest/FPExceptMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 
 TEST(LlvmLibcFEnvTest, RaiseAndCrash) {
 #if defined(LIBC_TARGET_ARCH_IS_ANY_ARM) ||                                    \
diff --git a/libc/test/src/fenv/feupdateenv_test.cpp b/libc/test/src/fenv/feupdateenv_test.cpp
index 96f253f76077a0..f976d6827d229c 100644
--- a/libc/test/src/fenv/feupdateenv_test.cpp
+++ b/libc/test/src/fenv/feupdateenv_test.cpp
@@ -11,7 +11,7 @@
 #include "src/__support/FPUtil/FEnvImpl.h"
 #include "test/UnitTest/Test.h"
 
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 #include <signal.h>
 
 TEST(LlvmLibcFEnvTest, UpdateEnvTest) {
diff --git a/libc/test/src/fenv/getenv_and_setenv_test.cpp b/libc/test/src/fenv/getenv_and_setenv_test.cpp
index 8184a5c3bb9997..52930a26fdb5ab 100644
--- a/libc/test/src/fenv/getenv_and_setenv_test.cpp
+++ b/libc/test/src/fenv/getenv_and_setenv_test.cpp
@@ -14,7 +14,7 @@
 #include "src/__support/FPUtil/FEnvImpl.h"
 #include "test/UnitTest/Test.h"
 
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 
 TEST(LlvmLibcFenvTest, GetEnvAndSetEnv) {
   // We will disable all exceptions to prevent invocation of the exception
diff --git a/libc/test/src/fenv/rounding_mode_test.cpp b/libc/test/src/fenv/rounding_mode_test.cpp
index 4560160e8e2e9b..ec2e27ecc818b2 100644
--- a/libc/test/src/fenv/rounding_mode_test.cpp
+++ b/libc/test/src/fenv/rounding_mode_test.cpp
@@ -11,7 +11,7 @@
 
 #include "test/UnitTest/Test.h"
 
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 
 TEST(LlvmLibcRoundingModeTest, SetAndGet) {
   struct ResetDefaultRoundingMode {
diff --git a/libc/test/src/math/RIntTest.h b/libc/test/src/math/RIntTest.h
index 5be34bece54b6a..28e596ed0a9984 100644
--- a/libc/test/src/math/RIntTest.h
+++ b/libc/test/src/math/RIntTest.h
@@ -16,7 +16,7 @@
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
 #include "hdr/math_macros.h"
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 #include <stdio.h>
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
diff --git a/libc/test/src/math/smoke/NextTowardTest.h b/libc/test/src/math/smoke/NextTowardTest.h
index d97aea96d83781..6811685088060d 100644
--- a/libc/test/src/math/smoke/NextTowardTest.h
+++ b/libc/test/src/math/smoke/NextTowardTest.h
@@ -16,7 +16,7 @@
 #include "src/__support/FPUtil/FPBits.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 
 #define ASSERT_FP_EQ_WITH_EXCEPTION(result, expected, expected_exception)      \
   ASSERT_FP_EQ(result, expected);                                              \
diff --git a/libc/test/src/math/smoke/RIntTest.h b/libc/test/src/math/smoke/RIntTest.h
index 73c3428047e9dd..67894eb1e7fda2 100644
--- a/libc/test/src/math/smoke/RIntTest.h
+++ b/libc/test/src/math/smoke/RIntTest.h
@@ -15,7 +15,7 @@
 #include "test/UnitTest/Test.h"
 
 #include "hdr/math_macros.h"
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 #include <stdio.h>
 
 static constexpr int ROUNDING_MODES[4] = {FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO,
diff --git a/libc/utils/MPFRWrapper/MPFRUtils.cpp b/libc/utils/MPFRWrapper/MPFRUtils.cpp
index 91a623ddfa12c8..996756c2b89fc2 100644
--- a/libc/utils/MPFRWrapper/MPFRUtils.cpp
+++ b/libc/utils/MPFRWrapper/MPFRUtils.cpp
@@ -15,7 +15,7 @@
 #include "test/UnitTest/FPMatcher.h"
 
 #include "hdr/math_macros.h"
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
 #include <memory>
 #include <stdint.h>
 
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 1fb93cac42b932..642b329e46f55e 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -70,6 +70,12 @@ libc_support_library(
     deps = [":llvm_libc_macros_limits_macros"],
 )
 
+libc_support_library(
+    name = "llvm_libc_macros_fenv_macros",
+    hdrs = ["include/llvm-libc-macros/fenv-macros.h"],
+    deps = [":llvm_libc_macros_limits_macros"],
+)
+
 libc_support_library(
     name = "llvm_libc_macros_limits_macros",
     hdrs = ["include/llvm-libc-macros/limits-macros.h"],

>From 8fa32e24a14bba8b20e39d31a8226550d65a106d Mon Sep 17 00:00:00 2001
From: Job Hernandez <hj93 at protonmail.com>
Date: Sat, 6 Apr 2024 14:49:01 -0700
Subject: [PATCH 2/7] run the formatter

---
 libc/AOR_v20.02/math/test/mathtest.c               | 14 +++++++-------
 libc/AOR_v20.02/math/test/ulp.c                    |  4 ++--
 libc/src/__support/FPUtil/FEnvImpl.h               |  2 +-
 libc/src/__support/FPUtil/aarch64/FEnvImpl.h       |  2 +-
 .../__support/FPUtil/aarch64/fenv_darwin_impl.h    |  2 +-
 libc/test/src/math/RIntTest.h                      |  2 +-
 libc/test/src/math/smoke/NextTowardTest.h          |  2 +-
 libc/test/src/math/smoke/RIntTest.h                |  2 +-
 libc/utils/MPFRWrapper/MPFRUtils.cpp               |  2 +-
 9 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/libc/AOR_v20.02/math/test/mathtest.c b/libc/AOR_v20.02/math/test/mathtest.c
index 9ac5e191d2d396..1b601795b2944b 100644
--- a/libc/AOR_v20.02/math/test/mathtest.c
+++ b/libc/AOR_v20.02/math/test/mathtest.c
@@ -6,17 +6,17 @@
  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  */
 
+#include "hdr/fenv_macros.h"
+#include "mathlib.h"
 #include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <setjmp.h>
 #include <ctype.h>
-#include <math.h>
 #include <errno.h>
 #include <limits.h>
-#include "hdr/fenv_macros.h"
-#include "mathlib.h"
+#include <math.h>
+#include <setjmp.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
 #ifndef math_errhandling
 # define math_errhandling 0
diff --git a/libc/AOR_v20.02/math/test/ulp.c b/libc/AOR_v20.02/math/test/ulp.c
index 7a17228698bcf0..d0a97317d7b500 100644
--- a/libc/AOR_v20.02/math/test/ulp.c
+++ b/libc/AOR_v20.02/math/test/ulp.c
@@ -6,15 +6,15 @@
  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  */
 
-#include <ctype.h>
 #include "hdr/fenv_macros.h"
+#include "mathlib.h"
+#include <ctype.h>
 #include <float.h>
 #include <math.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include "mathlib.h"
 
 /* Don't depend on mpfr by default.  */
 #ifndef USE_MPFR
diff --git a/libc/src/__support/FPUtil/FEnvImpl.h b/libc/src/__support/FPUtil/FEnvImpl.h
index 04ab015a9ae6bc..6f9499858fadc1 100644
--- a/libc/src/__support/FPUtil/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/FEnvImpl.h
@@ -9,11 +9,11 @@
 #ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_FENVIMPL_H
 #define LLVM_LIBC_SRC___SUPPORT_FPUTIL_FENVIMPL_H
 
+#include "hdr/fenv_macros.h"
 #include "hdr/math_macros.h"
 #include "src/__support/macros/attributes.h" // LIBC_INLINE
 #include "src/__support/macros/properties/architectures.h"
 #include "src/errno/libc_errno.h"
-#include "hdr/fenv_macros.h"
 
 #if defined(LIBC_TARGET_ARCH_IS_AARCH64)
 #if defined(__APPLE__)
diff --git a/libc/src/__support/FPUtil/aarch64/FEnvImpl.h b/libc/src/__support/FPUtil/aarch64/FEnvImpl.h
index 05df87a6208e6e..6d1f829646c378 100644
--- a/libc/src/__support/FPUtil/aarch64/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/aarch64/FEnvImpl.h
@@ -16,8 +16,8 @@
 #error "Invalid include"
 #endif
 
-#include <arm_acle.h>
 #include "hdr/fenv_macros.h"
+#include <arm_acle.h>
 #include <stdint.h>
 
 #include "src/__support/FPUtil/FPBits.h"
diff --git a/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h b/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h
index 9e11390c9b60da..906efded528949 100644
--- a/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h
+++ b/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h
@@ -16,8 +16,8 @@
 #error "Invalid include"
 #endif
 
-#include <arm_acle.h>
 #include "hdr/fenv_macros.h"
+#include <arm_acle.h>
 #include <stdint.h>
 
 #include "src/__support/FPUtil/FPBits.h"
diff --git a/libc/test/src/math/RIntTest.h b/libc/test/src/math/RIntTest.h
index 28e596ed0a9984..c706ff18f186e5 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 "hdr/math_macros.h"
 #include "hdr/fenv_macros.h"
+#include "hdr/math_macros.h"
 #include <stdio.h>
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
diff --git a/libc/test/src/math/smoke/NextTowardTest.h b/libc/test/src/math/smoke/NextTowardTest.h
index 6811685088060d..b6c1c8d1797da6 100644
--- a/libc/test/src/math/smoke/NextTowardTest.h
+++ b/libc/test/src/math/smoke/NextTowardTest.h
@@ -9,6 +9,7 @@
 #ifndef LLVM_LIBC_TEST_SRC_MATH_NEXTTOWARDTEST_H
 #define LLVM_LIBC_TEST_SRC_MATH_NEXTTOWARDTEST_H
 
+#include "hdr/fenv_macros.h"
 #include "hdr/math_macros.h"
 #include "src/__support/CPP/bit.h"
 #include "src/__support/CPP/type_traits.h"
@@ -16,7 +17,6 @@
 #include "src/__support/FPUtil/FPBits.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
-#include "hdr/fenv_macros.h"
 
 #define ASSERT_FP_EQ_WITH_EXCEPTION(result, expected, expected_exception)      \
   ASSERT_FP_EQ(result, expected);                                              \
diff --git a/libc/test/src/math/smoke/RIntTest.h b/libc/test/src/math/smoke/RIntTest.h
index 67894eb1e7fda2..cbed9a3b10baab 100644
--- a/libc/test/src/math/smoke/RIntTest.h
+++ b/libc/test/src/math/smoke/RIntTest.h
@@ -14,8 +14,8 @@
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include "hdr/math_macros.h"
 #include "hdr/fenv_macros.h"
+#include "hdr/math_macros.h"
 #include <stdio.h>
 
 static constexpr int ROUNDING_MODES[4] = {FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO,
diff --git a/libc/utils/MPFRWrapper/MPFRUtils.cpp b/libc/utils/MPFRWrapper/MPFRUtils.cpp
index 996756c2b89fc2..349729368e5587 100644
--- a/libc/utils/MPFRWrapper/MPFRUtils.cpp
+++ b/libc/utils/MPFRWrapper/MPFRUtils.cpp
@@ -14,8 +14,8 @@
 #include "src/__support/FPUtil/fpbits_str.h"
 #include "test/UnitTest/FPMatcher.h"
 
-#include "hdr/math_macros.h"
 #include "hdr/fenv_macros.h"
+#include "hdr/math_macros.h"
 #include <memory>
 #include <stdint.h>
 

>From c23cbc4b8c3f0340a340463dfe0206e7a7544e41 Mon Sep 17 00:00:00 2001
From: Job Hernandez <hj93 at protonmail.com>
Date: Sat, 6 Apr 2024 18:13:50 -0700
Subject: [PATCH 3/7] address review

---
 libc/AOR_v20.02/math/test/mathtest.c                 | 2 +-
 libc/AOR_v20.02/math/test/ulp.c                      | 2 +-
 libc/config/baremetal/arm/headers.txt                | 2 +-
 libc/config/baremetal/riscv/headers.txt              | 2 +-
 libc/config/darwin/arm/headers.txt                   | 2 +-
 libc/config/darwin/x86_64/headers.txt                | 2 +-
 libc/config/gpu/headers.txt                          | 2 +-
 libc/config/linux/aarch64/headers.txt                | 2 +-
 libc/config/linux/arm/headers.txt                    | 2 +-
 libc/config/linux/riscv/headers.txt                  | 2 +-
 libc/config/linux/x86_64/headers.txt                 | 2 +-
 libc/src/__support/FPUtil/aarch64/FEnvImpl.h         | 2 +-
 libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h | 2 +-
 libc/src/__support/FPUtil/arm/FEnvImpl.h             | 1 -
 libc/src/__support/FPUtil/generic/CMakeLists.txt     | 1 -
 libc/src/__support/FPUtil/riscv/FEnvImpl.h           | 1 -
 libc/src/__support/FPUtil/rounding_mode.h            | 3 +--
 libc/src/fenv/fegetenv.h                             | 2 +-
 libc/src/fenv/fegetexceptflag.cpp                    | 2 +-
 libc/src/fenv/fegetexceptflag.h                      | 2 +-
 libc/src/fenv/feholdexcept.cpp                       | 3 +--
 libc/src/fenv/feholdexcept.h                         | 2 +-
 libc/src/fenv/fesetenv.h                             | 2 +-
 libc/src/fenv/fesetexceptflag.cpp                    | 3 +--
 libc/src/fenv/fesetexceptflag.h                      | 2 +-
 libc/src/fenv/feupdateenv.cpp                        | 2 +-
 libc/src/fenv/feupdateenv.h                          | 2 +-
 27 files changed, 24 insertions(+), 30 deletions(-)

diff --git a/libc/AOR_v20.02/math/test/mathtest.c b/libc/AOR_v20.02/math/test/mathtest.c
index 1b601795b2944b..5fa6a4b2b04b51 100644
--- a/libc/AOR_v20.02/math/test/mathtest.c
+++ b/libc/AOR_v20.02/math/test/mathtest.c
@@ -6,7 +6,7 @@
  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  */
 
-#include "hdr/fenv_macros.h"
+#include <fenv.h>
 #include "mathlib.h"
 #include <assert.h>
 #include <ctype.h>
diff --git a/libc/AOR_v20.02/math/test/ulp.c b/libc/AOR_v20.02/math/test/ulp.c
index d0a97317d7b500..d3446498a312b2 100644
--- a/libc/AOR_v20.02/math/test/ulp.c
+++ b/libc/AOR_v20.02/math/test/ulp.c
@@ -6,7 +6,7 @@
  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  */
 
-#include "hdr/fenv_macros.h"
+#include <fenv.h>
 #include "mathlib.h"
 #include <ctype.h>
 #include <float.h>
diff --git a/libc/config/baremetal/arm/headers.txt b/libc/config/baremetal/arm/headers.txt
index 42f3274bc72962..3608364e45bdeb 100644
--- a/libc/config/baremetal/arm/headers.txt
+++ b/libc/config/baremetal/arm/headers.txt
@@ -1,7 +1,7 @@
 set(TARGET_PUBLIC_HEADERS
     libc.include.assert
     libc.include.ctype
-    libc.hdr.fenv_macros
+    libc.include.fenv
     libc.include.errno
     libc.include.float
     libc.include.stdint
diff --git a/libc/config/baremetal/riscv/headers.txt b/libc/config/baremetal/riscv/headers.txt
index 42f3274bc72962..3608364e45bdeb 100644
--- a/libc/config/baremetal/riscv/headers.txt
+++ b/libc/config/baremetal/riscv/headers.txt
@@ -1,7 +1,7 @@
 set(TARGET_PUBLIC_HEADERS
     libc.include.assert
     libc.include.ctype
-    libc.hdr.fenv_macros
+    libc.include.fenv
     libc.include.errno
     libc.include.float
     libc.include.stdint
diff --git a/libc/config/darwin/arm/headers.txt b/libc/config/darwin/arm/headers.txt
index 29b397edd594d6..86e7145972324a 100644
--- a/libc/config/darwin/arm/headers.txt
+++ b/libc/config/darwin/arm/headers.txt
@@ -1,7 +1,7 @@
 set(TARGET_PUBLIC_HEADERS
     libc.include.ctype
     libc.include.errno
-    libc.hdr.fenv_macros
+    libc.include.fenv
     libc.include.float
     libc.include.stdint
     libc.include.inttypes
diff --git a/libc/config/darwin/x86_64/headers.txt b/libc/config/darwin/x86_64/headers.txt
index 69f7e88d550448..acd24026498774 100644
--- a/libc/config/darwin/x86_64/headers.txt
+++ b/libc/config/darwin/x86_64/headers.txt
@@ -2,7 +2,7 @@ set(TARGET_PUBLIC_HEADERS
     libc.include.ctype
     libc.include.errno
     # Fenv is currently disabled.
-    #libc.hdr.fenv_macros
+    #libc.include.fenv
     libc.include.float
     libc.include.stdint
     libc.include.inttypes
diff --git a/libc/config/gpu/headers.txt b/libc/config/gpu/headers.txt
index bf0b5cfb7b0348..dd16938da8a447 100644
--- a/libc/config/gpu/headers.txt
+++ b/libc/config/gpu/headers.txt
@@ -7,7 +7,7 @@ set(TARGET_PUBLIC_HEADERS
     libc.include.inttypes
     libc.include.limits
     libc.include.math
-    libc.hdr.fenv_macros
+    libc.include.fenv
     libc.include.time
     libc.include.errno
     libc.include.stdlib
diff --git a/libc/config/linux/aarch64/headers.txt b/libc/config/linux/aarch64/headers.txt
index fd72001965eef9..47db4434b09b33 100644
--- a/libc/config/linux/aarch64/headers.txt
+++ b/libc/config/linux/aarch64/headers.txt
@@ -3,7 +3,7 @@ set(TARGET_PUBLIC_HEADERS
     libc.include.ctype
     libc.include.errno
     libc.include.features
-    libc.hdr.fenv_macros
+    libc.include.fenv
     libc.include.float
     libc.include.stdint
     libc.include.inttypes
diff --git a/libc/config/linux/arm/headers.txt b/libc/config/linux/arm/headers.txt
index f1adb96052ca97..307bb6b146a4cc 100644
--- a/libc/config/linux/arm/headers.txt
+++ b/libc/config/linux/arm/headers.txt
@@ -1,6 +1,6 @@
 set(TARGET_PUBLIC_HEADERS
     libc.include.ctype
-    libc.hdr.fenv_macros
+    libc.include.fenv
     libc.include.errno
     libc.include.float
     libc.include.stdint
diff --git a/libc/config/linux/riscv/headers.txt b/libc/config/linux/riscv/headers.txt
index a4fc31bb368c27..c858bcc978d9da 100644
--- a/libc/config/linux/riscv/headers.txt
+++ b/libc/config/linux/riscv/headers.txt
@@ -5,7 +5,7 @@ set(TARGET_PUBLIC_HEADERS
     libc.include.errno
     libc.include.fcntl
     libc.include.features
-    libc.hdr.fenv_macros
+    libc.include.fenv
     libc.include.float
     libc.include.stdint
     libc.include.inttypes
diff --git a/libc/config/linux/x86_64/headers.txt b/libc/config/linux/x86_64/headers.txt
index 74878111621ea5..e51c7931942706 100644
--- a/libc/config/linux/x86_64/headers.txt
+++ b/libc/config/linux/x86_64/headers.txt
@@ -5,7 +5,7 @@ set(TARGET_PUBLIC_HEADERS
     libc.include.errno
     libc.include.fcntl
     libc.include.features
-    libc.hdr.fenv_macros
+    libc.include.fenv
     libc.include.float
     libc.include.stdint
     libc.include.inttypes
diff --git a/libc/src/__support/FPUtil/aarch64/FEnvImpl.h b/libc/src/__support/FPUtil/aarch64/FEnvImpl.h
index 6d1f829646c378..097f78c527b5bc 100644
--- a/libc/src/__support/FPUtil/aarch64/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/aarch64/FEnvImpl.h
@@ -16,10 +16,10 @@
 #error "Invalid include"
 #endif
 
-#include "hdr/fenv_macros.h"
 #include <arm_acle.h>
 #include <stdint.h>
 
+#include "hdr/fenv_macros.h"
 #include "src/__support/FPUtil/FPBits.h"
 
 namespace LIBC_NAMESPACE {
diff --git a/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h b/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h
index 906efded528949..97a68e077d7d5f 100644
--- a/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h
+++ b/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h
@@ -16,10 +16,10 @@
 #error "Invalid include"
 #endif
 
-#include "hdr/fenv_macros.h"
 #include <arm_acle.h>
 #include <stdint.h>
 
+#include "hdr/fenv_macros.h"
 #include "src/__support/FPUtil/FPBits.h"
 
 namespace LIBC_NAMESPACE {
diff --git a/libc/src/__support/FPUtil/arm/FEnvImpl.h b/libc/src/__support/FPUtil/arm/FEnvImpl.h
index 458f4abf278fc3..672c4792ed3f99 100644
--- a/libc/src/__support/FPUtil/arm/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/arm/FEnvImpl.h
@@ -11,7 +11,6 @@
 
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/macros/attributes.h" // For LIBC_INLINE
-
 #include "hdr/fenv_macros.h"
 #include <stdint.h>
 
diff --git a/libc/src/__support/FPUtil/generic/CMakeLists.txt b/libc/src/__support/FPUtil/generic/CMakeLists.txt
index 5c941a6f7e7076..cc93ddb58f9b23 100644
--- a/libc/src/__support/FPUtil/generic/CMakeLists.txt
+++ b/libc/src/__support/FPUtil/generic/CMakeLists.txt
@@ -4,7 +4,6 @@ add_header_library(
     sqrt.h
     sqrt_80_bit_long_double.h
   DEPENDS
-    libc.hdr.fenv_macros
     libc.src.__support.common
     libc.src.__support.CPP.bit
     libc.src.__support.CPP.type_traits
diff --git a/libc/src/__support/FPUtil/riscv/FEnvImpl.h b/libc/src/__support/FPUtil/riscv/FEnvImpl.h
index 2a2a18b7e98e45..09af58cafad071 100644
--- a/libc/src/__support/FPUtil/riscv/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/riscv/FEnvImpl.h
@@ -12,7 +12,6 @@
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/macros/attributes.h" // For LIBC_INLINE_ASM
 #include "src/__support/macros/config.h"     // For LIBC_INLINE
-
 #include "hdr/fenv_macros.h"
 #include <stdint.h>
 
diff --git a/libc/src/__support/FPUtil/rounding_mode.h b/libc/src/__support/FPUtil/rounding_mode.h
index 41f2803e0e8fb5..aa5e00fa560bc0 100644
--- a/libc/src/__support/FPUtil/rounding_mode.h
+++ b/libc/src/__support/FPUtil/rounding_mode.h
@@ -9,9 +9,8 @@
 #ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_ROUNDING_MODE_H
 #define LLVM_LIBC_SRC___SUPPORT_FPUTIL_ROUNDING_MODE_H
 
-#include "src/__support/macros/attributes.h" // LIBC_INLINE
-
 #include "hdr/fenv_macros.h"
+#include "src/__support/macros/attributes.h" // LIBC_INLINE
 
 namespace LIBC_NAMESPACE::fputil {
 
diff --git a/libc/src/fenv/fegetenv.h b/libc/src/fenv/fegetenv.h
index 479b87d554fac6..658316482984e1 100644
--- a/libc/src/fenv/fegetenv.h
+++ b/libc/src/fenv/fegetenv.h
@@ -9,7 +9,7 @@
 #ifndef LLVM_LIBC_SRC_FENV_FEGETENV_H
 #define LLVM_LIBC_SRC_FENV_FEGETENV_H
 
-#include "hdr/fenv_macros.h"
+#include <fenv.h>
 
 namespace LIBC_NAMESPACE {
 
diff --git a/libc/src/fenv/fegetexceptflag.cpp b/libc/src/fenv/fegetexceptflag.cpp
index 035303b079ab22..c6160da7afbde2 100644
--- a/libc/src/fenv/fegetexceptflag.cpp
+++ b/libc/src/fenv/fegetexceptflag.cpp
@@ -10,7 +10,7 @@
 #include "src/__support/FPUtil/FEnvImpl.h"
 #include "src/__support/common.h"
 
-#include "hdr/fenv_macros.h"
+#include <fenv.h>
 
 namespace LIBC_NAMESPACE {
 
diff --git a/libc/src/fenv/fegetexceptflag.h b/libc/src/fenv/fegetexceptflag.h
index 41c77ed7c98a72..ad72161e536f83 100644
--- a/libc/src/fenv/fegetexceptflag.h
+++ b/libc/src/fenv/fegetexceptflag.h
@@ -9,7 +9,7 @@
 #ifndef LLVM_LIBC_SRC_FENV_FEGETEXCEPTFLAG_H
 #define LLVM_LIBC_SRC_FENV_FEGETEXCEPTFLAG_H
 
-#include "hdr/fenv_macros.h"
+#include <fenv.h>
 
 namespace LIBC_NAMESPACE {
 
diff --git a/libc/src/fenv/feholdexcept.cpp b/libc/src/fenv/feholdexcept.cpp
index 5e8b78b295672a..f264c5ae251d33 100644
--- a/libc/src/fenv/feholdexcept.cpp
+++ b/libc/src/fenv/feholdexcept.cpp
@@ -9,8 +9,7 @@
 #include "src/fenv/feholdexcept.h"
 #include "src/__support/FPUtil/FEnvImpl.h"
 #include "src/__support/common.h"
-
-#include "hdr/fenv_macros.h"
+#include <fenv.h>
 
 namespace LIBC_NAMESPACE {
 
diff --git a/libc/src/fenv/feholdexcept.h b/libc/src/fenv/feholdexcept.h
index ef7d145f26e3f5..bbefc4ecbd41b2 100644
--- a/libc/src/fenv/feholdexcept.h
+++ b/libc/src/fenv/feholdexcept.h
@@ -9,7 +9,7 @@
 #ifndef LLVM_LIBC_SRC_FENV_FEHOLDEXCEPT_H
 #define LLVM_LIBC_SRC_FENV_FEHOLDEXCEPT_H
 
-#include "hdr/fenv_macros.h"
+#include <fenv.h>
 
 namespace LIBC_NAMESPACE {
 
diff --git a/libc/src/fenv/fesetenv.h b/libc/src/fenv/fesetenv.h
index 8591e65d86e15f..8b56bebc2e36d4 100644
--- a/libc/src/fenv/fesetenv.h
+++ b/libc/src/fenv/fesetenv.h
@@ -9,7 +9,7 @@
 #ifndef LLVM_LIBC_SRC_FENV_FESETENV_H
 #define LLVM_LIBC_SRC_FENV_FESETENV_H
 
-#include "hdr/fenv_macros.h"
+#include <fenv.h>
 
 namespace LIBC_NAMESPACE {
 
diff --git a/libc/src/fenv/fesetexceptflag.cpp b/libc/src/fenv/fesetexceptflag.cpp
index 58c10ba97a141b..3ff8e270dc0a74 100644
--- a/libc/src/fenv/fesetexceptflag.cpp
+++ b/libc/src/fenv/fesetexceptflag.cpp
@@ -9,8 +9,7 @@
 #include "src/fenv/fesetexceptflag.h"
 #include "src/__support/FPUtil/FEnvImpl.h"
 #include "src/__support/common.h"
-
-#include "hdr/fenv_macros.h"
+#include <fenv.h>
 
 namespace LIBC_NAMESPACE {
 
diff --git a/libc/src/fenv/fesetexceptflag.h b/libc/src/fenv/fesetexceptflag.h
index a91abe0d6aa7c5..15e62eda1b840c 100644
--- a/libc/src/fenv/fesetexceptflag.h
+++ b/libc/src/fenv/fesetexceptflag.h
@@ -9,7 +9,7 @@
 #ifndef LLVM_LIBC_SRC_FENV_FESETEXCEPTFLAG_H
 #define LLVM_LIBC_SRC_FENV_FESETEXCEPTFLAG_H
 
-#include "hdr/fenv_macros.h"
+#include <fenv.h>
 
 namespace LIBC_NAMESPACE {
 
diff --git a/libc/src/fenv/feupdateenv.cpp b/libc/src/fenv/feupdateenv.cpp
index 72bc14bd50a74a..7e81b9476da91b 100644
--- a/libc/src/fenv/feupdateenv.cpp
+++ b/libc/src/fenv/feupdateenv.cpp
@@ -10,7 +10,7 @@
 #include "src/__support/FPUtil/FEnvImpl.h"
 #include "src/__support/common.h"
 
-#include "hdr/fenv_macros.h"
+#include <fenv.h>
 
 namespace LIBC_NAMESPACE {
 
diff --git a/libc/src/fenv/feupdateenv.h b/libc/src/fenv/feupdateenv.h
index a925d862f984bb..294c041ddeae79 100644
--- a/libc/src/fenv/feupdateenv.h
+++ b/libc/src/fenv/feupdateenv.h
@@ -9,7 +9,7 @@
 #ifndef LLVM_LIBC_SRC_FENV_FEUPDATEENV_H
 #define LLVM_LIBC_SRC_FENV_FEUPDATEENV_H
 
-#include "hdr/fenv_macros.h"
+#include <fenv.h>
 
 namespace LIBC_NAMESPACE {
 

>From 6021334d55a334f23241dbd3cffadaae145425b6 Mon Sep 17 00:00:00 2001
From: Job Hernandez <hj93 at protonmail.com>
Date: Sat, 6 Apr 2024 18:14:32 -0700
Subject: [PATCH 4/7] format code

---
 libc/AOR_v20.02/math/test/mathtest.c       | 2 +-
 libc/AOR_v20.02/math/test/ulp.c            | 2 +-
 libc/src/__support/FPUtil/arm/FEnvImpl.h   | 2 +-
 libc/src/__support/FPUtil/riscv/FEnvImpl.h | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libc/AOR_v20.02/math/test/mathtest.c b/libc/AOR_v20.02/math/test/mathtest.c
index 5fa6a4b2b04b51..01ace9f7afec2f 100644
--- a/libc/AOR_v20.02/math/test/mathtest.c
+++ b/libc/AOR_v20.02/math/test/mathtest.c
@@ -6,11 +6,11 @@
  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  */
 
-#include <fenv.h>
 #include "mathlib.h"
 #include <assert.h>
 #include <ctype.h>
 #include <errno.h>
+#include <fenv.h>
 #include <limits.h>
 #include <math.h>
 #include <setjmp.h>
diff --git a/libc/AOR_v20.02/math/test/ulp.c b/libc/AOR_v20.02/math/test/ulp.c
index d3446498a312b2..f74d5fa6a8e76d 100644
--- a/libc/AOR_v20.02/math/test/ulp.c
+++ b/libc/AOR_v20.02/math/test/ulp.c
@@ -6,9 +6,9 @@
  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  */
 
-#include <fenv.h>
 #include "mathlib.h"
 #include <ctype.h>
+#include <fenv.h>
 #include <float.h>
 #include <math.h>
 #include <stdint.h>
diff --git a/libc/src/__support/FPUtil/arm/FEnvImpl.h b/libc/src/__support/FPUtil/arm/FEnvImpl.h
index 672c4792ed3f99..e2f9781600dbad 100644
--- a/libc/src/__support/FPUtil/arm/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/arm/FEnvImpl.h
@@ -9,9 +9,9 @@
 #ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_ARM_FENVIMPL_H
 #define LLVM_LIBC_SRC___SUPPORT_FPUTIL_ARM_FENVIMPL_H
 
+#include "hdr/fenv_macros.h"
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/macros/attributes.h" // For LIBC_INLINE
-#include "hdr/fenv_macros.h"
 #include <stdint.h>
 
 namespace LIBC_NAMESPACE {
diff --git a/libc/src/__support/FPUtil/riscv/FEnvImpl.h b/libc/src/__support/FPUtil/riscv/FEnvImpl.h
index 09af58cafad071..3ea3a3077eb071 100644
--- a/libc/src/__support/FPUtil/riscv/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/riscv/FEnvImpl.h
@@ -9,10 +9,10 @@
 #ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_RISCV_FENVIMPL_H
 #define LLVM_LIBC_SRC___SUPPORT_FPUTIL_RISCV_FENVIMPL_H
 
+#include "hdr/fenv_macros.h"
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/macros/attributes.h" // For LIBC_INLINE_ASM
 #include "src/__support/macros/config.h"     // For LIBC_INLINE
-#include "hdr/fenv_macros.h"
 #include <stdint.h>
 
 namespace LIBC_NAMESPACE {

>From 9d056ec4bd43de099058674d96d18a865b47eeef Mon Sep 17 00:00:00 2001
From: Job Hernandez <hj93 at protonmail.com>
Date: Sat, 6 Apr 2024 22:09:17 -0700
Subject: [PATCH 5/7] address review

---
 libc/src/__support/FPUtil/CMakeLists.txt             | 2 +-
 libc/src/__support/FPUtil/FEnvImpl.h                 | 2 +-
 libc/src/__support/FPUtil/aarch64/FEnvImpl.h         | 2 +-
 libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h | 2 +-
 libc/src/__support/FPUtil/arm/FEnvImpl.h             | 2 +-
 libc/src/__support/FPUtil/riscv/FEnvImpl.h           | 2 +-
 libc/src/__support/FPUtil/x86_64/FEnvImpl.h          | 2 +-
 libc/test/UnitTest/FPExceptMatcher.cpp               | 2 +-
 libc/test/src/fenv/exception_flags_test.cpp          | 2 +-
 libc/test/src/fenv/feholdexcept_test.cpp             | 2 +-
 libc/test/src/fenv/feupdateenv_test.cpp              | 2 +-
 libc/test/src/fenv/getenv_and_setenv_test.cpp        | 2 +-
 libc/utils/MPFRWrapper/MPFRUtils.cpp                 | 1 -
 13 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/libc/src/__support/FPUtil/CMakeLists.txt b/libc/src/__support/FPUtil/CMakeLists.txt
index 4c0885ff756ecd..67d468efac4467 100644
--- a/libc/src/__support/FPUtil/CMakeLists.txt
+++ b/libc/src/__support/FPUtil/CMakeLists.txt
@@ -3,7 +3,7 @@ add_header_library(
   HDRS
     FEnvImpl.h
   DEPENDS
-    libc.hdr.fenv_macros
+    libc.include.fenv 
     libc.hdr.math_macros
     libc.src.__support.macros.attributes
     libc.src.errno.errno
diff --git a/libc/src/__support/FPUtil/FEnvImpl.h b/libc/src/__support/FPUtil/FEnvImpl.h
index 6f9499858fadc1..4be1a57f0f4b38 100644
--- a/libc/src/__support/FPUtil/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/FEnvImpl.h
@@ -9,11 +9,11 @@
 #ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_FENVIMPL_H
 #define LLVM_LIBC_SRC___SUPPORT_FPUTIL_FENVIMPL_H
 
-#include "hdr/fenv_macros.h"
 #include "hdr/math_macros.h"
 #include "src/__support/macros/attributes.h" // LIBC_INLINE
 #include "src/__support/macros/properties/architectures.h"
 #include "src/errno/libc_errno.h"
+#include <fenv.h>
 
 #if defined(LIBC_TARGET_ARCH_IS_AARCH64)
 #if defined(__APPLE__)
diff --git a/libc/src/__support/FPUtil/aarch64/FEnvImpl.h b/libc/src/__support/FPUtil/aarch64/FEnvImpl.h
index 097f78c527b5bc..c0ac2298b3c2d2 100644
--- a/libc/src/__support/FPUtil/aarch64/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/aarch64/FEnvImpl.h
@@ -19,7 +19,7 @@
 #include <arm_acle.h>
 #include <stdint.h>
 
-#include "hdr/fenv_macros.h"
+#include <fenv.h>
 #include "src/__support/FPUtil/FPBits.h"
 
 namespace LIBC_NAMESPACE {
diff --git a/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h b/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h
index 97a68e077d7d5f..827f5c1f467142 100644
--- a/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h
+++ b/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h
@@ -19,7 +19,7 @@
 #include <arm_acle.h>
 #include <stdint.h>
 
-#include "hdr/fenv_macros.h"
+#include <fenv.h>
 #include "src/__support/FPUtil/FPBits.h"
 
 namespace LIBC_NAMESPACE {
diff --git a/libc/src/__support/FPUtil/arm/FEnvImpl.h b/libc/src/__support/FPUtil/arm/FEnvImpl.h
index e2f9781600dbad..6535e2d55c6131 100644
--- a/libc/src/__support/FPUtil/arm/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/arm/FEnvImpl.h
@@ -9,10 +9,10 @@
 #ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_ARM_FENVIMPL_H
 #define LLVM_LIBC_SRC___SUPPORT_FPUTIL_ARM_FENVIMPL_H
 
-#include "hdr/fenv_macros.h"
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/macros/attributes.h" // For LIBC_INLINE
 #include <stdint.h>
+#include <fenv.h>
 
 namespace LIBC_NAMESPACE {
 namespace fputil {
diff --git a/libc/src/__support/FPUtil/riscv/FEnvImpl.h b/libc/src/__support/FPUtil/riscv/FEnvImpl.h
index 3ea3a3077eb071..592ede437a0ac4 100644
--- a/libc/src/__support/FPUtil/riscv/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/riscv/FEnvImpl.h
@@ -9,10 +9,10 @@
 #ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_RISCV_FENVIMPL_H
 #define LLVM_LIBC_SRC___SUPPORT_FPUTIL_RISCV_FENVIMPL_H
 
-#include "hdr/fenv_macros.h"
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/macros/attributes.h" // For LIBC_INLINE_ASM
 #include "src/__support/macros/config.h"     // For LIBC_INLINE
+#include <fenv.h>
 #include <stdint.h>
 
 namespace LIBC_NAMESPACE {
diff --git a/libc/src/__support/FPUtil/x86_64/FEnvImpl.h b/libc/src/__support/FPUtil/x86_64/FEnvImpl.h
index 5833d9c8deb50e..b73b70e907790f 100644
--- a/libc/src/__support/FPUtil/x86_64/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/x86_64/FEnvImpl.h
@@ -16,7 +16,7 @@
 #error "Invalid include"
 #endif
 
-#include "hdr/fenv_macros.h"
+#include <fenv.h>
 #include <stdint.h>
 
 #include "src/__support/macros/sanitizer.h"
diff --git a/libc/test/UnitTest/FPExceptMatcher.cpp b/libc/test/UnitTest/FPExceptMatcher.cpp
index 965059faf7eba0..1601b7e53f2be1 100644
--- a/libc/test/UnitTest/FPExceptMatcher.cpp
+++ b/libc/test/UnitTest/FPExceptMatcher.cpp
@@ -8,7 +8,7 @@
 
 #include "FPExceptMatcher.h"
 
-#include "hdr/fenv_macros.h"
+#include <fenv.h>
 #include <memory>
 #include <setjmp.h>
 #include <signal.h>
diff --git a/libc/test/src/fenv/exception_flags_test.cpp b/libc/test/src/fenv/exception_flags_test.cpp
index d62aaa00c26b03..434adc06b1a36a 100644
--- a/libc/test/src/fenv/exception_flags_test.cpp
+++ b/libc/test/src/fenv/exception_flags_test.cpp
@@ -12,7 +12,7 @@
 #include "src/__support/FPUtil/FEnvImpl.h"
 #include "test/UnitTest/Test.h"
 
-#include "hdr/fenv_macros.h"
+#include <fenv.h>
 
 TEST(LlvmLibcFenvTest, GetExceptFlagAndSetExceptFlag) {
   // We will disable all exceptions to prevent invocation of the exception
diff --git a/libc/test/src/fenv/feholdexcept_test.cpp b/libc/test/src/fenv/feholdexcept_test.cpp
index d1d76bcba78504..735c7705ff49c6 100644
--- a/libc/test/src/fenv/feholdexcept_test.cpp
+++ b/libc/test/src/fenv/feholdexcept_test.cpp
@@ -13,7 +13,7 @@
 #include "test/UnitTest/FPExceptMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include "hdr/fenv_macros.h"
+#include <fenv.h>
 
 TEST(LlvmLibcFEnvTest, RaiseAndCrash) {
 #if defined(LIBC_TARGET_ARCH_IS_ANY_ARM) ||                                    \
diff --git a/libc/test/src/fenv/feupdateenv_test.cpp b/libc/test/src/fenv/feupdateenv_test.cpp
index f976d6827d229c..96f253f76077a0 100644
--- a/libc/test/src/fenv/feupdateenv_test.cpp
+++ b/libc/test/src/fenv/feupdateenv_test.cpp
@@ -11,7 +11,7 @@
 #include "src/__support/FPUtil/FEnvImpl.h"
 #include "test/UnitTest/Test.h"
 
-#include "hdr/fenv_macros.h"
+#include <fenv.h>
 #include <signal.h>
 
 TEST(LlvmLibcFEnvTest, UpdateEnvTest) {
diff --git a/libc/test/src/fenv/getenv_and_setenv_test.cpp b/libc/test/src/fenv/getenv_and_setenv_test.cpp
index 52930a26fdb5ab..8184a5c3bb9997 100644
--- a/libc/test/src/fenv/getenv_and_setenv_test.cpp
+++ b/libc/test/src/fenv/getenv_and_setenv_test.cpp
@@ -14,7 +14,7 @@
 #include "src/__support/FPUtil/FEnvImpl.h"
 #include "test/UnitTest/Test.h"
 
-#include "hdr/fenv_macros.h"
+#include <fenv.h>
 
 TEST(LlvmLibcFenvTest, GetEnvAndSetEnv) {
   // We will disable all exceptions to prevent invocation of the exception
diff --git a/libc/utils/MPFRWrapper/MPFRUtils.cpp b/libc/utils/MPFRWrapper/MPFRUtils.cpp
index 349729368e5587..18a8ac044a9bbd 100644
--- a/libc/utils/MPFRWrapper/MPFRUtils.cpp
+++ b/libc/utils/MPFRWrapper/MPFRUtils.cpp
@@ -14,7 +14,6 @@
 #include "src/__support/FPUtil/fpbits_str.h"
 #include "test/UnitTest/FPMatcher.h"
 
-#include "hdr/fenv_macros.h"
 #include "hdr/math_macros.h"
 #include <memory>
 #include <stdint.h>

>From 81f88f4fd9824b2e5d51040d15bd650a669d5e6b Mon Sep 17 00:00:00 2001
From: Job Hernandez <hj93 at protonmail.com>
Date: Sat, 6 Apr 2024 22:10:19 -0700
Subject: [PATCH 6/7] format code

---
 libc/src/__support/FPUtil/aarch64/FEnvImpl.h         | 2 +-
 libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h | 2 +-
 libc/src/__support/FPUtil/arm/FEnvImpl.h             | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libc/src/__support/FPUtil/aarch64/FEnvImpl.h b/libc/src/__support/FPUtil/aarch64/FEnvImpl.h
index c0ac2298b3c2d2..cb959d6a001c95 100644
--- a/libc/src/__support/FPUtil/aarch64/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/aarch64/FEnvImpl.h
@@ -19,8 +19,8 @@
 #include <arm_acle.h>
 #include <stdint.h>
 
-#include <fenv.h>
 #include "src/__support/FPUtil/FPBits.h"
+#include <fenv.h>
 
 namespace LIBC_NAMESPACE {
 namespace fputil {
diff --git a/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h b/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h
index 827f5c1f467142..f26f13b0bbff76 100644
--- a/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h
+++ b/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h
@@ -19,8 +19,8 @@
 #include <arm_acle.h>
 #include <stdint.h>
 
-#include <fenv.h>
 #include "src/__support/FPUtil/FPBits.h"
+#include <fenv.h>
 
 namespace LIBC_NAMESPACE {
 namespace fputil {
diff --git a/libc/src/__support/FPUtil/arm/FEnvImpl.h b/libc/src/__support/FPUtil/arm/FEnvImpl.h
index 6535e2d55c6131..976f9b30a0b41e 100644
--- a/libc/src/__support/FPUtil/arm/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/arm/FEnvImpl.h
@@ -11,8 +11,8 @@
 
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/macros/attributes.h" // For LIBC_INLINE
-#include <stdint.h>
 #include <fenv.h>
+#include <stdint.h>
 
 namespace LIBC_NAMESPACE {
 namespace fputil {

>From 336516e9623f48dee6ba65d18e8fd299d4ea74ab Mon Sep 17 00:00:00 2001
From: Job Hernandez <hj93 at protonmail.com>
Date: Sun, 7 Apr 2024 14:11:49 -0700
Subject: [PATCH 7/7] address review

---
 libc/AOR_v20.02/math/test/mathtest.c                 |  1 -
 libc/AOR_v20.02/math/test/ulp.c                      |  1 -
 libc/hdr/CMakeLists.txt                              |  2 +-
 libc/hdr/fenv_macros.h                               |  2 +-
 libc/src/__support/FPUtil/CMakeLists.txt             |  3 ++-
 libc/src/__support/FPUtil/aarch64/FEnvImpl.h         |  1 +
 libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h |  1 +
 libc/src/__support/FPUtil/arm/FEnvImpl.h             |  1 +
 libc/src/__support/FPUtil/riscv/FEnvImpl.h           |  1 +
 libc/src/fenv/CMakeLists.txt                         |  2 +-
 utils/bazel/llvm-project-overlay/libc/BUILD.bazel    | 11 ++++-------
 11 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/libc/AOR_v20.02/math/test/mathtest.c b/libc/AOR_v20.02/math/test/mathtest.c
index 01ace9f7afec2f..84ae0441ba35b6 100644
--- a/libc/AOR_v20.02/math/test/mathtest.c
+++ b/libc/AOR_v20.02/math/test/mathtest.c
@@ -6,7 +6,6 @@
  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  */
 
-#include "mathlib.h"
 #include <assert.h>
 #include <ctype.h>
 #include <errno.h>
diff --git a/libc/AOR_v20.02/math/test/ulp.c b/libc/AOR_v20.02/math/test/ulp.c
index f74d5fa6a8e76d..913b396f4bc959 100644
--- a/libc/AOR_v20.02/math/test/ulp.c
+++ b/libc/AOR_v20.02/math/test/ulp.c
@@ -6,7 +6,6 @@
  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  */
 
-#include "mathlib.h"
 #include <ctype.h>
 #include <fenv.h>
 #include <float.h>
diff --git a/libc/hdr/CMakeLists.txt b/libc/hdr/CMakeLists.txt
index ff95a49e29b2f7..4ca7db5e98d607 100644
--- a/libc/hdr/CMakeLists.txt
+++ b/libc/hdr/CMakeLists.txt
@@ -38,5 +38,5 @@ add_proxy_header_library(
     fenv_macros.h
   FULL_BUILD_DEPENDS
     libc.include.llvm-libc-macros.fenv_macros
-    libc.hdr.fenv_macros
+    libc.incude.fenv
 )
diff --git a/libc/hdr/fenv_macros.h b/libc/hdr/fenv_macros.h
index 23b1ebed3c2871..1ad28cc278a97b 100644
--- a/libc/hdr/fenv_macros.h
+++ b/libc/hdr/fenv_macros.h
@@ -11,7 +11,7 @@
 
 #ifdef LIBC_FULL_BUILD
 
-#include "libc/include/llvm-libc-macros/fenv-macros.h"
+#include "include/llvm-libc-macros/fenv-macros.h"
 
 #else // Overlay mode
 
diff --git a/libc/src/__support/FPUtil/CMakeLists.txt b/libc/src/__support/FPUtil/CMakeLists.txt
index 67d468efac4467..a10c3c0dc491ac 100644
--- a/libc/src/__support/FPUtil/CMakeLists.txt
+++ b/libc/src/__support/FPUtil/CMakeLists.txt
@@ -3,7 +3,8 @@ add_header_library(
   HDRS
     FEnvImpl.h
   DEPENDS
-    libc.include.fenv 
+    libc.include.fenv
+    libc.hdr.fenv_macros
     libc.hdr.math_macros
     libc.src.__support.macros.attributes
     libc.src.errno.errno
diff --git a/libc/src/__support/FPUtil/aarch64/FEnvImpl.h b/libc/src/__support/FPUtil/aarch64/FEnvImpl.h
index cb959d6a001c95..e8857f524e575f 100644
--- a/libc/src/__support/FPUtil/aarch64/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/aarch64/FEnvImpl.h
@@ -21,6 +21,7 @@
 
 #include "src/__support/FPUtil/FPBits.h"
 #include <fenv.h>
+#include "hdr/fenv_macros.h"
 
 namespace LIBC_NAMESPACE {
 namespace fputil {
diff --git a/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h b/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h
index f26f13b0bbff76..7101e329fab8c9 100644
--- a/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h
+++ b/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h
@@ -20,6 +20,7 @@
 #include <stdint.h>
 
 #include "src/__support/FPUtil/FPBits.h"
+#include "hdr/fenv_macros.h"
 #include <fenv.h>
 
 namespace LIBC_NAMESPACE {
diff --git a/libc/src/__support/FPUtil/arm/FEnvImpl.h b/libc/src/__support/FPUtil/arm/FEnvImpl.h
index 976f9b30a0b41e..54c8506804cb9e 100644
--- a/libc/src/__support/FPUtil/arm/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/arm/FEnvImpl.h
@@ -11,6 +11,7 @@
 
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/macros/attributes.h" // For LIBC_INLINE
+#include "hdr/fenv_macros.h"
 #include <fenv.h>
 #include <stdint.h>
 
diff --git a/libc/src/__support/FPUtil/riscv/FEnvImpl.h b/libc/src/__support/FPUtil/riscv/FEnvImpl.h
index 592ede437a0ac4..49164c5f0c4061 100644
--- a/libc/src/__support/FPUtil/riscv/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/riscv/FEnvImpl.h
@@ -12,6 +12,7 @@
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/macros/attributes.h" // For LIBC_INLINE_ASM
 #include "src/__support/macros/config.h"     // For LIBC_INLINE
+#include "hdr/fenv_macros.h"
 #include <fenv.h>
 #include <stdint.h>
 
diff --git a/libc/src/fenv/CMakeLists.txt b/libc/src/fenv/CMakeLists.txt
index 965a783055add5..5dcf21de04f1a0 100644
--- a/libc/src/fenv/CMakeLists.txt
+++ b/libc/src/fenv/CMakeLists.txt
@@ -5,7 +5,7 @@ add_entrypoint_object(
   HDRS
     fegetround.h
   DEPENDS
-    libc.hdr.fenv_macros
+    libc.include.fenv
     libc.src.__support.FPUtil.fenv_impl
   COMPILE_OPTIONS
     -O2
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 642b329e46f55e..3cf81cac1697ff 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -70,12 +70,6 @@ libc_support_library(
     deps = [":llvm_libc_macros_limits_macros"],
 )
 
-libc_support_library(
-    name = "llvm_libc_macros_fenv_macros",
-    hdrs = ["include/llvm-libc-macros/fenv-macros.h"],
-    deps = [":llvm_libc_macros_limits_macros"],
-)
-
 libc_support_library(
     name = "llvm_libc_macros_limits_macros",
     hdrs = ["include/llvm-libc-macros/limits-macros.h"],
@@ -119,7 +113,10 @@ libc_support_library(
     hdrs = ["hdr/math_macros.h"],
 )
 
-
+libc_support_library(
+    name = "hdr_fenv_macros",
+    hdrs = ["hdr/fenv_macros.h"],
+)
 ############################### Support libraries ##############################
 
 libc_support_library(



More information about the llvm-commits mailing list