c++: normalizing ttp constraints [PR115656]
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / builtin-fegetround.c
blob56ffc50e3ee3accf56b0a28e8d1bd02a555e4cbc
1 /* { dg-do run } */
2 /* { dg-require-effective-target fenv_exceptions } */
3 /* { dg-options "-lm -fno-builtin" } */
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. */
10 #include <fenv.h>
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
21 int
22 main ()
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++)
28 fesetround(rm[i]);
29 rounding = __builtin_fegetround();
30 expected = fegetround();
31 if (rounding != expected)
32 FAIL(rounding, expected);
35 return 0;