Mercurial > hg > CbC > old > device
comparison test/inline.c @ 542:492f06738550
working... (struct init fix)
author | kono |
---|---|
date | Sun, 01 Jan 2006 18:49:07 +0900 |
parents | 0f24e1dba811 |
children | 74bbea56b8e5 |
comparison
equal
deleted
inserted
replaced
541:4d853ee76ad6 | 542:492f06738550 |
---|---|
12 int | 12 int |
13 main0() | 13 main0() |
14 { | 14 { |
15 volatile const int j = 3; | 15 volatile const int j = 3; |
16 switch(i) { | 16 switch(i) { |
17 case 1: printf("#0015:1\n"); break; | 17 case 1: printf("#0016:1\n"); break; |
18 case 2: printf("#0016:2\n"); break; | 18 case 2: printf("#0017:2\n"); break; |
19 case 3: printf("#0017:3\n"); break; | 19 case 3: printf("#0018:3\n"); break; |
20 case 4: printf("#0018:4\n"); break; | 20 case 4: printf("#0019:4\n"); break; |
21 } | 21 } |
22 switch(j) { | 22 switch(j) { |
23 case 1: printf("#0021:1\n"); break; | 23 case 1: printf("#0022:1\n"); break; |
24 case 2: printf("#0022:2\n"); break; | 24 case 2: printf("#0023:2\n"); break; |
25 case 3: printf("#0023:3\n"); break; | 25 case 3: printf("#0024:3\n"); break; |
26 case 4: printf("#0024:4\n"); break; | 26 case 4: printf("#0025:4\n"); break; |
27 } | 27 } |
28 return 0; | 28 return 0; |
29 } | 29 } |
30 | 30 |
31 | 31 |
43 } | 43 } |
44 | 44 |
45 static | 45 static |
46 inline int ins(int i,int j) | 46 inline int ins(int i,int j) |
47 { | 47 { |
48 printf("#0046:%d %d\n",i,j); | 48 printf("#0047:%d %d\n",i,j); |
49 if (f(i)>j) return j; | 49 if (f(i)>j) return j; |
50 else return i; | 50 else return i; |
51 } | 51 } |
52 | 52 |
53 static | 53 static |
54 inline int ins1(int i,int j, int k) | 54 inline int ins1(int i,int j, int k) |
55 { | 55 { |
56 printf("#0054:%d %d %d\n",i,j,k); | 56 printf("#0055:%d %d %d\n",i,j,k); |
57 if (f(i)>j) return j; | 57 if (f(i)>j) return j; |
58 else return i; | 58 else return i; |
59 } | 59 } |
60 | 60 |
61 inline __attribute__((always_inline)) int in2(int p,int i,int j) | 61 inline __attribute__((always_inline)) int in2(int p,int i,int j) |
62 { | 62 { |
63 int k = -20,m; | 63 int k = -20,m; |
64 do { | 64 do { |
65 k += 3; | 65 k += 3; |
66 } while ( k < j); | 66 } while ( k < j); |
67 printf("#0065: %d do %d\n",p,k); | 67 printf("#0066: %d do %d\n",p,k); |
68 | 68 |
69 while (k > j) { | 69 while (k > j) { |
70 k -= 3; | 70 k -= 3; |
71 } | 71 } |
72 printf("#0070: %d while %d\n",p,k); | 72 printf("#0071: %d while %d\n",p,k); |
73 | 73 |
74 m = 0; | 74 m = 0; |
75 for(k=0;k<j;k++) { | 75 for(k=0;k<j;k++) { |
76 m += k; | 76 m += k; |
77 } | 77 } |
78 printf("#0076: %d for %d\n",p,m); | 78 printf("#0077: %d for %d\n",p,m); |
79 | 79 |
80 switch(i) { | 80 switch(i) { |
81 case 1: k = 1; | 81 case 1: k = 1; |
82 break; | 82 break; |
83 case 2: k = 2; | 83 case 2: k = 2; |
86 break; | 86 break; |
87 case 4: k = 4; | 87 case 4: k = 4; |
88 break; | 88 break; |
89 default: k = 5; | 89 default: k = 5; |
90 } | 90 } |
91 printf("#0089: %d switch %d\n",p,k); | 91 printf("#0090: %d switch %d\n",p,k); |
92 | 92 |
93 for(k=0;k<j;k++) { | 93 for(k=0;k<j;k++) { |
94 i += k; | 94 i += k; |
95 if (k<3) continue; | 95 if (k<3) continue; |
96 } | 96 } |
97 printf("#0095: %d for %d\n",p,i); | 97 printf("#0096: %d for %d\n",p,i); |
98 goto hoge; | 98 goto hoge; |
99 hage: | 99 hage: |
100 goto hage; | 100 goto hage; |
101 hoge: | 101 hoge: |
102 return 0; | 102 return 0; |
113 int k1,j1; | 113 int k1,j1; |
114 const int v=3,x=6; | 114 const int v=3,x=6; |
115 // a = 10; | 115 // a = 10; |
116 | 116 |
117 k1 = in1(a,b); | 117 k1 = in1(a,b); |
118 printf("#0116:%d %d %d\n",a,b,k1); | 118 printf("#0117:%d %d %d\n",a,b,k1); |
119 j1 = in1(k,j-6)+f(k1); | 119 j1 = in1(k,j-6)+f(k1); |
120 printf("#0118:%d %d %s\n",k1,j1,hoo); | 120 printf("#0119:%d %d %s\n",k1,j1,hoo); |
121 k1 = &v-&x>0? &v-&x : &x-&v; | 121 k1 = &v-&x>0? &v-&x : &x-&v; |
122 printf("#0120:v-x: %d\n",k1); | 122 printf("#0121:v-x: %d\n",k1); |
123 | 123 |
124 k1 = ins(a,b); | 124 k1 = ins(a,b); |
125 j1 = ins(k,j-6)+f(k1); | 125 j1 = ins(k,j-6)+f(k1); |
126 printf("#0124:%d %d %s\n",k1,j1,haa); | 126 printf("#0125:%d %d %s\n",k1,j1,haa); |
127 | 127 |
128 k1 = ins(as,bs); | 128 k1 = ins(as,bs); |
129 j1 = ins(k,j-6)+f(k1); | 129 j1 = ins(k,j-6)+f(k1); |
130 printf("#0128:%d %d %s\n",k1,j1,haa); | 130 printf("#0129:%d %d %s\n",k1,j1,haa); |
131 | 131 |
132 k1 = ins(v,x); | 132 k1 = ins(v,x); |
133 j1 = ins(k,j-6)+f(v); | 133 j1 = ins(k,j-6)+f(v); |
134 printf("#0132:%d %d %s\n",k1,j1,haa); | 134 printf("#0133:%d %d %s\n",k1,j1,haa); |
135 | 135 |
136 k1 = fnp(v,x,5); | 136 k1 = fnp(v,x,5); |
137 j1 = ins1(k,j-6,6)+f(v); | 137 j1 = ins1(k,j-6,6)+f(v); |
138 printf("#0136:%d %d %s\n",k1,j1,haa); | 138 printf("#0137:%d %d %s\n",k1,j1,haa); |
139 } | 139 } |
140 | 140 |
141 void | 141 void |
142 a1(int k,int j) | 142 a1(int k,int j) |
143 { | 143 { |
152 } | 152 } |
153 | 153 |
154 static | 154 static |
155 inline int order(int a0,int a1,int a2, int a3, int a4) | 155 inline int order(int a0,int a1,int a2, int a3, int a4) |
156 { | 156 { |
157 printf("#0155:order %d %d %d %d %d\n",a0,a1,a2,a3,a4); | 157 printf("#0156:order %d %d %d %d %d\n",a0,a1,a2,a3,a4); |
158 } | 158 } |
159 | 159 |
160 static | 160 static |
161 inline int order1(int a0,int a1,int a2, int a3, int a4) | 161 inline int order1(int a0,int a1,int a2, int a3, int a4) |
162 { | 162 { |
163 printf("#0161:orderp %d %d %d %d %d\n",a0,a1,a2,a3,a4); | 163 printf("#0162:orderp %d %d %d %d %d\n",a0,a1,a2,a3,a4); |
164 } | 164 } |
165 | 165 |
166 int (*order1p)(int a0,int a1,int a2, int a3, int a4) = order1; | 166 int (*order1p)(int a0,int a1,int a2, int a3, int a4) = order1; |
167 | 167 |
168 static inline int inmain(int ac,char *av[]) | 168 static inline int inmain(int ac,char *av[]) |