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