[libc-commits] [libc] [libc][complex] fix compiler support matrix for cfloat128 (PR #122593)

Shourya Goel via libc-commits libc-commits at lists.llvm.org
Sat Jan 11 08:10:59 PST 2025


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

>From 582e8aee2001a600bfc20c90f5e798b1471d8517 Mon Sep 17 00:00:00 2001
From: Sh0g0-1758 <shouryagoel10000 at gmail.com>
Date: Sat, 11 Jan 2025 19:27:11 +0530
Subject: [PATCH 1/4] fix: compiler support matrix for cfloat128

---
 libc/include/llvm-libc-types/cfloat128.h | 37 ++++++++++++------------
 1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/libc/include/llvm-libc-types/cfloat128.h b/libc/include/llvm-libc-types/cfloat128.h
index f76a0c1c2f5af5..c8b54f2c052b13 100644
--- a/libc/include/llvm-libc-types/cfloat128.h
+++ b/libc/include/llvm-libc-types/cfloat128.h
@@ -18,25 +18,26 @@
 //
 // TODO: Update the complex variant of C23 `_Float128` type detection again when
 // clang supports it.
-#if defined(__STDC_IEC_60559_COMPLEX__) && !defined(__clang__)
-#if !defined(__cplusplus)
-#define LIBC_TYPES_HAS_CFLOAT128
-typedef _Complex _Float128 cfloat128;
-#elif defined(__GNUC__) && __GNUC__ >= 13
-#define LIBC_TYPES_HAS_CFLOAT128
-typedef _Complex _Float128 cfloat128;
-#endif
-#elif __clang_major__ >= 11 &&                                                 \
-    (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
-// Use _Complex __float128 type. clang uses __SIZEOF_FLOAT128__ or __FLOAT128__
-// macro to notify the availability of __float128 type:
-// https://reviews.llvm.org/D15120
-#define LIBC_TYPES_HAS_CFLOAT128
-typedef _Complex __float128 cfloat128;
+#if !defined(__clang__)
+    #if defined(__STDC_IEC_60559_COMPLEX__) || defined(__SIZEOF_FLOAT128__)
+        #if defined(__GNUC__) && !defined(__cplusplus)
+            #define LIBC_TYPES_HAS_CFLOAT128
+            typedef _Complex _Float128 cfloat128;
+        #elif defined(__GNUC__) && __GNUC__ >= 13
+            #define LIBC_TYPES_HAS_CFLOAT128
+            typedef _Complex _Float128 cfloat128;
+        #endif
+    #endif
+#elif (__clang_major__ >= 11) && (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
+    // Use _Complex __float128 type. clang uses __SIZEOF_FLOAT128__ or __FLOAT128__
+    // macro to notify the availability of __float128 type:
+    // https://reviews.llvm.org/D15120
+    #define LIBC_TYPES_HAS_CFLOAT128
+    typedef _Complex __float128 cfloat128;
 #elif (LDBL_MANT_DIG == 113)
-#define LIBC_TYPES_HAS_CFLOAT128
-#define LIBC_TYPES_CFLOAT128_IS_COMPLEX_LONG_DOUBLE
-typedef _Complex long double cfloat128;
+    #define LIBC_TYPES_HAS_CFLOAT128
+    #define LIBC_TYPES_CFLOAT128_IS_COMPLEX_LONG_DOUBLE
+    typedef _Complex long double cfloat128;
 #endif
 
 #endif // LLVM_LIBC_TYPES_CFLOAT128_H

>From a2bfc3f5255e1f8313fdc747b933b0eca4ff8487 Mon Sep 17 00:00:00 2001
From: Sh0g0-1758 <shouryagoel10000 at gmail.com>
Date: Sat, 11 Jan 2025 19:28:25 +0530
Subject: [PATCH 2/4] clang-fmt

---
 libc/include/llvm-libc-types/cfloat128.h | 37 ++++++++++++------------
 1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/libc/include/llvm-libc-types/cfloat128.h b/libc/include/llvm-libc-types/cfloat128.h
index c8b54f2c052b13..1a84cdf9de8d66 100644
--- a/libc/include/llvm-libc-types/cfloat128.h
+++ b/libc/include/llvm-libc-types/cfloat128.h
@@ -19,25 +19,26 @@
 // TODO: Update the complex variant of C23 `_Float128` type detection again when
 // clang supports it.
 #if !defined(__clang__)
-    #if defined(__STDC_IEC_60559_COMPLEX__) || defined(__SIZEOF_FLOAT128__)
-        #if defined(__GNUC__) && !defined(__cplusplus)
-            #define LIBC_TYPES_HAS_CFLOAT128
-            typedef _Complex _Float128 cfloat128;
-        #elif defined(__GNUC__) && __GNUC__ >= 13
-            #define LIBC_TYPES_HAS_CFLOAT128
-            typedef _Complex _Float128 cfloat128;
-        #endif
-    #endif
-#elif (__clang_major__ >= 11) && (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
-    // Use _Complex __float128 type. clang uses __SIZEOF_FLOAT128__ or __FLOAT128__
-    // macro to notify the availability of __float128 type:
-    // https://reviews.llvm.org/D15120
-    #define LIBC_TYPES_HAS_CFLOAT128
-    typedef _Complex __float128 cfloat128;
+#if defined(__STDC_IEC_60559_COMPLEX__) || defined(__SIZEOF_FLOAT128__)
+#if defined(__GNUC__) && !defined(__cplusplus)
+#define LIBC_TYPES_HAS_CFLOAT128
+typedef _Complex _Float128 cfloat128;
+#elif defined(__GNUC__) && __GNUC__ >= 13
+#define LIBC_TYPES_HAS_CFLOAT128
+typedef _Complex _Float128 cfloat128;
+#endif
+#endif
+#elif (__clang_major__ >= 11) &&                                               \
+    (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
+// Use _Complex __float128 type. clang uses __SIZEOF_FLOAT128__ or __FLOAT128__
+// macro to notify the availability of __float128 type:
+// https://reviews.llvm.org/D15120
+#define LIBC_TYPES_HAS_CFLOAT128
+typedef _Complex __float128 cfloat128;
 #elif (LDBL_MANT_DIG == 113)
-    #define LIBC_TYPES_HAS_CFLOAT128
-    #define LIBC_TYPES_CFLOAT128_IS_COMPLEX_LONG_DOUBLE
-    typedef _Complex long double cfloat128;
+#define LIBC_TYPES_HAS_CFLOAT128
+#define LIBC_TYPES_CFLOAT128_IS_COMPLEX_LONG_DOUBLE
+typedef _Complex long double cfloat128;
 #endif
 
 #endif // LLVM_LIBC_TYPES_CFLOAT128_H

>From 587239729ae5ef10916527ab8ee1e9e2fe23d1be Mon Sep 17 00:00:00 2001
From: Sh0g0-1758 <shouryagoel10000 at gmail.com>
Date: Sat, 11 Jan 2025 21:39:49 +0530
Subject: [PATCH 3/4] nit

---
 libc/include/llvm-libc-types/cfloat128.h | 29 ++++++++----------------
 1 file changed, 9 insertions(+), 20 deletions(-)

diff --git a/libc/include/llvm-libc-types/cfloat128.h b/libc/include/llvm-libc-types/cfloat128.h
index 1a84cdf9de8d66..1b92380f77f026 100644
--- a/libc/include/llvm-libc-types/cfloat128.h
+++ b/libc/include/llvm-libc-types/cfloat128.h
@@ -18,27 +18,16 @@
 //
 // TODO: Update the complex variant of C23 `_Float128` type detection again when
 // clang supports it.
-#if !defined(__clang__)
-#if defined(__STDC_IEC_60559_COMPLEX__) || defined(__SIZEOF_FLOAT128__)
-#if defined(__GNUC__) && !defined(__cplusplus)
-#define LIBC_TYPES_HAS_CFLOAT128
-typedef _Complex _Float128 cfloat128;
-#elif defined(__GNUC__) && __GNUC__ >= 13
-#define LIBC_TYPES_HAS_CFLOAT128
-typedef _Complex _Float128 cfloat128;
-#endif
-#endif
-#elif (__clang_major__ >= 11) &&                                               \
-    (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
-// Use _Complex __float128 type. clang uses __SIZEOF_FLOAT128__ or __FLOAT128__
-// macro to notify the availability of __float128 type:
-// https://reviews.llvm.org/D15120
-#define LIBC_TYPES_HAS_CFLOAT128
-typedef _Complex __float128 cfloat128;
+#if defined(__clang__) && (__clang_major__ >= 11) && (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
+    #define LIBC_TYPES_HAS_CFLOAT128
+    typedef _Complex __float128 cfloat128;
+#elif defined(__GNUC__) && (defined(__STDC_IEC_60559_COMPLEX__) || defined(__SIZEOF_FLOAT128__)) && (__GNUC__ >= 13 || (!defined(__cplusplus)))
+    #define LIBC_TYPES_HAS_CFLOAT128
+    typedef _Complex _Float128 cfloat128;
 #elif (LDBL_MANT_DIG == 113)
-#define LIBC_TYPES_HAS_CFLOAT128
-#define LIBC_TYPES_CFLOAT128_IS_COMPLEX_LONG_DOUBLE
-typedef _Complex long double cfloat128;
+    #define LIBC_TYPES_HAS_CFLOAT128
+    #define LIBC_TYPES_CFLOAT128_IS_COMPLEX_LONG_DOUBLE
+    typedef _Complex long double cfloat128;
 #endif
 
 #endif // LLVM_LIBC_TYPES_CFLOAT128_H

>From a7728e36f1128c166392573b282f67bdbda779b6 Mon Sep 17 00:00:00 2001
From: Sh0g0-1758 <shouryagoel10000 at gmail.com>
Date: Sat, 11 Jan 2025 21:40:22 +0530
Subject: [PATCH 4/4] fmt

---
 libc/include/llvm-libc-types/cfloat128.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/libc/include/llvm-libc-types/cfloat128.h b/libc/include/llvm-libc-types/cfloat128.h
index 1b92380f77f026..8b5f585eb12ebf 100644
--- a/libc/include/llvm-libc-types/cfloat128.h
+++ b/libc/include/llvm-libc-types/cfloat128.h
@@ -18,12 +18,15 @@
 //
 // TODO: Update the complex variant of C23 `_Float128` type detection again when
 // clang supports it.
-#if defined(__clang__) && (__clang_major__ >= 11) && (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
-    #define LIBC_TYPES_HAS_CFLOAT128
-    typedef _Complex __float128 cfloat128;
-#elif defined(__GNUC__) && (defined(__STDC_IEC_60559_COMPLEX__) || defined(__SIZEOF_FLOAT128__)) && (__GNUC__ >= 13 || (!defined(__cplusplus)))
-    #define LIBC_TYPES_HAS_CFLOAT128
-    typedef _Complex _Float128 cfloat128;
+#if defined(__clang__) && (__clang_major__ >= 11) &&                           \
+    (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
+#define LIBC_TYPES_HAS_CFLOAT128
+typedef _Complex __float128 cfloat128;
+#elif defined(__GNUC__) &&                                                     \
+    (defined(__STDC_IEC_60559_COMPLEX__) || defined(__SIZEOF_FLOAT128__)) &&   \
+    (__GNUC__ >= 13 || (!defined(__cplusplus)))
+#define LIBC_TYPES_HAS_CFLOAT128
+typedef _Complex _Float128 cfloat128;
 #elif (LDBL_MANT_DIG == 113)
     #define LIBC_TYPES_HAS_CFLOAT128
     #define LIBC_TYPES_CFLOAT128_IS_COMPLEX_LONG_DOUBLE



More information about the libc-commits mailing list