annotate test/tmp8.c @ 367:4efbb07f556b

global variable offset
author kono
date Wed, 07 Jul 2004 20:50:07 +0900
parents 84df3dd8cc3d
children 0c256ea2a97e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
312
a93e619cf772 typeof, MIPS stdarg
kono
parents: 172
diff changeset
1 #include <alloca.h>
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
2
172
096559f07a70 some check
kono
parents: 17
diff changeset
3 int asize = 100;
096559f07a70 some check
kono
parents: 17
diff changeset
4
096559f07a70 some check
kono
parents: 17
diff changeset
5 int f(int i,int j,int k,int *l);
096559f07a70 some check
kono
parents: 17
diff changeset
6 int g();
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
7 int f1(int i,int j,int *l,int k);
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
8 int g1(int k);
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
9 void f2();
172
096559f07a70 some check
kono
parents: 17
diff changeset
10
096559f07a70 some check
kono
parents: 17
diff changeset
11 int
096559f07a70 some check
kono
parents: 17
diff changeset
12 main()
096559f07a70 some check
kono
parents: 17
diff changeset
13 {
096559f07a70 some check
kono
parents: 17
diff changeset
14 int a[0] ;
315
84df3dd8cc3d minor fix
kono
parents: 313
diff changeset
15 for(asize=4;asize<64000;asize=asize*2+12) {
84df3dd8cc3d minor fix
kono
parents: 313
diff changeset
16 f2(1);
84df3dd8cc3d minor fix
kono
parents: 313
diff changeset
17 f2(0);
84df3dd8cc3d minor fix
kono
parents: 313
diff changeset
18 printf("%d %d\n",g(),f(0,1,2,a));
84df3dd8cc3d minor fix
kono
parents: 313
diff changeset
19 printf("%d %d\n",g1(100),f1(0,1,a,2));
84df3dd8cc3d minor fix
kono
parents: 313
diff changeset
20 }
172
096559f07a70 some check
kono
parents: 17
diff changeset
21 return 0;
096559f07a70 some check
kono
parents: 17
diff changeset
22 }
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
23
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
24 int
172
096559f07a70 some check
kono
parents: 17
diff changeset
25 g()
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
26 {
172
096559f07a70 some check
kono
parents: 17
diff changeset
27 int k = 0,i;
096559f07a70 some check
kono
parents: 17
diff changeset
28
315
84df3dd8cc3d minor fix
kono
parents: 313
diff changeset
29 char *p = alloca(asize<100?100:asize);
172
096559f07a70 some check
kono
parents: 17
diff changeset
30 for(i=0;i<100;i++) p[i]=i;
096559f07a70 some check
kono
parents: 17
diff changeset
31 for(i=0;i<100;i++) k += p[i];
096559f07a70 some check
kono
parents: 17
diff changeset
32 return k;
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
33 }
172
096559f07a70 some check
kono
parents: 17
diff changeset
34
096559f07a70 some check
kono
parents: 17
diff changeset
35 int
096559f07a70 some check
kono
parents: 17
diff changeset
36 f(int i,int j,int k,int *l)
096559f07a70 some check
kono
parents: 17
diff changeset
37 {
096559f07a70 some check
kono
parents: 17
diff changeset
38 *l = 3;
096559f07a70 some check
kono
parents: 17
diff changeset
39 if (i++ >20) return *l;
096559f07a70 some check
kono
parents: 17
diff changeset
40 return f(i,j,k,(int*)alloca(asize));
096559f07a70 some check
kono
parents: 17
diff changeset
41 }
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
42
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
43 int
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
44 g1(int k)
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
45 {
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
46 int i;
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
47
315
84df3dd8cc3d minor fix
kono
parents: 313
diff changeset
48 char *p = ((char *)alloca(asize>100?asize:100))+k;
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
49 p -= k;
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
50 for(i=0;i<100;i++) p[i]=i;
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
51 for(i=0;i<100;i++) k += p[i];
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
52 return k;
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
53 }
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
54
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
55 int
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
56 f1(int i,int j,int *l,int 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 // printf("f1 &i=%x &k=%x\n",&i,&k);
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
59 // printf("f1 i=%d j=%d *l=%0x k=%d\n",i,j,l,k);
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
60 *l = 3;
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
61 printf("f1 i=%d j=%d *l=%0x k=%d\n",i,j,*l,k);
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
62 if (i++ >20) return *l;
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
63 return f1(i,j,(int*)alloca(asize),k);
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
64 }
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
65
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
66 void
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
67 f2(int 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 int *l;
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
70 if (k==1)
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
71 l = alloca(asize);
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
72 else
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
73 l = 0;
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
74 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",
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
75 // l,
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
76 0,
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
77 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
78 );
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
79 }
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
80