Mercurial > hg > Members > kaito > longjump
changeset 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 | 76cd6ae48a1b |
children | d75a89b10176 |
files | global_longjump.c pointer_longjump.c |
diffstat | 2 files changed, 12 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/global_longjump.c Tue Nov 12 13:10:39 2013 +0900 +++ b/global_longjump.c Tue Nov 12 15:22:04 2013 +0900 @@ -3,30 +3,28 @@ #include <stdlib.h> int retval; -__code code1(int n,void *__return,void *__enviroment){ - void(*ret)(int,void *); - printf("code1\n"); - ret = (void(*)(int,void *))__return; - ret(n,__enviroment); +__code code1(int n,__code(*__return)(int,void *),void *__enviroment){ + printf("code1 : code1 entry\n"); + goto __return(n,__enviroment); } -void *return1 (int n,void* env){ - printf("return1\n"); +__code return1 (int n,void* env){ + printf("return1 : __return entry\n"); retval = n; longjmp(*(jmp_buf*)env,1); } int main1 (){ - void *__return; + __code (*__return)(); void *__enviroment; - printf("main1 entry\n"); + printf("main1 : main1 entry\n"); __enviroment = (void*)malloc(sizeof(jmp_buf)); if (setjmp(__enviroment)){ free(__enviroment); - printf("main1 return\n"); + printf("main1 : main1 return\n"); return retval; } - __return = (void*)return1; + __return = return1; goto code1(30,__return,__enviroment); return 0; } @@ -34,7 +32,6 @@ int main (){ int n; n = main1(); - printf("returned\n"); - printf("return = %d\n",n); + printf("main : return = %d\n",n); return 1; }
--- a/pointer_longjump.c Tue Nov 12 13:10:39 2013 +0900 +++ b/pointer_longjump.c Tue Nov 12 15:22:04 2013 +0900 @@ -7,6 +7,7 @@ printf("code1\n"); ret = (void(*)(int,void *,int *))__return; ret(n,__enviroment,__ret_p); + //((void(*)(int,void *,int *))__return)(n,__enviroment,__ret_p); } void *return1 (int n,void* env,int* __ret_p){ @@ -18,7 +19,7 @@ int main1 (){ void *__return; void *__enviroment; - int *__ret_p; + int *__ret_p; printf("main1 entry\n"); __enviroment = (void*)malloc(sizeof(jmp_buf)); __ret_p = (int*)malloc(sizeof(int));