[libc-commits] [libc] [libc][math] undef `iscanonical` before defining it using `LLVM_LIBC_FUNCTION` macro (PR #110865)

Shourya Goel via libc-commits libc-commits at lists.llvm.org
Wed Oct 2 08:57:36 PDT 2024


https://github.com/Sh0g0-1758 updated https://github.com/llvm/llvm-project/pull/110865

>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/3] 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/3] 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;
 }

>From 82794248a135b6e47e9bbb5c0d2b8ea325eae53b Mon Sep 17 00:00:00 2001
From: Sh0g0-1758 <shouryagoel10000 at gmail.com>
Date: Wed, 2 Oct 2024 21:20:51 +0530
Subject: [PATCH 3/3] undef iscanonical

---
 libc/src/math/generic/iscanonical.cpp     | 3 ++-
 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, 6 insertions(+), 5 deletions(-)

diff --git a/libc/src/math/generic/iscanonical.cpp b/libc/src/math/generic/iscanonical.cpp
index 69a95c719a85c9..ff922f3ae8ee72 100644
--- a/libc/src/math/generic/iscanonical.cpp
+++ b/libc/src/math/generic/iscanonical.cpp
@@ -13,7 +13,8 @@
 
 namespace LIBC_NAMESPACE_DECL {
 
-int iscanonical(double x) {
+#undef iscanonical
+LLVM_LIBC_FUNCTION(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 b27c0fd1fabf44..5c38e9b72ec582 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) {
+LLVM_LIBC_FUNCTION(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 ccd9b34411b2c4..ff549c3194cbaf 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) {
+LLVM_LIBC_FUNCTION(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 236b6276295137..f9b093dc8ff2dd 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) {
+LLVM_LIBC_FUNCTION(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 9aa28ecccf6a86..34e00359912b71 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) {
+LLVM_LIBC_FUNCTION(int, iscanonicall, (long double x)) {
   long double temp;
   return fputil::canonicalize(temp, x) == 0;
 }



More information about the libc-commits mailing list