| 1 | /* Macros to control TS 18661-3 glibc features on x86.  |
| 2 | Copyright (C) 2017-2020 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 |   |
| 24 | /* Defined to 1 if the current compiler invocation provides a  |
| 25 | floating-point type with the IEEE 754 binary128 format, and this  |
| 26 | glibc includes corresponding *f128 interfaces for it. The required  |
| 27 | libgcc support was added some time after the basic compiler  |
| 28 | support, for x86_64 and x86. */  |
| 29 | #if (defined __x86_64__ \  |
| 30 | ? __GNUC_PREREQ (4, 3) \  |
| 31 | : (defined __GNU__ ? __GNUC_PREREQ (4, 5) : __GNUC_PREREQ (4, 4))) \  |
| 32 | && !defined(__CUDACC__) && !defined(__ICC)  |
| 33 | # define __HAVE_FLOAT128 1  |
| 34 | #else  |
| 35 | # define __HAVE_FLOAT128 0  |
| 36 | #endif  |
| 37 |   |
| 38 | /* Defined to 1 if __HAVE_FLOAT128 is 1 and the type is ABI-distinct  |
| 39 | from the default float, double and long double types in this glibc. */  |
| 40 | #if __HAVE_FLOAT128  |
| 41 | # define __HAVE_DISTINCT_FLOAT128 1  |
| 42 | #else  |
| 43 | # define __HAVE_DISTINCT_FLOAT128 0  |
| 44 | #endif  |
| 45 |   |
| 46 | /* Defined to 1 if the current compiler invocation provides a  |
| 47 | floating-point type with the right format for _Float64x, and this  |
| 48 | glibc includes corresponding *f64x interfaces for it. */  |
| 49 | #define __HAVE_FLOAT64X 1  |
| 50 |   |
| 51 | /* Defined to 1 if __HAVE_FLOAT64X is 1 and _Float64x has the format  |
| 52 | of long double. Otherwise, if __HAVE_FLOAT64X is 1, _Float64x has  |
| 53 | the format of _Float128, which must be different from that of long  |
| 54 | double. */  |
| 55 | #define __HAVE_FLOAT64X_LONG_DOUBLE 1  |
| 56 |   |
| 57 | #ifndef __ASSEMBLER__  |
| 58 |   |
| 59 | /* Defined to concatenate the literal suffix to be used with _Float128  |
| 60 | types, if __HAVE_FLOAT128 is 1. */  |
| 61 | # if __HAVE_FLOAT128  |
| 62 | # if !__GNUC_PREREQ (7, 0) || defined __cplusplus  |
| 63 | /* The literal suffix f128 exists only since GCC 7.0. */  |
| 64 | # define __f128(x) x##q  |
| 65 | # else  |
| 66 | # define __f128(x) x##f128  |
| 67 | # endif  |
| 68 | # endif  |
| 69 |   |
| 70 | /* Defined to a complex binary128 type if __HAVE_FLOAT128 is 1. */  |
| 71 | # if __HAVE_FLOAT128  |
| 72 | # if !__GNUC_PREREQ (7, 0) || defined __cplusplus  |
| 73 | /* Add a typedef for older GCC compilers which don't natively support  |
| 74 | _Complex _Float128. */  |
| 75 | typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__)));  |
| 76 | # define __CFLOAT128 __cfloat128  |
| 77 | # else  |
| 78 | # define __CFLOAT128 _Complex _Float128  |
| 79 | # endif  |
| 80 | # endif  |
| 81 |   |
| 82 | /* The remaining of this file provides support for older compilers. */  |
| 83 | # if __HAVE_FLOAT128  |
| 84 |   |
| 85 | /* The type _Float128 exists only since GCC 7.0. */  |
| 86 | # if !__GNUC_PREREQ (7, 0) || defined __cplusplus  |
| 87 | typedef __float128 _Float128;  |
| 88 | # endif  |
| 89 |   |
| 90 | /* __builtin_huge_valf128 doesn't exist before GCC 7.0. */  |
| 91 | # if !__GNUC_PREREQ (7, 0)  |
| 92 | # define __builtin_huge_valf128() ((_Float128) __builtin_huge_val ())  |
| 93 | # endif  |
| 94 |   |
| 95 | /* Older GCC has only a subset of built-in functions for _Float128 on  |
| 96 | x86, and __builtin_infq is not usable in static initializers.  |
| 97 | Converting a narrower sNaN to _Float128 produces a quiet NaN, so  |
| 98 | attempts to use _Float128 sNaNs will not work properly with older  |
| 99 | compilers. */  |
| 100 | # if !__GNUC_PREREQ (7, 0)  |
| 101 | # define __builtin_copysignf128 __builtin_copysignq  |
| 102 | # define __builtin_fabsf128 __builtin_fabsq  |
| 103 | # define __builtin_inff128() ((_Float128) __builtin_inf ())  |
| 104 | # define __builtin_nanf128(x) ((_Float128) __builtin_nan (x))  |
| 105 | # define __builtin_nansf128(x) ((_Float128) __builtin_nans (x))  |
| 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 */  |
| 123 | |