1 /* Divide long double (ldbl-128) values, narrowing the result to
2    float, 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 f32divf64x __hide_f32divf64x
21 #define f32divf128 __hide_f32divf128
22 #include <math.h>
23 #undef f32divf64x
24 #undef f32divf128
25 
26 #include <math-narrow.h>
27 #include <libc-diag.h>
28 
29 /* R_f[01] are not set in cases where they are not used in packing,
30    but the compiler does not see that they are set in all cases where
31    they are used, resulting in warnings that they may be used
32    uninitialized.  The location of the warning differs in different
33    versions of GCC, it may be where R is defined using a macro or it
34    may be where the macro is defined.  This happens only with -O1.  */
35 DIAG_PUSH_NEEDS_COMMENT;
36 DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
37 #include <soft-fp.h>
38 #include <single.h>
39 #include <quad.h>
40 
41 float
__fdivl(_Float128 x,_Float128 y)42 __fdivl (_Float128 x, _Float128 y)
43 {
44   FP_DECL_EX;
45   FP_DECL_Q (X);
46   FP_DECL_Q (Y);
47   FP_DECL_Q (R);
48   FP_DECL_S (RN);
49   float ret;
50 
51   FP_INIT_ROUNDMODE;
52   FP_UNPACK_Q (X, x);
53   FP_UNPACK_Q (Y, y);
54   FP_DIV_Q (R, X, Y);
55 #if _FP_W_TYPE_SIZE < 64
56   FP_TRUNC_COOKED (S, Q, 1, 4, RN, R);
57 #else
58   FP_TRUNC_COOKED (S, Q, 1, 2, RN, R);
59 #endif
60   FP_PACK_S (ret, RN);
61   FP_HANDLE_EXCEPTIONS;
62   CHECK_NARROW_DIV (ret, x, y);
63   return ret;
64 }
65 DIAG_POP_NEEDS_COMMENT;
66 
67 libm_alias_float_ldouble (div)
68