1 /* fp-test.c - Check that all floating-point operations are available.
2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
3 Contributed by Ronald F. Guilmette <rfg@monkeys.com>.
5 This file is part of GCC.
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)
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.
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/>. */
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''.)
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.
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
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);
68 volatile signed char sc
;
69 volatile unsigned char uc
;
71 volatile signed short ss
;
72 volatile unsigned short us
;
74 volatile signed int si
;
75 volatile unsigned int ui
;
77 volatile signed long sl
;
78 volatile unsigned long ul
;
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;
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
);
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
);
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
);
238 d1
= frexp (d2
, &i1
);