148fb7bfaSmrg /* Software floating-point emulation.
248fb7bfaSmrg Truncate IEEE double into IEEE single
3*fb8a8121Smrg Copyright (C) 1997-2019 Free Software Foundation, Inc.
448fb7bfaSmrg This file is part of the GNU C Library.
548fb7bfaSmrg Contributed by Richard Henderson (rth@cygnus.com) and
648fb7bfaSmrg Jakub Jelinek (jj@ultra.linux.cz).
748fb7bfaSmrg
848fb7bfaSmrg The GNU C Library is free software; you can redistribute it and/or
948fb7bfaSmrg modify it under the terms of the GNU Lesser General Public
1048fb7bfaSmrg License as published by the Free Software Foundation; either
1148fb7bfaSmrg version 2.1 of the License, or (at your option) any later version.
1248fb7bfaSmrg
1348fb7bfaSmrg In addition to the permissions in the GNU Lesser General Public
1448fb7bfaSmrg License, the Free Software Foundation gives you unlimited
1548fb7bfaSmrg permission to link the compiled version of this file into
1648fb7bfaSmrg combinations with other programs, and to distribute those
1748fb7bfaSmrg combinations without any restriction coming from the use of this
1848fb7bfaSmrg file. (The Lesser General Public License restrictions do apply in
1948fb7bfaSmrg other respects; for example, they cover modification of the file,
2048fb7bfaSmrg and distribution when not linked into a combine executable.)
2148fb7bfaSmrg
2248fb7bfaSmrg The GNU C Library is distributed in the hope that it will be useful,
2348fb7bfaSmrg but WITHOUT ANY WARRANTY; without even the implied warranty of
2448fb7bfaSmrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2548fb7bfaSmrg Lesser General Public License for more details.
2648fb7bfaSmrg
2748fb7bfaSmrg You should have received a copy of the GNU Lesser General Public
2848fb7bfaSmrg License along with the GNU C Library; if not, see
2948fb7bfaSmrg <http://www.gnu.org/licenses/>. */
3048fb7bfaSmrg
3148fb7bfaSmrg #include "soft-fp.h"
3248fb7bfaSmrg #include "single.h"
3348fb7bfaSmrg #include "double.h"
3448fb7bfaSmrg
354d5abbe8Smrg SFtype
__truncdfsf2(DFtype a)364d5abbe8Smrg __truncdfsf2 (DFtype a)
3748fb7bfaSmrg {
3848fb7bfaSmrg FP_DECL_EX;
3948fb7bfaSmrg FP_DECL_D (A);
4048fb7bfaSmrg FP_DECL_S (R);
4148fb7bfaSmrg SFtype r;
4248fb7bfaSmrg
4348fb7bfaSmrg FP_INIT_ROUNDMODE;
4448fb7bfaSmrg FP_UNPACK_SEMIRAW_D (A, a);
4548fb7bfaSmrg #if _FP_W_TYPE_SIZE < _FP_FRACBITS_D
4648fb7bfaSmrg FP_TRUNC (S, D, 1, 2, R, A);
4748fb7bfaSmrg #else
4848fb7bfaSmrg FP_TRUNC (S, D, 1, 1, R, A);
4948fb7bfaSmrg #endif
5048fb7bfaSmrg FP_PACK_SEMIRAW_S (r, R);
5148fb7bfaSmrg FP_HANDLE_EXCEPTIONS;
5248fb7bfaSmrg
5348fb7bfaSmrg return r;
5448fb7bfaSmrg }
55