Introduce old redir program
[lcapit-junk-code.git] / books / apue / longjump.c
blob737a91da1203f7595b1f1d0b5e73f0714be4504a
1 /*
2 * setjmp() and longjmp() example usage
3 */
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <setjmp.h>
9 static jmp_buf jmpbuffer;
11 static void f2(void)
13 longjmp(jmpbuffer, 1);
16 static void f1(int i, int j, int k)
18 printf("in f1(): count = %d, val = %d, sum = %d\n", i, j, k);
19 f2();
22 int main(void)
24 int count;
25 register int val;
26 volatile int sum;
28 count = 2; val = 3; sum = 4;
29 if (setjmp(jmpbuffer) != 0) {
30 printf("after longjmp: count = %d, val = %d, sum = %d\n",
31 count, val, sum);
32 exit(0);
35 count = 97; val = 98; sum = 99;
36 f1(count, val, sum); /* never returns */
37 return 0;