[libc-commits] [libc] 2b8e81c - [libc][math] undef `iscanonical` before defining it using `LLVM_LIBC_FUNCTION` macro (#110865)
via libc-commits
libc-commits at lists.llvm.org
Wed Oct 2 10:03:57 PDT 2024
Author: Shourya Goel
Date: 2024-10-02T13:03:54-04:00
New Revision: 2b8e81ce919e8db857dc2ba20012e9020af07294
URL: https://github.com/llvm/llvm-project/commit/2b8e81ce919e8db857dc2ba20012e9020af07294
DIFF: https://github.com/llvm/llvm-project/commit/2b8e81ce919e8db857dc2ba20012e9020af07294.diff
LOG: [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++.
Added:
Modified:
libc/src/math/generic/iscanonical.cpp
libc/src/math/generic/iscanonicalf.cpp
libc/src/math/generic/iscanonicalf128.cpp
libc/src/math/generic/iscanonicalf16.cpp
libc/src/math/generic/iscanonicall.cpp
Removed:
################################################################################
diff --git a/libc/src/math/generic/iscanonical.cpp b/libc/src/math/generic/iscanonical.cpp
index d67a6b87b3e506..ff922f3ae8ee72 100644
--- a/libc/src/math/generic/iscanonical.cpp
+++ b/libc/src/math/generic/iscanonical.cpp
@@ -13,9 +13,10 @@
namespace LIBC_NAMESPACE_DECL {
+#undef iscanonical
LLVM_LIBC_FUNCTION(int, iscanonical, (double x)) {
double temp;
- return static_cast<int>(fputil::canonicalize(temp, x) == 0);
+ return fputil::canonicalize(temp, x) == 0;
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/iscanonicalf.cpp b/libc/src/math/generic/iscanonicalf.cpp
index daa0708794d2f4..5c38e9b72ec582 100644
--- a/libc/src/math/generic/iscanonicalf.cpp
+++ b/libc/src/math/generic/iscanonicalf.cpp
@@ -15,7 +15,7 @@ namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(int, iscanonicalf, (float x)) {
float temp;
- return static_cast<int>(fputil::canonicalize(temp, x) == 0);
+ return fputil::canonicalize(temp, x) == 0;
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/iscanonicalf128.cpp b/libc/src/math/generic/iscanonicalf128.cpp
index 9be50050f8234c..ff549c3194cbaf 100644
--- a/libc/src/math/generic/iscanonicalf128.cpp
+++ b/libc/src/math/generic/iscanonicalf128.cpp
@@ -15,7 +15,7 @@ namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(int, iscanonicalf128, (float128 x)) {
float128 temp;
- return static_cast<int>(fputil::canonicalize(temp, x) == 0);
+ return fputil::canonicalize(temp, x) == 0;
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/iscanonicalf16.cpp b/libc/src/math/generic/iscanonicalf16.cpp
index 4f7bb1a0050f51..f9b093dc8ff2dd 100644
--- a/libc/src/math/generic/iscanonicalf16.cpp
+++ b/libc/src/math/generic/iscanonicalf16.cpp
@@ -15,7 +15,7 @@ namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(int, iscanonicalf16, (float16 x)) {
float16 temp;
- return static_cast<int>(fputil::canonicalize(temp, x) == 0);
+ return fputil::canonicalize(temp, x) == 0;
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/iscanonicall.cpp b/libc/src/math/generic/iscanonicall.cpp
index 756c1f8fb4abfa..34e00359912b71 100644
--- a/libc/src/math/generic/iscanonicall.cpp
+++ b/libc/src/math/generic/iscanonicall.cpp
@@ -15,7 +15,7 @@ namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(int, iscanonicall, (long double x)) {
long double temp;
- return static_cast<int>(fputil::canonicalize(temp, x) == 0);
+ return fputil::canonicalize(temp, x) == 0;
}
} // namespace LIBC_NAMESPACE_DECL
More information about the libc-commits
mailing list