annotate test/tmp8.c @ 691:25115b50d033

*** empty log message ***
author kono
date Wed, 10 Oct 2007 17:58:15 +0900
parents cddab906095e
children c2c709727221
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
467
32737bad7489 fix list/tag interference
kono
parents: 427
diff changeset
1 int printf(const char *format, ...);
32737bad7489 fix list/tag interference
kono
parents: 427
diff changeset
2
312
a93e619cf772 typeof, MIPS stdarg
kono
parents: 172
diff changeset
3 #include <alloca.h>
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
4
172
096559f07a70 some check
kono
parents: 17
diff changeset
5 int asize = 100;
096559f07a70 some check
kono
parents: 17
diff changeset
6
096559f07a70 some check
kono
parents: 17
diff changeset
7 int f(int i,int j,int k,int *l);
096559f07a70 some check
kono
parents: 17
diff changeset
8 int g();
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
9 int f1(int i,int j,int *l,int k);
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
10 int g1(int k);
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
11 void f2();
172
096559f07a70 some check
kono
parents: 17
diff changeset
12
096559f07a70 some check
kono
parents: 17
diff changeset
13 int
096559f07a70 some check
kono
parents: 17
diff changeset
14 main()
096559f07a70 some check
kono
parents: 17
diff changeset
15 {
620
0e7281ec9007 *** empty log message ***
kono
parents: 491
diff changeset
16 int a[1] ;
315
84df3dd8cc3d minor fix
kono
parents: 313
diff changeset
17 for(asize=4;asize<64000;asize=asize*2+12) {
84df3dd8cc3d minor fix
kono
parents: 313
diff changeset
18 f2(1);
84df3dd8cc3d minor fix
kono
parents: 313
diff changeset
19 f2(0);
491
a379da780856 cond signed/unsigned
kono
parents: 467
diff changeset
20 printf("#0019:%d %d\n",g(),f(0,1,2,a));
a379da780856 cond signed/unsigned
kono
parents: 467
diff changeset
21 printf("#0020:%d %d\n",g1(100),f1(0,1,a,2));
315
84df3dd8cc3d minor fix
kono
parents: 313
diff changeset
22 }
172
096559f07a70 some check
kono
parents: 17
diff changeset
23 return 0;
096559f07a70 some check
kono
parents: 17
diff changeset
24 }
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
25
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
26 int
172
096559f07a70 some check
kono
parents: 17
diff changeset
27 g()
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
28 {
172
096559f07a70 some check
kono
parents: 17
diff changeset
29 int k = 0,i;
096559f07a70 some check
kono
parents: 17
diff changeset
30
655
cddab906095e struct init in function arg (or other expression).
kono
parents: 620
diff changeset
31 char *q = alloca(100);
315
84df3dd8cc3d minor fix
kono
parents: 313
diff changeset
32 char *p = alloca(asize<100?100:asize);
172
096559f07a70 some check
kono
parents: 17
diff changeset
33 for(i=0;i<100;i++) p[i]=i;
096559f07a70 some check
kono
parents: 17
diff changeset
34 for(i=0;i<100;i++) k += p[i];
655
cddab906095e struct init in function arg (or other expression).
kono
parents: 620
diff changeset
35 for(i=0;i<100;i++) q[i]=i;
172
096559f07a70 some check
kono
parents: 17
diff changeset
36 return k;
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
37 }
172
096559f07a70 some check
kono
parents: 17
diff changeset
38
096559f07a70 some check
kono
parents: 17
diff changeset
39 int
096559f07a70 some check
kono
parents: 17
diff changeset
40 f(int i,int j,int k,int *l)
096559f07a70 some check
kono
parents: 17
diff changeset
41 {
096559f07a70 some check
kono
parents: 17
diff changeset
42 *l = 3;
096559f07a70 some check
kono
parents: 17
diff changeset
43 if (i++ >20) return *l;
096559f07a70 some check
kono
parents: 17
diff changeset
44 return f(i,j,k,(int*)alloca(asize));
096559f07a70 some check
kono
parents: 17
diff changeset
45 }
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
46
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
47 int
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
48 g1(int k)
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
49 {
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
50 int i;
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
51
315
84df3dd8cc3d minor fix
kono
parents: 313
diff changeset
52 char *p = ((char *)alloca(asize>100?asize:100))+k;
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
53 p -= k;
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
54 for(i=0;i<100;i++) p[i]=i;
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
55 for(i=0;i<100;i++) k += p[i];
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
56 return k;
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
57 }
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
58
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
59 int
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
60 f1(int i,int j,int *l,int k)
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
61 {
491
a379da780856 cond signed/unsigned
kono
parents: 467
diff changeset
62 // printf("#0059:f1 &i=%x &k=%x\n",&i,&k);
a379da780856 cond signed/unsigned
kono
parents: 467
diff changeset
63 // printf("#0060:f1 i=%d j=%d *l=%0x k=%d\n",i,j,l,k);
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
64 *l = 3;
491
a379da780856 cond signed/unsigned
kono
parents: 467
diff changeset
65 printf("#0062:f1 i=%d j=%d *l=%0x k=%d\n",i,j,*l,k);
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
66 if (i++ >20) return *l;
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
67 return f1(i,j,(int*)alloca(asize),k);
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
68 }
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
69
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
70 void
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
71 f2(int k)
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
72 {
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
73 int *l;
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
74 if (k==1)
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
75 l = alloca(asize);
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
76 else
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
77 l = 0;
491
a379da780856 cond signed/unsigned
kono
parents: 467
diff changeset
78 printf("#0075: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",
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
79 // l,
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
80 0,
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
81 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
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
82 );
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
83 }
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
84