xref: /netbsd-src/external/gpl3/gdb/dist/libdecnumber/decLibrary.c (revision 4559860ef23039476746699b4757c1b6983b488b)
14e98e3e1Schristos /* Temporary library support for decimal floating point.
2*4559860eSchristos    Copyright (C) 2005-2018 Free Software Foundation, Inc.
34e98e3e1Schristos 
44e98e3e1Schristos    This file is part of GCC.
54e98e3e1Schristos 
64e98e3e1Schristos    GCC is free software; you can redistribute it and/or modify it
74e98e3e1Schristos    under the terms of the GNU General Public License as published by
84e98e3e1Schristos    the Free Software Foundation; either version 3, or (at your option)
94e98e3e1Schristos    any later version.
104e98e3e1Schristos 
114e98e3e1Schristos    GCC is distributed in the hope that it will be useful, but WITHOUT
124e98e3e1Schristos    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
134e98e3e1Schristos    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
144e98e3e1Schristos    License for more details.
154e98e3e1Schristos 
164e98e3e1Schristos Under Section 7 of GPL version 3, you are granted additional
174e98e3e1Schristos permissions described in the GCC Runtime Library Exception, version
184e98e3e1Schristos 3.1, as published by the Free Software Foundation.
194e98e3e1Schristos 
204e98e3e1Schristos You should have received a copy of the GNU General Public License and
214e98e3e1Schristos a copy of the GCC Runtime Library Exception along with this program;
224e98e3e1Schristos see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
234e98e3e1Schristos <http://www.gnu.org/licenses/>.  */
244e98e3e1Schristos 
254e98e3e1Schristos #include "dconfig.h"
264e98e3e1Schristos #include "decContext.h"
274e98e3e1Schristos #include "decimal128.h"
284e98e3e1Schristos #include "decimal64.h"
294e98e3e1Schristos #include "decimal32.h"
304e98e3e1Schristos 
314e98e3e1Schristos void __host_to_ieee_32 (_Decimal32, decimal32 *);
324e98e3e1Schristos void __host_to_ieee_64 (_Decimal64, decimal64 *);
334e98e3e1Schristos void __host_to_ieee_128 (_Decimal128, decimal128 *);
344e98e3e1Schristos 
354e98e3e1Schristos extern int isinfd32 (_Decimal32);
364e98e3e1Schristos extern int isinfd64 (_Decimal64);
374e98e3e1Schristos extern int isinfd128 (_Decimal128);
384e98e3e1Schristos uint32_t __dec_byte_swap (uint32_t);
394e98e3e1Schristos 
404e98e3e1Schristos int
isinfd32(_Decimal32 arg)414e98e3e1Schristos isinfd32 (_Decimal32 arg)
424e98e3e1Schristos {
434e98e3e1Schristos   decNumber dn;
444e98e3e1Schristos   decimal32 d32;
454e98e3e1Schristos 
464e98e3e1Schristos   __host_to_ieee_32 (arg, &d32);
474e98e3e1Schristos   decimal32ToNumber (&d32, &dn);
484e98e3e1Schristos   return (decNumberIsInfinite (&dn));
494e98e3e1Schristos }
504e98e3e1Schristos 
514e98e3e1Schristos int
isinfd64(_Decimal64 arg)524e98e3e1Schristos isinfd64 (_Decimal64 arg)
534e98e3e1Schristos {
544e98e3e1Schristos   decNumber dn;
554e98e3e1Schristos   decimal64 d64;
564e98e3e1Schristos 
574e98e3e1Schristos   __host_to_ieee_64 (arg, &d64);
584e98e3e1Schristos   decimal64ToNumber (&d64, &dn);
594e98e3e1Schristos   return (decNumberIsInfinite (&dn));
604e98e3e1Schristos }
614e98e3e1Schristos 
624e98e3e1Schristos int
isinfd128(_Decimal128 arg)634e98e3e1Schristos isinfd128 (_Decimal128 arg)
644e98e3e1Schristos {
654e98e3e1Schristos   decNumber dn;
664e98e3e1Schristos   decimal128 d128;
674e98e3e1Schristos 
684e98e3e1Schristos   __host_to_ieee_128 (arg, &d128);
694e98e3e1Schristos   decimal128ToNumber (&d128, &dn);
704e98e3e1Schristos   return (decNumberIsInfinite (&dn));
714e98e3e1Schristos }
72