[libc-commits] [libc] [libc] Fix generated float128 header for aarch64 target. (PR #78017)
via libc-commits
libc-commits at lists.llvm.org
Fri Feb 2 10:56:29 PST 2024
https://github.com/lntue updated https://github.com/llvm/llvm-project/pull/78017
>From 4690a6ce4b68bce1c252a8b5a1eb96af49ceb1bf Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue at google.com>
Date: Fri, 12 Jan 2024 21:25:34 -0500
Subject: [PATCH 1/8] [libc] Fix generated float128 header for aarch64 target.
---
libc/config/linux/api.td | 2 +-
libc/include/CMakeLists.txt | 1 +
libc/include/llvm-libc-types/CMakeLists.txt | 1 +
libc/include/llvm-libc-types/float128.h | 30 ++++++++++++++++++++
libc/spec/spec.td | 2 +-
libc/spec/stdc.td | 1 +
libc/src/__support/macros/properties/float.h | 9 ++++--
7 files changed, 41 insertions(+), 5 deletions(-)
create mode 100644 libc/include/llvm-libc-types/float128.h
diff --git a/libc/config/linux/api.td b/libc/config/linux/api.td
index b8fe16cc0c79e..c1f052e1bfa3c 100644
--- a/libc/config/linux/api.td
+++ b/libc/config/linux/api.td
@@ -55,7 +55,7 @@ def IntTypesAPI : PublicAPI<"inttypes.h"> {
}
def MathAPI : PublicAPI<"math.h"> {
- let Types = ["double_t", "float_t"];
+ let Types = ["double_t", "float_t", "float128"];
}
def FenvAPI: PublicAPI<"fenv.h"> {
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index e3151140374a6..4f4d8434757d7 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -100,6 +100,7 @@ add_gen_header(
.llvm-libc-macros.math_macros
.llvm-libc-types.double_t
.llvm-libc-types.float_t
+ .llvm-libc-types.float128
)
# TODO: This should be conditional on POSIX networking being included.
diff --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt
index 6f004d2d64697..6c1b52a9c8151 100644
--- a/libc/include/llvm-libc-types/CMakeLists.txt
+++ b/libc/include/llvm-libc-types/CMakeLists.txt
@@ -98,3 +98,4 @@ add_header(ENTRY HDR ENTRY.h)
add_header(struct_hsearch_data HDR struct_hsearch_data.h)
add_header(struct_epoll_event HDR struct_epoll_event.h)
add_header(struct_epoll_data HDR struct_epoll_data.h)
+add_header(float128 HDR float128.h)
diff --git a/libc/include/llvm-libc-types/float128.h b/libc/include/llvm-libc-types/float128.h
new file mode 100644
index 0000000000000..7030384e7d314
--- /dev/null
+++ b/libc/include/llvm-libc-types/float128.h
@@ -0,0 +1,30 @@
+//===-- Definition of float128 type ---------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef __LLVM_LIBC_TYPES_FLOAT128_H__
+#define __LLVM_LIBC_TYPES_FLOAT128_H__
+
+#if defined(__clang__)
+#define LIBC_COMPILER_IS_CLANG
+#define LIBC_COMPILER_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
+#elif defined(__GNUC__)
+#define LIBC_COMPILER_IS_GCC
+#define LIBC_COMPILER_GCC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
+#endif
+
+#if (defined(LIBC_COMPILER_GCC_VER) && (LIBC_COMPILER_GCC_VER >= 1301)) && \
+ (defined(__aarch64__) || defined(__riscv) || defined(__x86_64__))
+typedef _Float128 float128;
+#elif (defined(LIBC_COMPILER_CLANG_VER) && (LIBC_COMPILER_CLANG_VER >= 600)) &&\
+ (defined(__x86_64__) && !defined(__Fuchsia__))
+typedef __float128 float128;
+#elif (LDBL_MANT_DIG == 113) || (__LDBL_MANT_DIG__ == 113)
+typedef long double float128;
+#endif
+
+#endif // __LLVM_LIBC_TYPES_FLOAT128_H__
diff --git a/libc/spec/spec.td b/libc/spec/spec.td
index 16abf97bf0b1c..0b557c807a546 100644
--- a/libc/spec/spec.td
+++ b/libc/spec/spec.td
@@ -53,7 +53,7 @@ def UnsignedCharType : NamedType<"unsigned char">;
def UnsignedShortType : NamedType<"unsigned short">;
// TODO: Add compatibility layer to use C23 type _Float128 if possible.
-def Float128Type : NamedType<"__float128">;
+def Float128Type : NamedType<"float128">;
// Common types
def VoidPtr : PtrType<VoidType>;
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index 6ff2c7c613696..2f9e25807021b 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -352,6 +352,7 @@ def StdC : StandardSpec<"stdc"> {
[
NamedType<"float_t">,
NamedType<"double_t">,
+ NamedType<"float128">,
],
[], // Enumerations
[
diff --git a/libc/src/__support/macros/properties/float.h b/libc/src/__support/macros/properties/float.h
index 98ca2a5d4bc46..bf2bcc7ffd9d6 100644
--- a/libc/src/__support/macros/properties/float.h
+++ b/libc/src/__support/macros/properties/float.h
@@ -19,11 +19,11 @@
#include <float.h> // LDBL_MANT_DIG
// 'long double' properties.
-#if (LDBL_MANT_DIG == 53)
+#if (LDBL_MANT_DIG == 53) || (__LDBL_MANT_DIG__ == 53)
#define LIBC_LONG_DOUBLE_IS_FLOAT64
-#elif (LDBL_MANT_DIG == 64)
+#elif (LDBL_MANT_DIG == 64) || (__LDBL_MANT_DIG__ == 64)
#define LIBC_LONG_DOUBLE_IS_X86_FLOAT80
-#elif (LDBL_MANT_DIG == 113)
+#elif (LDBL_MANT_DIG == 113) || (__LDBL_MANT_DIG__ == 113)
#define LIBC_LONG_DOUBLE_IS_FLOAT128
#endif
@@ -53,6 +53,9 @@ using float16 = _Float16;
#endif
// float128 support.
+// If the definition of float128 here is updated, also update
+// include/llvm-libc-types/float128.h
+// so that the type definition in generated header `math.h` matched.
#if (defined(LIBC_COMPILER_GCC_VER) && (LIBC_COMPILER_GCC_VER >= 1301)) && \
(defined(LIBC_TARGET_ARCH_IS_AARCH64) || \
defined(LIBC_TARGET_ARCH_IS_ANY_RISCV) || \
>From 7e476e065f877853ac7213de8b0fe6767f741af5 Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue at google.com>
Date: Fri, 12 Jan 2024 22:30:22 -0500
Subject: [PATCH 2/8] Fix formatting.
---
libc/include/llvm-libc-types/float128.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libc/include/llvm-libc-types/float128.h b/libc/include/llvm-libc-types/float128.h
index 7030384e7d314..ce3a69ec80345 100644
--- a/libc/include/llvm-libc-types/float128.h
+++ b/libc/include/llvm-libc-types/float128.h
@@ -20,7 +20,8 @@
#if (defined(LIBC_COMPILER_GCC_VER) && (LIBC_COMPILER_GCC_VER >= 1301)) && \
(defined(__aarch64__) || defined(__riscv) || defined(__x86_64__))
typedef _Float128 float128;
-#elif (defined(LIBC_COMPILER_CLANG_VER) && (LIBC_COMPILER_CLANG_VER >= 600)) &&\
+#elif (defined(LIBC_COMPILER_CLANG_VER) && \
+ (LIBC_COMPILER_CLANG_VER >= 600)) && \
(defined(__x86_64__) && !defined(__Fuchsia__))
typedef __float128 float128;
#elif (LDBL_MANT_DIG == 113) || (__LDBL_MANT_DIG__ == 113)
>From e30b666797d00dc20a81d70036edd11d9768ee35 Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue at google.com>
Date: Mon, 22 Jan 2024 22:46:34 -0500
Subject: [PATCH 3/8] Sync and consolidate float128 type logic in one place.
---
libc/config/linux/aarch64/entrypoints.txt | 3 +-
libc/include/llvm-libc-types/CMakeLists.txt | 8 ++++-
libc/include/llvm-libc-types/float128.h | 32 +++++++++++++-----
.../macros/properties/CMakeLists.txt | 1 +
libc/src/__support/macros/properties/float.h | 33 +++----------------
5 files changed, 37 insertions(+), 40 deletions(-)
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index c8e12ff8d71bc..12c535174435c 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -379,8 +379,7 @@ set(TARGET_LIBM_ENTRYPOINTS
if(LIBC_COMPILER_HAS_FLOAT128)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# math.h C23 _Float128 entrypoints
- # Temporarily disabled since float128 isn't working on the aarch64 buildbot
- # libc.src.math.fabsf128
+ libc.src.math.fabsf128
)
endif()
diff --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt
index 6c1b52a9c8151..e4f23b2a78130 100644
--- a/libc/include/llvm-libc-types/CMakeLists.txt
+++ b/libc/include/llvm-libc-types/CMakeLists.txt
@@ -98,4 +98,10 @@ add_header(ENTRY HDR ENTRY.h)
add_header(struct_hsearch_data HDR struct_hsearch_data.h)
add_header(struct_epoll_event HDR struct_epoll_event.h)
add_header(struct_epoll_data HDR struct_epoll_data.h)
-add_header(float128 HDR float128.h)
+add_header(
+ float128
+ HDR
+ float128.h
+ DEPENDS
+ libc.include.llvm-libc-macros.float_macros
+)
diff --git a/libc/include/llvm-libc-types/float128.h b/libc/include/llvm-libc-types/float128.h
index ce3a69ec80345..61dfb64746918 100644
--- a/libc/include/llvm-libc-types/float128.h
+++ b/libc/include/llvm-libc-types/float128.h
@@ -9,23 +9,37 @@
#ifndef __LLVM_LIBC_TYPES_FLOAT128_H__
#define __LLVM_LIBC_TYPES_FLOAT128_H__
+#include <llvm-libc-macros/float-macros.h> // LDBL_MANT_DIG
+
+// Define temporary compiler and its version
#if defined(__clang__)
-#define LIBC_COMPILER_IS_CLANG
-#define LIBC_COMPILER_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
+#define __LIBC_COMPILER_IS_CLANG
+#define __LIBC_COMPILER_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
#elif defined(__GNUC__)
-#define LIBC_COMPILER_IS_GCC
-#define LIBC_COMPILER_GCC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
-#endif
+#define __LIBC_COMPILER_IS_GCC
+#define __LIBC_COMPILER_GCC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
+#endif // __clang__, __GNUC__
-#if (defined(LIBC_COMPILER_GCC_VER) && (LIBC_COMPILER_GCC_VER >= 1301)) && \
+#if (defined(__LIBC_COMPILER_GCC_VER) && (__LIBC_COMPILER_GCC_VER >= 1301)) && \
(defined(__aarch64__) || defined(__riscv) || defined(__x86_64__))
+#define LIBC_COMPILER_HAS_C23_FLOAT128
typedef _Float128 float128;
-#elif (defined(LIBC_COMPILER_CLANG_VER) && \
- (LIBC_COMPILER_CLANG_VER >= 600)) && \
+#elif (defined(__LIBC_COMPILER_CLANG_VER) && \
+ (__LIBC_COMPILER_CLANG_VER >= 600)) && \
(defined(__x86_64__) && !defined(__Fuchsia__))
+#define LIBC_COMPILER_HAS_FLOAT128_EXTENSION
typedef __float128 float128;
-#elif (LDBL_MANT_DIG == 113) || (__LDBL_MANT_DIG__ == 113)
+#elif (LDBL_MANT_DIG == 113)
typedef long double float128;
#endif
+// Clean up temporary macros
+#ifdef __LIBC_COMPILER_IS_CLANG
+#undef __LIBC_COMPILER_IS_CLANG
+#undef __LIBC_COMPILER_CLANG_VER
+#elif defined(__LIBC_COMPILER_IS_GCC)
+#undef __LIBC_COMPILER_IS_GCC
+#undef __LIBC_COMPILER_GCC_VER
+#endif // __LIBC_COMPILER_IS_CLANG, __LIBC_COMPILER_IS_GCC
+
#endif // __LLVM_LIBC_TYPES_FLOAT128_H__
diff --git a/libc/src/__support/macros/properties/CMakeLists.txt b/libc/src/__support/macros/properties/CMakeLists.txt
index ee87ce68c9da3..b309c052a5907 100644
--- a/libc/src/__support/macros/properties/CMakeLists.txt
+++ b/libc/src/__support/macros/properties/CMakeLists.txt
@@ -33,4 +33,5 @@ add_header_library(
.compiler
.cpu_features
.os
+ libc.include.llvm-libc-types.float128
)
diff --git a/libc/src/__support/macros/properties/float.h b/libc/src/__support/macros/properties/float.h
index bf2bcc7ffd9d6..510f392374935 100644
--- a/libc/src/__support/macros/properties/float.h
+++ b/libc/src/__support/macros/properties/float.h
@@ -11,19 +11,19 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_FLOAT_H
#define LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_FLOAT_H
+#include "llvm-libc-macros/float-macros.h" // LDBL_MANT_DIG
+#include "llvm-libc-types/float128.h" // float128
#include "src/__support/macros/properties/architectures.h"
#include "src/__support/macros/properties/compiler.h"
#include "src/__support/macros/properties/cpu_features.h"
#include "src/__support/macros/properties/os.h"
-#include <float.h> // LDBL_MANT_DIG
-
// 'long double' properties.
-#if (LDBL_MANT_DIG == 53) || (__LDBL_MANT_DIG__ == 53)
+#if (LDBL_MANT_DIG == 53)
#define LIBC_LONG_DOUBLE_IS_FLOAT64
-#elif (LDBL_MANT_DIG == 64) || (__LDBL_MANT_DIG__ == 64)
+#elif (LDBL_MANT_DIG == 64)
#define LIBC_LONG_DOUBLE_IS_X86_FLOAT80
-#elif (LDBL_MANT_DIG == 113) || (__LDBL_MANT_DIG__ == 113)
+#elif (LDBL_MANT_DIG == 113)
#define LIBC_LONG_DOUBLE_IS_FLOAT128
#endif
@@ -53,29 +53,6 @@ using float16 = _Float16;
#endif
// float128 support.
-// If the definition of float128 here is updated, also update
-// include/llvm-libc-types/float128.h
-// so that the type definition in generated header `math.h` matched.
-#if (defined(LIBC_COMPILER_GCC_VER) && (LIBC_COMPILER_GCC_VER >= 1301)) && \
- (defined(LIBC_TARGET_ARCH_IS_AARCH64) || \
- defined(LIBC_TARGET_ARCH_IS_ANY_RISCV) || \
- defined(LIBC_TARGET_ARCH_IS_X86_64))
-#define LIBC_COMPILER_HAS_C23_FLOAT128
-#endif
-#if (defined(LIBC_COMPILER_CLANG_VER) && (LIBC_COMPILER_CLANG_VER >= 600)) && \
- (defined(LIBC_TARGET_ARCH_IS_X86_64) && \
- defined(LIBC_TARGET_OS_IS_LINUX) && !defined(LIBC_TARGET_OS_IS_FUCHSIA))
-#define LIBC_COMPILER_HAS_FLOAT128_EXTENSION
-#endif
-
-#if defined(LIBC_COMPILER_HAS_C23_FLOAT128)
-using float128 = _Float128;
-#elif defined(LIBC_COMPILER_HAS_FLOAT128_EXTENSION)
-using float128 = __float128;
-#elif defined(LIBC_LONG_DOUBLE_IS_FLOAT128)
-using float128 = long double;
-#endif
-
#if defined(LIBC_COMPILER_HAS_C23_FLOAT128) || \
defined(LIBC_COMPILER_HAS_FLOAT128_EXTENSION) || \
defined(LIBC_LONG_DOUBLE_IS_FLOAT128)
>From 1014ffb113cc91a983a6f65925359e71fe305f8e Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue at google.com>
Date: Tue, 23 Jan 2024 08:56:32 -0500
Subject: [PATCH 4/8] Add missing dependency and fix __copied_hdr__ target
issues.
---
libc/include/llvm-libc-types/float128.h | 2 +-
libc/src/__support/macros/properties/CMakeLists.txt | 1 +
libc/src/__support/macros/properties/float.h | 4 ++--
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/libc/include/llvm-libc-types/float128.h b/libc/include/llvm-libc-types/float128.h
index 61dfb64746918..f592fc43b17c4 100644
--- a/libc/include/llvm-libc-types/float128.h
+++ b/libc/include/llvm-libc-types/float128.h
@@ -9,7 +9,7 @@
#ifndef __LLVM_LIBC_TYPES_FLOAT128_H__
#define __LLVM_LIBC_TYPES_FLOAT128_H__
-#include <llvm-libc-macros/float-macros.h> // LDBL_MANT_DIG
+#include <include/llvm-libc-macros/float-macros.h> // LDBL_MANT_DIG
// Define temporary compiler and its version
#if defined(__clang__)
diff --git a/libc/src/__support/macros/properties/CMakeLists.txt b/libc/src/__support/macros/properties/CMakeLists.txt
index b309c052a5907..3c492ab55a90c 100644
--- a/libc/src/__support/macros/properties/CMakeLists.txt
+++ b/libc/src/__support/macros/properties/CMakeLists.txt
@@ -33,5 +33,6 @@ add_header_library(
.compiler
.cpu_features
.os
+ libc.include.llvm-libc-macros.float_macros
libc.include.llvm-libc-types.float128
)
diff --git a/libc/src/__support/macros/properties/float.h b/libc/src/__support/macros/properties/float.h
index 510f392374935..08a1ab726cbde 100644
--- a/libc/src/__support/macros/properties/float.h
+++ b/libc/src/__support/macros/properties/float.h
@@ -11,8 +11,8 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_FLOAT_H
#define LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_FLOAT_H
-#include "llvm-libc-macros/float-macros.h" // LDBL_MANT_DIG
-#include "llvm-libc-types/float128.h" // float128
+#include "include/llvm-libc-macros/float-macros.h" // LDBL_MANT_DIG
+#include "include/llvm-libc-types/float128.h" // float128
#include "src/__support/macros/properties/architectures.h"
#include "src/__support/macros/properties/compiler.h"
#include "src/__support/macros/properties/cpu_features.h"
>From a7773b3875bc935ca95a73e17f5f1485df4b50aa Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue at google.com>
Date: Tue, 23 Jan 2024 16:23:20 -0500
Subject: [PATCH 5/8] Add TODO to update float128 type detection macros.
---
libc/include/llvm-libc-types/float128.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libc/include/llvm-libc-types/float128.h b/libc/include/llvm-libc-types/float128.h
index f592fc43b17c4..67d2fa890e628 100644
--- a/libc/include/llvm-libc-types/float128.h
+++ b/libc/include/llvm-libc-types/float128.h
@@ -20,6 +20,8 @@
#define __LIBC_COMPILER_GCC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
#endif // __clang__, __GNUC__
+// TODO: Simplify and update the type detection, especially when clang supports
+// _Float128 C23 type.
#if (defined(__LIBC_COMPILER_GCC_VER) && (__LIBC_COMPILER_GCC_VER >= 1301)) && \
(defined(__aarch64__) || defined(__riscv) || defined(__x86_64__))
#define LIBC_COMPILER_HAS_C23_FLOAT128
>From 0c53bce7cf7f6efd48e8e4e2df6b385dbf60f4ad Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue at google.com>
Date: Fri, 2 Feb 2024 12:55:56 -0500
Subject: [PATCH 6/8] Simplify float128 type detection macros.
---
libc/include/llvm-libc-types/float128.h | 34 +++++++------------------
1 file changed, 9 insertions(+), 25 deletions(-)
diff --git a/libc/include/llvm-libc-types/float128.h b/libc/include/llvm-libc-types/float128.h
index 67d2fa890e628..a2dc07c5ec9fe 100644
--- a/libc/include/llvm-libc-types/float128.h
+++ b/libc/include/llvm-libc-types/float128.h
@@ -11,37 +11,21 @@
#include <include/llvm-libc-macros/float-macros.h> // LDBL_MANT_DIG
-// Define temporary compiler and its version
-#if defined(__clang__)
-#define __LIBC_COMPILER_IS_CLANG
-#define __LIBC_COMPILER_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
-#elif defined(__GNUC__)
-#define __LIBC_COMPILER_IS_GCC
-#define __LIBC_COMPILER_GCC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
-#endif // __clang__, __GNUC__
-
-// TODO: Simplify and update the type detection, especially when clang supports
-// _Float128 C23 type.
-#if (defined(__LIBC_COMPILER_GCC_VER) && (__LIBC_COMPILER_GCC_VER >= 1301)) && \
- (defined(__aarch64__) || defined(__riscv) || defined(__x86_64__))
+// TODO: https://github.com/llvm/llvm-project/issues/80195
+// Check _Float128 C23 type detection again when clang supports it.
+#if (__STDC_IEC_60559_BFP__)
+// Use _Float128 C23 type.
#define LIBC_COMPILER_HAS_C23_FLOAT128
typedef _Float128 float128;
-#elif (defined(__LIBC_COMPILER_CLANG_VER) && \
- (__LIBC_COMPILER_CLANG_VER >= 600)) && \
- (defined(__x86_64__) && !defined(__Fuchsia__))
+#elif defined(__FLOAT128__)
+// Use __float128 type.
+// clang uses __FLOAT128__ macro to notify the availability of __float128 type:
+// https://reviews.llvm.org/D15120
#define LIBC_COMPILER_HAS_FLOAT128_EXTENSION
typedef __float128 float128;
#elif (LDBL_MANT_DIG == 113)
+// Use long double.
typedef long double float128;
#endif
-// Clean up temporary macros
-#ifdef __LIBC_COMPILER_IS_CLANG
-#undef __LIBC_COMPILER_IS_CLANG
-#undef __LIBC_COMPILER_CLANG_VER
-#elif defined(__LIBC_COMPILER_IS_GCC)
-#undef __LIBC_COMPILER_IS_GCC
-#undef __LIBC_COMPILER_GCC_VER
-#endif // __LIBC_COMPILER_IS_CLANG, __LIBC_COMPILER_IS_GCC
-
#endif // __LLVM_LIBC_TYPES_FLOAT128_H__
>From 503687a6cfb8724bffa3aec113f250f653e2a87e Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue at google.com>
Date: Fri, 2 Feb 2024 13:30:34 -0500
Subject: [PATCH 7/8] Fix ifdef.
---
libc/include/llvm-libc-types/float128.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libc/include/llvm-libc-types/float128.h b/libc/include/llvm-libc-types/float128.h
index a2dc07c5ec9fe..271045827788b 100644
--- a/libc/include/llvm-libc-types/float128.h
+++ b/libc/include/llvm-libc-types/float128.h
@@ -13,7 +13,7 @@
// TODO: https://github.com/llvm/llvm-project/issues/80195
// Check _Float128 C23 type detection again when clang supports it.
-#if (__STDC_IEC_60559_BFP__)
+#ifdef __STDC_IEC_60559_BFP__
// Use _Float128 C23 type.
#define LIBC_COMPILER_HAS_C23_FLOAT128
typedef _Float128 float128;
>From 76aedc891307c10cd58b448ae89189c20d577330 Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue at google.com>
Date: Fri, 2 Feb 2024 13:56:01 -0500
Subject: [PATCH 8/8] Exclude clang from using C23 _Float128 type.
---
libc/include/llvm-libc-types/float128.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libc/include/llvm-libc-types/float128.h b/libc/include/llvm-libc-types/float128.h
index 271045827788b..3ee41ade60bfc 100644
--- a/libc/include/llvm-libc-types/float128.h
+++ b/libc/include/llvm-libc-types/float128.h
@@ -13,7 +13,7 @@
// TODO: https://github.com/llvm/llvm-project/issues/80195
// Check _Float128 C23 type detection again when clang supports it.
-#ifdef __STDC_IEC_60559_BFP__
+#if defined(__STDC_IEC_60559_BFP__) && !defined(__clang__)
// Use _Float128 C23 type.
#define LIBC_COMPILER_HAS_C23_FLOAT128
typedef _Float128 float128;
More information about the libc-commits
mailing list