2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / config / pa / quadlib.c
blobcfec5e9723c9f8a87c0896c3df6d7a754b4f7dc0
1 /* Subroutines for long double support.
2 Copyright (C) 2000, 2002 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 In addition to the permissions in the GNU General Public License, the
12 Free Software Foundation gives you unlimited permission to link the
13 compiled version of this file into combinations with other programs,
14 and to distribute those combinations without any restriction coming
15 from the use of this file. (The General Public License restrictions
16 do apply in other respects; for example, they cover modification of
17 the file, and distribution when not linked into a combine
18 executable.)
20 GCC is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
25 You should have received a copy of the GNU General Public License
26 along with GCC; see the file COPYING. If not, write to
27 the Free Software Foundation, 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. */
30 int _U_Qfcmp (long double a, long double b, int);
31 long _U_Qfcnvfxt_quad_to_sgl (long double);
33 int _U_Qfeq (long double, long double);
34 int _U_Qfne (long double, long double);
35 int _U_Qfgt (long double, long double);
36 int _U_Qfge (long double, long double);
37 int _U_Qflt (long double, long double);
38 int _U_Qfle (long double, long double);
39 int _U_Qfcomp (long double, long double);
40 long double _U_Qfneg (long double);
41 #ifdef __LP64__
42 int __U_Qfcnvfxt_quad_to_sgl (long double);
43 #endif
44 unsigned int _U_Qfcnvfxt_quad_to_usgl(long double);
45 unsigned long long _U_Qfcnvfxt_quad_to_udbl(long double);
47 int
48 _U_Qfeq (long double a, long double b)
50 return (_U_Qfcmp (a, b, 4) != 0);
53 int
54 _U_Qfne (long double a, long double b)
56 return (_U_Qfcmp (a, b, 4) == 0);
59 int
60 _U_Qfgt (long double a, long double b)
62 return (_U_Qfcmp (a, b, 17) != 0);
65 int
66 _U_Qfge (long double a, long double b)
68 return (_U_Qfcmp (a, b, 21) != 0);
71 int
72 _U_Qflt (long double a, long double b)
74 return (_U_Qfcmp (a, b, 9) != 0);
77 int
78 _U_Qfle (long double a, long double b)
80 return (_U_Qfcmp (a, b, 13) != 0);
83 int
84 _U_Qfcomp (long double a, long double b)
86 if (_U_Qfcmp (a, b, 4) == 0)
87 return 0;
89 return (_U_Qfcmp (a, b, 22) != 0 ? 1 : -1);
93 long double
94 _U_Qfneg (long double a)
96 return (0.0L - a);
99 #ifdef __LP64__
100 /* This routine is only necessary for the PA64 port; for reasons unknown
101 _U_Qfcnvfxt_quad_to_sgl returns the integer in the high 32bits of the
102 return value. Ugh. */
104 __U_Qfcnvfxt_quad_to_sgl (long double a)
106 return _U_Qfcnvfxt_quad_to_sgl (a) >> 32;
108 #endif
110 /* HP only has signed conversion in library, so need to synthesize an
111 unsigned version */
112 unsigned int
113 _U_Qfcnvfxt_quad_to_usgl(long double a)
115 extern long long _U_Qfcnvfxt_quad_to_dbl (long double a);
116 return (unsigned int) _U_Qfcnvfxt_quad_to_dbl (a);
119 /* HP only has signed conversion in library, so need to synthesize an
120 unsigned version */
121 typedef union {
122 long long unsigned int u[2];
123 long double d[1];
124 } quad_type;
126 unsigned long long
127 _U_Qfcnvfxt_quad_to_udbl(long double a)
129 extern quad_type _U_Qfcnvfxt_quad_to_quad (long double a);
130 quad_type u;
131 u = _U_Qfcnvfxt_quad_to_quad(a);
132 return u.u[1];