Skip to content

Commit c93f399

Browse files
committed
[libc] Add proxy header math_macros.h.
1 parent d89914f commit c93f399

File tree

143 files changed

+220
-385
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+220
-385
lines changed

libc/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ endforeach()
381381

382382
add_subdirectory(include)
383383
add_subdirectory(config)
384+
add_subdirectory(hdr)
384385
add_subdirectory(src)
385386
add_subdirectory(utils)
386387

libc/fuzzing/math/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ add_libc_fuzzer(
88
SingleInputSingleOutputDiff.h
99
TwoInputSingleOutputDiff.h
1010
DEPENDS
11+
libc.hdr.math_macros
1112
libc.src.math.ceil
1213
libc.src.math.ceilf
1314
libc.src.math.ceill

libc/fuzzing/math/RemQuoDiff.h

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

1212
#include "src/__support/FPUtil/FPBits.h"
1313

14-
#include "include/llvm-libc-macros/math-macros.h"
14+
#include "hdr/math_macros.h"
1515
#include <stddef.h>
1616
#include <stdint.h>
1717

libc/fuzzing/stdlib/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ add_libc_fuzzer(
2222
SRCS
2323
strtofloat_fuzz.cpp
2424
DEPENDS
25+
libc.hdr.math_macros
2526
libc.src.stdlib.atof
2627
libc.src.stdlib.strtof
2728
libc.src.stdlib.strtod

libc/fuzzing/stdlib/strtofloat_fuzz.cpp

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

1717
#include "src/__support/FPUtil/FPBits.h"
1818

19-
#include "include/llvm-libc-macros/math-macros.h"
19+
#include "hdr/math_macros.h"
2020
#include <stddef.h>
2121
#include <stdint.h>
2222

libc/hdr/CMakeLists.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
function(add_proxy_header_library target_name)
2+
cmake_parse_arguments(
3+
"ADD_PROXY_HEADER"
4+
"" # Optional arguments
5+
"" # Single value arguments
6+
"DEPENDS;FULL_BUILD_DEPENDS" # Multi-value arguments
7+
${ARGN}
8+
)
9+
10+
set(deps "")
11+
if(ADD_PROXY_HEADER_DEPENDS)
12+
list(APPEND deps ${ADD_PROXY_HEADER_DEPENDS})
13+
endif()
14+
15+
if(LLVM_LIBC_FULL_BUILD AND ADD_PROXY_HEADER_FULL_BUILD_DEPENDS)
16+
list(APPEND deps ${ADD_PROXY_HEADER_FULL_BUILD_DEPENDS})
17+
endif()
18+
19+
add_header_library(
20+
${target_name}
21+
${ADD_PROXY_HEADER_UNPARSED_ARGUMENTS}
22+
DEPENDS ${deps}
23+
)
24+
endfunction()
25+
26+
add_proxy_header_library(
27+
math_macros
28+
HDRS
29+
math_macros.h
30+
FULL_BUILD_DEPENDS
31+
libc.include.llvm-libc-macros.math_macros
32+
libc.include.math
33+
)

libc/hdr/math_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 math.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_MATH_MACROS_H
10+
#define LLVM_LIBC_HDR_MATH_MACROS_H
11+
12+
#ifdef LLVM_LIBC_FULL_BUILD
13+
14+
#include "include/llvm-libc-macros/math-macros.h"
15+
16+
#else // Overlay mode
17+
18+
#include <math.h>
19+
20+
#endif // LLVM_LIBC_FULL_BUILD
21+
22+
#endif // LLVM_LIBC_HDR_MATH_MACROS_H

libc/include/llvm-libc-macros/math-macros.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030
#define INFINITY __builtin_inf()
3131
#define NAN __builtin_nanf("")
3232

33-
#define FP_ILOGB0 (-INT_MAX - 1)
34-
#define FP_LLOGB0 (-LONG_MAX - 1)
33+
#define FP_ILOGB0 INT_MIN
34+
#define FP_LLOGB0 LONG_MIN
3535

3636
#ifdef __FP_LOGBNAN_MIN
37-
#define FP_ILOGBNAN (-INT_MAX - 1)
38-
#define FP_LLOGBNAN (-LONG_MAX - 1)
37+
#define FP_ILOGBNAN INT_MIN
38+
#define FP_LLOGBNAN LONG_MIN
3939
#else
4040
#define FP_ILOGBNAN INT_MAX
4141
#define FP_LLOGBNAN LONG_MAX

libc/src/__support/FPUtil/CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ add_header_library(
44
FEnvImpl.h
55
DEPENDS
66
libc.include.fenv
7-
libc.include.math
7+
libc.hdr.math_macros
88
libc.src.__support.macros.attributes
99
libc.src.errno.errno
1010
)
@@ -15,7 +15,6 @@ add_header_library(
1515
rounding_mode.h
1616
DEPENDS
1717
libc.include.fenv
18-
libc.include.math
1918
libc.src.__support.macros.attributes
2019
libc.src.__support.macros.properties.architectures
2120
libc.src.__support.macros.sanitizer
@@ -59,9 +58,9 @@ add_header_library(
5958
.fp_bits
6059
.fenv_impl
6160
.rounding_mode
61+
libc.hdr.math_macros
6262
libc.src.__support.CPP.type_traits
6363
libc.src.__support.common
64-
libc.include.math
6564
libc.src.errno.errno
6665
)
6766

@@ -216,12 +215,12 @@ add_header_library(
216215
.dyadic_float
217216
.nearest_integer_operations
218217
.normal_float
218+
libc.hdr.math_macros
219219
libc.src.__support.CPP.bit
220220
libc.src.__support.CPP.limits
221221
libc.src.__support.CPP.type_traits
222222
libc.src.__support.common
223223
libc.src.__support.macros.optimization
224-
libc.include.math
225224
libc.src.errno.errno
226225
)
227226

libc/src/__support/FPUtil/FEnvImpl.h

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

12-
#include "include/llvm-libc-macros/math-macros.h"
12+
#include "hdr/math_macros.h"
1313
#include "src/__support/macros/attributes.h" // LIBC_INLINE
1414
#include "src/__support/macros/properties/architectures.h"
1515
#include "src/errno/libc_errno.h"

libc/src/__support/FPUtil/ManipulationFunctions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "dyadic_float.h"
1616
#include "rounding_mode.h"
1717

18-
#include "include/llvm-libc-macros/math-macros.h"
18+
#include "hdr/math_macros.h"
1919
#include "src/__support/CPP/bit.h"
2020
#include "src/__support/CPP/limits.h" // INT_MAX, INT_MIN
2121
#include "src/__support/CPP/type_traits.h"

libc/src/__support/FPUtil/NearestIntegerOperations.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "FPBits.h"
1414
#include "rounding_mode.h"
1515

16-
#include "include/llvm-libc-macros/math-macros.h"
16+
#include "hdr/math_macros.h"
1717
#include "src/__support/CPP/type_traits.h"
1818
#include "src/__support/common.h"
1919

libc/src/math/generic/CMakeLists.txt

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ add_object_library(
102102
HDRS
103103
math_utils.h
104104
DEPENDS
105+
libc.hdr.math_macros
105106
libc.include.errno
106-
libc.include.math
107107
libc.src.errno.errno
108108
)
109109

@@ -139,7 +139,6 @@ add_entrypoint_object(
139139
../cosf.h
140140
DEPENDS
141141
.sincosf_utils
142-
libc.include.math
143142
libc.src.errno.errno
144143
libc.src.__support.FPUtil.basic_operations
145144
libc.src.__support.FPUtil.fenv_impl
@@ -162,7 +161,6 @@ add_entrypoint_object(
162161
DEPENDS
163162
.range_reduction
164163
.sincosf_utils
165-
libc.include.math
166164
libc.src.errno.errno
167165
libc.src.__support.FPUtil.basic_operations
168166
libc.src.__support.FPUtil.fenv_impl
@@ -185,7 +183,6 @@ add_entrypoint_object(
185183
DEPENDS
186184
.range_reduction
187185
.sincosf_utils
188-
libc.include.math
189186
libc.src.errno.errno
190187
libc.src.__support.FPUtil.fenv_impl
191188
libc.src.__support.FPUtil.fp_bits
@@ -207,7 +204,6 @@ add_entrypoint_object(
207204
DEPENDS
208205
.range_reduction
209206
.sincosf_utils
210-
libc.include.math
211207
libc.src.errno.errno
212208
libc.src.__support.FPUtil.fenv_impl
213209
libc.src.__support.FPUtil.fenv_impl
@@ -721,7 +717,6 @@ add_entrypoint_object(
721717
libc.src.__support.FPUtil.multiply_add
722718
libc.src.__support.FPUtil.polyeval
723719
libc.src.__support.macros.optimization
724-
libc.include.math
725720
COMPILE_OPTIONS
726721
-O3
727722
)
@@ -736,7 +731,6 @@ add_entrypoint_object(
736731
.common_constants
737732
.explogxf
738733
libc.include.errno
739-
libc.include.math
740734
libc.src.__support.CPP.bit
741735
libc.src.__support.CPP.optional
742736
libc.src.__support.FPUtil.dyadic_float
@@ -772,7 +766,6 @@ add_entrypoint_object(
772766
libc.src.__support.macros.optimization
773767
libc.include.errno
774768
libc.src.errno.errno
775-
libc.include.math
776769
COMPILE_OPTIONS
777770
-O3
778771
)
@@ -787,7 +780,6 @@ add_entrypoint_object(
787780
.common_constants
788781
.explogxf
789782
libc.include.errno
790-
libc.include.math
791783
libc.src.__support.CPP.bit
792784
libc.src.__support.CPP.optional
793785
libc.src.__support.FPUtil.dyadic_float
@@ -822,7 +814,6 @@ add_header_library(
822814
libc.src.__support.common
823815
libc.include.errno
824816
libc.src.errno.errno
825-
libc.include.math
826817
)
827818

828819
add_entrypoint_object(
@@ -847,7 +838,6 @@ add_entrypoint_object(
847838
.common_constants
848839
.explogxf
849840
libc.include.errno
850-
libc.include.math
851841
libc.src.__support.CPP.bit
852842
libc.src.__support.CPP.optional
853843
libc.src.__support.FPUtil.dyadic_float
@@ -881,7 +871,6 @@ add_header_library(
881871
libc.src.__support.common
882872
libc.include.errno
883873
libc.src.errno.errno
884-
libc.include.math
885874
COMPILE_OPTIONS
886875
-O3
887876
)
@@ -908,7 +897,6 @@ add_entrypoint_object(
908897
.common_constants
909898
.explogxf
910899
libc.include.errno
911-
libc.include.math
912900
libc.src.__support.CPP.bit
913901
libc.src.__support.CPP.optional
914902
libc.src.__support.FPUtil.dyadic_float
@@ -944,7 +932,6 @@ add_entrypoint_object(
944932
libc.src.__support.macros.optimization
945933
libc.include.errno
946934
libc.src.errno.errno
947-
libc.include.math
948935
COMPILE_OPTIONS
949936
-O3
950937
)
@@ -961,7 +948,6 @@ add_entrypoint_object(
961948
.exp2f_impl
962949
.explogxf
963950
libc.include.errno
964-
libc.include.math
965951
libc.src.__support.CPP.bit
966952
libc.src.__support.CPP.optional
967953
libc.src.__support.FPUtil.fenv_impl
@@ -2685,7 +2671,6 @@ add_object_library(
26852671
libc.src.__support.common
26862672
libc.include.errno
26872673
libc.src.errno.errno
2688-
libc.include.math
26892674
COMPILE_OPTIONS
26902675
-O3
26912676
)

libc/src/math/generic/math_utils.h

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

12-
#include "include/llvm-libc-macros/math-macros.h"
12+
#include "hdr/math_macros.h"
1313
#include "src/__support/CPP/bit.h"
1414
#include "src/__support/CPP/type_traits.h"
1515
#include "src/__support/common.h"

libc/test/CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ add_subdirectory(include)
1818
add_subdirectory(src)
1919
add_subdirectory(utils)
2020

21-
if(LLVM_LIBC_FULL_BUILD AND NOT LIBC_TARGET_OS_IS_BAREMETAL)
22-
add_subdirectory(IntegrationTest)
23-
endif()
24-
2521
if(NOT LLVM_LIBC_FULL_BUILD)
2622
return()
2723
endif()
@@ -31,4 +27,6 @@ if(NOT ${LIBC_TARGET_OS} STREQUAL "linux" AND
3127
# Integration tests are currently only available for linux and the GPU.
3228
return()
3329
endif()
30+
31+
add_subdirectory(IntegrationTest)
3432
add_subdirectory(integration)

libc/test/UnitTest/FPMatcher.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "test/UnitTest/StringUtils.h"
1919
#include "test/UnitTest/Test.h"
2020

21-
#include "include/llvm-libc-macros/math-macros.h"
21+
#include "hdr/math_macros.h"
2222

2323
namespace LIBC_NAMESPACE {
2424
namespace testing {

libc/test/src/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ function(add_fp_unittest name)
33
"MATH_UNITTEST"
44
"NEED_MPFR;UNIT_TEST_ONLY;HERMETIC_TEST_ONLY" # Optional arguments
55
"" # Single value arguments
6-
"LINK_LIBRARIES" # Multi-value arguments
6+
"LINK_LIBRARIES;DEPENDS" # Multi-value arguments
77
${ARGN}
88
)
99

@@ -28,11 +28,17 @@ function(add_fp_unittest name)
2828
endif()
2929
list(APPEND MATH_UNITTEST_LINK_LIBRARIES LibcFPTestHelpers)
3030

31+
set(deps libc.hdr.math_macros)
32+
if(MATH_UNITTEST_DEPENDS)
33+
list(APPEND deps ${MATH_UNITTEST_DEPENDS})
34+
endif()
35+
3136
add_libc_test(
3237
${name}
3338
${test_type}
3439
LINK_LIBRARIES "${MATH_UNITTEST_LINK_LIBRARIES}"
3540
"${MATH_UNITTEST_UNPARSED_ARGUMENTS}"
41+
DEPENDS "${deps}"
3642
)
3743
endfunction(add_fp_unittest)
3844

libc/test/src/__support/uint_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "src/__support/UInt.h"
1111
#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128
1212

13-
#include "include/llvm-libc-macros/math-macros.h" // HUGE_VALF, HUGE_VALF
13+
#include "hdr/math_macros.h" // HUGE_VALF, HUGE_VALF
1414
#include "test/UnitTest/Test.h"
1515

1616
namespace LIBC_NAMESPACE {

0 commit comments

Comments
 (0)