00001 /* Temporary library support for decimal floating point. 00002 Copyright (C) 2005, 2006 Free Software Foundation, Inc. 00003 00004 This file is part of GCC. 00005 00006 GCC is free software; you can redistribute it and/or modify it 00007 under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2, or (at your option) 00009 any later version. 00010 00011 In addition to the permissions in the GNU General Public License, 00012 the Free Software Foundation gives you unlimited permission to link 00013 the compiled version of this file into combinations with other 00014 programs, and to distribute those combinations without any 00015 restriction coming from the use of this file. (The General Public 00016 License restrictions do apply in other respects; for example, they 00017 cover modification of the file, and distribution when not linked 00018 into a combine executable.) 00019 00020 GCC is distributed in the hope that it will be useful, but WITHOUT 00021 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 00022 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 00023 License for more details. 00024 00025 You should have received a copy of the GNU General Public License 00026 along with GCC; see the file COPYING. If not, write to the Free 00027 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 00028 02110-1301, USA. */ 00029 00030 #include "config.h" 00031 #include "decContext.h" 00032 #include "decimal128.h" 00033 #include "decimal64.h" 00034 #include "decimal32.h" 00035 00036 void __host_to_ieee_32 (_Decimal32, decimal32 *); 00037 void __host_to_ieee_64 (_Decimal64, decimal64 *); 00038 void __host_to_ieee_128 (_Decimal128, decimal128 *); 00039 00040 extern int isinfd32 (_Decimal32); 00041 extern int isinfd64 (_Decimal64); 00042 extern int isinfd128 (_Decimal128); 00043 extern void __dfp_enable_traps (void); 00044 extern void __dfp_raise (int exception __attribute__ ((unused))); 00045 00046 int 00047 isinfd32 (_Decimal32 arg) 00048 { 00049 decNumber dn; 00050 decimal32 d32; 00051 00052 __host_to_ieee_32 (arg, &d32); 00053 decimal32ToNumber (&d32, &dn); 00054 return (decNumberIsInfinite (&dn)); 00055 } 00056 00057 int 00058 isinfd64 (_Decimal64 arg) 00059 { 00060 decNumber dn; 00061 decimal64 d64; 00062 00063 __host_to_ieee_64 (arg, &d64); 00064 decimal64ToNumber (&d64, &dn); 00065 return (decNumberIsInfinite (&dn)); 00066 } 00067 00068 int 00069 isinfd128 (_Decimal128 arg) 00070 { 00071 decNumber dn; 00072 decimal128 d128; 00073 00074 __host_to_ieee_128 (arg, &d128); 00075 decimal128ToNumber (&d128, &dn); 00076 return (decNumberIsInfinite (&dn)); 00077 } 00078 00079 int __dfp_traps; 00080 00081 void 00082 __dfp_enable_traps (void) 00083 { 00084 __dfp_traps = 1; 00085 } 00086 00087 void 00088 __dfp_raise (int exception __attribute__ ((unused))) 00089 { 00090 raise (SIGFPE); 00091 } 00092 00093 uint32_t 00094 __dec_byte_swap (uint32_t in) 00095 { 00096 uint32_t out = 0; 00097 unsigned char *p = (unsigned char *) &out; 00098 union { 00099 uint32_t i; 00100 unsigned char b[4]; 00101 } u; 00102 00103 u.i = in; 00104 p[0] = u.b[3]; 00105 p[1] = u.b[2]; 00106 p[2] = u.b[1]; 00107 p[3] = u.b[0]; 00108 00109 return out; 00110 }
1.5.6