Debian Codegraph @

gcc/testsuite/gcc.target/powerpc/builtin-fegetround.c

raw
1 /* { dg-do run } */
2 /* { dg-require-effective-target fenv_exceptions } */
3 /* { dg-options "-lm -fno-builtin" } */
4
5 /* This testcase ensures that the builtins is correctly expanded and match the
6 expected result from the standard function.
7 "-fno-builtin" option is used to enable calls to libc implementation of the
8 gcc builtins tested when not using __builtin_ prefix. */
9
10 #include <fenv.h>
11
12 #ifdef DEBUG
13 #include <stdio.h>
14 #define FAIL(v, e) printf("ERROR, __builtin_fegetround() returned %d," \
15 " not the expecected value %d\n", v, e);
16 #else
17 void abort (void);
18 #define FAIL(v, e) abort()
19 #endif
20
21 int
22 main ()
23 {
24 int i, rounding, expected;
25 const int rm[] = {FE_TONEAREST, FE_TOWARDZERO, FE_UPWARD, FE_DOWNWARD};
26 for (i = 0; i < sizeof rm / sizeof rm[0]; i++)
27 {
28 fesetround(rm[i]);
29 rounding = __builtin_fegetround();
30 expected = fegetround();
31 if (rounding != expected)
32 FAIL(rounding, expected);
33 }
34
35 return 0;
36 }