Implement C _FloatN, _FloatNx types.
[official-gcc.git] / gcc / testsuite / gcc.dg / torture / floatn-tg.h
blob822229764aec4ff73ad1e54a2e1cfc59a90e9aed
1 /* Tests for _FloatN / _FloatNx types: compile and execution tests for
2 type-generic built-in functions. Before including this file,
3 define WIDTH as the value N; define EXT to 1 for _FloatNx and 0 for
4 _FloatN. */
6 #define __STDC_WANT_IEC_60559_TYPES_EXT__
7 #include <float.h>
9 #define CONCATX(X, Y) X ## Y
10 #define CONCAT(X, Y) CONCATX (X, Y)
11 #define CONCAT3(X, Y, Z) CONCAT (CONCAT (X, Y), Z)
12 #define CONCAT4(W, X, Y, Z) CONCAT (CONCAT (CONCAT (W, X), Y), Z)
14 #if EXT
15 # define TYPE CONCAT3 (_Float, WIDTH, x)
16 # define CST(C) CONCAT4 (C, f, WIDTH, x)
17 # define TRUE_MIN CONCAT3 (FLT, WIDTH, X_TRUE_MIN)
18 #else
19 # define TYPE CONCAT (_Float, WIDTH)
20 # define CST(C) CONCAT3 (C, f, WIDTH)
21 # define TRUE_MIN CONCAT3 (FLT, WIDTH, _TRUE_MIN)
22 #endif
24 extern void exit (int);
25 extern void abort (void);
27 volatile TYPE inf = __builtin_inf (), nanval = __builtin_nan ("");
28 volatile TYPE zero = CST (0.0), negzero = -CST (0.0), one = CST (1.0);
29 volatile TYPE true_min = TRUE_MIN;
31 int
32 main (void)
34 if (__builtin_signbit (inf) != 0)
35 abort ();
36 if (__builtin_signbit (zero) != 0)
37 abort ();
38 if (__builtin_signbit (negzero) == 0)
39 abort ();
40 if (__builtin_isfinite (nanval) != 0)
41 abort ();
42 if (__builtin_isfinite (inf) != 0)
43 abort ();
44 if (__builtin_isfinite (one) == 0)
45 abort ();
46 if (__builtin_isinf (nanval) != 0)
47 abort ();
48 if (__builtin_isinf (inf) == 0)
49 abort ();
50 if (__builtin_isnan (nanval) == 0)
51 abort ();
52 if (__builtin_isnan (inf) != 0)
53 abort ();
54 if (__builtin_isnormal (inf) != 0)
55 abort ();
56 if (__builtin_isnormal (one) == 0)
57 abort ();
58 if (__builtin_isnormal (nanval) != 0)
59 abort ();
60 if (__builtin_isnormal (zero) != 0)
61 abort ();
62 if (__builtin_isnormal (true_min) != 0)
63 abort ();
64 if (__builtin_islessequal (zero, one) != 1)
65 abort ();
66 if (__builtin_islessequal (one, zero) != 0)
67 abort ();
68 if (__builtin_islessequal (zero, negzero) != 1)
69 abort ();
70 if (__builtin_islessequal (zero, nanval) != 0)
71 abort ();
72 if (__builtin_isless (zero, one) != 1)
73 abort ();
74 if (__builtin_isless (one, zero) != 0)
75 abort ();
76 if (__builtin_isless (zero, negzero) != 0)
77 abort ();
78 if (__builtin_isless (zero, nanval) != 0)
79 abort ();
80 if (__builtin_isgreaterequal (zero, one) != 0)
81 abort ();
82 if (__builtin_isgreaterequal (one, zero) != 1)
83 abort ();
84 if (__builtin_isgreaterequal (zero, negzero) != 1)
85 abort ();
86 if (__builtin_isgreaterequal (zero, nanval) != 0)
87 abort ();
88 if (__builtin_isgreater (zero, one) != 0)
89 abort ();
90 if (__builtin_isgreater (one, zero) != 1)
91 abort ();
92 if (__builtin_isgreater (zero, negzero) != 0)
93 abort ();
94 if (__builtin_isgreater (zero, nanval) != 0)
95 abort ();
96 if (__builtin_islessgreater (zero, one) != 1)
97 abort ();
98 if (__builtin_islessgreater (one, zero) != 1)
99 abort ();
100 if (__builtin_islessgreater (zero, negzero) != 0)
101 abort ();
102 if (__builtin_islessgreater (zero, nanval) != 0)
103 abort ();
104 if (__builtin_isunordered (zero, one) != 0)
105 abort ();
106 if (__builtin_isunordered (one, zero) != 0)
107 abort ();
108 if (__builtin_isunordered (zero, negzero) != 0)
109 abort ();
110 if (__builtin_isunordered (zero, nanval) != 1)
111 abort ();
112 exit (0);