Daily bump.
[official-gcc.git] / gcc / fp-test.c
blob667059c1dda38a9ea86c11f40f8650c8fc11e031
1 /* fp-test.c - Check that all floating-point operations are available.
2 Copyright (C) 1995 Free Software Foundation, Inc.
3 Contributed by Ronald F. Guilmette <rfg@monkeys.com>.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 /* This is a trivial test program which may be useful to people who are
23 porting the GCC or G++ compilers to a new system. The intent here is
24 merely to check that all floating-point operations have been provided
25 by the port. (Note that I say ``provided'' rather than ``implemented''.)
27 To use this file, simply compile it (with GCC or G++) and then try to
28 link it in the normal way (also using GCC or G++ respectively). If
29 all of the floating -point operations (including conversions) have
30 been provided, then this file will link without incident. If however
31 one or more of the primitive floating-point operations have not been
32 properly provided, you will get link-time errors indicating which
33 floating-point operations are unavailable.
35 This file will typically be used when porting the GNU compilers to
36 some system which lacks floating-point hardware, and for which
37 software emulation routines (for FP ops) are needed in order to
38 complete the port. */
40 #if 0
41 #include <math.h>
42 #endif
44 extern double acos (double);
45 extern double asin (double);
46 extern double atan (double);
47 extern double atan2 (double, double);
48 extern double cos (double);
49 extern double sin (double);
50 extern double tan (double);
51 extern double cosh (double);
52 extern double sinh (double);
53 extern double tanh (double);
54 extern double exp (double);
55 extern double frexp (double, int *);
56 extern double ldexp (double, int);
57 extern double log (double);
58 extern double log10 (double);
59 extern double modf (double, double *);
60 extern double pow (double, double);
61 extern double sqrt (double);
62 extern double ceil (double);
63 extern double fabs (double);
64 extern double floor (double);
65 extern double fmod (double, double);
67 int i1, i2 = 2;
69 volatile signed char sc;
70 volatile unsigned char uc;
72 volatile signed short ss;
73 volatile unsigned short us;
75 volatile signed int si;
76 volatile unsigned int ui;
78 volatile signed long sl;
79 volatile unsigned long ul;
81 volatile float f1 = 1.0, f2 = 1.0, f3 = 1.0;
82 volatile double d1 = 1.0, d2 = 1.0, d3 = 1.0;
83 volatile long double D1 = 1.0, D2 = 1.0, D3 = 1.0;
85 int
86 main ()
88 /* TYPE: float */
90 f1 = -f2;
91 f1 = f2 + f3;
92 f1 = f2 - f3;
93 f1 = f2 * f3;
94 f1 = f2 / f3;
95 f1 += f2;
96 f1 -= f2;
97 f1 *= f2;
98 f1 /= f2;
100 si = f1 == f2;
101 si = f1 != f2;
102 si = f1 > f2;
103 si = f1 < f2;
104 si = f1 >= f2;
105 si = f1 <= f2;
107 sc = f1;
108 uc = f1;
109 ss = f1;
110 us = f1;
111 si = f1;
112 ui = f1;
113 sl = f1;
114 ul = f1;
115 d1 = f1;
116 D1 = f1;
118 f1 = sc;
119 f1 = uc;
120 f1 = ss;
121 f1 = us;
122 f1 = si;
123 f1 = ui;
124 f1 = sl;
125 f1 = ul;
126 f1 = d1;
127 f1 = D1;
129 d1 = -d2;
130 d1 = d2 + d3;
131 d1 = d2 - d3;
132 d1 = d2 * d3;
133 d1 = d2 / d3;
134 d1 += d2;
135 d1 -= d2;
136 d1 *= d2;
137 d1 /= d2;
139 si = d1 == d2;
140 si = d1 != d2;
141 si = d1 > d2;
142 si = d1 < d2;
143 si = d1 >= d2;
144 si = d1 <= d2;
146 sc = d1;
147 uc = d1;
148 ss = d1;
149 us = d1;
150 si = d1;
151 ui = d1;
152 sl = d1;
153 ul = d1;
154 f1 = d1;
155 D1 = d1;
157 d1 = sc;
158 d1 = uc;
159 d1 = ss;
160 d1 = us;
161 d1 = si;
162 d1 = ui;
163 d1 = sl;
164 d1 = ul;
165 d1 = f1;
166 d1 = D1;
168 D1 = -D2;
169 D1 = D2 + D3;
170 D1 = D2 - D3;
171 D1 = D2 * D3;
172 D1 = D2 / D3;
173 D1 += D2;
174 D1 -= D2;
175 D1 *= D2;
176 D1 /= D2;
178 si = D1 == D2;
179 si = D1 != D2;
180 si = D1 > D2;
181 si = D1 < D2;
182 si = D1 >= D2;
183 si = D1 <= D2;
185 sc = D1;
186 uc = D1;
187 ss = D1;
188 us = D1;
189 si = D1;
190 ui = D1;
191 sl = D1;
192 ul = D1;
193 f1 = D1;
194 d1 = D1;
196 D1 = sc;
197 D1 = uc;
198 D1 = ss;
199 D1 = us;
200 D1 = si;
201 D1 = ui;
202 D1 = sl;
203 D1 = ul;
204 D1 = f1;
205 D1 = d1;
207 d1 = acos (d2);
208 d1 = asin (d2);
209 d1 = atan (d2);
210 d1 = atan2 (d2, d3);
211 d1 = cos (d2);
212 d1 = sin (d2);
213 d1 = tan (d2);
214 d1 = cosh (d2);
215 d1 = sinh (d2);
216 d1 = tanh (d2);
217 d1 = exp (d2);
218 d1 = frexp (d2, &i1);
219 d1 = ldexp (d2, i2);
220 d1 = log (d2);
221 d1 = log10 (d2);
222 d1 = modf (d2, &d3);
223 d1 = pow (d2, d3);
224 d1 = sqrt (d2);
225 d1 = ceil (d2);
226 d1 = fabs (d2);
227 d1 = floor (d2);
228 d1 = fmod (d2, d3);
230 return 0;