Mercurial > hg > CbC > old > device
view test/throw.c @ 580:31b736fb4516 environment-switch
*** empty log message ***
author | kono |
---|---|
date | Sun, 15 Jan 2006 22:32:17 +0900 |
parents | |
children | ad9ef203f95b |
line wrap: on
line source
extern int printf(const char *,...); code (*ret)(); void *env; #define ENVSIZE (1<<14) typedef struct interface1 { int a; int b; char c[100]; int last; } interface1; code throw2(interface1 arg,int i,int j) { goto ret(3),env; } code throw1(interface1 arg,int i,int j) { printf("%d %d %d %d\n",arg.last,arg.a,arg.c[99],j); arg.last=97; goto throw2(arg,i,77); } code throw(interface1 arg,int i,int j) { char *space = (char *)malloc(ENVSIZE)+ENVSIZE/2; printf("%d %d %d %d\n",arg.last,arg.a,arg.c[99],j); arg.last=98; goto throw1(arg,i,77),space; } void setup(interface1 *arg) { for(int i=0;i<100;i++) arg->c[i]=i; } int main0() { interface1 arg; arg.a = 3; arg.b = 55; setup(&arg); arg.c[99] = 66; arg.last = 96; printf("main0\n"); ret = return; env = environment; goto throw(arg,1,0); } int main1() { int dummy; int dummy1; interface1 arg; char *space = (char *)malloc(ENVSIZE)+ENVSIZE/2; arg.a = 3; arg.b = 55; setup(&arg); arg.c[99] = 66; arg.last=99; printf("main1\n"); ret = return; env = environment; goto throw1(arg,1,0),space; } int main2() { int dummy; interface1 arg; char *space = (char *)malloc(ENVSIZE)+ENVSIZE/2; arg.a = 3; arg.b = 55; setup(&arg); arg.c[99] = 66; arg.last=99; printf("main2\n"); ret = return; env = environment; goto throw1(arg,1,0); } int main() { main0(); main1(); main2(); return 0; } /* end */