[libc-commits] [libc] [libc][math] exapnd macro definition for iscanonical variants (PR #110865)
Shourya Goel via libc-commits
libc-commits at lists.llvm.org
Wed Oct 2 08:17:25 PDT 2024
https://github.com/Sh0g0-1758 created https://github.com/llvm/llvm-project/pull/110865
It appears that #110565 fails because the macro LLVM_LIBC_FUNCTION is not being recognized or expanded properly. This PR expands the macro and also removes the static_assert since conversion from bool to int is well defined in C/C++.
>From 83aecfe62b142d047c677b144861c89aecaad962 Mon Sep 17 00:00:00 2001
From: Sh0g0-1758 <shouryagoel10000 at gmail.com>
Date: Wed, 2 Oct 2024 20:40:08 +0530
Subject: [PATCH 1/2] fix
---
libc/src/math/generic/iscanonical.cpp | 4 ++--
libc/src/math/generic/iscanonicalf.cpp | 4 ++--
libc/src/math/generic/iscanonicalf128.cpp | 4 ++--
libc/src/math/generic/iscanonicalf16.cpp | 4 ++--
libc/src/math/generic/iscanonicall.cpp | 4 ++--
5 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/libc/src/math/generic/iscanonical.cpp b/libc/src/math/generic/iscanonical.cpp
index d67a6b87b3e506..0d39821832dcf1 100644
--- a/libc/src/math/generic/iscanonical.cpp
+++ b/libc/src/math/generic/iscanonical.cpp
@@ -13,9 +13,9 @@
namespace LIBC_NAMESPACE_DECL {
-LLVM_LIBC_FUNCTION(int, iscanonical, (double x)) {
+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..2a37edf58755b9 100644
--- a/libc/src/math/generic/iscanonicalf.cpp
+++ b/libc/src/math/generic/iscanonicalf.cpp
@@ -13,9 +13,9 @@
namespace LIBC_NAMESPACE_DECL {
-LLVM_LIBC_FUNCTION(int, iscanonicalf, (float x)) {
+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..8650cd150678ef 100644
--- a/libc/src/math/generic/iscanonicalf128.cpp
+++ b/libc/src/math/generic/iscanonicalf128.cpp
@@ -13,9 +13,9 @@
namespace LIBC_NAMESPACE_DECL {
-LLVM_LIBC_FUNCTION(int, iscanonicalf128, (float128 x)) {
+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..1769697c79c633 100644
--- a/libc/src/math/generic/iscanonicalf16.cpp
+++ b/libc/src/math/generic/iscanonicalf16.cpp
@@ -13,9 +13,9 @@
namespace LIBC_NAMESPACE_DECL {
-LLVM_LIBC_FUNCTION(int, iscanonicalf16, (float16 x)) {
+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..a639015fb27e40 100644
--- a/libc/src/math/generic/iscanonicall.cpp
+++ b/libc/src/math/generic/iscanonicall.cpp
@@ -13,9 +13,9 @@
namespace LIBC_NAMESPACE_DECL {
-LLVM_LIBC_FUNCTION(int, iscanonicall, (long double x)) {
+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
>From 150c911902e89f512dfac9dc3a2a607e83984aa8 Mon Sep 17 00:00:00 2001
From: Sh0g0-1758 <shouryagoel10000 at gmail.com>
Date: Wed, 2 Oct 2024 20:40:29 +0530
Subject: [PATCH 2/2] fmt
---
libc/src/math/generic/iscanonical.cpp | 2 +-
libc/src/math/generic/iscanonicalf.cpp | 2 +-
libc/src/math/generic/iscanonicalf128.cpp | 2 +-
libc/src/math/generic/iscanonicalf16.cpp | 2 +-
libc/src/math/generic/iscanonicall.cpp | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/libc/src/math/generic/iscanonical.cpp b/libc/src/math/generic/iscanonical.cpp
index 0d39821832dcf1..69a95c719a85c9 100644
--- a/libc/src/math/generic/iscanonical.cpp
+++ b/libc/src/math/generic/iscanonical.cpp
@@ -13,7 +13,7 @@
namespace LIBC_NAMESPACE_DECL {
-int iscanonical (double x) {
+int iscanonical(double x) {
double temp;
return fputil::canonicalize(temp, x) == 0;
}
diff --git a/libc/src/math/generic/iscanonicalf.cpp b/libc/src/math/generic/iscanonicalf.cpp
index 2a37edf58755b9..b27c0fd1fabf44 100644
--- a/libc/src/math/generic/iscanonicalf.cpp
+++ b/libc/src/math/generic/iscanonicalf.cpp
@@ -13,7 +13,7 @@
namespace LIBC_NAMESPACE_DECL {
-int iscanonicalf (float x) {
+int iscanonicalf(float x) {
float temp;
return fputil::canonicalize(temp, x) == 0;
}
diff --git a/libc/src/math/generic/iscanonicalf128.cpp b/libc/src/math/generic/iscanonicalf128.cpp
index 8650cd150678ef..ccd9b34411b2c4 100644
--- a/libc/src/math/generic/iscanonicalf128.cpp
+++ b/libc/src/math/generic/iscanonicalf128.cpp
@@ -13,7 +13,7 @@
namespace LIBC_NAMESPACE_DECL {
-int iscanonicalf128 (float128 x) {
+int iscanonicalf128(float128 x) {
float128 temp;
return fputil::canonicalize(temp, x) == 0;
}
diff --git a/libc/src/math/generic/iscanonicalf16.cpp b/libc/src/math/generic/iscanonicalf16.cpp
index 1769697c79c633..236b6276295137 100644
--- a/libc/src/math/generic/iscanonicalf16.cpp
+++ b/libc/src/math/generic/iscanonicalf16.cpp
@@ -13,7 +13,7 @@
namespace LIBC_NAMESPACE_DECL {
-int iscanonicalf16 (float16 x) {
+int iscanonicalf16(float16 x) {
float16 temp;
return fputil::canonicalize(temp, x) == 0;
}
diff --git a/libc/src/math/generic/iscanonicall.cpp b/libc/src/math/generic/iscanonicall.cpp
index a639015fb27e40..9aa28ecccf6a86 100644
--- a/libc/src/math/generic/iscanonicall.cpp
+++ b/libc/src/math/generic/iscanonicall.cpp
@@ -13,7 +13,7 @@
namespace LIBC_NAMESPACE_DECL {
-int iscanonicall (long double x) {
+int iscanonicall(long double x) {
long double temp;
return fputil::canonicalize(temp, x) == 0;
}
More information about the libc-commits
mailing list