# HG changeset patch # User Kaito Tokumori # Date 1413972177 -32400 # Node ID 90e6146d24cd38cc3a3fc0c0a27bfc9f77d287a7 # Parent 175041088754fd1bb62a4b48f56b5727a1610848 fix stack1.c diff -r 175041088754 -r 90e6146d24cd Makefile --- a/Makefile Wed Oct 22 18:54:12 2014 +0900 +++ b/Makefile Wed Oct 22 19:02:57 2014 +0900 @@ -1,5 +1,5 @@ CC=/Users/e105711/prog/seminar/CbC/llvmInst/Debug+Asserts/bin/clang -TARGET=bug conv fact-a loto6 normal normal2 test01 test02 test04 test05 test_array test_call test_cs test_para test_para2 test_para4 test_return test_struct test_tailcall1 test_tree tmp1 tmp2 tmp4 test_csp1 test_func2code tmpa too-long-argument test1 +TARGET=bug conv fact-a loto6 normal normal2 test01 test02 test04 test05 test_array test_call test_cs test_para test_para2 test_para4 test_return test_struct test_tailcall1 test_tree tmp1 tmp2 tmp4 test_csp1 test_func2code tmpa too-long-argument test1 stack1 CFLAGS= -D"CLANG" .SUFFIXES: .c .o diff -r 175041088754 -r 90e6146d24cd stack1.c --- a/stack1.c Wed Oct 22 18:54:12 2014 +0900 +++ b/stack1.c Wed Oct 22 19:02:57 2014 +0900 @@ -3,22 +3,23 @@ */ #include +#include #define NULL 0 -extern void *malloc(int); typedef void *stack; void *stack0; /* size of void* == 1 */ struct cont_save { /* General Return Continuation */ - __code (*ret)(); + __code (*ret)(int, void*); }; __code g(int,void *); __code f_g0(int ,int ,void *); __code f_g1(int,void *); __code print(int i,int j,__code (*exit1)(),void*exit1env); +int main0( int ac, char *av[]); struct f_g0_save { /* Specialized Return Continuation */ __code (*ret)(); @@ -42,13 +43,13 @@ __code f(int i,void *sp) { int k,j; struct f_g0_save *c; - printf("#0042:f 0 sp: %x\n",sp-stack0); + printf("#0042:f 0 sp: %lx\n",sp-stack0); k = 3+i; - printf("#0046:f 1 sp: %x\n",sp-stack0); + printf("#0046:f 1 sp: %lx\n",sp-stack0); sp -= sizeof(struct f_g0_save); - printf("#0048:f 2 sp: %x\n",sp-stack0); + printf("#0048:f 2 sp: %lx\n",sp-stack0); c = sp; c->kk = k; c->ii = i; @@ -60,32 +61,32 @@ struct f0_save { /* Specialized Return Continuation */ - __code (*ret)(); - __code (*exit1)(); + __code (*ret)(int, void*); + __code (*exit1)(int, void*); void *exit1env; int jj; }; __code f1(int i,void *sp) ; -__code f0(int i,int j,__code(*exit2)(), void *exit2env,void *sp) +__code f0(int i,int j,__code(*exit2)(int, void*), void *exit2env,void *sp) { struct f0_save *c; - printf("#0070:f0 1 sp: %x\n",sp-stack0); + printf("#0070:f0 1 sp: %lx\n",sp-stack0); sp -= sizeof(struct f0_save); - printf("#0072:f0 2 sp: %x\n",sp-stack0); + printf("#0072:f0 2 sp: %lx\n",sp-stack0); c = sp; c->jj = j; c->exit1 = exit2; c->exit1env = exit2env; c->ret = f1; - printf("#0078:f0 3 sp: %x\n",sp-stack0); + printf("#0078:f0 3 sp: %lx\n",sp-stack0); goto f(i,sp); } __code f1(int i,void *sp) { int j; int *exit2env; - __code (*exit2)(); + __code (*exit2)(int, void*); struct f0_save *c; c = sp; @@ -106,21 +107,19 @@ int i,j; int *sp; - // i = atoi(av[1]); i = 1; stack0 = ((char *)malloc(1024)+1024); sp = stack0; j = i; - printf("#0108:sp: %x %x\n",sp-(int*)stack0,sizeof(*stack0)); - //goto f0(i,j,_CbC_return,_CbC_environment,sp); + printf("#0108:sp: %lx %lx\n",sp-(int*)stack0,sizeof(*stack0)); goto f0(i,j,NULL,NULL,sp); + return 0; } __code print(int i,int j,__code (*exit1)(),void*exit1env) { printf("#0114:%d %d\n",i,j); - //goto (*exit1)(0),exit1env; exit(0); }