Skip to content

Commit 4956118

Browse files
author
Job Henandez Lara
authored
[libc] Add proxy header for fenv.h macro constants. #87863 (#87896)
Hello, this addresses #87863.
1 parent 9e418c9 commit 4956118

29 files changed

+77
-33
lines changed

libc/hdr/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,12 @@ add_proxy_header_library(
3131
libc.include.llvm-libc-macros.math_macros
3232
libc.include.math
3333
)
34+
35+
add_proxy_header_library(
36+
fenv_macros
37+
HDRS
38+
fenv_macros.h
39+
FULL_BUILD_DEPENDS
40+
libc.include.llvm-libc-macros.fenv_macros
41+
libc.incude.fenv
42+
)

libc/hdr/fenv_macros.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===-- Definition of macros from fenv.h ----------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIBC_HDR_FENV_MACROS_H
10+
#define LLVM_LIBC_HDR_FENV_MACROS_H
11+
12+
#ifdef LIBC_FULL_BUILD
13+
14+
#include "include/llvm-libc-macros/fenv-macros.h"
15+
16+
#else // Overlay mode
17+
18+
#include <fenv.h>
19+
20+
#endif // LLVM_LIBC_FULL_BUILD
21+
22+
#endif // LLVM_LIBC_HDR_FENV_MACROS_H

