/* Macros to control TS 18661-3 glibc features where the same
definitions are appropriate for all platforms.
- Copyright (C) 2017 Free Software Foundation, Inc.
+ Copyright (C) 2017-2019 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
+ <https://www.gnu.org/licenses/>. */
#ifndef _BITS_FLOATN_COMMON_H
#define _BITS_FLOATN_COMMON_H
#include <features.h>
+#include <bits/long-double.h>
/* This header should be included at the bottom of each bits/floatn.h.
It defines the following macros for each _FloatN and _FloatNx type,
floating-point type with the right format for this type, and this
glibc includes corresponding *fN or *fNx interfaces for it. */
#define __HAVE_FLOAT16 0
-#define __HAVE_FLOAT32 0
-#define __HAVE_FLOAT64 0
-#define __HAVE_FLOAT32X 0
+#define __HAVE_FLOAT32 1
+#define __HAVE_FLOAT64 1
+#define __HAVE_FLOAT32X 1
#define __HAVE_FLOAT128X 0
/* Defined to 1 if the corresponding __HAVE_<type> macro is 1 and the
#define __HAVE_DISTINCT_FLOAT64X 0
#define __HAVE_DISTINCT_FLOAT128X __HAVE_FLOAT128X
+/* Defined to 1 if the corresponding _FloatN type is not binary compatible
+ with the corresponding ISO C type in the current compilation unit as
+ opposed to __HAVE_DISTINCT_FLOATN, which indicates the default types built
+ in glibc. */
+#define __HAVE_FLOAT128_UNLIKE_LDBL (__HAVE_DISTINCT_FLOAT128 \
+ && __LDBL_MANT_DIG__ != 113)
+
/* Defined to 1 if any _FloatN or _FloatNx types that are not
ABI-distinct are however distinct types at the C language level (so
for the purposes of __builtin_types_compatible_p and _Generic). */
# if __HAVE_FLOAT64
# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
-# define __f64(x) x
+# ifdef __NO_LONG_DOUBLE_MATH
+# define __f64(x) x##l
+# else
+# define __f64(x) x
+# endif
# else
# define __f64(x) x##f64
# endif
# if __HAVE_FLOAT64
# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
-# define __CFLOAT64 _Complex double
+# ifdef __NO_LONG_DOUBLE_MATH
+# define __CFLOAT64 _Complex long double
+# else
+# define __CFLOAT64 _Complex double
+# endif
# else
# define __CFLOAT64 _Complex _Float64
# endif
# if __HAVE_FLOAT64
-# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
+/* If double, long double and _Float64 all have the same set of
+ values, TS 18661-3 requires the usual arithmetic conversions on
+ long double and _Float64 to produce _Float64. For this to be the
+ case when building with a compiler without a distinct _Float64
+ type, _Float64 must be a typedef for long double, not for
+ double. */
+
+# ifdef __NO_LONG_DOUBLE_MATH
+
+# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
+typedef long double _Float64;
+# endif
+
+# if !__GNUC_PREREQ (7, 0)
+# define __builtin_huge_valf64() (__builtin_huge_vall ())
+# define __builtin_inff64() (__builtin_infl ())
+# define __builtin_nanf64(x) (__builtin_nanl (x))
+# define __builtin_nansf64(x) (__builtin_nansl (x))
+# endif
+
+# else
+
+# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
typedef double _Float64;
-# endif
+# endif
+
+# if !__GNUC_PREREQ (7, 0)
+# define __builtin_huge_valf64() (__builtin_huge_val ())
+# define __builtin_inff64() (__builtin_inf ())
+# define __builtin_nanf64(x) (__builtin_nan (x))
+# define __builtin_nansf64(x) (__builtin_nans (x))
+# endif
-# if !__GNUC_PREREQ (7, 0)
-# define __builtin_huge_valf64() (__builtin_huge_val ())
-# define __builtin_inff64() (__builtin_inf ())
-# define __builtin_nanf64(x) (__builtin_nan (x))
-# define __builtin_nansf64(x) (__builtin_nans (x))
# endif
# endif