-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjumpfrombook.c
More file actions
45 lines (36 loc) · 1004 Bytes
/
jumpfrombook.c
File metadata and controls
45 lines (36 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include<setjmp.h>
#include<stdio.h>
#include<stdlib.h>
void f1(int, int, int, int);
void f2(void);
jmp_buf jmpbuffer;
static int globval;
int main(void) {
int autoval;
register int regival;
volatile int volaval;
static int statval;
globval = 1;
autoval = 2;
regival = 3;
volaval = 4;
statval = 5;
if (setjmp(jmpbuffer) != 0)
{
printf("after longjmp:\n");
printf("globval = %d, autoval = %d, regival = %d," " volaval = %d, statval = %d\n", globval, autoval, regival, volaval, statval);
exit(0);
}
globval = 95; autoval = 96; regival = 97; volaval = 98; statval = 99;
f1(autoval, regival, volaval, statval);
exit(0); }
void f1(int i, int j, int k, int l)
{
printf("in f1():\n");
printf("globval = %d, autoval = %d, regival = %d," " volaval = %d, statval = %d\n", globval, i, j, k, l);
f2();
}
void f2(void)
{
longjmp(jmpbuffer, 1);
}