annotate test/inline.c @ 534:0f24e1dba811

*** empty log message ***
author kono
date Sat, 31 Dec 2005 01:25:25 +0900
parents d686497e8fd2
children 492f06738550
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
459
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
1 const int a = 5,b = -3;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
2 int kkkk = 333;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
3 static const int as = 5,bs = -3;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
4 const char hoo[] = "test";
517
d686497e8fd2 cstring array fix.
kono
parents: 516
diff changeset
5 char hoo0[] = "test";
459
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
6 static const char haa[] = "test";
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
7 static inline const int f(int k);
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
8
460
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
9 volatile const int i = 3;
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
10
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
11 extern int printf(char *,...);
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
12 int
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
13 main0()
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
14 {
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
15 volatile const int j = 3;
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
16 switch(i) {
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
17 case 1: printf("#0015:1\n"); break;
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
18 case 2: printf("#0016:2\n"); break;
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
19 case 3: printf("#0017:3\n"); break;
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
20 case 4: printf("#0018:4\n"); break;
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
21 }
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
22 switch(j) {
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
23 case 1: printf("#0021:1\n"); break;
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
24 case 2: printf("#0022:2\n"); break;
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
25 case 3: printf("#0023:3\n"); break;
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
26 case 4: printf("#0024:4\n"); break;
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
27 }
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
28 return 0;
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
29 }
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
30
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
31
459
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
32 extern int printf(char *,...);
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
33
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
34 static inline const int f(int k)
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
35 {
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
36 return k+1;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
37 }
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
38
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
39 inline int in1(int i,int j)
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
40 {
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
41 if (i>j) return j;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
42 else return i;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
43 }
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
44
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
45 static
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
46 inline int ins(int i,int j)
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
47 {
460
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
48 printf("#0046:%d %d\n",i,j);
459
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
49 if (f(i)>j) return j;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
50 else return i;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
51 }
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
52
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
53 static
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 515
diff changeset
54 inline int ins1(int i,int j, int k)
459
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
55 {
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 515
diff changeset
56 printf("#0054:%d %d %d\n",i,j,k);
459
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
57 if (f(i)>j) return j;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
58 else return i;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
59 }
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
60
460
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
61 inline __attribute__((always_inline)) int in2(int p,int i,int j)
459
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
62 {
534
0f24e1dba811 *** empty log message ***
kono
parents: 517
diff changeset
63 int k = -20,m;
459
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
64 do {
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
65 k += 3;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
66 } while ( k < j);
460
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
67 printf("#0065: %d do %d\n",p,k);
459
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
68
534
0f24e1dba811 *** empty log message ***
kono
parents: 517
diff changeset
69 while (k > j) {
459
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
70 k -= 3;
534
0f24e1dba811 *** empty log message ***
kono
parents: 517
diff changeset
71 }
460
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
72 printf("#0070: %d while %d\n",p,k);
459
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
73
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
74 m = 0;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
75 for(k=0;k<j;k++) {
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
76 m += k;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
77 }
460
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
78 printf("#0076: %d for %d\n",p,m);
459
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
79
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
80 switch(i) {
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
81 case 1: k = 1;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
82 break;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
83 case 2: k = 2;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
84 break;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
85 case 3: k = 3;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
86 break;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
87 case 4: k = 4;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
88 break;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
89 default: k = 5;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
90 }
460
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
91 printf("#0089: %d switch %d\n",p,k);
459
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
92
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
93 for(k=0;k<j;k++) {
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
94 i += k;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
95 if (k<3) continue;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
96 }
460
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
97 printf("#0095: %d for %d\n",p,i);
459
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
98 goto hoge;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
99 hage:
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
100 goto hage;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
101 hoge:
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
102 return 0;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
103
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
104 }
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
105
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 515
diff changeset
106 int (*fnp)(int i,int j,int k);
459
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
107
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
108 int (*fnp3)(int i,int j,int k);
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
109
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
110 void
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
111 a0(int k,int j)
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
112 {
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
113 int k1,j1;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
114 const int v=3,x=6;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
115 // a = 10;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
116
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
117 k1 = in1(a,b);
460
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
118 printf("#0116:%d %d %d\n",a,b,k1);
459
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
119 j1 = in1(k,j-6)+f(k1);
460
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
120 printf("#0118:%d %d %s\n",k1,j1,hoo);
459
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
121 k1 = &v-&x>0? &v-&x : &x-&v;
460
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
122 printf("#0120:v-x: %d\n",k1);
459
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
123
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
124 k1 = ins(a,b);
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
125 j1 = ins(k,j-6)+f(k1);
460
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
126 printf("#0124:%d %d %s\n",k1,j1,haa);
459
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
127
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
128 k1 = ins(as,bs);
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
129 j1 = ins(k,j-6)+f(k1);
460
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
130 printf("#0128:%d %d %s\n",k1,j1,haa);
459
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
131
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
132 k1 = ins(v,x);
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
133 j1 = ins(k,j-6)+f(v);
460
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
134 printf("#0132:%d %d %s\n",k1,j1,haa);
459
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
135
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 515
diff changeset
136 k1 = fnp(v,x,5);
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 515
diff changeset
137 j1 = ins1(k,j-6,6)+f(v);
460
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
138 printf("#0136:%d %d %s\n",k1,j1,haa);
459
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
139 }
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
140
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
141 void
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
142 a1(int k,int j)
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
143 {
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
144 in2(1,k,j);
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
145 in2(2,3,10);
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
146 in2(3,k,10);
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
147 in2(4,2,j);
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
148 in2(5,2,1);
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
149 in2(6,0,2);
460
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
150 in2(8,j*3,in2(7,k+3,10-j));
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
151 fnp3(9,0,2);
459
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
152 }
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
153
515
3d921f7a8e74 *** empty log message ***
kono
parents: 460
diff changeset
154 static
3d921f7a8e74 *** empty log message ***
kono
parents: 460
diff changeset
155 inline int order(int a0,int a1,int a2, int a3, int a4)
3d921f7a8e74 *** empty log message ***
kono
parents: 460
diff changeset
156 {
517
d686497e8fd2 cstring array fix.
kono
parents: 516
diff changeset
157 printf("#0155:order %d %d %d %d %d\n",a0,a1,a2,a3,a4);
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 515
diff changeset
158 }
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 515
diff changeset
159
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 515
diff changeset
160 static
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 515
diff changeset
161 inline int order1(int a0,int a1,int a2, int a3, int a4)
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 515
diff changeset
162 {
517
d686497e8fd2 cstring array fix.
kono
parents: 516
diff changeset
163 printf("#0161:orderp %d %d %d %d %d\n",a0,a1,a2,a3,a4);
515
3d921f7a8e74 *** empty log message ***
kono
parents: 460
diff changeset
164 }
3d921f7a8e74 *** empty log message ***
kono
parents: 460
diff changeset
165
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 515
diff changeset
166 int (*order1p)(int a0,int a1,int a2, int a3, int a4) = order1;
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 515
diff changeset
167
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 515
diff changeset
168 static inline int inmain(int ac,char *av[])
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 515
diff changeset
169 {
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 515
diff changeset
170 fnp = ins1;
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 515
diff changeset
171 order(11,12,13,14,15);
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 515
diff changeset
172 order1p(11,12,13,14,15);
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 515
diff changeset
173 a0(15,16);
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 515
diff changeset
174 a0(-19,16);
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 515
diff changeset
175 fnp3 = in2;
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 515
diff changeset
176 a1(19,110);
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 515
diff changeset
177 main0(ac,av);
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 515
diff changeset
178 return 0;
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 515
diff changeset
179 }
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 515
diff changeset
180
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 515
diff changeset
181
459
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
182 int
460
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
183 main(int ac,char *av[])
459
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
184 {
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
185 fnp = ins1;
515
3d921f7a8e74 *** empty log message ***
kono
parents: 460
diff changeset
186 order(1,2,3,4,5);
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 515
diff changeset
187 order1p(1,2,3,4,5);
459
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
188 a0(5,6);
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
189 a0(-9,6);
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
190 fnp3 = in2;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
191 a1(9,10);
460
2859bb9d5fb3 volatile/const
kono
parents: 459
diff changeset
192 main0(ac,av);
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 515
diff changeset
193 inmain(ac,av);
459
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
194 return 0;
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
195 }
9fc266d4010f *** empty log message ***
kono
parents:
diff changeset
196
515
3d921f7a8e74 *** empty log message ***
kono
parents: 460
diff changeset
197