* sim/cris: New directory with C and assembly tests for the CRIS
[binutils-gdb.git] / sim / testsuite / sim / cris / c / sjlj.c
1 /* Check that setjmp and longjmp stand a chance to work; that the used machine
2 primitives work in the simulator. */
3
4 #include <stdio.h>
5 #include <setjmp.h>
6 #include <stdlib.h>
7
8 extern void f (void);
9
10 int ok = 0;
11 jmp_buf b;
12
13 int
14 main ()
15 {
16 int ret = setjmp (b);
17
18 if (ret == 42)
19 ok = 100;
20 else if (ret == 0)
21 f ();
22
23 if (ok == 100)
24 printf ("pass\n");
25 else
26 printf ("fail\n");
27 exit (0);
28 }
29
30 void
31 f (void)
32 {
33 longjmp (b, 42);
34 }