xref: /netbsd-src/external/gpl3/gdb.old/dist/libdecnumber/decLibrary.c (revision 47c37bc27558091724f1a0d4eef4c8f80c94c00a)
1bb16d227Schristos /* Temporary library support for decimal floating point.
2*47c37bc2Schristos    Copyright (C) 2005-2018 Free Software Foundation, Inc.
3bb16d227Schristos 
4bb16d227Schristos    This file is part of GCC.
5bb16d227Schristos 
6bb16d227Schristos    GCC is free software; you can redistribute it and/or modify it
7bb16d227Schristos    under the terms of the GNU General Public License as published by
8bb16d227Schristos    the Free Software Foundation; either version 3, or (at your option)
9bb16d227Schristos    any later version.
10bb16d227Schristos 
11bb16d227Schristos    GCC is distributed in the hope that it will be useful, but WITHOUT
12bb16d227Schristos    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13bb16d227Schristos    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
14bb16d227Schristos    License for more details.
15bb16d227Schristos 
16bb16d227Schristos Under Section 7 of GPL version 3, you are granted additional
17bb16d227Schristos permissions described in the GCC Runtime Library Exception, version
18bb16d227Schristos 3.1, as published by the Free Software Foundation.
19bb16d227Schristos 
20bb16d227Schristos You should have received a copy of the GNU General Public License and
21bb16d227Schristos a copy of the GCC Runtime Library Exception along with this program;
22bb16d227Schristos see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23bb16d227Schristos <http://www.gnu.org/licenses/>.  */
24bb16d227Schristos 
25bb16d227Schristos #include "dconfig.h"
26bb16d227Schristos #include "decContext.h"
27bb16d227Schristos #include "decimal128.h"
28bb16d227Schristos #include "decimal64.h"
29bb16d227Schristos #include "decimal32.h"
30bb16d227Schristos 
31bb16d227Schristos void __host_to_ieee_32 (_Decimal32, decimal32 *);
32bb16d227Schristos void __host_to_ieee_64 (_Decimal64, decimal64 *);
33bb16d227Schristos void __host_to_ieee_128 (_Decimal128, decimal128 *);
34bb16d227Schristos 
35bb16d227Schristos extern int isinfd32 (_Decimal32);
36bb16d227Schristos extern int isinfd64 (_Decimal64);
37bb16d227Schristos extern int isinfd128 (_Decimal128);
38bb16d227Schristos uint32_t __dec_byte_swap (uint32_t);
39bb16d227Schristos 
40bb16d227Schristos int
isinfd32(_Decimal32 arg)41bb16d227Schristos isinfd32 (_Decimal32 arg)
42bb16d227Schristos {
43bb16d227Schristos   decNumber dn;
44bb16d227Schristos   decimal32 d32;
45bb16d227Schristos 
46bb16d227Schristos   __host_to_ieee_32 (arg, &d32);
47bb16d227Schristos   decimal32ToNumber (&d32, &dn);
48bb16d227Schristos   return (decNumberIsInfinite (&dn));
49bb16d227Schristos }
50bb16d227Schristos 
51bb16d227Schristos int
isinfd64(_Decimal64 arg)52bb16d227Schristos isinfd64 (_Decimal64 arg)
53bb16d227Schristos {
54bb16d227Schristos   decNumber dn;
55bb16d227Schristos   decimal64 d64;
56bb16d227Schristos 
57bb16d227Schristos   __host_to_ieee_64 (arg, &d64);
58bb16d227Schristos   decimal64ToNumber (&d64, &dn);
59bb16d227Schristos   return (decNumberIsInfinite (&dn));
60bb16d227Schristos }
61bb16d227Schristos 
62bb16d227Schristos int
isinfd128(_Decimal128 arg)63bb16d227Schristos isinfd128 (_Decimal128 arg)
64bb16d227Schristos {
65bb16d227Schristos   decNumber dn;
66bb16d227Schristos   decimal128 d128;
67bb16d227Schristos 
68bb16d227Schristos   __host_to_ieee_128 (arg, &d128);
69bb16d227Schristos   decimal128ToNumber (&d128, &dn);
70bb16d227Schristos   return (decNumberIsInfinite (&dn));
71bb16d227Schristos }
72