Sort sysdeps/powerpc/fpu/libm-test-ulps
[glibc.git] / stdlib / bug-getcontext.c
blob7db49c849912429da8d69e0f98fcab43127957d2
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
13 printf("Skipping test; no support for FP exceptions.\n");
14 #else
15 int except_mask = FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW;
16 int status = feenableexcept (except_mask);
18 except_mask = fegetexcept ();
19 if (except_mask == -1)
21 printf("\nBefore getcontext(): fegetexcept returned: %d\n",
22 except_mask);
23 return 1;
26 ucontext_t ctx;
27 status = getcontext(&ctx);
28 if (status)
30 printf("\ngetcontext failed, errno: %d.\n", errno);
31 return 1;
34 printf ("\nDone with getcontext()!\n");
35 fflush (NULL);
37 int mask = fegetexcept ();
38 if (mask != except_mask)
40 printf("\nAfter getcontext(): fegetexcept returned: %d, expected: %d.\n",
41 mask, except_mask);
42 return 1;
45 printf("\nAt end fegetexcept() returned %d, expected: %d.\n",
46 mask, except_mask);
47 #endif
48 return 0;
51 #define TEST_FUNCTION do_test ()
52 #include "../test-skeleton.c"