xref: /llvm-project/lldb/test/API/functionalities/longjmp/main.c (revision fdea9a4ec9b0d9585b8fe8a612686d9f44f40ddc)
1 #include <setjmp.h>
2 #include <stdio.h>
3 #include <time.h>
4 
5 jmp_buf j;
6 
do_jump(void)7 void do_jump(void)
8 {
9     // We can't let the compiler know this will always happen or it might make
10     // optimizations that break our test.
11     if (!clock())
12         longjmp(j, 1); // non-local goto
13 }
14 
main(void)15 int main (void)
16 {
17     if (setjmp(j) == 0)
18         do_jump();
19     else
20         return 0; // destination of longjmp
21 
22     return 1;
23 }
24