| 1 |
/* Test for _Atomic in C11. Test floating-point exceptions for |
| 2 |
compound assignment are consistent with result (so that if multiple |
| 3 |
iterations of the compare-and-exchange loop are needed, exceptions |
| 4 |
get properly cleared). */ |
| 5 |
/* { dg-do run } */ |
| 6 |
/* { dg-options "-std=c11 -pedantic-errors -pthread -U_POSIX_C_SOURCE -D_POSIX_C_SOURCE=200809L" } */ |
| 7 |
/* { dg-add-options ieee } */ |
| 8 |
/* { dg-additional-options "-mfp-trap-mode=sui" { target alpha*-*-* } } */ |
| 9 |
/* { dg-additional-options "-D_XOPEN_SOURCE=600" { target *-*-solaris2* } } */ |
| 10 |
/* { dg-additional-options "-D_HPUX_SOURCE" { target *-*-hpux* } } */ |
| 11 |
/* { dg-require-effective-target fenv_exceptions } */ |
| 12 |
/* { dg-require-effective-target pthread } */ |
| 13 |
/* { dg-timeout-factor 2 } */ |
| 14 |
|
| 15 |
#include <fenv.h> |
| 16 |
#include <float.h> |
| 17 |
#include <pthread.h> |
| 18 |
#include <stdbool.h> |
| 19 |
#include <stdio.h> |
| 20 |
#include <stdlib.h> |
| 21 |
|
| 22 |
#define TEST_ALL_EXCEPT (FE_DIVBYZERO \ |
| 23 |
| FE_INEXACT \ |
| 24 |
| FE_INVALID \ |
| 25 |
| FE_OVERFLOW \ |
| 26 |
| FE_UNDERFLOW) |
| 27 |
|
| 28 |
#if defined __alpha__ || defined __aarch64__ |
| 29 |
#define ITER_COUNT 100 |
| 30 |
#else |
| 31 |
#define ITER_COUNT 10000 |
| 32 |
#endif |
| 33 |
|
| 34 |
static volatile _Atomic bool thread_ready, thread_stop; |
| 35 |
|
| 36 |
/* Generate test code (with NAME used to name functions and variables) |
| 37 |
for atomic compound assignments to a variable of type LHSTYPE. One |
| 38 |
thread repeatedly stores the values INIT1 and INIT2 in a variable, |
| 39 |
while the other repeatedly executes PRE var POST having set |
| 40 |
floating-point exceptions to BEXC. If the value of the assignment |
| 41 |
operation satisfies VALTEST1 (var), the floating-point exceptions |
| 42 |
should be BEXC | EXC1; otherwise, they should be BEXC | EXC2. A |
| 43 |
function test_main_##NAME is generated that returns nonzero on |
| 44 |
failure, zero on success. */ |
| 45 |
|
| 46 |
#define TEST_FUNCS(NAME, LHSTYPE, PRE, POST, BEXC, \ |
| 47 |
INIT1, VALTEST1, EXC1, INIT2, EXC2) \ |
| 48 |
\ |
| 49 |
static volatile _Atomic LHSTYPE var_##NAME; \ |
| 50 |
\ |
| 51 |
static void * \ |
| 52 |
test_thread_##NAME (void *arg) \ |
| 53 |
{ \ |
| 54 |
thread_ready = true; \ |
| 55 |
while (!thread_stop) \ |
| 56 |
{ \ |
| 57 |
sched_yield (); \ |
| 58 |
var_##NAME = (INIT1); \ |
| 59 |
sched_yield (); \ |
| 60 |
var_##NAME = (INIT2); \ |
| 61 |
sched_yield (); \ |
| 62 |
} \ |
| 63 |
return NULL; \ |
| 64 |
} \ |
| 65 |
\ |
| 66 |
static int \ |
| 67 |
test_main_##NAME (void) \ |
| 68 |
{ \ |
| 69 |
thread_stop = false; \ |
| 70 |
thread_ready = false; \ |
| 71 |
var_##NAME = (INIT1); \ |
| 72 |
pthread_t thread_id; \ |
| 73 |
int pret = pthread_create (&thread_id, NULL, test_thread_##NAME, \ |
| 74 |
NULL); \ |
| 75 |
if (pret != 0) \ |
| 76 |
{ \ |
| 77 |
printf ("pthread_create failed: %d\n", pret); \ |
| 78 |
return 1; \ |
| 79 |
} \ |
| 80 |
int num_1_pass = 0, num_1_fail = 0, num_2_pass = 0, num_2_fail = 0; \ |
| 81 |
while (!thread_ready) \ |
| 82 |
sched_yield (); \ |
| 83 |
for (int i = 0; i < ITER_COUNT; i++) \ |
| 84 |
{ \ |
| 85 |
feclearexcept (FE_ALL_EXCEPT); \ |
| 86 |
feraiseexcept (BEXC); \ |
| 87 |
LHSTYPE r = (PRE var_##NAME POST); \ |
| 88 |
int rexc = fetestexcept (TEST_ALL_EXCEPT); \ |
| 89 |
sched_yield (); \ |
| 90 |
if (VALTEST1 (r)) \ |
| 91 |
{ \ |
| 92 |
if (rexc == ((BEXC) | (EXC1))) \ |
| 93 |
num_1_pass++; \ |
| 94 |
else \ |
| 95 |
num_1_fail++; \ |
| 96 |
var_##NAME = (INIT2); \ |
| 97 |
} \ |
| 98 |
else \ |
| 99 |
{ \ |
| 100 |
if (rexc == ((BEXC) | (EXC2))) \ |
| 101 |
num_2_pass++; \ |
| 102 |
else \ |
| 103 |
num_2_fail++; \ |
| 104 |
var_##NAME = (INIT1); \ |
| 105 |
} \ |
| 106 |
} \ |
| 107 |
thread_stop = true; \ |
| 108 |
pthread_join (thread_id, NULL); \ |
| 109 |
printf (#NAME " (a) %d pass, %d fail; (b) %d pass, %d fail\n", \ |
| 110 |
num_1_pass, num_1_fail, num_2_pass, num_2_fail); \ |
| 111 |
return num_1_fail || num_2_fail; \ |
| 112 |
} |
| 113 |
|
| 114 |
TEST_FUNCS (float_add_invalid, float, , += __builtin_inff (), 0, |
| 115 |
0, __builtin_isinf, 0, |
| 116 |
-__builtin_inff (), FE_INVALID) |
| 117 |
TEST_FUNCS (float_add_invalid_prev, float, , += __builtin_inff (), |
| 118 |
FE_DIVBYZERO | FE_INEXACT | FE_OVERFLOW | FE_UNDERFLOW, |
| 119 |
0, __builtin_isinf, 0, |
| 120 |
-__builtin_inff (), FE_INVALID) |
| 121 |
TEST_FUNCS (float_add_overflow, float, , += FLT_MAX, 0, |
| 122 |
FLT_MAX, __builtin_isinf, FE_OVERFLOW | FE_INEXACT, |
| 123 |
0, 0) |
| 124 |
TEST_FUNCS (float_add_overflow_prev, float, , += FLT_MAX, FE_INVALID, |
| 125 |
FLT_MAX, __builtin_isinf, FE_OVERFLOW | FE_INEXACT, |
| 126 |
0, 0) |
| 127 |
TEST_FUNCS (float_add_overflow_double, float, , += (double) FLT_MAX, 0, |
| 128 |
FLT_MAX, __builtin_isinf, FE_OVERFLOW | FE_INEXACT, |
| 129 |
0, 0) |
| 130 |
TEST_FUNCS (float_add_overflow_long_double, float, , += (long double) FLT_MAX, 0, |
| 131 |
FLT_MAX, __builtin_isinf, FE_OVERFLOW | FE_INEXACT, |
| 132 |
0, 0) |
| 133 |
#define NOT_FLT_EPSILON_2(X) ((X) != FLT_EPSILON / 2) |
| 134 |
TEST_FUNCS (float_add_inexact, float, , += FLT_EPSILON / 2, 0, |
| 135 |
1.0f, NOT_FLT_EPSILON_2, FE_INEXACT, |
| 136 |
0, 0) |
| 137 |
#define NOT_0(X) ((X) != 0) |
| 138 |
TEST_FUNCS (float_add_inexact_int, float, , += 1, 0, |
| 139 |
FLT_EPSILON / 2, NOT_0, FE_INEXACT, |
| 140 |
-1, 0) |
| 141 |
TEST_FUNCS (float_preinc_inexact, float, ++, , 0, |
| 142 |
FLT_EPSILON / 2, NOT_0, FE_INEXACT, |
| 143 |
-1, 0) |
| 144 |
#define NOT_MINUS_1(X) ((X) != -1) |
| 145 |
TEST_FUNCS (float_postinc_inexact, float, , ++, 0, |
| 146 |
FLT_EPSILON / 2, NOT_MINUS_1, FE_INEXACT, |
| 147 |
-1, 0) |
| 148 |
#if FLT_EVAL_METHOD == 0 |
| 149 |
TEST_FUNCS (long_add_float_inexact, long, , += 2 / FLT_EPSILON, 0, |
| 150 |
1, NOT_0, FE_INEXACT, |
| 151 |
-2 / FLT_EPSILON, 0) |
| 152 |
#endif |
| 153 |
#define REAL_ISINF(X) (__builtin_isinf (__real__ (X))) |
| 154 |
TEST_FUNCS (complex_float_add_overflow, _Complex float, , += FLT_MAX, 0, |
| 155 |
FLT_MAX, REAL_ISINF, FE_OVERFLOW | FE_INEXACT, |
| 156 |
0, 0) |
| 157 |
TEST_FUNCS (float_sub_invalid, float, , -= __builtin_inff (), 0, |
| 158 |
0, __builtin_isinf, 0, |
| 159 |
__builtin_inff (), FE_INVALID) |
| 160 |
TEST_FUNCS (float_sub_overflow, float, , -= FLT_MAX, 0, |
| 161 |
-FLT_MAX, __builtin_isinf, FE_OVERFLOW | FE_INEXACT, |
| 162 |
0, 0) |
| 163 |
#define NOT_MINUS_FLT_EPSILON_2(X) ((X) != -FLT_EPSILON / 2) |
| 164 |
TEST_FUNCS (float_sub_inexact, float, , -= FLT_EPSILON / 2, 0, |
| 165 |
-1.0f, NOT_MINUS_FLT_EPSILON_2, FE_INEXACT, |
| 166 |
0, 0) |
| 167 |
#define NOT_0(X) ((X) != 0) |
| 168 |
TEST_FUNCS (float_sub_inexact_int, float, , -= 1, 0, |
| 169 |
-FLT_EPSILON / 2, NOT_0, FE_INEXACT, |
| 170 |
1, 0) |
| 171 |
TEST_FUNCS (float_predec_inexact, float, --, , 0, |
| 172 |
-FLT_EPSILON / 2, NOT_0, FE_INEXACT, |
| 173 |
1, 0) |
| 174 |
#define NOT_1(X) ((X) != 1) |
| 175 |
TEST_FUNCS (float_postdec_inexact, float, , --, 0, |
| 176 |
-FLT_EPSILON / 2, NOT_1, FE_INEXACT, |
| 177 |
1, 0) |
| 178 |
#if FLT_EVAL_METHOD == 0 |
| 179 |
TEST_FUNCS (long_sub_float_inexact, long, , -= 2 / FLT_EPSILON, 0, |
| 180 |
-1, NOT_0, FE_INEXACT, |
| 181 |
2 / FLT_EPSILON, 0) |
| 182 |
#endif |
| 183 |
TEST_FUNCS (complex_float_sub_overflow, _Complex float, , -= FLT_MAX, 0, |
| 184 |
-FLT_MAX, REAL_ISINF, FE_OVERFLOW | FE_INEXACT, |
| 185 |
0, 0) |
| 186 |
TEST_FUNCS (float_mul_invalid, float, , *= __builtin_inff (), 0, |
| 187 |
__builtin_inff (), __builtin_isinf, 0, |
| 188 |
0, FE_INVALID) |
| 189 |
TEST_FUNCS (float_mul_overflow, float, , *= FLT_MAX, 0, |
| 190 |
FLT_MAX, __builtin_isinf, FE_OVERFLOW | FE_INEXACT, |
| 191 |
0, 0) |
| 192 |
#define IS_0(X) ((X) == 0) |
| 193 |
TEST_FUNCS (float_mul_underflow, float, , *= FLT_MIN, 0, |
| 194 |
FLT_MIN, IS_0, FE_UNDERFLOW | FE_INEXACT, |
| 195 |
1, 0) |
| 196 |
TEST_FUNCS (float_mul_inexact, float, , *= 1 + FLT_EPSILON, 0, |
| 197 |
1 + FLT_EPSILON, NOT_0, FE_INEXACT, |
| 198 |
0, 0) |
| 199 |
TEST_FUNCS (float_mul_inexact_int, float, , *= 3, 0, |
| 200 |
1 + FLT_EPSILON, NOT_0, FE_INEXACT, |
| 201 |
0, 0) |
| 202 |
#if FLT_EVAL_METHOD == 0 |
| 203 |
TEST_FUNCS(long_mul_float_inexact, long, , *= 3.0f, 0, |
| 204 |
1 + 1 / FLT_EPSILON, NOT_0, FE_INEXACT, |
| 205 |
0, 0) |
| 206 |
#endif |
| 207 |
TEST_FUNCS (complex_float_mul_overflow, _Complex float, , *= FLT_MAX, 0, |
| 208 |
FLT_MAX, REAL_ISINF, FE_OVERFLOW | FE_INEXACT, |
| 209 |
0, 0) |
| 210 |
TEST_FUNCS (float_div_invalid_divbyzero, float, , /= 0.0f, 0, |
| 211 |
1, __builtin_isinf, FE_DIVBYZERO, |
| 212 |
0, FE_INVALID) |
| 213 |
TEST_FUNCS (float_div_overflow, float, , /= FLT_MIN, 0, |
| 214 |
FLT_MAX, __builtin_isinf, FE_OVERFLOW | FE_INEXACT, |
| 215 |
0, 0) |
| 216 |
TEST_FUNCS (float_div_underflow, float, , /= FLT_MAX, 0, |
| 217 |
FLT_MIN, IS_0, FE_UNDERFLOW | FE_INEXACT, |
| 218 |
FLT_MAX, 0) |
| 219 |
TEST_FUNCS (float_div_inexact, float, , /= 3.0f, 0, |
| 220 |
1, NOT_0, FE_INEXACT, |
| 221 |
0, 0) |
| 222 |
TEST_FUNCS (float_div_inexact_int, float, , /= 3, 0, |
| 223 |
1, NOT_0, FE_INEXACT, |
| 224 |
0, 0) |
| 225 |
TEST_FUNCS (int_div_float_inexact, int, , /= 3.0f, 0, |
| 226 |
4, NOT_0, FE_INEXACT, |
| 227 |
0, 0) |
| 228 |
TEST_FUNCS (complex_float_div_overflow, _Complex float, , /= FLT_MIN, 0, |
| 229 |
FLT_MAX, REAL_ISINF, FE_OVERFLOW | FE_INEXACT, |
| 230 |
0, 0) |
| 231 |
|
| 232 |
TEST_FUNCS (double_add_invalid, double, , += __builtin_inf (), 0, |
| 233 |
0, __builtin_isinf, 0, |
| 234 |
-__builtin_inf (), FE_INVALID) |
| 235 |
TEST_FUNCS (double_add_overflow, double, , += DBL_MAX, 0, |
| 236 |
DBL_MAX, __builtin_isinf, FE_OVERFLOW | FE_INEXACT, |
| 237 |
0, 0) |
| 238 |
TEST_FUNCS (double_add_overflow_long_double, double, , += (long double) DBL_MAX, 0, |
| 239 |
DBL_MAX, __builtin_isinf, FE_OVERFLOW | FE_INEXACT, |
| 240 |
0, 0) |
| 241 |
#define NOT_DBL_EPSILON_2(X) ((X) != DBL_EPSILON / 2) |
| 242 |
TEST_FUNCS (double_add_inexact, double, , += DBL_EPSILON / 2, 0, |
| 243 |
1.0, NOT_DBL_EPSILON_2, FE_INEXACT, |
| 244 |
0, 0) |
| 245 |
TEST_FUNCS (double_add_inexact_int, double, , += 1, 0, |
| 246 |
DBL_EPSILON / 2, NOT_0, FE_INEXACT, |
| 247 |
-1, 0) |
| 248 |
TEST_FUNCS (double_preinc_inexact, double, ++, , 0, |
| 249 |
DBL_EPSILON / 2, NOT_0, FE_INEXACT, |
| 250 |
-1, 0) |
| 251 |
TEST_FUNCS (double_postinc_inexact, double, , ++, 0, |
| 252 |
DBL_EPSILON / 2, NOT_MINUS_1, FE_INEXACT, |
| 253 |
-1, 0) |
| 254 |
#if FLT_EVAL_METHOD == 0 |
| 255 |
TEST_FUNCS (long_long_add_double_inexact, long long, , += 2 / DBL_EPSILON, 0, |
| 256 |
1, NOT_0, FE_INEXACT, |
| 257 |
-2 / DBL_EPSILON, 0) |
| 258 |
#endif |
| 259 |
TEST_FUNCS (complex_double_add_overflow, _Complex double, , += DBL_MAX, 0, |
| 260 |
DBL_MAX, REAL_ISINF, FE_OVERFLOW | FE_INEXACT, |
| 261 |
0, 0) |
| 262 |
TEST_FUNCS (double_sub_invalid, double, , -= __builtin_inf (), 0, |
| 263 |
0, __builtin_isinf, 0, |
| 264 |
__builtin_inf (), FE_INVALID) |
| 265 |
TEST_FUNCS (double_sub_overflow, double, , -= DBL_MAX, 0, |
| 266 |
-DBL_MAX, __builtin_isinf, FE_OVERFLOW | FE_INEXACT, |
| 267 |
0, 0) |
| 268 |
#define NOT_MINUS_DBL_EPSILON_2(X) ((X) != -DBL_EPSILON / 2) |
| 269 |
TEST_FUNCS (double_sub_inexact, double, , -= DBL_EPSILON / 2, 0, |
| 270 |
-1.0, NOT_MINUS_DBL_EPSILON_2, FE_INEXACT, |
| 271 |
0, 0) |
| 272 |
TEST_FUNCS (double_sub_inexact_int, double, , -= 1, 0, |
| 273 |
-DBL_EPSILON / 2, NOT_0, FE_INEXACT, |
| 274 |
1, 0) |
| 275 |
TEST_FUNCS (double_predec_inexact, double, --, , 0, |
| 276 |
-DBL_EPSILON / 2, NOT_0, FE_INEXACT, |
| 277 |
1, 0) |
| 278 |
TEST_FUNCS (double_postdec_inexact, double, , --, 0, |
| 279 |
-DBL_EPSILON / 2, NOT_1, FE_INEXACT, |
| 280 |
1, 0) |
| 281 |
#if FLT_EVAL_METHOD == 0 |
| 282 |
TEST_FUNCS (long_long_sub_double_inexact, long long, , -= 2 / DBL_EPSILON, 0, |
| 283 |
-1, NOT_0, FE_INEXACT, |
| 284 |
2 / DBL_EPSILON, 0) |
| 285 |
#endif |
| 286 |
TEST_FUNCS (complex_double_sub_overflow, _Complex double, , -= DBL_MAX, 0, |
| 287 |
-DBL_MAX, REAL_ISINF, FE_OVERFLOW | FE_INEXACT, |
| 288 |
0, 0) |
| 289 |
TEST_FUNCS (double_mul_invalid, double, , *= __builtin_inf (), 0, |
| 290 |
__builtin_inf (), __builtin_isinf, 0, |
| 291 |
0, FE_INVALID) |
| 292 |
TEST_FUNCS (double_mul_overflow, double, , *= DBL_MAX, 0, |
| 293 |
DBL_MAX, __builtin_isinf, FE_OVERFLOW | FE_INEXACT, |
| 294 |
0, 0) |
| 295 |
TEST_FUNCS (double_mul_overflow_float, double, , *= FLT_MAX, 0, |
| 296 |
DBL_MAX, __builtin_isinf, FE_OVERFLOW | FE_INEXACT, |
| 297 |
0, 0) |
| 298 |
TEST_FUNCS (double_mul_underflow, double, , *= DBL_MIN, 0, |
| 299 |
DBL_MIN, IS_0, FE_UNDERFLOW | FE_INEXACT, |
| 300 |
1, 0) |
| 301 |
TEST_FUNCS (double_mul_inexact, double, , *= 1 + DBL_EPSILON, 0, |
| 302 |
1 + DBL_EPSILON, NOT_0, FE_INEXACT, |
| 303 |
0, 0) |
| 304 |
TEST_FUNCS (double_mul_inexact_int, double, , *= 3, 0, |
| 305 |
1 + DBL_EPSILON, NOT_0, FE_INEXACT, |
| 306 |
0, 0) |
| 307 |
#if FLT_EVAL_METHOD == 0 |
| 308 |
TEST_FUNCS(long_long_mul_double_inexact, long long, , *= 3.0, 0, |
| 309 |
1 + 1 / DBL_EPSILON, NOT_0, FE_INEXACT, |
| 310 |
0, 0) |
| 311 |
#endif |
| 312 |
TEST_FUNCS (complex_double_mul_overflow, _Complex double, , *= DBL_MAX, 0, |
| 313 |
DBL_MAX, REAL_ISINF, FE_OVERFLOW | FE_INEXACT, |
| 314 |
0, 0) |
| 315 |
TEST_FUNCS (double_div_invalid_divbyzero, double, , /= 0.0, 0, |
| 316 |
1, __builtin_isinf, FE_DIVBYZERO, |
| 317 |
0, FE_INVALID) |
| 318 |
TEST_FUNCS (double_div_overflow, double, , /= DBL_MIN, 0, |
| 319 |
DBL_MAX, __builtin_isinf, FE_OVERFLOW | FE_INEXACT, |
| 320 |
0, 0) |
| 321 |
TEST_FUNCS (double_div_underflow, double, , /= DBL_MAX, 0, |
| 322 |
DBL_MIN, IS_0, FE_UNDERFLOW | FE_INEXACT, |
| 323 |
DBL_MAX, 0) |
| 324 |
TEST_FUNCS (double_div_inexact, double, , /= 3.0, 0, |
| 325 |
1, NOT_0, FE_INEXACT, |
| 326 |
0, 0) |
| 327 |
TEST_FUNCS (double_div_inexact_int, double, , /= 3, 0, |
| 328 |
1, NOT_0, FE_INEXACT, |
| 329 |
0, 0) |
| 330 |
TEST_FUNCS (int_div_double_inexact, int, , /= 3.0, 0, |
| 331 |
4, NOT_0, FE_INEXACT, |
| 332 |
0, 0) |
| 333 |
TEST_FUNCS (complex_double_div_overflow, _Complex double, , /= DBL_MIN, 0, |
| 334 |
DBL_MAX, REAL_ISINF, FE_OVERFLOW | FE_INEXACT, |
| 335 |
0, 0) |
| 336 |
|
| 337 |
TEST_FUNCS (long_double_add_invalid, long double, , += __builtin_infl (), 0, |
| 338 |
0, __builtin_isinf, 0, |
| 339 |
-__builtin_infl (), FE_INVALID) |
| 340 |
#if LDBL_MANT_DIG != 106 |
| 341 |
TEST_FUNCS (long_double_add_overflow, long double, , += LDBL_MAX, 0, |
| 342 |
LDBL_MAX, __builtin_isinf, FE_OVERFLOW | FE_INEXACT, |
| 343 |
0, 0) |
| 344 |
#define NOT_LDBL_EPSILON_2(X) ((X) != LDBL_EPSILON / 2) |
| 345 |
TEST_FUNCS (long_double_add_inexact, long double, , += LDBL_EPSILON / 2, 0, |
| 346 |
1.0L, NOT_LDBL_EPSILON_2, FE_INEXACT, |
| 347 |
0, 0) |
| 348 |
TEST_FUNCS (long_double_add_inexact_int, long double, , += 1, 0, |
| 349 |
LDBL_EPSILON / 2, NOT_0, FE_INEXACT, |
| 350 |
-1, 0) |
| 351 |
TEST_FUNCS (long_double_preinc_inexact, long double, ++, , 0, |
| 352 |
LDBL_EPSILON / 2, NOT_0, FE_INEXACT, |
| 353 |
-1, 0) |
| 354 |
TEST_FUNCS (long_double_postinc_inexact, long double, , ++, 0, |
| 355 |
LDBL_EPSILON / 2, NOT_MINUS_1, FE_INEXACT, |
| 356 |
-1, 0) |
| 357 |
TEST_FUNCS (complex_long_double_add_overflow, _Complex long double, , += LDBL_MAX, 0, |
| 358 |
LDBL_MAX, REAL_ISINF, FE_OVERFLOW | FE_INEXACT, |
| 359 |
0, 0) |
| 360 |
#endif |
| 361 |
TEST_FUNCS (long_double_sub_invalid, long double, , -= __builtin_infl (), 0, |
| 362 |
0, __builtin_isinf, 0, |
| 363 |
__builtin_infl (), FE_INVALID) |
| 364 |
#if LDBL_MANT_DIG != 106 |
| 365 |
TEST_FUNCS (long_double_sub_overflow, long double, , -= LDBL_MAX, 0, |
| 366 |
-LDBL_MAX, __builtin_isinf, FE_OVERFLOW | FE_INEXACT, |
| 367 |
0, 0) |
| 368 |
#define NOT_MINUS_LDBL_EPSILON_2(X) ((X) != -LDBL_EPSILON / 2) |
| 369 |
TEST_FUNCS (long_double_sub_inexact, long double, , -= LDBL_EPSILON / 2, 0, |
| 370 |
-1.0L, NOT_MINUS_LDBL_EPSILON_2, FE_INEXACT, |
| 371 |
0, 0) |
| 372 |
TEST_FUNCS (long_double_sub_inexact_int, long double, , -= 1, 0, |
| 373 |
-LDBL_EPSILON / 2, NOT_0, FE_INEXACT, |
| 374 |
1, 0) |
| 375 |
TEST_FUNCS (long_double_predec_inexact, long double, --, , 0, |
| 376 |
-LDBL_EPSILON / 2, NOT_0, FE_INEXACT, |
| 377 |
1, 0) |
| 378 |
TEST_FUNCS (long_double_postdec_inexact, long double, , --, 0, |
| 379 |
-LDBL_EPSILON / 2, NOT_1, FE_INEXACT, |
| 380 |
1, 0) |
| 381 |
TEST_FUNCS (complex_long_double_sub_overflow, _Complex long double, , -= LDBL_MAX, 0, |
| 382 |
-LDBL_MAX, REAL_ISINF, FE_OVERFLOW | FE_INEXACT, |
| 383 |
0, 0) |
| 384 |
#endif |
| 385 |
TEST_FUNCS (long_double_mul_invalid, long double, , *= __builtin_infl (), 0, |
| 386 |
__builtin_infl (), __builtin_isinf, 0, |
| 387 |
0, FE_INVALID) |
| 388 |
TEST_FUNCS (long_double_mul_overflow, long double, , *= LDBL_MAX, 0, |
| 389 |
LDBL_MAX, __builtin_isinf, FE_OVERFLOW | FE_INEXACT, |
| 390 |
0, 0) |
| 391 |
TEST_FUNCS (long_double_mul_overflow_float, long double, , *= FLT_MAX, 0, |
| 392 |
LDBL_MAX, __builtin_isinf, FE_OVERFLOW | FE_INEXACT, |
| 393 |
0, 0) |
| 394 |
TEST_FUNCS (long_double_mul_overflow_double, long double, , *= DBL_MAX, 0, |
| 395 |
LDBL_MAX, __builtin_isinf, FE_OVERFLOW | FE_INEXACT, |
| 396 |
0, 0) |
| 397 |
TEST_FUNCS (long_double_mul_underflow, long double, , *= LDBL_MIN, 0, |
| 398 |
LDBL_MIN, IS_0, FE_UNDERFLOW | FE_INEXACT, |
| 399 |
1, 0) |
| 400 |
#if LDBL_MANT_DIG != 106 |
| 401 |
TEST_FUNCS (long_double_mul_inexact, long double, , *= 1 + LDBL_EPSILON, 0, |
| 402 |
1 + LDBL_EPSILON, NOT_0, FE_INEXACT, |
| 403 |
0, 0) |
| 404 |
TEST_FUNCS (long_double_mul_inexact_int, long double, , *= 3, 0, |
| 405 |
1 + LDBL_EPSILON, NOT_0, FE_INEXACT, |
| 406 |
0, 0) |
| 407 |
#endif |
| 408 |
TEST_FUNCS (complex_long_double_mul_overflow, _Complex long double, , *= LDBL_MAX, 0, |
| 409 |
LDBL_MAX, REAL_ISINF, FE_OVERFLOW | FE_INEXACT, |
| 410 |
0, 0) |
| 411 |
TEST_FUNCS (long_double_div_invalid_divbyzero, long double, , /= 0.0L, 0, |
| 412 |
1, __builtin_isinf, FE_DIVBYZERO, |
| 413 |
0, FE_INVALID) |
| 414 |
TEST_FUNCS (long_double_div_overflow, long double, , /= LDBL_MIN, 0, |
| 415 |
LDBL_MAX, __builtin_isinf, FE_OVERFLOW | FE_INEXACT, |
| 416 |
0, 0) |
| 417 |
TEST_FUNCS (long_double_div_underflow, long double, , /= LDBL_MAX, 0, |
| 418 |
LDBL_MIN, IS_0, FE_UNDERFLOW | FE_INEXACT, |
| 419 |
LDBL_MAX, 0) |
| 420 |
TEST_FUNCS (long_double_div_inexact, long double, , /= 3.0L, 0, |
| 421 |
1, NOT_0, FE_INEXACT, |
| 422 |
0, 0) |
| 423 |
TEST_FUNCS (long_double_div_inexact_int, long double, , /= 3, 0, |
| 424 |
1, NOT_0, FE_INEXACT, |
| 425 |
0, 0) |
| 426 |
TEST_FUNCS (int_div_long_double_inexact, int, , /= 3.0L, 0, |
| 427 |
4, NOT_0, FE_INEXACT, |
| 428 |
0, 0) |
| 429 |
TEST_FUNCS (complex_long_double_div_overflow, _Complex long double, , /= LDBL_MIN, 0, |
| 430 |
LDBL_MAX, REAL_ISINF, FE_OVERFLOW | FE_INEXACT, |
| 431 |
0, 0) |
| 432 |
|
| 433 |
int |
| 434 |
main (void) |
| 435 |
{ |
| 436 |
int ret = 0; |
| 437 |
ret |= test_main_float_add_invalid (); |
| 438 |
ret |= test_main_float_add_invalid_prev (); |
| 439 |
ret |= test_main_float_add_overflow (); |
| 440 |
ret |= test_main_float_add_overflow_prev (); |
| 441 |
ret |= test_main_float_add_overflow_double (); |
| 442 |
ret |= test_main_float_add_overflow_long_double (); |
| 443 |
ret |= test_main_float_add_inexact (); |
| 444 |
ret |= test_main_float_add_inexact_int (); |
| 445 |
ret |= test_main_float_preinc_inexact (); |
| 446 |
ret |= test_main_float_postinc_inexact (); |
| 447 |
#if FLT_EVAL_METHOD == 0 |
| 448 |
ret |= test_main_long_add_float_inexact (); |
| 449 |
#endif |
| 450 |
ret |= test_main_complex_float_add_overflow (); |
| 451 |
ret |= test_main_float_sub_invalid (); |
| 452 |
ret |= test_main_float_sub_overflow (); |
| 453 |
ret |= test_main_float_sub_inexact (); |
| 454 |
ret |= test_main_float_sub_inexact_int (); |
| 455 |
ret |= test_main_float_predec_inexact (); |
| 456 |
ret |= test_main_float_postdec_inexact (); |
| 457 |
#if FLT_EVAL_METHOD == 0 |
| 458 |
ret |= test_main_long_sub_float_inexact (); |
| 459 |
#endif |
| 460 |
ret |= test_main_complex_float_sub_overflow (); |
| 461 |
ret |= test_main_float_mul_invalid (); |
| 462 |
ret |= test_main_float_mul_overflow (); |
| 463 |
ret |= test_main_float_mul_underflow (); |
| 464 |
ret |= test_main_float_mul_inexact (); |
| 465 |
ret |= test_main_float_mul_inexact_int (); |
| 466 |
#if FLT_EVAL_METHOD == 0 |
| 467 |
ret |= test_main_long_mul_float_inexact (); |
| 468 |
#endif |
| 469 |
ret |= test_main_complex_float_mul_overflow (); |
| 470 |
ret |= test_main_float_div_invalid_divbyzero (); |
| 471 |
ret |= test_main_float_div_overflow (); |
| 472 |
ret |= test_main_float_div_underflow (); |
| 473 |
ret |= test_main_float_div_inexact (); |
| 474 |
ret |= test_main_float_div_inexact_int (); |
| 475 |
ret |= test_main_int_div_float_inexact (); |
| 476 |
ret |= test_main_complex_float_div_overflow (); |
| 477 |
ret |= test_main_double_add_invalid (); |
| 478 |
ret |= test_main_double_add_overflow (); |
| 479 |
ret |= test_main_double_add_overflow_long_double (); |
| 480 |
ret |= test_main_double_add_inexact (); |
| 481 |
ret |= test_main_double_add_inexact_int (); |
| 482 |
ret |= test_main_double_preinc_inexact (); |
| 483 |
ret |= test_main_double_postinc_inexact (); |
| 484 |
#if FLT_EVAL_METHOD == 0 |
| 485 |
ret |= test_main_long_long_add_double_inexact (); |
| 486 |
#endif |
| 487 |
ret |= test_main_complex_double_add_overflow (); |
| 488 |
ret |= test_main_double_sub_invalid (); |
| 489 |
ret |= test_main_double_sub_overflow (); |
| 490 |
ret |= test_main_double_sub_inexact (); |
| 491 |
ret |= test_main_double_sub_inexact_int (); |
| 492 |
ret |= test_main_double_predec_inexact (); |
| 493 |
ret |= test_main_double_postdec_inexact (); |
| 494 |
#if FLT_EVAL_METHOD == 0 |
| 495 |
ret |= test_main_long_long_sub_double_inexact (); |
| 496 |
#endif |
| 497 |
ret |= test_main_complex_double_sub_overflow (); |
| 498 |
ret |= test_main_double_mul_invalid (); |
| 499 |
ret |= test_main_double_mul_overflow (); |
| 500 |
ret |= test_main_double_mul_overflow_float (); |
| 501 |
ret |= test_main_double_mul_underflow (); |
| 502 |
ret |= test_main_double_mul_inexact (); |
| 503 |
ret |= test_main_double_mul_inexact_int (); |
| 504 |
#if FLT_EVAL_METHOD == 0 |
| 505 |
ret |= test_main_long_long_mul_double_inexact (); |
| 506 |
#endif |
| 507 |
ret |= test_main_complex_double_mul_overflow (); |
| 508 |
ret |= test_main_double_div_invalid_divbyzero (); |
| 509 |
ret |= test_main_double_div_overflow (); |
| 510 |
ret |= test_main_double_div_underflow (); |
| 511 |
ret |= test_main_double_div_inexact (); |
| 512 |
ret |= test_main_double_div_inexact_int (); |
| 513 |
ret |= test_main_int_div_double_inexact (); |
| 514 |
ret |= test_main_complex_double_div_overflow (); |
| 515 |
ret |= test_main_long_double_add_invalid (); |
| 516 |
#if LDBL_MANT_DIG != 106 |
| 517 |
ret |= test_main_long_double_add_overflow (); |
| 518 |
ret |= test_main_long_double_add_inexact (); |
| 519 |
ret |= test_main_long_double_add_inexact_int (); |
| 520 |
ret |= test_main_long_double_preinc_inexact (); |
| 521 |
ret |= test_main_long_double_postinc_inexact (); |
| 522 |
ret |= test_main_complex_long_double_add_overflow (); |
| 523 |
#endif |
| 524 |
ret |= test_main_long_double_sub_invalid (); |
| 525 |
#if LDBL_MANT_DIG != 106 |
| 526 |
ret |= test_main_long_double_sub_overflow (); |
| 527 |
ret |= test_main_long_double_sub_inexact (); |
| 528 |
ret |= test_main_long_double_sub_inexact_int (); |
| 529 |
ret |= test_main_long_double_predec_inexact (); |
| 530 |
ret |= test_main_long_double_postdec_inexact (); |
| 531 |
ret |= test_main_complex_long_double_sub_overflow (); |
| 532 |
#endif |
| 533 |
ret |= test_main_long_double_mul_invalid (); |
| 534 |
ret |= test_main_long_double_mul_overflow (); |
| 535 |
ret |= test_main_long_double_mul_overflow_float (); |
| 536 |
ret |= test_main_long_double_mul_overflow_double (); |
| 537 |
ret |= test_main_long_double_mul_underflow (); |
| 538 |
#if LDBL_MANT_DIG != 106 |
| 539 |
ret |= test_main_long_double_mul_inexact (); |
| 540 |
ret |= test_main_long_double_mul_inexact_int (); |
| 541 |
#endif |
| 542 |
ret |= test_main_complex_long_double_mul_overflow (); |
| 543 |
ret |= test_main_long_double_div_invalid_divbyzero (); |
| 544 |
ret |= test_main_long_double_div_overflow (); |
| 545 |
ret |= test_main_long_double_div_underflow (); |
| 546 |
ret |= test_main_long_double_div_inexact (); |
| 547 |
ret |= test_main_long_double_div_inexact_int (); |
| 548 |
ret |= test_main_int_div_long_double_inexact (); |
| 549 |
ret |= test_main_complex_long_double_div_overflow (); |
| 550 |
if (ret != 0) |
| 551 |
abort (); |
| 552 |
else |
| 553 |
exit (0); |
| 554 |
} |