powerpc: Add hwcap2 bits for POWER9.
[glibc.git] / stdlib / bug-getcontext.c
blob133ee91eff8e27846d32df1a95624eedbf94eaeb
1 /* BZ 12420 */
3 #include <errno.h>
4 #include <fenv.h>
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <ucontext.h>
9 static int
10 do_test (void)
12 if (FE_ALL_EXCEPT == 0)
14 printf("Skipping test; no support for FP exceptions.\n");
15 return 0;
18 int except_mask = 0;
19 #ifdef FE_DIVBYZERO
20 except_mask |= FE_DIVBYZERO;
21 #endif
22 #ifdef FE_INVALID
23 except_mask |= FE_INVALID;
24 #endif
25 #ifdef FE_OVERFLOW
26 except_mask |= FE_OVERFLOW;
27 #endif
28 #ifdef FE_UNDERFLOW
29 except_mask |= FE_UNDERFLOW;
30 #endif
31 int status = feenableexcept (except_mask);
33 except_mask = fegetexcept ();
34 if (except_mask == -1)
36 printf("\nBefore getcontext(): fegetexcept returned: %d\n",
37 except_mask);
38 return 1;
41 ucontext_t ctx;
42 status = getcontext(&ctx);
43 if (status)
45 printf("\ngetcontext failed, errno: %d.\n", errno);
46 return 1;
49 printf ("\nDone with getcontext()!\n");
50 fflush (NULL);
52 int mask = fegetexcept ();
53 if (mask != except_mask)
55 printf("\nAfter getcontext(): fegetexcept returned: %d, expected: %d.\n",
56 mask, except_mask);
57 return 1;
60 printf("\nAt end fegetexcept() returned %d, expected: %d.\n",
61 mask, except_mask);
63 return 0;
66 #define TEST_FUNCTION do_test ()
67 #include "../test-skeleton.c"