xref: /netbsd-src/external/gpl3/gcc/dist/libgcc/soft-fp/fixdfsi.c (revision fb8a8121f28072308659629b86cfb7c449bd93e1)
148fb7bfaSmrg /* Software floating-point emulation.
248fb7bfaSmrg    Convert a to 32bit signed integer
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 "double.h"
3348fb7bfaSmrg 
344d5abbe8Smrg SItype
__fixdfsi(DFtype a)354d5abbe8Smrg __fixdfsi (DFtype a)
3648fb7bfaSmrg {
3748fb7bfaSmrg   FP_DECL_EX;
3848fb7bfaSmrg   FP_DECL_D (A);
3948fb7bfaSmrg   USItype r;
4048fb7bfaSmrg 
414d5abbe8Smrg   FP_INIT_EXCEPTIONS;
4248fb7bfaSmrg   FP_UNPACK_RAW_D (A, a);
4348fb7bfaSmrg   FP_TO_INT_D (r, A, SI_BITS, 1);
4448fb7bfaSmrg   FP_HANDLE_EXCEPTIONS;
4548fb7bfaSmrg 
4648fb7bfaSmrg   return r;
4748fb7bfaSmrg }
48