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 main()14main () 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 f(void)31f (void) 32 { 33 longjmp (b, 42); 34 } 35