1 /* Macros to control TS 18661-3 glibc features on powerpc.
2    Copyright (C) 2017-2021 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4 
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9 
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14 
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, see
17    <https://www.gnu.org/licenses/>.  */
18 
19 #ifndef _BITS_FLOATN_H
20 #define _BITS_FLOATN_H
21 
22 #include <features.h>
23 #include <bits/long-double.h>
24 
25 /* Defined to 1 if the current compiler invocation provides a
26    floating-point type with the IEEE 754 binary128 format, and this glibc
27    includes corresponding *f128 interfaces for it.  */
28 #if defined _ARCH_PWR8 && defined __LITTLE_ENDIAN__ && (_CALL_ELF == 2) \
29     && defined __FLOAT128__ && !defined __NO_LONG_DOUBLE_MATH
30 # define __HAVE_FLOAT128 1
31 #else
32 # define __HAVE_FLOAT128 0
33 #endif
34 
35 /* Defined to 1 if __HAVE_FLOAT128 is 1 and the type is ABI-distinct
36    from the default float, double and long double types in this glibc, i.e.
37    calls to the binary128 functions go to *f128 symbols instead of *l.  */
38 #if __HAVE_FLOAT128
39 # define __HAVE_DISTINCT_FLOAT128 1
40 #else
41 # define __HAVE_DISTINCT_FLOAT128 0
42 #endif
43 
44 /* Defined to 1 if the current compiler invocation provides a
45    floating-point type with the right format for _Float64x, and this
46    glibc includes corresponding *f64x interfaces for it.  */
47 #define __HAVE_FLOAT64X __HAVE_FLOAT128
48 
49 /* Defined to 1 if __HAVE_FLOAT64X is 1 and _Float64x has the format
50    of long double.  Otherwise, if __HAVE_FLOAT64X is 1, _Float64x has
51    the format of _Float128, which must be different from that of long
52    double.  */
53 #define __HAVE_FLOAT64X_LONG_DOUBLE 0
54 
55 #ifndef __ASSEMBLER__
56 
57 /* Defined to concatenate the literal suffix to be used with _Float128
58    types, if __HAVE_FLOAT128 is 1. */
59 # if __HAVE_FLOAT128
60 #  if !__GNUC_PREREQ (7, 0) || defined __cplusplus
61 /* The literal suffix (f128) exist for powerpc only since GCC 7.0.  */
62 #   if __LDBL_MANT_DIG__ == 113
63 #    define __f128(x) x##l
64 #   else
65 #    define __f128(x) x##q
66 #   endif
67 #  else
68 #   define __f128(x) x##f128
69 #  endif
70 # endif
71 
72 /* Defined to a complex binary128 type if __HAVE_FLOAT128 is 1.  */
73 # if __HAVE_FLOAT128
74 #  if __LDBL_MANT_DIG__ == 113 && defined __cplusplus
75 typedef long double _Float128;
76 #   define __CFLOAT128 _Complex long double
77 #  elif !__GNUC_PREREQ (7, 0) || defined __cplusplus
78 /* The type _Float128 exist for powerpc only since GCC 7.0.  */
79 typedef __float128 _Float128;
80 /* Add a typedef for older GCC and C++ compilers which don't natively support
81    _Complex _Float128.  */
82 typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__KC__)));
83 #   define __CFLOAT128 __cfloat128
84 #  else
85 #   define __CFLOAT128 _Complex _Float128
86 #  endif
87 # endif
88 
89 /* The remaining of this file provides support for older compilers.  */
90 # if __HAVE_FLOAT128
91 /* Builtin __builtin_huge_valf128 doesn't exist before GCC 7.0.  */
92 #  if !__GNUC_PREREQ (7, 0)
93 #   define __builtin_huge_valf128() ((_Float128) __builtin_huge_val ())
94 #  endif
95 
96 /* The following builtins (suffixed with 'q') are available in GCC >= 6.2,
97    which is the minimum version required for float128 support on powerpc64le.
98    Since GCC 7.0 the builtins suffixed with f128 are also available, then
99    there is no need to redefined them.  */
100 #  if !__GNUC_PREREQ (7, 0)
101 #   define __builtin_copysignf128 __builtin_copysignq
102 #   define __builtin_fabsf128 __builtin_fabsq
103 #   define __builtin_inff128 __builtin_infq
104 #   define __builtin_nanf128 __builtin_nanq
105 #   define __builtin_nansf128 __builtin_nansq
106 #  endif
107 
108 /* In math/math.h, __MATH_TG will expand signbit to __builtin_signbit*,
109    e.g.: __builtin_signbitf128, before GCC 6.  However, there has never
110    been a __builtin_signbitf128 in GCC and the type-generic builtin is
111    only available since GCC 6.  */
112 #  if !__GNUC_PREREQ (6, 0)
113 #   define __builtin_signbitf128 __signbitf128
114 #  endif
115 
116 # endif
117 
118 #endif /* !__ASSEMBLER__.  */
119 
120 #include <bits/floatn-common.h>
121 
122 #endif /* _BITS_FLOATN_H */