| 1 |
/* Tests for _FloatN / _FloatNx types: compile and execution tests for |
| 2 |
built-in functions. Before including this file, define WIDTH as |
| 3 |
the value N; define EXT to 1 for _FloatNx and 0 for _FloatN. */ |
| 4 |
|
| 5 |
#define CONCATX(X, Y) X ## Y |
| 6 |
#define CONCAT(X, Y) CONCATX (X, Y) |
| 7 |
#define CONCAT3(X, Y, Z) CONCAT (CONCAT (X, Y), Z) |
| 8 |
#define CONCAT4(W, X, Y, Z) CONCAT (CONCAT (CONCAT (W, X), Y), Z) |
| 9 |
|
| 10 |
#if EXT |
| 11 |
# define TYPE CONCAT3 (_Float, WIDTH, x) |
| 12 |
# define CST(C) CONCAT4 (C, f, WIDTH, x) |
| 13 |
# define FN(F) CONCAT4 (F, f, WIDTH, x) |
| 14 |
#else |
| 15 |
# define TYPE CONCAT (_Float, WIDTH) |
| 16 |
# define CST(C) CONCAT3 (C, f, WIDTH) |
| 17 |
# define FN(F) CONCAT3 (F, f, WIDTH) |
| 18 |
#endif |
| 19 |
|
| 20 |
extern void exit (int); |
| 21 |
extern void abort (void); |
| 22 |
|
| 23 |
extern int test_i; |
| 24 |
extern long int test_l; |
| 25 |
extern long long int test_ll; |
| 26 |
extern TYPE test_type; |
| 27 |
extern __typeof (FN (__builtin_inf) ()) test_type; |
| 28 |
extern __typeof (FN (__builtin_huge_val) ()) test_type; |
| 29 |
extern __typeof (FN (__builtin_nan) ("")) test_type; |
| 30 |
extern __typeof (FN (__builtin_nans) ("")) test_type; |
| 31 |
extern __typeof (FN (__builtin_fabs) (0)) test_type; |
| 32 |
extern __typeof (FN (__builtin_copysign) (0, 0)) test_type; |
| 33 |
extern __typeof (FN (__builtin_acosh) (0)) test_type; |
| 34 |
extern __typeof (FN (__builtin_acos) (0)) test_type; |
| 35 |
extern __typeof (FN (__builtin_asinh) (0)) test_type; |
| 36 |
extern __typeof (FN (__builtin_asin) (0)) test_type; |
| 37 |
extern __typeof (FN (__builtin_atanh) (0)) test_type; |
| 38 |
extern __typeof (FN (__builtin_atan) (0)) test_type; |
| 39 |
extern __typeof (FN (__builtin_cbrt) (0)) test_type; |
| 40 |
extern __typeof (FN (__builtin_cosh) (0)) test_type; |
| 41 |
extern __typeof (FN (__builtin_cos) (0)) test_type; |
| 42 |
extern __typeof (FN (__builtin_erfc) (0)) test_type; |
| 43 |
extern __typeof (FN (__builtin_erf) (0)) test_type; |
| 44 |
extern __typeof (FN (__builtin_exp2) (0)) test_type; |
| 45 |
extern __typeof (FN (__builtin_exp) (0)) test_type; |
| 46 |
extern __typeof (FN (__builtin_expm1) (0)) test_type; |
| 47 |
extern __typeof (FN (__builtin_lgamma) (0)) test_type; |
| 48 |
extern __typeof (FN (__builtin_log10) (0)) test_type; |
| 49 |
extern __typeof (FN (__builtin_log1p) (0)) test_type; |
| 50 |
extern __typeof (FN (__builtin_log2) (0)) test_type; |
| 51 |
extern __typeof (FN (__builtin_logb) (0)) test_type; |
| 52 |
extern __typeof (FN (__builtin_log) (0)) test_type; |
| 53 |
extern __typeof (FN (__builtin_nextafter) (0, 0)) test_type; |
| 54 |
extern __typeof (FN (__builtin_sinh) (0)) test_type; |
| 55 |
extern __typeof (FN (__builtin_sin) (0)) test_type; |
| 56 |
extern __typeof (FN (__builtin_tanh) (0)) test_type; |
| 57 |
extern __typeof (FN (__builtin_tan) (0)) test_type; |
| 58 |
extern __typeof (FN (__builtin_tgamma) (0)) test_type; |
| 59 |
extern __typeof (FN (__builtin_atan2) (0, 0)) test_type; |
| 60 |
extern __typeof (FN (__builtin_fdim) (0, 0)) test_type; |
| 61 |
extern __typeof (FN (__builtin_fmod) (0, 0)) test_type; |
| 62 |
extern __typeof (FN (__builtin_frexp) (0, &test_i)) test_type; |
| 63 |
extern __typeof (FN (__builtin_ldexp) (0, 0)) test_type; |
| 64 |
extern __typeof (FN (__builtin_hypot) (0, 0)) test_type; |
| 65 |
extern __typeof (FN (__builtin_ilogb) (0)) test_i; |
| 66 |
extern __typeof (FN (__builtin_llrint) (0)) test_ll; |
| 67 |
extern __typeof (FN (__builtin_llround) (0)) test_ll; |
| 68 |
extern __typeof (FN (__builtin_lrint) (0)) test_l; |
| 69 |
extern __typeof (FN (__builtin_lround) (0)) test_l; |
| 70 |
extern __typeof (FN (__builtin_modf) (0, &test_type)) test_type; |
| 71 |
extern __typeof (FN (__builtin_pow) (0, 0)) test_type; |
| 72 |
extern __typeof (FN (__builtin_remainder) (0, 0)) test_type; |
| 73 |
extern __typeof (FN (__builtin_remquo) (0, 0, &test_i)) test_type; |
| 74 |
extern __typeof (FN (__builtin_scalbln) (0, 0L)) test_type; |
| 75 |
extern __typeof (FN (__builtin_scalbn) (0, 0)) test_type; |
| 76 |
|
| 77 |
volatile TYPE inf_cst = FN (__builtin_inf) (); |
| 78 |
volatile TYPE huge_val_cst = FN (__builtin_huge_val) (); |
| 79 |
volatile TYPE nan_cst = FN (__builtin_nan) (""); |
| 80 |
volatile TYPE nans_cst = FN (__builtin_nans) (""); |
| 81 |
volatile TYPE neg0 = -CST (0.0), neg1 = -CST (1.0), one = 1.0; |
| 82 |
volatile TYPE t1 = FN (__builtin_acosh) (CST (1.0)); |
| 83 |
volatile TYPE t2 = FN (__builtin_acos) (CST (1.0)); |
| 84 |
volatile TYPE t3 = FN (__builtin_asinh) (CST (0.0)); |
| 85 |
volatile TYPE t4 = FN (__builtin_asin) (CST (0.0)); |
| 86 |
volatile TYPE t5 = FN (__builtin_atanh) (CST (0.0)); |
| 87 |
volatile TYPE t6 = FN (__builtin_atan) (CST (0.0)); |
| 88 |
volatile TYPE t7 = FN (__builtin_cbrt) (CST (27.0)); |
| 89 |
volatile TYPE t8 = FN (__builtin_cosh) (CST (0.0)); |
| 90 |
volatile TYPE t9 = FN (__builtin_cos) (CST (0.0)); |
| 91 |
volatile TYPE t10 = FN (__builtin_erfc) (CST (0.0)); |
| 92 |
volatile TYPE t11 = FN (__builtin_erf) (CST (0.0)); |
| 93 |
volatile TYPE t12 = FN (__builtin_exp2) (CST (1.0)); |
| 94 |
volatile TYPE t13 = FN (__builtin_exp) (CST (0.0)); |
| 95 |
volatile TYPE t14 = FN (__builtin_expm1) (CST (0.0)); |
| 96 |
volatile TYPE t15 = FN (__builtin_log10) (CST (1.0)); |
| 97 |
volatile TYPE t16 = FN (__builtin_log1p) (CST (0.0)); |
| 98 |
volatile TYPE t17 = FN (__builtin_log2) (CST (1.0)); |
| 99 |
volatile TYPE t18 = FN (__builtin_logb) (CST (1.0)); |
| 100 |
volatile TYPE t19 = FN (__builtin_log) (CST (1.0)); |
| 101 |
volatile TYPE t20 = FN (__builtin_nextafter) (CST (0.0), CST (0.0)); |
| 102 |
volatile TYPE t21 = FN (__builtin_sinh) (CST (0.0)); |
| 103 |
volatile TYPE t22 = FN (__builtin_sin) (CST (0.0)); |
| 104 |
volatile TYPE t23 = FN (__builtin_tanh) (CST (0.0)); |
| 105 |
volatile TYPE t24 = FN (__builtin_tan) (CST (0.0)); |
| 106 |
volatile TYPE t25 = FN (__builtin_atan2) (CST (0.0), CST (1.0)); |
| 107 |
volatile TYPE t26 = FN (__builtin_fdim) (CST (0.0), CST (0.0)); |
| 108 |
volatile TYPE t27 = FN (__builtin_fmod) (CST (0.0), CST (1.0)); |
| 109 |
volatile TYPE t28 = FN (__builtin_ldexp) (CST (1.0), 1); |
| 110 |
volatile TYPE t29 = FN (__builtin_hypot) (CST (3.0), CST (4.0)); |
| 111 |
volatile int t30 = FN (__builtin_ilogb) (CST (1.0)); |
| 112 |
volatile long long int t31 = FN (__builtin_llround) (CST (42.25)); |
| 113 |
volatile long int t32 = FN (__builtin_lround) (CST (42.25)); |
| 114 |
volatile TYPE t33 = FN (__builtin_pow) (CST (1.0), CST (2.0)); |
| 115 |
volatile TYPE t34 = FN (__builtin_remainder) (CST (7.0), CST (4.0)); |
| 116 |
volatile TYPE t35 = FN (__builtin_scalbln) (CST (1.0), 1L); |
| 117 |
volatile TYPE t36 = FN (__builtin_scalbn) (CST (1.0), 1); |
| 118 |
|
| 119 |
int |
| 120 |
main (void) |
| 121 |
{ |
| 122 |
volatile TYPE r; |
| 123 |
if (!__builtin_isinf (inf_cst)) |
| 124 |
abort (); |
| 125 |
if (!__builtin_isinf (huge_val_cst)) |
| 126 |
abort (); |
| 127 |
if (inf_cst != huge_val_cst) |
| 128 |
abort (); |
| 129 |
if (!__builtin_isnan (nan_cst)) |
| 130 |
abort (); |
| 131 |
if (!__builtin_isnan (nans_cst)) |
| 132 |
abort (); |
| 133 |
r = FN (__builtin_fabs) (neg1); |
| 134 |
if (r != CST (1.0)) |
| 135 |
abort (); |
| 136 |
r = FN (__builtin_copysign) (one, neg0); |
| 137 |
if (r != neg1) |
| 138 |
abort (); |
| 139 |
r = FN (__builtin_copysign) (inf_cst, neg1); |
| 140 |
if (r != -huge_val_cst) |
| 141 |
abort (); |
| 142 |
r = FN (__builtin_copysign) (-inf_cst, one); |
| 143 |
if (r != huge_val_cst) |
| 144 |
abort (); |
| 145 |
if (t1 != CST (0.0)) |
| 146 |
abort (); |
| 147 |
if (t2 != CST (0.0)) |
| 148 |
abort (); |
| 149 |
if (t3 != CST (0.0)) |
| 150 |
abort (); |
| 151 |
if (t4 != CST (0.0)) |
| 152 |
abort (); |
| 153 |
if (t5 != CST (0.0)) |
| 154 |
abort (); |
| 155 |
if (t6 != CST (0.0)) |
| 156 |
abort (); |
| 157 |
if (t7 != CST (3.0)) |
| 158 |
abort (); |
| 159 |
if (t8 != CST (1.0)) |
| 160 |
abort (); |
| 161 |
if (t9 != CST (1.0)) |
| 162 |
abort (); |
| 163 |
if (t10 != CST (1.0)) |
| 164 |
abort (); |
| 165 |
if (t11 != CST (0.0)) |
| 166 |
abort (); |
| 167 |
if (t12 != CST (2.0)) |
| 168 |
abort (); |
| 169 |
if (t13 != CST (1.0)) |
| 170 |
abort (); |
| 171 |
if (t14 != CST (0.0)) |
| 172 |
abort (); |
| 173 |
if (t15 != CST (0.0)) |
| 174 |
abort (); |
| 175 |
if (t16 != CST (0.0)) |
| 176 |
abort (); |
| 177 |
if (t17 != CST (0.0)) |
| 178 |
abort (); |
| 179 |
if (t18 != CST (0.0)) |
| 180 |
abort (); |
| 181 |
if (t19 != CST (0.0)) |
| 182 |
abort (); |
| 183 |
if (t20 != CST (0.0)) |
| 184 |
abort (); |
| 185 |
if (t21 != CST (0.0)) |
| 186 |
abort (); |
| 187 |
if (t22 != CST (0.0)) |
| 188 |
abort (); |
| 189 |
if (t23 != CST (0.0)) |
| 190 |
abort (); |
| 191 |
if (t24 != CST (0.0)) |
| 192 |
abort (); |
| 193 |
if (t25 != CST (0.0)) |
| 194 |
abort (); |
| 195 |
if (t26 != CST (0.0)) |
| 196 |
abort (); |
| 197 |
if (t27 != CST (0.0)) |
| 198 |
abort (); |
| 199 |
if (t28 != CST (2.0)) |
| 200 |
abort (); |
| 201 |
if (t29 != CST (5.0)) |
| 202 |
abort (); |
| 203 |
if (t30 != 0) |
| 204 |
abort (); |
| 205 |
if (t31 != 42) |
| 206 |
abort (); |
| 207 |
if (t32 != 42) |
| 208 |
abort (); |
| 209 |
if (t33 != CST (1.0)) |
| 210 |
abort (); |
| 211 |
if (t34 != -CST (1.0)) |
| 212 |
abort (); |
| 213 |
if (t35 != CST (2.0)) |
| 214 |
abort (); |
| 215 |
if (t36 != CST (2.0)) |
| 216 |
abort (); |
| 217 |
exit (0); |
| 218 |
} |