xref: /haiku/src/tests/system/libroot/posix/sigsetjmp_test.c (revision 21258e2674226d6aa732321b6f8494841895af5f)
1 /*
2  * Copyright 2005-2006, Axel Dörfler, axeld@pinc-software.de.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include <setjmp.h>
8 #include <stdio.h>
9 
10 
11 static void
12 jump_to_top_level(jmp_buf *state, int value)
13 {
14 	siglongjmp(*state, value);
15 }
16 
17 
18 int
19 main(int argc, char **argv)
20 {
21 	jmp_buf state;
22 	int value;
23 
24 	if ((value = sigsetjmp(state, 1)) != 0) {
25 		printf("failed with: %d!\n", value);
26 	} else {
27 		printf("here I am: %d\n", value);
28 		jump_to_top_level(&state, 42);
29 		printf("you won't see me!\n");
30 	}
31 
32 	puts("done.");
33 	return 0;
34 }
35