libc/src/__support/FPUtil/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ add_header_library(
44
FEnvImpl.h
55
DEPENDS
66
libc.include.fenv
7+
libc.hdr.fenv_macros
78
libc.hdr.math_macros
89
libc.src.__support.macros.attributes
910
libc.src.errno.errno
@@ -14,7 +15,7 @@ add_header_library(
1415
HDRS
1516
rounding_mode.h
1617
DEPENDS
17-
libc.include.fenv
18+
libc.hdr.fenv_macros
1819
libc.src.__support.macros.attributes
1920
libc.src.__support.macros.properties.architectures
2021
libc.src.__support.macros.sanitizer

libc/src/__support/FPUtil/aarch64/FEnvImpl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <fenv.h>
2121
#include <stdint.h>
2222

23+
#include "hdr/fenv_macros.h"
2324
#include "src/__support/FPUtil/FPBits.h"
2425

2526
namespace LIBC_NAMESPACE {

libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <fenv.h>
2121
#include <stdint.h>
2222

23+
#include "hdr/fenv_macros.h"
2324
#include "src/__support/FPUtil/FPBits.h"
2425

2526
namespace LIBC_NAMESPACE {

libc/src/__support/FPUtil/arm/FEnvImpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
#ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_ARM_FENVIMPL_H
1010
#define LLVM_LIBC_SRC___SUPPORT_FPUTIL_ARM_FENVIMPL_H
1111

12+
#include "hdr/fenv_macros.h"
1213
#include "src/__support/FPUtil/FPBits.h"
1314
#include "src/__support/macros/attributes.h" // For LIBC_INLINE
14-
1515
#include <fenv.h>
1616
#include <stdint.h>
1717

libc/src/__support/FPUtil/generic/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ add_header_library(
44
sqrt.h
55
sqrt_80_bit_long_double.h
66
DEPENDS
7-
libc.include.fenv
87
libc.src.__support.common
98
libc.src.__support.CPP.bit
109
libc.src.__support.CPP.type_traits

libc/src/__support/FPUtil/riscv/FEnvImpl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_RISCV_FENVIMPL_H
1010
#define LLVM_LIBC_SRC___SUPPORT_FPUTIL_RISCV_FENVIMPL_H
1111

12+
#include "hdr/fenv_macros.h"
1213
#include "src/__support/FPUtil/FPBits.h"
1314
#include "src/__support/macros/attributes.h" // For LIBC_INLINE_ASM
1415
#include "src/__support/macros/config.h" // For LIBC_INLINE

libc/src/__support/FPUtil/rounding_mode.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
#ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_ROUNDING_MODE_H
1010
#define LLVM_LIBC_SRC___SUPPORT_FPUTIL_ROUNDING_MODE_H
1111

12+
#include "hdr/fenv_macros.h"
1213
#include "src/__support/macros/attributes.h" // LIBC_INLINE
1314

14-
#include <fenv.h>
15-
1615
namespace LIBC_NAMESPACE::fputil {
1716

1817
// Quick free-standing test whether fegetround() == FE_UPWARD.

libc/src/fenv/CMakeLists.txt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ add_entrypoint_object(
1818
HDRS
1919
fesetround.h
2020
DEPENDS
21-
libc.include.fenv
21+
libc.hdr.fenv_macros
2222
libc.src.__support.FPUtil.fenv_impl
2323
COMPILE_OPTIONS
2424
-O2
@@ -31,7 +31,7 @@ add_entrypoint_object(
3131
HDRS
3232
feclearexcept.h
3333
DEPENDS
34-
libc.include.fenv
34+
libc.hdr.fenv_macros
3535
libc.src.__support.FPUtil.fenv_impl
3636
COMPILE_OPTIONS
3737
-O2
@@ -44,7 +44,7 @@ add_entrypoint_object(
4444
HDRS
4545
feraiseexcept.h
4646
DEPENDS
47-
libc.include.fenv
47+
libc.hdr.fenv_macros
4848
libc.src.__support.FPUtil.fenv_impl
4949
COMPILE_OPTIONS
5050
-O2
@@ -57,7 +57,7 @@ add_entrypoint_object(
5757
HDRS
5858
fetestexcept.h
5959
DEPENDS
60-
libc.include.fenv
60+
libc.hdr.fenv_macros
6161
libc.src.__support.FPUtil.fenv_impl
6262
COMPILE_OPTIONS
6363
-O2
@@ -70,7 +70,7 @@ add_entrypoint_object(
7070
HDRS
7171
fegetenv.h
7272
DEPENDS
73-
libc.include.fenv
73+
libc.hdr.fenv_macros
7474
libc.src.__support.FPUtil.fenv_impl
7575
COMPILE_OPTIONS
7676
-O2
@@ -83,7 +83,7 @@ add_entrypoint_object(
8383
HDRS
8484
fesetenv.h
8585
DEPENDS
86-
libc.include.fenv
86+
libc.hdr.fenv_macros
8787
libc.src.__support.FPUtil.fenv_impl
8888
COMPILE_OPTIONS
8989
-O2
@@ -96,7 +96,7 @@ add_entrypoint_object(
9696
HDRS
9797
fegetexceptflag.h
9898
DEPENDS
99-
libc.include.fenv
99+
libc.hdr.fenv_macros
100100
libc.src.__support.FPUtil.fenv_impl
101101
COMPILE_OPTIONS
102102
-O2
@@ -109,7 +109,7 @@ add_entrypoint_object(
109109
HDRS
110110
fesetexcept.h
111111
DEPENDS
112-
libc.include.fenv
112+
libc.hdr.fenv_macros
113113
libc.src.__support.FPUtil.fenv_impl
114114
COMPILE_OPTIONS
115115
-O2
@@ -122,7 +122,7 @@ add_entrypoint_object(
122122
HDRS
123123
fesetexceptflag.h
124124
DEPENDS
125-
libc.include.fenv
125+
libc.hdr.fenv_macros
126126
libc.src.__support.FPUtil.fenv_impl
127127
COMPILE_OPTIONS
128128
-O2
@@ -135,7 +135,7 @@ add_entrypoint_object(
135135
HDRS
136136
feholdexcept.h
137137
DEPENDS
138-
libc.include.fenv
138+
libc.hdr.fenv_macros
139139
libc.src.__support.FPUtil.fenv_impl
140140
COMPILE_OPTIONS
141141
-O2
@@ -148,7 +148,7 @@ add_entrypoint_object(
148148
HDRS
149149
feupdateenv.h
150150
DEPENDS
151-
libc.include.fenv
151+
libc.hdr.fenv_macros
152152
libc.src.__support.FPUtil.fenv_impl
153153
COMPILE_OPTIONS
154154
-O2
@@ -161,7 +161,7 @@ add_entrypoint_object(
161161
HDRS
162162
feenableexcept.h
163163
DEPENDS
164-
libc.include.fenv
164+
libc.hdr.fenv_macros
165165
libc.src.__support.FPUtil.fenv_impl
166166
COMPILE_OPTIONS
167167
-O2
@@ -174,7 +174,7 @@ add_entrypoint_object(
174174
HDRS
175175
fedisableexcept.h
176176
DEPENDS
177-
libc.include.fenv
177+
libc.hdr.fenv_macros
178178
libc.src.__support.FPUtil.fenv_impl
179179
COMPILE_OPTIONS
180180
-O2
@@ -187,7 +187,7 @@ add_entrypoint_object(
187187
HDRS
188188
fegetexcept.h
189189
DEPENDS
190-
libc.include.fenv
190+
libc.hdr.fenv_macros
191191
libc.src.__support.FPUtil.fenv_impl
192192
COMPILE_OPTIONS
193193
-O2

libc/src/fenv/feholdexcept.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "src/fenv/feholdexcept.h"
1010
#include "src/__support/FPUtil/FEnvImpl.h"
1111
#include "src/__support/common.h"
12-
1312
#include <fenv.h>
1413

1514
namespace LIBC_NAMESPACE {

libc/src/fenv/fesetexceptflag.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "src/fenv/fesetexceptflag.h"
1010
#include "src/__support/FPUtil/FEnvImpl.h"
1111
#include "src/__support/common.h"
12-
1312
#include <fenv.h>
1413

1514
namespace LIBC_NAMESPACE {

libc/test/UnitTest/RoundingModeUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "src/__support/FPUtil/FEnvImpl.h"
1111
#include "src/__support/FPUtil/rounding_mode.h"
1212

13-
#include <fenv.h>
13+
#include "hdr/fenv_macros.h"
1414

1515
namespace LIBC_NAMESPACE {
1616
namespace fputil {

libc/test/src/__support/FPUtil/rounding_mode_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "test/UnitTest/Test.h"
1111
#include "utils/MPFRWrapper/MPFRUtils.h"
1212

13-
#include <fenv.h>
13+
#include "hdr/fenv_macros.h"
1414

1515
using LIBC_NAMESPACE::testing::mpfr::ForceRoundingMode;
1616
using LIBC_NAMESPACE::testing::mpfr::RoundingMode;

libc/test/src/fenv/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ if (NOT (LLVM_USE_SANITIZER OR (${LIBC_TARGET_OS} STREQUAL "windows")
118118
SRCS
119119
feholdexcept_test.cpp
120120
DEPENDS
121-
libc.include.fenv
121+
libc.hdr.fenv_macros
122122
libc.src.fenv.feholdexcept
123123
libc.src.__support.FPUtil.fenv_impl
124124
LINK_LIBRARIES

libc/test/src/fenv/enabled_exceptions_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "test/UnitTest/FPExceptMatcher.h"
1616
#include "test/UnitTest/Test.h"
1717

18-
#include <fenv.h>
18+
#include "hdr/fenv_macros.h"
1919
#include <signal.h>
2020

2121
// This test enables an exception and verifies that raising that exception

libc/test/src/fenv/exception_status_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "src/__support/FPUtil/FEnvImpl.h"
1616
#include "test/UnitTest/Test.h"
1717

18-
#include <fenv.h>
18+
#include "hdr/fenv_macros.h"
1919

2020
TEST(LlvmLibcExceptionStatusTest, RaiseAndTest) {
2121
// This test raises a set of exceptions and checks that the exception

libc/test/src/fenv/feclearexcept_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "src/__support/FPUtil/FEnvImpl.h"
1212
#include "test/UnitTest/Test.h"
1313

14-
#include <fenv.h>
14+
#include "hdr/fenv_macros.h"
1515
#include <stdint.h>
1616

1717
TEST(LlvmLibcFEnvTest, ClearTest) {

libc/test/src/fenv/feenableexcept_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include "test/UnitTest/Test.h"
1515

16-
#include <fenv.h>
16+
#include "hdr/fenv_macros.h"
1717

1818
TEST(LlvmLibcFEnvTest, EnableTest) {
1919
#if defined(LIBC_TARGET_ARCH_IS_ANY_ARM) || \

libc/test/src/fenv/rounding_mode_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#include "test/UnitTest/Test.h"
1313

14-
#include <fenv.h>
14+
#include "hdr/fenv_macros.h"
1515

1616
TEST(LlvmLibcRoundingModeTest, SetAndGet) {
1717
struct ResetDefaultRoundingMode {

libc/test/src/math/RIntTest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
#include "test/UnitTest/Test.h"
1616
#include "utils/MPFRWrapper/MPFRUtils.h"
1717

18+
#include "hdr/fenv_macros.h"
1819
#include "hdr/math_macros.h"
19-
#include <fenv.h>
2020
#include <stdio.h>
2121

2222
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

libc/test/src/math/smoke/NextTowardTest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
#ifndef LLVM_LIBC_TEST_SRC_MATH_NEXTTOWARDTEST_H
1010
#define LLVM_LIBC_TEST_SRC_MATH_NEXTTOWARDTEST_H
1111

12+
#include "hdr/fenv_macros.h"
1213
#include "hdr/math_macros.h"
1314
#include "src/__support/CPP/bit.h"
1415
#include "src/__support/CPP/type_traits.h"
1516
#include "src/__support/FPUtil/BasicOperations.h"
1617
#include "src/__support/FPUtil/FPBits.h"
1718
#include "test/UnitTest/FPMatcher.h"
1819
#include "test/UnitTest/Test.h"
19-
#include <fenv.h>
2020

2121
#define ASSERT_FP_EQ_WITH_EXCEPTION(result, expected, expected_exception) \
2222
ASSERT_FP_EQ(result, expected); \

libc/test/src/math/smoke/RIntTest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
#include "test/UnitTest/FPMatcher.h"
1515
#include "test/UnitTest/Test.h"
1616

17+
#include "hdr/fenv_macros.h"
1718
#include "hdr/math_macros.h"
18-
#include <fenv.h>
1919
#include <stdio.h>
2020

2121
static constexpr int ROUNDING_MODES[4] = {FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO,

libc/utils/MPFRWrapper/MPFRUtils.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "test/UnitTest/FPMatcher.h"
1616

1717
#include "hdr/math_macros.h"
18-
#include <fenv.h>
1918
#include <memory>
2019
#include <stdint.h>
2120

utils/bazel/llvm-project-overlay/libc/BUILD.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ libc_support_library(
113113
hdrs = ["hdr/math_macros.h"],
114114
)
115115

116+
libc_support_library(
117+
name = "hdr_fenv_macros",
118+
hdrs = ["hdr/fenv_macros.h"],
119+
)
120+
116121
############################### Support libraries ##############################
117122

118123
libc_support_library(
@@ -751,6 +756,7 @@ libc_support_library(
751756
hdrs = ["src/__support/FPUtil/rounding_mode.h"],
752757
deps = [
753758
":__support_macros_attributes",
759+
":hdr_fenv_macros",
754760
],
755761
)
756762

utils/bazel/llvm-project-overlay/libc/test/UnitTest/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ libc_support_library(
8686
"//libc:__support_fputil_fpbits_str",
8787
"//libc:__support_fputil_rounding_mode",
8888
"//libc:hdr_math_macros",
89+
"//libc:hdr_fenv_macros",
8990
],
9091
)
9192

0 commit comments

Comments
 (0)