Skip to content

Commit f8f5b17

Browse files
[libc] Create a separate proxy header for math-function-macros.h (#98430)
Fix #98393
1 parent 62e5b6e commit f8f5b17

Some content is hidden

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

48 files changed

+117
-73
lines changed

libc/hdr/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ add_proxy_header_library(
3232
libc.include.math
3333
)
3434

35+
add_proxy_header_library(
36+
math_function_macros
37+
HDRS
38+
math_function_macros.h
39+
FULL_BUILD_DEPENDS
40+
libc.include.llvm-libc-macros.math_function_macros
41+
libc.include.math
42+
)
43+
3544
add_proxy_header_library(
3645
errno_macros
3746
HDRS

libc/hdr/math_function_macros.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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_FUNCTION_MACROS_H
10+
#define LLVM_LIBC_HDR_MATH_FUNCTION_MACROS_H
11+
12+
#ifdef LIBC_FULL_BUILD
13+
14+
#include "include/llvm-libc-macros/math-function-macros.h"
15+
16+
#else // Overlay mode
17+
18+
// GCC will include CXX headers when __cplusplus is defined. This behavior
19+
// can be suppressed by defining _GLIBCXX_INCLUDE_NEXT_C_HEADERS.
20+
#if defined(__GNUC__) && !defined(__clang__)
21+
#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS
22+
#endif
23+
#include <math.h>
24+
25+
#endif // LLVM_LIBC_FULL_BUILD
26+
27+
#endif // LLVM_LIBC_HDR_MATH_MACROS_H

libc/hdr/math_macros.h

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

1212
#ifdef LIBC_FULL_BUILD
1313

14-
#include "include/llvm-libc-macros/math-function-macros.h"
1514
#include "include/llvm-libc-macros/math-macros.h"
1615

1716
#else // Overlay mode

libc/test/src/math/CopySignTest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class CopySignTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
3939
constexpr StorageType STEP = STORAGE_MAX / COUNT;
4040
for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
4141
T x = FPBits(v).get_val();
42-
if (isnan(x) || isinf(x))
42+
if (FPBits(v).is_nan() || FPBits(v).is_inf())
4343
continue;
4444

4545
double res1 = func(x, -x);

libc/test/src/math/FAbsTest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class FAbsTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
4141
constexpr StorageType STEP = STORAGE_MAX / COUNT;
4242
for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
4343
T x = FPBits(v).get_val();
44-
if (isnan(x) || isinf(x))
44+
if (FPBits(v).is_nan() || FPBits(v).is_inf())
4545
continue;
4646
ASSERT_MPFR_MATCH(mpfr::Operation::Abs, x, func(x), 0.0);
4747
}

libc/test/src/math/FDimTest.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ class FDimTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
6767
for (StorageType i = 0, v = 0, w = STORAGE_MAX; i <= COUNT;
6868
++i, v += STEP, w -= STEP) {
6969
T x = FPBits(v).get_val(), y = FPBits(w).get_val();
70-
if (isnan(x) || isinf(x))
70+
if (FPBits(v).is_nan() || FPBits(v).is_inf())
7171
continue;
72-
if (isnan(y) || isinf(y))
72+
if (FPBits(w).is_nan() || FPBits(w).is_inf())
7373
continue;
7474

7575
if (x > y) {

libc/test/src/math/FMaxTest.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ class FMaxTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
6565
for (StorageType i = 0, v = 0, w = STORAGE_MAX; i <= COUNT;
6666
++i, v += STEP, w -= STEP) {
6767
T x = FPBits(v).get_val(), y = FPBits(w).get_val();
68-
if (isnan(x) || isinf(x))
68+
if (FPBits(v).is_nan() || FPBits(v).is_inf())
6969
continue;
70-
if (isnan(y) || isinf(y))
70+
if (FPBits(w).is_nan() || FPBits(w).is_inf())
7171
continue;
7272
if ((x == 0) && (y == 0))
7373
continue;

libc/test/src/math/FMinTest.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#ifndef LLVM_LIBC_TEST_SRC_MATH_FMINTEST_H
1010
#define LLVM_LIBC_TEST_SRC_MATH_FMINTEST_H
1111

12+
#include "src/__support/FPUtil/FPBits.h"
1213
#include "test/UnitTest/FEnvSafeTest.h"
1314
#include "test/UnitTest/FPMatcher.h"
1415
#include "test/UnitTest/Test.h"
@@ -65,9 +66,9 @@ class FMinTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
6566
for (StorageType i = 0, v = 0, w = STORAGE_MAX; i <= COUNT;
6667
++i, v += STEP, w -= STEP) {
6768
T x = FPBits(v).get_val(), y = FPBits(w).get_val();
68-
if (isnan(x) || isinf(x))
69+
if (FPBits(v).is_nan() || FPBits(v).is_inf())
6970
continue;
70-
if (isnan(y) || isinf(y))
71+
if (FPBits(w).is_nan() || FPBits(w).is_inf())
7172
continue;
7273
if ((x == 0) && (y == 0))
7374
continue;

libc/test/src/math/FrexpTest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class FrexpTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
9999
constexpr StorageType STEP = STORAGE_MAX / COUNT;
100100
for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
101101
T x = FPBits(v).get_val();
102-
if (isnan(x) || isinf(x) || x == 0.0l)
102+
if (FPBits(v).is_nan() || FPBits(v).is_inf() || x == 0.0l)
103103
continue;
104104

105105
mpfr::BinaryOutput<T> result;

libc/test/src/math/ILogbTest.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class LlvmLibcILogbTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
8282
constexpr StorageType STEP = (MAX_SUBNORMAL - MIN_SUBNORMAL) / COUNT;
8383
for (StorageType v = MIN_SUBNORMAL; v <= MAX_SUBNORMAL; v += STEP) {
8484
T x = FPBits(v).get_val();
85-
if (isnan(x) || isinf(x) || x == 0.0)
85+
if (FPBits(v).is_nan() || FPBits(v).is_inf() || x == 0.0)
8686
continue;
8787

8888
int exponent;
@@ -101,7 +101,7 @@ class LlvmLibcILogbTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
101101
constexpr StorageType STEP = (MAX_NORMAL - MIN_NORMAL) / COUNT;
102102
for (StorageType v = MIN_NORMAL; v <= MAX_NORMAL; v += STEP) {
103103
T x = FPBits(v).get_val();
104-
if (isnan(x) || isinf(x) || x == 0.0)
104+
if (FPBits(v).is_nan() || FPBits(v).is_inf() || x == 0.0)
105105
continue;
106106

107107
int exponent;

libc/test/src/math/LogbTest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class LogbTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
7878
constexpr StorageType STEP = STORAGE_MAX / COUNT;
7979
for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
8080
T x = FPBits(v).get_val();
81-
if (isnan(x) || isinf(x) || x == 0.0l)
81+
if (FPBits(v).is_nan() || FPBits(v).is_inf() || x == 0.0l)
8282
continue;
8383

8484
int exponent;

libc/test/src/math/ModfTest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class ModfTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
9090
constexpr StorageType STEP = STORAGE_MAX / COUNT;
9191
for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
9292
T x = FPBits(v).get_val();
93-
if (isnan(x) || isinf(x) || x == T(0.0))
93+
if (FPBits(v).is_nan() || FPBits(v).is_inf() || x == T(0.0))
9494
continue;
9595

9696
T integral;

libc/test/src/math/RemQuoTest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class RemQuoTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
127127

128128
// In normal range on x86 platforms, the long double implicit 1 bit can be
129129
// zero making the numbers NaN. Hence we test for them separately.
130-
if (isnan(x) || isnan(y)) {
130+
if (FPBits(v).is_nan() || FPBits(w).is_nan()) {
131131
ASSERT_FP_EQ(result.f, nan);
132132
continue;
133133
}

libc/test/src/math/acosf_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ TEST_F(LlvmLibcAcosfTest, InFloatRange) {
4848
constexpr uint32_t STEP = UINT32_MAX / COUNT;
4949
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
5050
float x = FPBits(v).get_val();
51-
if (isnan(x) || isinf(x))
51+
if (FPBits(v).is_nan() || FPBits(v).is_inf())
5252
continue;
5353
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Acos, x,
5454
LIBC_NAMESPACE::acosf(x), 0.5);

libc/test/src/math/acoshf_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ TEST_F(LlvmLibcAcoshfTest, InFloatRange) {
4545
constexpr uint32_t STEP = UINT32_MAX / COUNT;
4646
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
4747
float x = FPBits(v).get_val();
48-
if (isnan(x) || isinf(x))
48+
if (FPBits(v).is_nan() || FPBits(v).is_inf())
4949
continue;
5050
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Acosh, x,
5151
LIBC_NAMESPACE::acoshf(x), 0.5);

libc/test/src/math/asinf_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ TEST_F(LlvmLibcAsinfTest, InFloatRange) {
4646
constexpr uint32_t STEP = UINT32_MAX / COUNT;
4747
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
4848
float x = FPBits(v).get_val();
49-
if (isnan(x) || isinf(x))
49+
if (FPBits(v).is_nan() || FPBits(v).is_inf())
5050
continue;
5151
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Asin, x,
5252
LIBC_NAMESPACE::asinf(x), 0.5);

libc/test/src/math/asinhf_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ TEST_F(LlvmLibcAsinhfTest, InFloatRange) {
4545
constexpr uint32_t STEP = UINT32_MAX / COUNT;
4646
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
4747
float x = FPBits(v).get_val();
48-
if (isnan(x) || isinf(x))
48+
if (FPBits(v).is_nan() || FPBits(v).is_inf())
4949
continue;
5050
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Asinh, x,
5151
LIBC_NAMESPACE::asinhf(x), 0.5);

libc/test/src/math/atan2f_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,18 @@ TEST_F(LlvmLibcAtan2fTest, InFloatRange) {
7373

7474
for (uint32_t i = 0, v = X_START; i <= X_COUNT; ++i, v += X_STEP) {
7575
float x = FPBits(v).get_val();
76-
if (isnan(x) || isinf(x) || x < 0.0)
76+
if (FPBits(v).is_nan() || FPBits(v).is_inf() || x < 0.0)
7777
continue;
7878

7979
for (uint32_t j = 0, w = Y_START; j <= Y_COUNT; ++j, w += Y_STEP) {
8080
float y = FPBits(w).get_val();
81-
if (isnan(y) || isinf(y))
81+
if (FPBits(w).is_nan() || FPBits(w).is_inf())
8282
continue;
8383

8484
LIBC_NAMESPACE::libc_errno = 0;
8585
float result = LIBC_NAMESPACE::atan2f(x, y);
8686
++total_count;
87-
if (isnan(result) || isinf(result))
87+
if (FPBits(result).is_nan() || FPBits(result).is_inf())
8888
continue;
8989

9090
++finite_count;

libc/test/src/math/cos_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ TEST_F(LlvmLibcCosTest, InDoubleRange) {
8181

8282
for (uint64_t i = 0, v = START; i <= COUNT; ++i, v += STEP) {
8383
double x = FPBits(v).get_val();
84-
if (isnan(x) || isinf(x))
84+
if (FPBits(v).is_nan() || FPBits(v).is_inf())
8585
continue;
8686

8787
double result = LIBC_NAMESPACE::cos(x);
8888
++total;
89-
if (isnan(result) || isinf(result))
89+
if (FPBits(result).is_nan() || FPBits(result).is_inf())
9090
continue;
9191

9292
++tested;

libc/test/src/math/cosf_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ TEST_F(LlvmLibcCosfTest, InFloatRange) {
4747
constexpr uint32_t STEP = UINT32_MAX / COUNT;
4848
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
4949
float x = FPBits(v).get_val();
50-
if (isnan(x) || isinf(x))
50+
if (FPBits(v).is_nan() || FPBits(v).is_inf())
5151
continue;
5252
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Cos, x,
5353
LIBC_NAMESPACE::cosf(x), 0.5);

libc/test/src/math/coshf_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ TEST_F(LlvmLibcCoshfTest, InFloatRange) {
6161
constexpr uint32_t STEP = UINT32_MAX / COUNT;
6262
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
6363
float x = FPBits(v).get_val();
64-
if (isnan(x) || isinf(x))
64+
if (FPBits(v).is_nan() || FPBits(v).is_inf())
6565
continue;
6666
ASSERT_MPFR_MATCH(mpfr::Operation::Cosh, x, LIBC_NAMESPACE::coshf(x), 0.5);
6767
}

libc/test/src/math/erff_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ TEST_F(LlvmLibcErffTest, InFloatRange) {
6464

6565
for (uint32_t i = 0, v = START; i <= COUNT; ++i, v += STEP) {
6666
float x = FPBits(v).get_val();
67-
if (isnan(x))
67+
if (FPBits(v).is_nan())
6868
continue;
6969

7070
float result = LIBC_NAMESPACE::erff(x);
7171
++cc;
72-
if (isnan(result))
72+
if (FPBits(result).is_nan())
7373
continue;
7474

7575
++count;

libc/test/src/math/exp10_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ TEST_F(LlvmLibcExp10Test, InDoubleRange) {
104104

105105
for (uint64_t i = 0, v = START; i <= COUNT; ++i, v += STEP) {
106106
double x = FPBits(v).get_val();
107-
if (isnan(x) || isinf(x) || x < 0.0)
107+
if (FPBits(v).is_nan() || FPBits(v).is_inf() || x < 0.0)
108108
continue;
109109
LIBC_NAMESPACE::libc_errno = 0;
110110
double result = LIBC_NAMESPACE::exp10(x);
111111
++cc;
112-
if (isnan(result) || isinf(result))
112+
if (FPBits(result).is_nan() || FPBits(result).is_inf())
113113
continue;
114114

115115
++count;

libc/test/src/math/exp10f_test.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ TEST_F(LlvmLibcExp10fTest, InFloatRange) {
111111
constexpr uint32_t STEP = UINT32_MAX / COUNT;
112112
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
113113
float x = FPBits(v).get_val();
114-
if (isnan(x) || isinf(x))
114+
if (FPBits(v).is_nan() || FPBits(v).is_inf())
115115
continue;
116116
LIBC_NAMESPACE::libc_errno = 0;
117117
float result = LIBC_NAMESPACE::exp10f(x);
@@ -120,7 +120,8 @@ TEST_F(LlvmLibcExp10fTest, InFloatRange) {
120120
// in the single-precision floating point range, then ignore comparing with
121121
// MPFR result as MPFR can still produce valid results because of its
122122
// wider precision.
123-
if (isnan(result) || isinf(result) || LIBC_NAMESPACE::libc_errno != 0)
123+
if (FPBits(result).is_nan() || FPBits(result).is_inf() ||
124+
LIBC_NAMESPACE::libc_errno != 0)
124125
continue;
125126
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp10, x,
126127
LIBC_NAMESPACE::exp10f(x), 0.5);

libc/test/src/math/exp2_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ TEST_F(LlvmLibcExp2Test, InDoubleRange) {
7979

8080
for (uint64_t i = 0, v = START; i <= COUNT; ++i, v += STEP) {
8181
double x = FPBits(v).get_val();
82-
if (isnan(x) || isinf(x) || x < 0.0)
82+
if (FPBits(v).is_nan() || FPBits(v).is_inf() || x < 0.0)
8383
continue;
8484
LIBC_NAMESPACE::libc_errno = 0;
8585
double result = LIBC_NAMESPACE::exp2(x);
8686
++cc;
87-
if (isnan(result) || isinf(result))
87+
if (FPBits(result).is_nan() || FPBits(result).is_inf())
8888
continue;
8989

9090
++count;

libc/test/src/math/exp2f_test.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ TEST_F(LlvmLibcExp2fTest, InFloatRange) {
107107
constexpr uint32_t STEP = UINT32_MAX / COUNT;
108108
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
109109
float x = FPBits(v).get_val();
110-
if (isnan(x) || isinf(x))
110+
if (FPBits(v).is_nan() || FPBits(v).is_inf())
111111
continue;
112112
LIBC_NAMESPACE::libc_errno = 0;
113113
float result = LIBC_NAMESPACE::exp2f(x);
@@ -116,7 +116,8 @@ TEST_F(LlvmLibcExp2fTest, InFloatRange) {
116116
// in the single-precision floating point range, then ignore comparing with
117117
// MPFR result as MPFR can still produce valid results because of its
118118
// wider precision.
119-
if (isnan(result) || isinf(result) || LIBC_NAMESPACE::libc_errno != 0)
119+
if (FPBits(result).is_nan() || FPBits(result).is_inf() ||
120+
LIBC_NAMESPACE::libc_errno != 0)
120121
continue;
121122
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp2, x,
122123
LIBC_NAMESPACE::exp2f(x), 0.5);

libc/test/src/math/exp2m1f_test.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ TEST_F(LlvmLibcExp2m1fTest, InFloatRange) {
4949
constexpr uint32_t STEP = UINT32_MAX / COUNT;
5050
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
5151
float x = FPBits(v).get_val();
52-
if (isnan(x) || isinf(x))
52+
if (FPBits(v).is_nan() || FPBits(v).is_inf())
5353
continue;
5454
LIBC_NAMESPACE::libc_errno = 0;
5555
float result = LIBC_NAMESPACE::exp2m1f(x);
@@ -58,7 +58,8 @@ TEST_F(LlvmLibcExp2m1fTest, InFloatRange) {
5858
// in the single-precision floating point range, then ignore comparing with
5959
// MPFR result as MPFR can still produce valid results because of its
6060
// wider precision.
61-
if (isnan(result) || isinf(result) || LIBC_NAMESPACE::libc_errno != 0)
61+
if (FPBits(result).is_nan() || FPBits(result).is_inf() ||
62+
LIBC_NAMESPACE::libc_errno != 0)
6263
continue;
6364
ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp2m1, x,
6465
LIBC_NAMESPACE::exp2m1f(x), 0.5);

libc/test/src/math/exp_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ TEST_F(LlvmLibcExpTest, InDoubleRange) {
7777

7878
for (uint64_t i = 0, v = START; i <= COUNT; ++i, v += STEP) {
7979
double x = FPBits(v).get_val();
80-
if (isnan(x) || isinf(x) || x < 0.0)
80+
if (FPBits(v).is_nan() || FPBits(v).is_inf() || x < 0.0)
8181
continue;
8282
LIBC_NAMESPACE::libc_errno = 0;
8383
double result = LIBC_NAMESPACE::exp(x);
8484
++cc;
85-
if (isnan(result) || isinf(result))
85+
if (FPBits(result).is_nan() || FPBits(result).is_inf())
8686
continue;
8787

8888
++count;

libc/test/src/math/expf_test.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ TEST_F(LlvmLibcExpfTest, InFloatRange) {
108108
constexpr uint32_t STEP = UINT32_MAX / COUNT;
109109
for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
110110
float x = FPBits(v).get_val();
111-
if (isnan(x) || isinf(x))
111+
if (FPBits(v).is_nan() || FPBits(v).is_inf())
112112
continue;
113113
LIBC_NAMESPACE::libc_errno = 0;
114114
float result = LIBC_NAMESPACE::expf(x);
@@ -117,7 +117,8 @@ TEST_F(LlvmLibcExpfTest, InFloatRange) {
117117
// in the single-precision floating point range, then ignore comparing with
118118
// MPFR result as MPFR can still produce valid results because of its
119119
// wider precision.
120-
if (isnan(result) || isinf(result) || LIBC_NAMESPACE::libc_errno != 0)
120+
if (FPBits(result).is_nan() || FPBits(result).is_inf() ||
121+
LIBC_NAMESPACE::libc_errno != 0)
121122
continue;
122123
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp, x,
123124
LIBC_NAMESPACE::expf(x), 0.5);

0 commit comments

Comments
 (0)