]>
Commit | Line | Data |
---|---|---|
d8742dd8 JM |
1 | /* Add long double (ldbl-128) values, narrowing the result to double, |
2 | using soft-fp. | |
d614a753 | 3 | Copyright (C) 2018-2020 Free Software Foundation, Inc. |
d8742dd8 JM |
4 | This file is part of the GNU C Library. |
5 | ||
6 | The GNU C Library is free software; you can redistribute it and/or | |
7 | modify it under the terms of the GNU Lesser General Public | |
8 | License as published by the Free Software Foundation; either | |
9 | version 2.1 of the License, or (at your option) any later version. | |
10 | ||
11 | The GNU C Library is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | Lesser General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU Lesser General Public | |
17 | License along with the GNU C Library; if not, see | |
5a82c748 | 18 | <https://www.gnu.org/licenses/>. */ |
d8742dd8 JM |
19 | |
20 | #define f32xaddf64x __hide_f32xaddf64x | |
21 | #define f32xaddf128 __hide_f32xaddf128 | |
22 | #define f64addf64x __hide_f64addf64x | |
23 | #define f64addf128 __hide_f64addf128 | |
24 | #include <math.h> | |
25 | #undef f32xaddf64x | |
26 | #undef f32xaddf128 | |
27 | #undef f64addf64x | |
28 | #undef f64addf128 | |
29 | ||
30 | #include <math-narrow.h> | |
31 | #include <soft-fp.h> | |
32 | #include <double.h> | |
33 | #include <quad.h> | |
34 | ||
35 | double | |
36 | __daddl (_Float128 x, _Float128 y) | |
37 | { | |
38 | FP_DECL_EX; | |
39 | FP_DECL_Q (X); | |
40 | FP_DECL_Q (Y); | |
41 | FP_DECL_Q (R); | |
42 | FP_DECL_D (RN); | |
43 | double ret; | |
44 | ||
45 | FP_INIT_ROUNDMODE; | |
46 | FP_UNPACK_SEMIRAW_Q (X, x); | |
47 | FP_UNPACK_SEMIRAW_Q (Y, y); | |
48 | FP_ADD_Q (R, X, Y); | |
69da3c9e | 49 | #if _FP_W_TYPE_SIZE < 64 |
d8742dd8 JM |
50 | FP_TRUNC (D, Q, 2, 4, RN, R); |
51 | #else | |
52 | FP_TRUNC (D, Q, 1, 2, RN, R); | |
53 | #endif | |
54 | FP_PACK_SEMIRAW_D (ret, RN); | |
55 | FP_HANDLE_EXCEPTIONS; | |
56 | CHECK_NARROW_ADD (ret, x, y); | |
57 | return ret; | |
58 | } | |
59 | libm_alias_double_ldouble (add) |