1//===-- Definition of float128 type ---------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_LIBC_TYPES_FLOAT128_H
10#define LLVM_LIBC_TYPES_FLOAT128_H
11
12#include "../llvm-libc-macros/float-macros.h" // LDBL_MANT_DIG
13
14// Currently, C23 `_Float128` type is only defined as a built-in type in GCC 7
15// or later, and only for C. For C++, or for clang, `__float128` is defined
16// instead, and only on x86-64 targets.
17//
18// TODO: Update C23 `_Float128` type detection again when clang supports it.
19// https://github.com/llvm/llvm-project/issues/80195
20#if defined(__STDC_IEC_60559_BFP__) && !defined(__clang__) && \
21 !defined(__cplusplus)
22#define LIBC_TYPES_HAS_FLOAT128
23typedef _Float128 float128;
24#elif defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
25// Use __float128 type. gcc and clang sometime use __SIZEOF_FLOAT128__ to
26// notify the availability of __float128.
27// clang also uses __FLOAT128__ macro to notify the availability of __float128
28// type: https://reviews.llvm.org/D15120
29#define LIBC_TYPES_HAS_FLOAT128
30typedef __float128 float128;
31#elif (LDBL_MANT_DIG == 113)
32#define LIBC_TYPES_HAS_FLOAT128
33typedef long double float128;
34#endif
35
36#endif // LLVM_LIBC_TYPES_FLOAT128_H
37

source code of libc/include/llvm-libc-types/float128.h