annotate global_longjump.c @ 3:e6aa3b678e4a

remove ret from global_longjump.c
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Tue, 12 Nov 2013 15:22:04 +0900
parents dee9711aeb06
children d75a89b10176
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include <stdio.h>
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #include <setjmp.h>
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #include <stdlib.h>
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 int retval;
3
e6aa3b678e4a remove ret from global_longjump.c
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
6 __code code1(int n,__code(*__return)(int,void *),void *__enviroment){
e6aa3b678e4a remove ret from global_longjump.c
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
7 printf("code1 : code1 entry\n");
e6aa3b678e4a remove ret from global_longjump.c
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
8 goto __return(n,__enviroment);
0
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
3
e6aa3b678e4a remove ret from global_longjump.c
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
11 __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
12 printf("return1 : __return entry\n");
0
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 retval = n;
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 longjmp(*(jmp_buf*)env,1);
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
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 int main1 (){
3
e6aa3b678e4a remove ret from global_longjump.c
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
18 __code (*__return)();
0
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 void *__enviroment;
3
e6aa3b678e4a remove ret from global_longjump.c
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
20 printf("main1 : main1 entry\n");
0
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 __enviroment = (void*)malloc(sizeof(jmp_buf));
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 if (setjmp(__enviroment)){
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 free(__enviroment);
3
e6aa3b678e4a remove ret from global_longjump.c
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
24 printf("main1 : main1 return\n");
0
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 return retval;
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 }
3
e6aa3b678e4a remove ret from global_longjump.c
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
27 __return = return1;
0
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 goto code1(30,__return,__enviroment);
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 return 0;
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 }
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 int main (){
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 int n;
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 n = main1();
3
e6aa3b678e4a remove ret from global_longjump.c
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
35 printf("main : return = %d\n",n);
0
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 return 1;
dee9711aeb06 the first commit
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 }