[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 10:11:52 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/7] 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/7] 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/7] 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/7] 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
>From 1bb3bd6ec6622a4c68a2b8b68ee85c6716876985 Mon Sep 17 00:00:00 2001
From: Sh0g0-1758 <shouryagoel10000 at gmail.com>
Date: Sat, 11 Jan 2025 23:32:42 +0530
Subject: [PATCH 5/7] nit
---
libc/include/llvm-libc-types/cfloat128.h | 26 +++++++++++++-----------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/libc/include/llvm-libc-types/cfloat128.h b/libc/include/llvm-libc-types/cfloat128.h
index 8b5f585eb12ebf..13e79a8c57fc51 100644
--- a/libc/include/llvm-libc-types/cfloat128.h
+++ b/libc/include/llvm-libc-types/cfloat128.h
@@ -18,19 +18,21 @@
//
// 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;
-#elif (LDBL_MANT_DIG == 113)
+#ifdef __clang__
+ #if (__clang_major__ >= 11) && (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
#define LIBC_TYPES_HAS_CFLOAT128
- #define LIBC_TYPES_CFLOAT128_IS_COMPLEX_LONG_DOUBLE
- typedef _Complex long double cfloat128;
+ typedef _Complex __float128 cfloat128;
+ #endif
+#elif defined(__GNUC__)
+ #if (defined(__STDC_IEC_60559_COMPLEX__) || defined(__SIZEOF_FLOAT128__)) && \
+ (__GNUC__ >= 13 || (!defined(__cplusplus)))
+ #define LIBC_TYPES_HAS_CFLOAT128
+ typedef _Complex _Float128 cfloat128;
+ #endif
+#elif (LDBL_MANT_DIG == 113)
+#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 d3f0ee5c7c654aac64b1eb7dedc77fd949754e58 Mon Sep 17 00:00:00 2001
From: Sh0g0-1758 <shouryagoel10000 at gmail.com>
Date: Sat, 11 Jan 2025 23:36:01 +0530
Subject: [PATCH 6/7] nit
---
libc/include/llvm-libc-types/cfloat128.h | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/libc/include/llvm-libc-types/cfloat128.h b/libc/include/llvm-libc-types/cfloat128.h
index 13e79a8c57fc51..e03c32dca0eaac 100644
--- a/libc/include/llvm-libc-types/cfloat128.h
+++ b/libc/include/llvm-libc-types/cfloat128.h
@@ -19,17 +19,20 @@
// TODO: Update the complex variant of C23 `_Float128` type detection again when
// clang supports it.
#ifdef __clang__
- #if (__clang_major__ >= 11) && (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
- #define LIBC_TYPES_HAS_CFLOAT128
- typedef _Complex __float128 cfloat128;
- #endif
+#if (__clang_major__ >= 11) && \
+ (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
+#define LIBC_TYPES_HAS_CFLOAT128
+typedef _Complex __float128 cfloat128;
+#endif
#elif defined(__GNUC__)
- #if (defined(__STDC_IEC_60559_COMPLEX__) || defined(__SIZEOF_FLOAT128__)) && \
- (__GNUC__ >= 13 || (!defined(__cplusplus)))
- #define LIBC_TYPES_HAS_CFLOAT128
- typedef _Complex _Float128 cfloat128;
- #endif
-#elif (LDBL_MANT_DIG == 113)
+#if (defined(__STDC_IEC_60559_COMPLEX__) || defined(__SIZEOF_FLOAT128__)) && \
+ (__GNUC__ >= 13 || (!defined(__cplusplus)))
+#define LIBC_TYPES_HAS_CFLOAT128
+typedef _Complex _Float128 cfloat128;
+#endif
+#endif
+
+#if !defined(LIBC_TYPES_HAS_CFLOAT128) && (LDBL_MANT_DIG == 113)
#define LIBC_TYPES_HAS_CFLOAT128
#define LIBC_TYPES_CFLOAT128_IS_COMPLEX_LONG_DOUBLE
typedef _Complex long double cfloat128;
>From aec03f13a2633b9aa68be40dde5bbfa41bcb2fed Mon Sep 17 00:00:00 2001
From: Sh0g0-1758 <shouryagoel10000 at gmail.com>
Date: Sat, 11 Jan 2025 23:41:34 +0530
Subject: [PATCH 7/7] nit
---
libc/include/llvm-libc-types/cfloat128.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libc/include/llvm-libc-types/cfloat128.h b/libc/include/llvm-libc-types/cfloat128.h
index e03c32dca0eaac..83fad87910137f 100644
--- a/libc/include/llvm-libc-types/cfloat128.h
+++ b/libc/include/llvm-libc-types/cfloat128.h
@@ -21,6 +21,9 @@
#ifdef __clang__
#if (__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;
#endif
More information about the libc-commits
mailing list