OSDN Git Service

7cfd9b2b9522e5e594a0f372399c6434e7e465a0
[pf3gnuchains/gcc-fork.git] / libdecnumber / decLibrary.c
1 /* Temporary library support for decimal floating point.
2    Copyright (C) 2005 Free Software Foundation, Inc.
3
4 This file is part of GCC.
5
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
9 version.
10
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING.  If not, write to the Free
18 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301, USA.  */
20
21 #include "config.h"
22 #include "decContext.h"
23 #include "decimal128.h"
24 #include "decimal64.h"
25 #include "decimal32.h"
26
27 void __host_to_ieee_32 (_Decimal32, decimal32 *);
28 void __host_to_ieee_64 (_Decimal64, decimal64 *);
29 void __host_to_ieee_128 (_Decimal128, decimal128 *);
30
31 extern int isinfd32 (_Decimal32);
32 extern int isinfd64 (_Decimal64);
33 extern int isinfd128 (_Decimal128);
34 extern void __dfp_enable_traps (void);
35 extern void __dfp_raise (int exception __attribute__ ((unused)));
36
37 int
38 isinfd32 (_Decimal32 arg)
39 {
40   decNumber dn;
41   decimal32 d32;
42
43   __host_to_ieee_32 (arg, &d32);
44   decimal32ToNumber (&d32, &dn);
45   return (decNumberIsInfinite (&dn));
46 }
47
48 int
49 isinfd64 (_Decimal64 arg)
50 {
51   decNumber dn;
52   decimal64 d64;
53
54   __host_to_ieee_64 (arg, &d64);
55   decimal64ToNumber (&d64, &dn);
56   return (decNumberIsInfinite (&dn));
57 }
58
59 int
60 isinfd128 (_Decimal128 arg)
61 {
62   decNumber dn;
63   decimal128 d128;
64
65   __host_to_ieee_128 (arg, &d128);
66   decimal128ToNumber (&d128, &dn);
67   return (decNumberIsInfinite (&dn));
68 }
69
70 int __dfp_traps;
71
72 void
73 __dfp_enable_traps (void)
74 {
75   __dfp_traps = 1;
76 }
77
78 void
79 __dfp_raise (int exception __attribute__ ((unused)))
80 {
81   raise (SIGFPE);
82 }