# HG changeset patch # User kono # Date 1520479202 -32400 # Node ID 9d1ff3ae1824d004c9dde16059f4897b42156021 # Parent fd00160c1b76c13c5c671285a551184ebe9c9656 fix conv1 example diff -r fd00160c1b76 -r 9d1ff3ae1824 CbC-examples/conv1.c --- a/CbC-examples/conv1.c Tue Feb 27 15:01:35 2018 +0900 +++ b/CbC-examples/conv1.c Thu Mar 08 12:20:02 2018 +0900 @@ -1,5 +1,7 @@ #include "stdio.h" +extern int atoi (const char *); + static int loop; #if 1 // def __micro_c__ @@ -9,7 +11,10 @@ #endif /* classical function call case (0) */ +int g0(int); +int h0(int); +int f0(int i) { int k,j; k = 3+i; @@ -17,10 +22,12 @@ return k+4+j; } +int g0(int i) { return h0(i+4)+i; } +int h0(int i) { return i+4; } @@ -29,12 +36,25 @@ /* straight conversion case (1) */ -typedef char *stack; +typedef void *stack; struct cont_interface { // General Return Continuation __code (*ret)(int, void *); }; +#ifndef __llvm__ +__code f_g0(int i,int k,stack sp); +__code f_g1(int j,stack sp); +__code g(int i,stack sp); +__code h(int i,stack sp); +__code f2(int i,char *sp); +__code g2(int i,int k,int j,char *sp); +__code h2(int i,int k,char *sp); +__code main_return2(int i,stack sp); +__code g2_1(int k,int i,stack *sp); +__code h2_11(int i,int k,stack *sp); +#endif + __code f(int i,stack sp) { int k,j; k = 3+i; @@ -137,26 +157,26 @@ /* little optimizaed case (3) */ -__code f2_1(int i,char *sp) { +__code f2_1(int i,stack *sp) { int k,j; k = 3+i; goto g2_1(k,i+3,sp); } -__code g2_1(int k,int i,char *sp) { +__code g2_1(int k,int i,stack *sp) { goto h2_11(k,i+4,sp); } -__code f2_0_1(int k,int j,char *sp); -__code h2_1_1(int i,int k,int j,char *sp) { +__code f2_0_1(int k,int j,stack *sp); +__code h2_1_1(int i,int k,int j,stack *sp) { goto f2_0_1(k,i+j,sp); } -__code h2_11(int i,int k,char *sp) { +__code h2_11(int i,int k,stack *sp) { goto h2_1_1(i,k,i+4,sp); } -__code f2_0_1(int k,int j,char *sp) { +__code f2_0_1(int k,int j,stack *sp) { goto (( (struct cont_interface *)sp)->ret)(k+4+j,sp); } @@ -176,6 +196,7 @@ #define LOOP_COUNT 10000000 +int main(int ac,char *av[]) { #if !CC_ONLY