[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 05:59:39 PST 2025


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

None

>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/2] 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/2] 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



More information about the libc-commits mailing list