OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [fp-test.c] - Blame information for rev 859

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.