]>
Commit | Line | Data |
---|---|---|
302bb1a3 | 1 | /* _Float128 overrides for building ldbl-128 as _Float128. |
688903eb | 2 | Copyright (C) 2017-2018 Free Software Foundation, Inc. |
302bb1a3 PM |
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 | /* This must be included before the function renames below. */ | |
32bf1d09 | 20 | #include <gmp.h> |
302bb1a3 PM |
21 | #include <math.h> |
22 | #undef HUGE_VALL | |
23 | #define HUGE_VALL HUGE_VAL_F128 | |
24 | #include <math/mul_splitl.h> | |
25 | ||
db7a548d JM |
26 | /* This must be included before the renames of types and macros from |
27 | it. */ | |
28 | #include <ieee754.h> | |
29 | ||
302bb1a3 PM |
30 | /* Renames derived from math_private.h. */ |
31 | #include <math_private.h> | |
32 | #include <ieee754_float128.h> | |
33 | #define ieee854_long_double_shape_type ieee854_float128_shape_type | |
34 | #define ieee854_long_double ieee854_float128 | |
35 | ||
36 | #undef GET_LDOUBLE_LSW64 | |
37 | #undef GET_LDOUBLE_MSW64 | |
38 | #undef GET_LDOUBLE_WORDS64 | |
39 | #undef SET_LDOUBLE_LSW64 | |
40 | #undef SET_LDOUBLE_MSW64 | |
41 | #undef SET_LDOUBLE_WORDS64 | |
42 | #define GET_LDOUBLE_LSW64(x,y) GET_FLOAT128_LSW64 (x, y) | |
43 | #define GET_LDOUBLE_MSW64(x,y) GET_FLOAT128_MSW64 (x, y) | |
44 | #define GET_LDOUBLE_WORDS64(x,y,z) GET_FLOAT128_WORDS64 (x, y, z) | |
45 | #define SET_LDOUBLE_LSW64(x,y) SET_FLOAT128_LSW64 (x, y) | |
46 | #define SET_LDOUBLE_MSW64(x,y) SET_FLOAT128_MSW64 (x, y) | |
47 | #define SET_LDOUBLE_WORDS64(x,y,z) SET_FLOAT128_WORDS64 (x, y, z) | |
48 | ||
49 | #undef IEEE854_LONG_DOUBLE_BIAS | |
50 | #define IEEE854_LONG_DOUBLE_BIAS IEEE854_FLOAT128_BIAS | |
51 | ||
52 | #ifdef SET_RESTORE_ROUNDF128 | |
53 | # undef SET_RESTORE_ROUNDL | |
f20079d2 | 54 | # define SET_RESTORE_ROUNDL(RM) SET_RESTORE_ROUNDF128 (RM) |
302bb1a3 PM |
55 | #endif |
56 | ||
63716ab2 JM |
57 | #ifdef libc_feholdexcept_setroundf128 |
58 | # undef libc_feholdexcept_setroundl | |
59 | # define libc_feholdexcept_setroundl(ENV, RM) \ | |
60 | libc_feholdexcept_setroundf128 (ENV, RM) | |
61 | #endif | |
62 | ||
63 | #ifdef libc_feupdateenv_testf128 | |
64 | # undef libc_feupdateenv_testl | |
65 | # define libc_feupdateenv_testl(ENV, EX) libc_feupdateenv_testf128 (ENV, EX) | |
66 | #endif | |
302bb1a3 PM |
67 | |
68 | /* misc macros from the header below. */ | |
69 | #include <fix-fp-int-convert-overflow.h> | |
70 | #undef FIX_LDBL_LONG_CONVERT_OVERFLOW | |
71 | #undef FIX_LDBL_LLONG_CONVERT_OVERFLOW | |
72 | #define FIX_LDBL_LONG_CONVERT_OVERFLOW FIX_FLT128_LONG_CONVERT_OVERFLOW | |
73 | #define FIX_LDBL_LLONG_CONVERT_OVERFLOW FIX_FLT128_LLONG_CONVERT_OVERFLOW | |
74 | ||
75 | ||
76 | /* float.h constants. */ | |
77 | #include <float.h> | |
78 | #undef LDBL_DIG | |
79 | #undef LDBL_EPSILON | |
80 | #undef LDBL_MANT_DIG | |
81 | #undef LDBL_MAX | |
82 | #undef LDBL_MAX_10_EXP | |
83 | #undef LDBL_MAX_EXP | |
84 | #undef LDBL_MIN | |
85 | #undef LDBL_MIN_10_EXP | |
86 | #undef LDBL_MIN_EXP | |
87 | #undef LDBL_TRUE_MIN | |
88 | #define LDBL_DIG FLT128_DIG | |
89 | #define LDBL_EPSILON FLT128_EPSILON | |
90 | #define LDBL_MANT_DIG FLT128_MANT_DIG | |
91 | #define LDBL_MAX FLT128_MAX | |
92 | #define LDBL_MAX_10_EXP FLT128_MAX_10_EXP | |
93 | #define LDBL_MAX_EXP FLT128_MAX_EXP | |
94 | #define LDBL_MIN FLT128_MIN | |
95 | #define LDBL_MIN_10_EXP FLT128_MIN_10_EXP | |
96 | #define LDBL_MIN_EXP FLT128_MIN_EXP | |
97 | #define LDBL_TRUE_MIN FLT128_TRUE_MIN | |
98 | ||
99 | ||
100 | /* math.h GNU constants. */ | |
101 | #undef M_El | |
102 | #undef M_LOG2El | |
103 | #undef M_LOG10El | |
104 | #undef M_LN2l | |
105 | #undef M_LN10l | |
106 | #undef M_PIl | |
107 | #undef M_PI_2l | |
108 | #undef M_PI_4l | |
109 | #undef M_1_PIl | |
110 | #undef M_2_PIl | |
111 | #undef M_2_SQRTPIl | |
112 | #undef M_SQRT2l | |
113 | #undef M_SQRT1_2l | |
114 | #define M_El M_Ef128 | |
115 | #define M_LOG2El M_LOG2Ef128 | |
116 | #define M_LOG10El M_LOG10Ef128 | |
117 | #define M_LN2l M_LN2f128 | |
118 | #define M_LN10l M_LN10f128 | |
119 | #define M_PIl M_PIf128 | |
120 | #define M_PI_2l M_PI_2f128 | |
121 | #define M_PI_4l M_PI_4f128 | |
122 | #define M_1_PIl M_1_PIf128 | |
123 | #define M_2_PIl M_2_PIf128 | |
124 | #define M_2_SQRTPIl M_2_SQRTPIf128 | |
125 | #define M_SQRT2l M_SQRT2f128 | |
126 | #define M_SQRT1_2l M_SQRT1_2f128 | |
127 | ||
128 | ||
fd3b4e7c JM |
129 | #include <libm-alias-ldouble.h> |
130 | #include <libm-alias-float128.h> | |
131 | #undef libm_alias_ldouble_r | |
132 | #define libm_alias_ldouble_r(from, to, r) libm_alias_float128_r (from, to, r) | |
133 | ||
134 | ||
63716ab2 JM |
135 | #include <math/math-narrow.h> |
136 | #undef libm_alias_float_ldouble | |
137 | #define libm_alias_float_ldouble(func) libm_alias_float32_float128 (func) | |
138 | #undef libm_alias_double_ldouble | |
139 | #define libm_alias_double_ldouble(func) libm_alias_float64_float128 (func) | |
140 | ||
141 | ||
302bb1a3 PM |
142 | /* IEEE function renames. */ |
143 | #define __ieee754_acoshl __ieee754_acoshf128 | |
144 | #define __ieee754_acosl __ieee754_acosf128 | |
145 | #define __ieee754_asinhl __ieee754_asinhf128 | |
146 | #define __ieee754_asinl __ieee754_asinf128 | |
147 | #define __ieee754_atan2l __ieee754_atan2f128 | |
148 | #define __ieee754_atanhl __ieee754_atanhf128 | |
149 | #define __ieee754_coshl __ieee754_coshf128 | |
150 | #define __ieee754_cosl __ieee754_cosf128 | |
151 | #define __ieee754_exp10l __ieee754_exp10f128 | |
152 | #define __ieee754_exp2l __ieee754_exp2f128 | |
153 | #define __ieee754_expl __ieee754_expf128 | |
154 | #define __ieee754_fmodl __ieee754_fmodf128 | |
155 | #define __ieee754_gammal_r __ieee754_gammaf128_r | |
156 | #define __ieee754_hypotl __ieee754_hypotf128 | |
157 | #define __ieee754_ilogbl __ieee754_ilogbf128 | |
158 | #define __ieee754_j0l __ieee754_j0f128 | |
159 | #define __ieee754_j1l __ieee754_j1f128 | |
160 | #define __ieee754_jnl __ieee754_jnf128 | |
161 | #define __ieee754_lgammal_r __ieee754_lgammaf128_r | |
162 | #define __ieee754_log10l __ieee754_log10f128 | |
163 | #define __ieee754_log2l __ieee754_log2f128 | |
164 | #define __ieee754_logl __ieee754_logf128 | |
165 | #define __ieee754_powl __ieee754_powf128 | |
166 | #define __ieee754_rem_pio2l __ieee754_rem_pio2f128 | |
167 | #define __ieee754_remainderl __ieee754_remainderf128 | |
168 | #define __ieee754_sinhl __ieee754_sinhf128 | |
169 | #define __ieee754_sqrtl __ieee754_sqrtf128 | |
170 | #define __ieee754_y0l __ieee754_y0f128 | |
171 | #define __ieee754_y1l __ieee754_y1f128 | |
172 | #define __ieee754_ynl __ieee754_ynf128 | |
173 | ||
174 | ||
175 | /* finite math entry points. */ | |
176 | #define __acoshl_finite __acoshf128_finite | |
177 | #define __acosl_finite __acosf128_finite | |
178 | #define __asinl_finite __asinf128_finite | |
179 | #define __atan2l_finite __atan2f128_finite | |
180 | #define __atanhl_finite __atanhf128_finite | |
181 | #define __coshl_finite __coshf128_finite | |
182 | #define __cosl_finite __cosf128_finite | |
183 | #define __exp10l_finite __exp10f128_finite | |
184 | #define __exp2l_finite __exp2f128_finite | |
185 | #define __expl_finite __expf128_finite | |
186 | #define __fmodl_finite __fmodf128_finite | |
187 | #define __hypotl_finite __hypotf128_finite | |
188 | #define __ilogbl_finite __ilogbf128_finite | |
189 | #define __j0l_finite __j0f128_finite | |
190 | #define __j1l_finite __j1f128_finite | |
191 | #define __jnl_finite __jnf128_finite | |
192 | #define __lgammal_r_finite __lgammaf128_r_finite | |
193 | #define __log10l_finite __log10f128_finite | |
194 | #define __log2l_finite __log2f128_finite | |
195 | #define __logl_finite __logf128_finite | |
196 | #define __powl_finite __powf128_finite | |
197 | #define __remainderl_finite __remainderf128_finite | |
198 | #define __sinhl_finite __sinhf128_finite | |
199 | #define __y0l_finite __y0f128_finite | |
200 | #define __y1l_finite __y1f128_finite | |
201 | #define __ynl_finite __ynf128_finite | |
202 | ||
203 | ||
204 | /* internal function names. */ | |
205 | #define __asinhl __asinhf128 | |
206 | #define __atanl __atanf128 | |
207 | #define __cbrtl __cbrtf128 | |
208 | #define __ceill __ceilf128 | |
209 | #define __copysignl __copysignf128 | |
210 | #define __cosl __cosf128 | |
211 | #define __erfcl __erfcf128 | |
212 | #define __erfl __erff128 | |
213 | #define __expl __expf128 | |
214 | #define __expm1l __expm1f128 | |
215 | #define __fabsl __fabsf128 | |
216 | #define __fdiml __fdimf128 | |
217 | #define __finitel __finitef128 | |
218 | #define __floorl __floorf128 | |
219 | #define __fmal __fmaf128 | |
220 | #define __fmaxl __fmaxf128 | |
221 | #define __fminl __fminf128 | |
222 | #define __fpclassifyl __fpclassifyf128 | |
223 | #define __frexpl __frexpf128 | |
224 | #define __gammal_r_finite __gammaf128_r_finite | |
01f28812 | 225 | #define __getpayloadl __getpayloadf128 |
302bb1a3 PM |
226 | #define __isinfl __isinff128 |
227 | #define __isnanl __isnanf128 | |
228 | #define __issignalingl __issignalingf128 | |
229 | #define __ldexpl __ldexpf128 | |
230 | #define __llrintl __llrintf128 | |
231 | #define __llroundl __llroundf128 | |
232 | #define __log1pl __log1pf128 | |
233 | #define __logbl __logbf128 | |
234 | #define __logl __logf128 | |
235 | #define __lrintl __lrintf128 | |
236 | #define __lroundl __lroundf128 | |
237 | #define __modfl __modff128 | |
238 | #define __nearbyintl __nearbyintf128 | |
239 | #define __nextafterl __nextafterf128 | |
240 | #define __nextdownl __nextdownf128 | |
241 | #define __nextupl __nextupf128 | |
242 | #define __remquol __remquof128 | |
243 | #define __rintl __rintf128 | |
01f28812 | 244 | #define __roundevenl __roundevenf128 |
302bb1a3 PM |
245 | #define __roundl __roundf128 |
246 | #define __scalblnl __scalblnf128 | |
247 | #define __scalbnl __scalbnf128 | |
248 | #define __signbitl __signbitf128 | |
249 | #define __sincosl __sincosf128 | |
250 | #define __sinl __sinf128 | |
251 | #define __sqrtl __sqrtf128 | |
252 | #define __tanhl __tanhf128 | |
253 | #define __tanl __tanf128 | |
01f28812 JM |
254 | #define __totalorderl __totalorderf128 |
255 | #define __totalordermagl __totalordermagf128 | |
302bb1a3 PM |
256 | #define __truncl __truncf128 |
257 | #define __x2y2m1l __x2y2m1f128 | |
258 | ||
d8742dd8 JM |
259 | #define __faddl __f32addf128 |
260 | #define __daddl __f64addf128 | |
632a6cbe JM |
261 | #define __fdivl __f32divf128 |
262 | #define __ddivl __f64divf128 | |
69a01461 JM |
263 | #define __fmull __f32mulf128 |
264 | #define __dmull __f64mulf128 | |
8d3f9e85 JM |
265 | #define __fsubl __f32subf128 |
266 | #define __dsubl __f64subf128 | |
d8742dd8 | 267 | |
302bb1a3 PM |
268 | /* __nexttowardf128 is not _Float128 API. */ |
269 | #define __nexttowardl __nexttowardf128_do_not_use | |
270 | #define nexttowardl nexttowardf128_do_not_use | |
271 | ||
272 | ||
273 | /* public entry points. */ | |
274 | #define asinhl asinhf128 | |
275 | #define atanl atanf128 | |
276 | #define cbrtl cbrtf128 | |
277 | #define ceill ceilf128 | |
278 | #define copysignl copysignf128 | |
279 | #define cosl cosf128 | |
280 | #define erfcl erfcf128 | |
281 | #define erfl erff128 | |
282 | #define expl expf128 | |
283 | #define expm1l expm1f128 | |
284 | #define fabsl fabsf128 | |
285 | #define fdiml fdimf128 | |
286 | #define finitel finitef128_do_not_use | |
287 | #define floorl floorf128 | |
288 | #define fmal fmaf128 | |
289 | #define fmaxl fmaxf128 | |
290 | #define fminl fminf128 | |
291 | #define frexpl frexpf128 | |
292 | #define getpayloadl getpayloadf128 | |
293 | #define isinfl isinff128_do_not_use | |
294 | #define isnanl isnanf128_do_not_use | |
295 | #define ldexpl ldexpf128 | |
296 | #define llrintl llrintf128 | |
297 | #define llroundl llroundf128 | |
298 | #define log1pl log1pf128 | |
299 | #define logbl logbf128 | |
300 | #define logl logf128 | |
301 | #define lrintl lrintf128 | |
302 | #define lroundl lroundf128 | |
303 | #define modfl modff128 | |
304 | #define nanl nanf128 | |
305 | #define nearbyintl nearbyintf128 | |
306 | #define nextafterl nextafterf128 | |
307 | #define nextdownl nextdownf128 | |
308 | #define nextupl nextupf128 | |
309 | #define remquol remquof128 | |
310 | #define rintl rintf128 | |
311 | #define roundevenl roundevenf128 | |
312 | #define roundl roundf128 | |
313 | #define scalbnl scalbnf128 | |
314 | #define sincosl sincosf128 | |
315 | #define sinl sinf128 | |
316 | #define sqrtl sqrtf128 | |
317 | #define tanhl tanhf128 | |
318 | #define tanl tanf128 | |
319 | #define totalorderl totalorderf128 | |
320 | #define totalordermagl totalordermagf128 | |
321 | #define truncl truncf128 | |
322 | ||
323 | ||
324 | /* misc internal renames. */ | |
325 | #define __builtin_fmal __builtin_fmaf128 | |
326 | #define __expl_table __expf128_table | |
327 | #define __gamma_productl __gamma_productf128 | |
328 | #define __kernel_cosl __kernel_cosf128 | |
329 | #define __kernel_rem_pio2l __kernel_rem_pio2f128 | |
330 | #define __kernel_sincosl __kernel_sincosf128 | |
331 | #define __kernel_sinl __kernel_sinf128 | |
332 | #define __kernel_tanl __kernel_tanf128 | |
333 | #define __lgamma_negl __lgamma_negf128 | |
334 | #define __lgamma_productl __lgamma_productf128 | |
32bf1d09 | 335 | #define __mpn_extract_long_double __mpn_extract_float128 |
302bb1a3 PM |
336 | #define __sincosl_table __sincosf128_table |
337 | #define mul_splitl mul_splitf128 | |
338 | ||
339 | /* Builtin renames. */ | |
340 | #define __builtin_copysignl __builtin_copysignf128 | |
341 | #define __builtin_signbitl __builtin_signbit | |
342 | ||
343 | /* Get the constant suffix from bits/floatn-compat.h. */ | |
344 | #define L(x) __f128 (x) | |
345 | ||
346 | static inline void | |
347 | mul_splitf128 (_Float128 *hi, _Float128 *lo, _Float128 x, _Float128 y) | |
348 | { | |
349 | #ifdef __FP_FAST_FMAF128 | |
350 | /* Fast built-in fused multiply-add. */ | |
351 | *hi = x * y; | |
352 | *lo = __builtin_fmal (x, y, -*hi); | |
353 | #else | |
354 | /* Apply Dekker's algorithm. */ | |
355 | *hi = x * y; | |
356 | # define C ((1LL << (FLT128_MANT_DIG + 1) / 2) + 1) | |
357 | _Float128 x1 = x * C; | |
358 | _Float128 y1 = y * C; | |
359 | # undef C | |
360 | x1 = (x - x1) + x1; | |
361 | y1 = (y - y1) + y1; | |
362 | _Float128 x2 = x - x1; | |
363 | _Float128 y2 = y - y1; | |
364 | *lo = (((x1 * y1 - *hi) + x1 * y2) + x2 * y1) + x2 * y2; | |
365 | #endif | |
366 | } |