OSDN Git Service

* libdecnumber: Import decNumber sources from the dfp-branch.
[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 "decContext.h"
22 #include "decimal128.h"
23 #include "decimal64.h"
24 #include "decimal32.h"
25
26 void __host_to_ieee_32 (_Decimal32, decimal32 *);
27 void __host_to_ieee_64 (_Decimal64, decimal64 *);
28 void __host_to_ieee_128 (_Decimal128, decimal128 *);
29
30 extern int isinfd32 (_Decimal32);
31 extern int isinfd64 (_Decimal64);
32 extern int isinfd128 (_Decimal128);
33 extern void __dfp_enable_traps (void);
34 extern void __dfp_raise (int exception __attribute__ ((unused)));
35
36 int
37 isinfd32 (_Decimal32 arg)
38 {
39   decNumber dn;
40   decimal32 d32;
41
42   __host_to_ieee_32 (arg, &d32);
43   decimal32ToNumber (&d32, &dn);
44   return (decNumberIsInfinite (&dn));
45 }
46
47 int
48 isinfd64 (_Decimal64 arg)
49 {
50   decNumber dn;
51   decimal64 d64;
52
53   __host_to_ieee_64 (arg, &d64);
54   decimal64ToNumber (&d64, &dn);
55   return (decNumberIsInfinite (&dn));
56 }
57
58 int
59 isinfd128 (_Decimal128 arg)
60 {
61   decNumber dn;
62   decimal128 d128;
63
64   __host_to_ieee_128 (arg, &d128);
65   decimal128ToNumber (&d128, &dn);
66   return (decNumberIsInfinite (&dn));
67 }
68
69 int __dfp_traps;
70
71 void
72 __dfp_enable_traps (void)
73 {
74   __dfp_traps = 1;
75 }
76
77 void
78 __dfp_raise (int exception __attribute__ ((unused)))
79 {
80   raise (SIGFPE);
81 }