]>
Commit | Line | Data |
---|---|---|
c86ed71d | 1 | /* Macros to control TS 18661-3 glibc features on x86. |
688903eb | 2 | Copyright (C) 2017-2018 Free Software Foundation, Inc. |
c86ed71d JM |
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 | <http://www.gnu.org/licenses/>. */ | |
18 | ||
19 | #ifndef _BITS_FLOATN_H | |
20 | #define _BITS_FLOATN_H | |
21 | ||
22 | #include <features.h> | |
23 | ||
6b6086fe | 24 | #if 0 /* for macro expansion debugging */ |
dfb17f12 | 25 | #define capture(sym, val) extern int sym[val] |
6b6086fe | 26 | #endif |
dfb17f12 | 27 | |
c86ed71d JM |
28 | /* Defined to 1 if the current compiler invocation provides a |
29 | floating-point type with the IEEE 754 binary128 format, and this | |
30 | glibc includes corresponding *f128 interfaces for it. The required | |
31 | libgcc support was added some time after the basic compiler | |
32 | support, for x86_64 and x86. */ | |
33 | #if (defined __x86_64__ \ | |
34 | ? __GNUC_PREREQ (4, 3) \ | |
26767932 | 35 | : (defined __GNU__ ? __GNUC_PREREQ (4, 5) : __GNUC_PREREQ (4, 4))) \ |
5ac69dee | 36 | || defined __clang__ |
c86ed71d JM |
37 | # define __HAVE_FLOAT128 1 |
38 | #else | |
39 | # define __HAVE_FLOAT128 0 | |
40 | #endif | |
41 | ||
42 | /* Defined to 1 if __HAVE_FLOAT128 is 1 and the type is ABI-distinct | |
43 | from the default float, double and long double types in this glibc. */ | |
44 | #if __HAVE_FLOAT128 | |
45 | # define __HAVE_DISTINCT_FLOAT128 1 | |
46 | #else | |
47 | # define __HAVE_DISTINCT_FLOAT128 0 | |
48 | #endif | |
49 | ||
a23aa5b7 JM |
50 | /* Defined to 1 if the current compiler invocation provides a |
51 | floating-point type with the right format for _Float64x, and this | |
52 | glibc includes corresponding *f64x interfaces for it. */ | |
53 | #define __HAVE_FLOAT64X 1 | |
54 | ||
55 | /* Defined to 1 if __HAVE_FLOAT64X is 1 and _Float64x has the format | |
56 | of long double. Otherwise, if __HAVE_FLOAT64X is 1, _Float64x has | |
57 | the format of _Float128, which must be different from that of long | |
58 | double. */ | |
59 | #define __HAVE_FLOAT64X_LONG_DOUBLE 1 | |
60 | ||
015c6dc2 JM |
61 | #ifndef __ASSEMBLER__ |
62 | ||
6b6086fe | 63 | #if 0 /* for macro expansion debugging */ |
dfb17f12 SS |
64 | capture(i_have_float128, __HAVE_FLOAT128); |
65 | capture(i_have_distinct_float128, __HAVE_DISTINCT_FLOAT128); | |
6b6086fe | 66 | #endif |
dfb17f12 | 67 | |
c86ed71d JM |
68 | /* Defined to concatenate the literal suffix to be used with _Float128 |
69 | types, if __HAVE_FLOAT128 is 1. */ | |
015c6dc2 | 70 | # if __HAVE_FLOAT128 |
26767932 FS |
71 | # if !__GNUC_PREREQ (7, 0) || defined __cplusplus \ |
72 | || defined __clang__ | |
c86ed71d | 73 | /* The literal suffix f128 exists only since GCC 7.0. */ |
015c6dc2 JM |
74 | # define __f128(x) x##q |
75 | # else | |
76 | # define __f128(x) x##f128 | |
77 | # endif | |
c86ed71d | 78 | # endif |
c86ed71d JM |
79 | |
80 | /* Defined to a complex binary128 type if __HAVE_FLOAT128 is 1. */ | |
015c6dc2 | 81 | # if __HAVE_FLOAT128 |
26767932 FS |
82 | # if !__GNUC_PREREQ (7, 0) || defined __cplusplus \ |
83 | || defined __clang__ | |
c86ed71d JM |
84 | /* Add a typedef for older GCC compilers which don't natively support |
85 | _Complex _Float128. */ | |
86 | typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__))); | |
015c6dc2 JM |
87 | # define __CFLOAT128 __cfloat128 |
88 | # else | |
89 | # define __CFLOAT128 _Complex _Float128 | |
90 | # endif | |
c86ed71d | 91 | # endif |
c86ed71d JM |
92 | |
93 | /* The remaining of this file provides support for older compilers. */ | |
015c6dc2 | 94 | # if __HAVE_FLOAT128 |
c86ed71d JM |
95 | |
96 | /* The type _Float128 exists only since GCC 7.0. */ | |
26767932 FS |
97 | # if !__GNUC_PREREQ (7, 0) || defined __cplusplus \ |
98 | || defined __clang__ | |
c86ed71d | 99 | typedef __float128 _Float128; |
015c6dc2 | 100 | # endif |
c86ed71d | 101 | |
dfb17f12 SS |
102 | #if defined __clang__ |
103 | ||
104 | #if 0 /* clang 5.0 or less */ | |
105 | #define __builtin_huge_valf128() ((_Float128) __builtin_huge_val ()) | |
106 | #define __builtin_inff128() ((_Float128) __builtin_inf ()) | |
107 | #define __builtin_nanf128(x) ((_Float128) __builtin_nan (x)) | |
108 | #define __builtin_nansf128(x) ((_Float128) __builtin_nans (x)) | |
109 | ||
110 | #define __builtin_copysignf128(x,y) ((_Float128) __builtin_copysign ((double)(x),(double)(y))) | |
111 | #define __builtin_fabsf128(x) ((_Float128) __builtin_fabs ((double)(x))) | |
112 | #endif | |
113 | #define __builtin_signbitf128(x) (__builtin_signbit (x)) | |
114 | ||
115 | #else /* GCC */ | |
116 | ||
c86ed71d | 117 | /* __builtin_huge_valf128 doesn't exist before GCC 7.0. */ |
26767932 | 118 | # if !__GNUC_PREREQ (7, 0) && !defined __clang__ |
015c6dc2 JM |
119 | # define __builtin_huge_valf128() ((_Float128) __builtin_huge_val ()) |
120 | # endif | |
c86ed71d JM |
121 | |
122 | /* Older GCC has only a subset of built-in functions for _Float128 on | |
123 | x86, and __builtin_infq is not usable in static initializers. | |
124 | Converting a narrower sNaN to _Float128 produces a quiet NaN, so | |
125 | attempts to use _Float128 sNaNs will not work properly with older | |
126 | compilers. */ | |
26767932 | 127 | # if !__GNUC_PREREQ (7, 0) && !defined __clang__ |
015c6dc2 JM |
128 | # define __builtin_copysignf128 __builtin_copysignq |
129 | # define __builtin_fabsf128 __builtin_fabsq | |
130 | # define __builtin_inff128() ((_Float128) __builtin_inf ()) | |
131 | # define __builtin_nanf128(x) ((_Float128) __builtin_nan (x)) | |
132 | # define __builtin_nansf128(x) ((_Float128) __builtin_nans (x)) | |
133 | # endif | |
c86ed71d | 134 | |
8466ee1c GG |
135 | /* In math/math.h, __MATH_TG will expand signbit to __builtin_signbit*, |
136 | e.g.: __builtin_signbitf128, before GCC 6. However, there has never | |
137 | been a __builtin_signbitf128 in GCC and the type-generic builtin is | |
138 | only available since GCC 6. */ | |
26767932 | 139 | # if !__GNUC_PREREQ (6, 0) && !defined __clang__ |
015c6dc2 JM |
140 | # define __builtin_signbitf128 __signbitf128 |
141 | # endif | |
142 | ||
dfb17f12 SS |
143 | #endif /* clang or GCC */ |
144 | ||
8466ee1c GG |
145 | # endif |
146 | ||
dfb17f12 SS |
147 | #if !__HAVE_FLOAT128 && defined __clang__ |
148 | typedef long double _Float128; | |
149 | #endif | |
150 | ||
015c6dc2 | 151 | #endif /* !__ASSEMBLER__. */ |
c86ed71d | 152 | |
797ba44b JM |
153 | #include <bits/floatn-common.h> |
154 | ||
c86ed71d | 155 | #endif /* _BITS_FLOATN_H */ |