annotate global_longjump.c @ 16:6ec369858a50 default tip

aua
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Fri, 24 Jan 2014 00:10:05 +0900
parents 4e7858590985
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
4e7858590985 remove malloc , free and include<stdlib.h>
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
1 /*
4e7858590985 remove malloc , free and include<stdlib.h>
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
2 please use pointer version. that is spuerior to this.
4e7858590985 remove malloc , free and include<stdlib.h>
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
3 */
4e7858590985 remove malloc , free and include<stdlib.h>
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
4
4e7858590985 remove malloc , free and include<stdlib.h>
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
5
0
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 #include <stdio.h>
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 #include <setjmp.h>
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 #include <stdlib.h>
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 int retval;
4
d75a89b10176 write pointer_longjump.c
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
11
d75a89b10176 write pointer_longjump.c
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
12 __code code1(int n,__code(*__return)(int,void *),void *__environment){
3
e6aa3b678e4a remove ret from global_longjump.c
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
13 printf("code1 : code1 entry\n");
4
d75a89b10176 write pointer_longjump.c
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
14 goto __return(n,__environment);
0
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 }
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
3
e6aa3b678e4a remove ret from global_longjump.c
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
17 __code return1 (int n,void* env){
e6aa3b678e4a remove ret from global_longjump.c
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
18 printf("return1 : __return entry\n");
0
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 retval = n;
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 longjmp(*(jmp_buf*)env,1);
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 }
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 int main1 (){
3
e6aa3b678e4a remove ret from global_longjump.c
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
24 __code (*__return)();
4
d75a89b10176 write pointer_longjump.c
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
25 void *__environment;
3
e6aa3b678e4a remove ret from global_longjump.c
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
26 printf("main1 : main1 entry\n");
4
d75a89b10176 write pointer_longjump.c
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
27 __environment = (void*)malloc(sizeof(jmp_buf));
d75a89b10176 write pointer_longjump.c
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
28 if (setjmp(__environment)){
d75a89b10176 write pointer_longjump.c
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
29 free(__environment);
3
e6aa3b678e4a remove ret from global_longjump.c
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
30 printf("main1 : main1 return\n");
0
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 return retval;
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 }
3
e6aa3b678e4a remove ret from global_longjump.c
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
33 __return = return1;
4
d75a89b10176 write pointer_longjump.c
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
34 goto code1(30,__return,__environment);
0
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 return 0;
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 }
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 int main (){
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 int n;
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 n = main1();
3
e6aa3b678e4a remove ret from global_longjump.c
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
41 printf("main : return = %d\n",n);
0
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 return 1;
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 }