annotate test/tmp8.c @ 491:a379da780856

cond signed/unsigned
author kono
date Wed, 21 Dec 2005 11:33:53 +0900
parents 32737bad7489
children 0e7281ec9007
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 {
096559f07a70 some check
kono
parents: 17
diff changeset
16 int a[0] ;
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
315
84df3dd8cc3d minor fix
kono
parents: 313
diff changeset
31 char *p = alloca(asize<100?100:asize);
172
096559f07a70 some check
kono
parents: 17
diff changeset
32 for(i=0;i<100;i++) p[i]=i;
096559f07a70 some check
kono
parents: 17
diff changeset
33 for(i=0;i<100;i++) k += p[i];
096559f07a70 some check
kono
parents: 17
diff changeset
34 return k;
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
35 }
172
096559f07a70 some check
kono
parents: 17
diff changeset
36
096559f07a70 some check
kono
parents: 17
diff changeset
37 int
096559f07a70 some check
kono
parents: 17
diff changeset
38 f(int i,int j,int k,int *l)
096559f07a70 some check
kono
parents: 17
diff changeset
39 {
096559f07a70 some check
kono
parents: 17
diff changeset
40 *l = 3;
096559f07a70 some check
kono
parents: 17
diff changeset
41 if (i++ >20) return *l;
096559f07a70 some check
kono
parents: 17
diff changeset
42 return f(i,j,k,(int*)alloca(asize));
096559f07a70 some check
kono
parents: 17
diff changeset
43 }
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
44
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
45 int
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
46 g1(int k)
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
47 {
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
48 int i;
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
49
315
84df3dd8cc3d minor fix
kono
parents: 313
diff changeset
50 char *p = ((char *)alloca(asize>100?asize:100))+k;
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
51 p -= k;
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
52 for(i=0;i<100;i++) p[i]=i;
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
53 for(i=0;i<100;i++) k += p[i];
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
54 return k;
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
55 }
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
56
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
57 int
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
58 f1(int i,int j,int *l,int k)
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
59 {
491
a379da780856 cond signed/unsigned
kono
parents: 467
diff changeset
60 // printf("#0059:f1 &i=%x &k=%x\n",&i,&k);
a379da780856 cond signed/unsigned
kono
parents: 467
diff changeset
61 // 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
62 *l = 3;
491
a379da780856 cond signed/unsigned
kono
parents: 467
diff changeset
63 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
64 if (i++ >20) return *l;
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
65 return f1(i,j,(int*)alloca(asize),k);
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
66 }
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
67
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
68 void
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
69 f2(int k)
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
70 {
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
71 int *l;
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
72 if (k==1)
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
73 l = alloca(asize);
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
74 else
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
75 l = 0;
491
a379da780856 cond signed/unsigned
kono
parents: 467
diff changeset
76 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
77 // l,
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
78 0,
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
79 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
80 );
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
81 }
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
82