Mercurial > hg > CbC > old > device
diff test/tmp8.c @ 313:f73b93de216a alloca
alloca done for ia32, powerpc, mips
author | kono |
---|---|
date | Tue, 15 Jun 2004 00:11:26 +0900 |
parents | a93e619cf772 |
children | 84df3dd8cc3d |
line wrap: on
line diff
--- a/test/tmp8.c Sat Jun 12 15:58:56 2004 +0900 +++ b/test/tmp8.c Tue Jun 15 00:11:26 2004 +0900 @@ -4,12 +4,18 @@ int f(int i,int j,int k,int *l); int g(); +int f1(int i,int j,int *l,int k); +int g1(int k); +void f2(); int main() { int a[0] ; + f2(1); + f2(0); printf("%d %d\n",g(),f(0,1,2,a)); + printf("%d %d\n",g1(100),f1(0,1,a,2)); return 0; } @@ -31,3 +37,42 @@ if (i++ >20) return *l; return f(i,j,k,(int*)alloca(asize)); } + +int +g1(int k) +{ + int i; + + char *p = ((char *)alloca(asize))+k; + p -= k; + for(i=0;i<100;i++) p[i]=i; + for(i=0;i<100;i++) k += p[i]; + return k; +} + +int +f1(int i,int j,int *l,int k) +{ + // printf("f1 &i=%x &k=%x\n",&i,&k); + // printf("f1 i=%d j=%d *l=%0x k=%d\n",i,j,l,k); + *l = 3; + printf("f1 i=%d j=%d *l=%0x k=%d\n",i,j,*l,k); + if (i++ >20) return *l; + return f1(i,j,(int*)alloca(asize),k); +} + +void +f2(int k) +{ + int *l; + if (k==1) + l = alloca(asize); + else + l = 0; + printf("f2: %0x %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", + // l, + 0, +0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40 + ); +} +