Skip to content

Commit 2b8e81c

Browse files
authored
[libc][math] undef iscanonical before defining it using LLVM_LIBC_FUNCTION macro (#110865)
It appears that #110565 fails because the macro definition of iscanonical is included somewhere. This PR ensures that the macro expands correctly and also removes the static_cast because implicit conversion from bool to int is defined in C++.
1 parent 67dd9d2 commit 2b8e81c

File tree

5 files changed

+6
-5
lines changed

5 files changed

+6
-5
lines changed

libc/src/math/generic/iscanonical.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313

1414
namespace LIBC_NAMESPACE_DECL {
1515

16+
#undef iscanonical
1617
LLVM_LIBC_FUNCTION(int, iscanonical, (double x)) {
1718
double temp;
18-
return static_cast<int>(fputil::canonicalize(temp, x) == 0);
19+
return fputil::canonicalize(temp, x) == 0;
1920
}
2021

2122
} // namespace LIBC_NAMESPACE_DECL

libc/src/math/generic/iscanonicalf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace LIBC_NAMESPACE_DECL {
1515

1616
LLVM_LIBC_FUNCTION(int, iscanonicalf, (float x)) {
1717
float temp;
18-
return static_cast<int>(fputil::canonicalize(temp, x) == 0);
18+
return fputil::canonicalize(temp, x) == 0;
1919
}
2020

2121
} // namespace LIBC_NAMESPACE_DECL

libc/src/math/generic/iscanonicalf128.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace LIBC_NAMESPACE_DECL {
1515

1616
LLVM_LIBC_FUNCTION(int, iscanonicalf128, (float128 x)) {
1717
float128 temp;
18-
return static_cast<int>(fputil::canonicalize(temp, x) == 0);
18+
return fputil::canonicalize(temp, x) == 0;
1919
}
2020

2121
} // namespace LIBC_NAMESPACE_DECL

libc/src/math/generic/iscanonicalf16.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace LIBC_NAMESPACE_DECL {
1515

1616
LLVM_LIBC_FUNCTION(int, iscanonicalf16, (float16 x)) {
1717
float16 temp;
18-
return static_cast<int>(fputil::canonicalize(temp, x) == 0);
18+
return fputil::canonicalize(temp, x) == 0;
1919
}
2020

2121
} // namespace LIBC_NAMESPACE_DECL

libc/src/math/generic/iscanonicall.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace LIBC_NAMESPACE_DECL {
1515

1616
LLVM_LIBC_FUNCTION(int, iscanonicall, (long double x)) {
1717
long double temp;
18-
return static_cast<int>(fputil::canonicalize(temp, x) == 0);
18+
return fputil::canonicalize(temp, x) == 0;
1919
}
2020

2121
} // namespace LIBC_NAMESPACE_DECL

0 commit comments

Comments
 (0)