1 /* Divide long double (ldbl-128) values, narrowing the result to
2    double, using soft-fp.
3    Copyright (C) 2018-2022 Free Software Foundation, Inc.
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
18    <https://www.gnu.org/licenses/>.  */
19 
20 #define f32xdivf64x __hide_f32xdivf64x
21 #define f32xdivf128 __hide_f32xdivf128
22 #define f64divf64x __hide_f64divf64x
23 #define f64divf128 __hide_f64divf128
24 #include <math.h>
25 #undef f32xdivf64x
26 #undef f32xdivf128
27 #undef f64divf64x
28 #undef f64divf128
29 
30 #include <math-narrow.h>
31 #include <libc-diag.h>
32 
33 /* R_f[01] are not set in cases where they are not used in packing,
34    but the compiler does not see that they are set in all cases where
35    they are used, resulting in warnings that they may be used
36    uninitialized.  The location of the warning differs in different
37    versions of GCC, it may be where R is defined using a macro or it
38    may be where the macro is defined.  This happens only with -O1.  */
39 DIAG_PUSH_NEEDS_COMMENT;
40 DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
41 #include <soft-fp.h>
42 #include <double.h>
43 #include <quad.h>
44 
45 double
__ddivl(_Float128 x,_Float128 y)46 __ddivl (_Float128 x, _Float128 y)
47 {
48   FP_DECL_EX;
49   FP_DECL_Q (X);
50   FP_DECL_Q (Y);
51   FP_DECL_Q (R);
52   FP_DECL_D (RN);
53   double ret;
54 
55   FP_INIT_ROUNDMODE;
56   FP_UNPACK_Q (X, x);
57   FP_UNPACK_Q (Y, y);
58   FP_DIV_Q (R, X, Y);
59 #if _FP_W_TYPE_SIZE < 64
60   FP_TRUNC_COOKED (D, Q, 2, 4, RN, R);
61 #else
62   FP_TRUNC_COOKED (D, Q, 1, 2, RN, R);
63 #endif
64   FP_PACK_D (ret, RN);
65   FP_HANDLE_EXCEPTIONS;
66   CHECK_NARROW_DIV (ret, x, y);
67   return ret;
68 }
69 DIAG_POP_NEEDS_COMMENT;
70 
71 libm_alias_double_ldouble (div)
72