From 8f3e7c3fb0552fcfffcf22e74761291e5c21d748 Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 Date: Tue, 10 Dec 2024 10:37:43 +0530 Subject: [PATCH 1/2] fix: check that cfloat128 is not defined _Complex long double --- libc/src/__support/complex_type.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libc/src/__support/complex_type.h b/libc/src/__support/complex_type.h index 4c861b05bc752..7d9f21229fa94 100644 --- a/libc/src/__support/complex_type.h +++ b/libc/src/__support/complex_type.h @@ -37,10 +37,12 @@ template <> struct make_complex { }; #endif #if defined(LIBC_TYPES_HAS_CFLOAT128) +#if (LDBL_MANT_DIG != 113) template <> struct make_complex { using type = cfloat128; }; #endif +#endif template using make_complex_t = typename make_complex::type; @@ -62,10 +64,12 @@ template <> struct make_real { }; #endif #if defined(LIBC_TYPES_HAS_CFLOAT128) +#if (LDBL_MANT_DIG != 113) template <> struct make_real { using type = float128; }; #endif +#endif template using make_real_t = typename make_real::type; From c3185c371d48fe1a8fb973e5ff5aa396e43f1d2a Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 Date: Tue, 10 Dec 2024 11:16:51 +0530 Subject: [PATCH 2/2] nit --- libc/include/llvm-libc-types/cfloat128.h | 1 + libc/src/__support/complex_type.h | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libc/include/llvm-libc-types/cfloat128.h b/libc/include/llvm-libc-types/cfloat128.h index a371671cf6235..f76a0c1c2f5af 100644 --- a/libc/include/llvm-libc-types/cfloat128.h +++ b/libc/include/llvm-libc-types/cfloat128.h @@ -35,6 +35,7 @@ typedef _Complex _Float128 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; #endif diff --git a/libc/src/__support/complex_type.h b/libc/src/__support/complex_type.h index 7d9f21229fa94..88239886f983b 100644 --- a/libc/src/__support/complex_type.h +++ b/libc/src/__support/complex_type.h @@ -37,7 +37,7 @@ template <> struct make_complex { }; #endif #if defined(LIBC_TYPES_HAS_CFLOAT128) -#if (LDBL_MANT_DIG != 113) +#if !(LIBC_TYPES_LONG_DOUBLE_IS_FLOAT128) template <> struct make_complex { using type = cfloat128; }; @@ -64,7 +64,7 @@ template <> struct make_real { }; #endif #if defined(LIBC_TYPES_HAS_CFLOAT128) -#if (LDBL_MANT_DIG != 113) +#if !(LIBC_TYPES_CFLOAT128_IS_COMPLEX_LONG_DOUBLE) template <> struct make_real { using type = float128; };