Mercurial > hg > CbC > old > device
annotate test/strinit.c @ 794:032dc03be02e
i64 arg_register in inline mode
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 23 Nov 2010 09:42:08 +0900 |
parents | b674d8421430 |
children | c55337499f96 |
rev | line source |
---|---|
467 | 1 #include <stdio.h> |
448 | 2 |
656 | 3 #ifndef INLINE |
4 #define INLINE | |
5 #endif | |
6 | |
7 INLINE void main7(); | |
8 INLINE int main8(); | |
608 | 9 |
448 | 10 int b[3] = {1,2,3}; |
11 | |
12 struct temp { | |
770
b674d8421430
i64 inline ( indirect call )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
748
diff
changeset
|
13 long a; |
b674d8421430
i64 inline ( indirect call )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
748
diff
changeset
|
14 long b; |
b674d8421430
i64 inline ( indirect call )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
748
diff
changeset
|
15 long c; |
b674d8421430
i64 inline ( indirect call )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
748
diff
changeset
|
16 long d; |
542 | 17 struct hoge { |
770
b674d8421430
i64 inline ( indirect call )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
748
diff
changeset
|
18 long k; |
b674d8421430
i64 inline ( indirect call )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
748
diff
changeset
|
19 long j; |
542 | 20 } m; |
770
b674d8421430
i64 inline ( indirect call )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
748
diff
changeset
|
21 long e; |
448 | 22 } temp1 = { |
23 // 101, | |
24 // 102, | |
25 // 103, | |
26 // 104, | |
27 // 105, | |
28 .e = 5, | |
29 .a = 3 | |
30 }; | |
31 | |
32 struct temp temp3 = { | |
770
b674d8421430
i64 inline ( indirect call )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
748
diff
changeset
|
33 .c = (long)&b, |
448 | 34 .d = -10, |
770
b674d8421430
i64 inline ( indirect call )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
748
diff
changeset
|
35 .a = (long)b |
448 | 36 }; |
37 | |
542 | 38 struct temp temp4 = { 1,2,3,4,5,6,7}; |
39 struct temp temp7 = { 1,2,3,4,{5,6},7}; | |
448 | 40 |
553 | 41 #if 0 |
42 struct temp temp10 = { | |
43 .m = (struct hoge){}, // not allowed in global | |
44 .c = (int)&b, | |
45 }; | |
46 #endif | |
47 | |
656 | 48 INLINE void |
547 | 49 linux_kernel(); |
448 | 50 |
559 | 51 struct test{ |
52 int a,b,c; | |
53 } huga = { | |
54 0,0,0, | |
55 }; | |
56 | |
547 | 57 typedef unsigned int __u32; |
58 typedef unsigned short __u16; | |
59 typedef unsigned char __u8; | |
60 typedef unsigned int u32; | |
61 typedef unsigned short u16; | |
62 typedef unsigned char u8; | |
63 struct in6_addr { char hoge[128]; }; | |
64 | |
65 struct flowi { | |
66 int oif; | |
67 int iif; | |
68 | |
69 union { | |
70 struct { | |
71 __u32 daddr; | |
72 __u32 saddr; | |
73 __u32 fwmark; | |
74 __u8 tos; | |
75 __u8 scope; | |
76 } ip4_u; | |
77 | |
78 struct { | |
79 struct in6_addr daddr; | |
80 struct in6_addr saddr; | |
81 __u32 flowlabel; | |
82 } ip6_u; | |
83 | |
84 struct { | |
85 __u16 daddr; | |
86 __u16 saddr; | |
87 __u32 fwmark; | |
88 __u8 scope; | |
89 } dn_u; | |
90 } nl_u; | |
91 __u8 proto; | |
92 __u8 flags; | |
93 union { | |
94 struct { | |
95 __u16 sport; | |
96 __u16 dport; | |
97 } ports; | |
98 | |
99 struct { | |
100 __u8 type; | |
101 __u8 code__; | |
102 } icmpt; | |
103 | |
104 struct { | |
105 __u16 sport; | |
106 __u16 dport; | |
107 | |
108 __u8 objnum; | |
109 __u8 objnamel; | |
110 __u8 objname[16]; | |
111 } dnports; | |
112 | |
113 __u32 spi; | |
114 } uli_u; | |
115 } __attribute__((__aligned__(32/8))); | |
116 | |
117 | |
682 | 118 INLINE static /* __inline__ __attribute__((always_inline)) __attribute__((always_inline)) */ |
559 | 119 void ip_route_connect(/* struct rtable **rp, */ u32 dst, |
547 | 120 u32 src, u32 tos, int oif, u8 protocol, |
121 u16 sport, u16 dport /*, struct sock *sk */) | |
122 { | |
123 struct flowi fl = { .oif = oif, | |
124 .nl_u = { .ip4_u = { .daddr = dst, | |
125 .saddr = src, | |
126 .tos = tos } }, | |
127 .proto = protocol, | |
128 .uli_u = { .ports = | |
129 { .sport = sport, | |
130 .dport = dport } } }; | |
131 | |
682 | 132 printf("#0131:%x %x\n",fl.oif,fl.uli_u.ports.dport); |
547 | 133 } |
134 | |
656 | 135 INLINE static |
559 | 136 void ip_route_connect0(/* struct rtable **rp, */ u32 dst, |
548 | 137 u32 src, u32 tos, int oif, u8 protocol, |
138 u16 sport, u16 dport /*, struct sock *sk */) | |
139 { | |
140 struct flowi fl = { .oif = oif, | |
141 .iif = 55, | |
142 .nl_u = { .ip4_u = { .daddr = dst, | |
143 .saddr = 66, | |
144 .tos = tos } }, | |
145 .proto = protocol, | |
146 .uli_u = { .ports = | |
147 { .sport = sport, | |
148 .dport = dport } } }; | |
149 | |
682 | 150 printf("#0149:%x %x\n",fl.oif,fl.uli_u.ports.dport); |
151 printf("#0150:%x %x\n",fl.iif,fl.nl_u.ip4_u.saddr); | |
152 } | |
153 | |
154 INLINE static | |
155 void ip_route_connect1(/* struct rtable **rp, */ u32 dst, | |
156 u32 src, u32 tos, int oif, u8 protocol, | |
157 u16 sport, u16 dport /*, struct sock *sk */) | |
158 { | |
159 struct flowi fl, *flp; | |
160 fl = (struct flowi){ .oif = oif, | |
161 .iif = 55, | |
162 .nl_u = { .ip4_u = { .daddr = dst, | |
163 .saddr = 66, | |
164 .tos = tos } }, | |
165 .proto = protocol, | |
166 .uli_u = { .ports = | |
167 { .sport = sport, | |
168 .dport = dport } } }; | |
169 flp = &fl; | |
170 | |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
694
diff
changeset
|
171 printf("#0170:%x %x\n",flp->oif,flp->uli_u.ports.dport); |
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
694
diff
changeset
|
172 printf("#0171:%x %x\n",flp->iif,flp->nl_u.ip4_u.saddr); |
548 | 173 } |
174 | |
656 | 175 INLINE void |
547 | 176 linux_kernel() |
177 { | |
684 | 178 int i=1,j=2; |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
694
diff
changeset
|
179 printf("#0178:%d %d\n",i,j); |
548 | 180 ip_route_connect0(1,2,3,4,5,6,7); |
547 | 181 ip_route_connect(1,2,3,4,5,6,7); |
548 | 182 ip_route_connect(11,12,13,14,15,16,17); |
682 | 183 ip_route_connect1(1,2,3,4,5,6,7); |
547 | 184 } |
185 | |
608 | 186 struct st_child { |
187 int a,b; | |
188 char c; | |
189 }; | |
190 | |
191 struct st_parent{ | |
192 char ch; | |
193 struct st_child s1; | |
194 int i,j; | |
195 }; | |
196 | |
656 | 197 INLINE void |
608 | 198 main7() |
199 { | |
200 struct st_parent st1 = {'A',{1,2,'E'},5,6}; | |
201 struct st_child st2 = {10,11,'F'}; | |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
694
diff
changeset
|
202 printf("#0201:st1.ch = %c\n",st1.ch); |
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
694
diff
changeset
|
203 printf("#0202:st1.s1.a = %d\n",st1.s1.a); |
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
694
diff
changeset
|
204 printf("#0203:st1.s1.b = %d\n",st1.s1.b); |
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
694
diff
changeset
|
205 printf("#0204:st1.s1.c = %c\n",st1.s1.c); |
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
694
diff
changeset
|
206 printf("#0205:st1.i = %d\n",st1.i); |
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
694
diff
changeset
|
207 printf("#0206:st1.j = %d\n\n",st1.j); |
608 | 208 |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
694
diff
changeset
|
209 printf("#0208:st2.a = %d\n",st2.a); |
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
694
diff
changeset
|
210 printf("#0209:st2.b = %d\n",st2.b); |
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
694
diff
changeset
|
211 printf("#0210:st2.c = %c\n",st2.c); |
608 | 212 |
213 return; | |
214 | |
215 } | |
216 | |
655 | 217 |
218 | |
219 struct arg { int hage, fuga; int aho; }; | |
220 | |
656 | 221 INLINE void f(struct arg h) { |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
694
diff
changeset
|
222 printf("#0221:%d %d %d\n",h.hage,h.fuga,h.aho); |
655 | 223 } |
224 | |
656 | 225 INLINE int main8() { |
655 | 226 f((struct arg){.fuga = 3,.aho=5}); |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
694
diff
changeset
|
227 printf("#0226:%d\n",((struct arg){.aho=120, .hage=55}).aho); |
656 | 228 } |
229 | |
230 int | |
231 main() | |
232 { | |
233 struct temp temp2 = { .c = 5, .e=99 }; | |
234 #ifdef WRONG | |
235 struct temp temp5 = { 1,2,3,4,5,6,7,8}; | |
236 struct temp temp6 = { 1,2,3,4,5,6}; | |
237 #else | |
238 struct temp temp5 = { 1,2,3,4,5,6,7}; | |
239 struct temp temp6 = { 1,2,3,4,5,6,7}; | |
240 struct temp temp8 = { 1,2,3,4,{5,6},7}; | |
241 #endif | |
242 struct temp temp11 = { | |
243 .m = (struct hoge){}, | |
770
b674d8421430
i64 inline ( indirect call )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
748
diff
changeset
|
244 .c = (long)&b, |
656 | 245 }; |
246 struct temp temp12 = { | |
247 .m = (struct hoge){1,3}, | |
770
b674d8421430
i64 inline ( indirect call )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
748
diff
changeset
|
248 .c = (long)&temp4, |
656 | 249 }; |
694 | 250 int c[3] = {1,2,3}; |
656 | 251 |
770
b674d8421430
i64 inline ( indirect call )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
748
diff
changeset
|
252 printf("#0251:1: %ld\n",temp1.a); |
b674d8421430
i64 inline ( indirect call )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
748
diff
changeset
|
253 printf("#0252:1: %ld\n",temp1.e); |
b674d8421430
i64 inline ( indirect call )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
748
diff
changeset
|
254 printf("#0253:1: %ld\n",temp1.b); |
b674d8421430
i64 inline ( indirect call )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
748
diff
changeset
|
255 printf("#0254:2: %ld\n",temp2.c); |
b674d8421430
i64 inline ( indirect call )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
748
diff
changeset
|
256 printf("#0255:2: %ld\n",temp2.e); |
b674d8421430
i64 inline ( indirect call )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
748
diff
changeset
|
257 printf("#0256:2: %ld\n",temp2.b); |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
694
diff
changeset
|
258 printf("#0257:2: %d\n",(void*)temp3.c==b); |
770
b674d8421430
i64 inline ( indirect call )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
748
diff
changeset
|
259 printf("#0258:2: %d\n",temp3.c==(long)b); |
b674d8421430
i64 inline ( indirect call )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
748
diff
changeset
|
260 printf("#0259:2: %d\n",temp3.a==(long)&b); |
b674d8421430
i64 inline ( indirect call )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
748
diff
changeset
|
261 printf("#0260:2: %ld\n",temp4.m.j); |
b674d8421430
i64 inline ( indirect call )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
748
diff
changeset
|
262 printf("#0261:2: %ld\n",temp5.m.j); |
b674d8421430
i64 inline ( indirect call )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
748
diff
changeset
|
263 printf("#0262:2: %ld\n",temp11.m.j); |
b674d8421430
i64 inline ( indirect call )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
748
diff
changeset
|
264 printf("#0263:2: %ld\n",temp12.m.k); |
b674d8421430
i64 inline ( indirect call )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
748
diff
changeset
|
265 printf("#0264:2: %ld\n",temp12.m.j); |
b674d8421430
i64 inline ( indirect call )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
748
diff
changeset
|
266 printf("#0265:2: %d\n",temp11.c==(long)&b); |
b674d8421430
i64 inline ( indirect call )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
748
diff
changeset
|
267 printf("#0266:2: %ld\n",temp8.e); |
b674d8421430
i64 inline ( indirect call )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
748
diff
changeset
|
268 printf("#0267:2: %ld\n",temp6.e); |
656 | 269 main7(); |
270 main8(); | |
271 linux_kernel(); | |
684 | 272 int i=1,j=2; |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
694
diff
changeset
|
273 printf("#0272:%d %d\n",i,j); |
694 | 274 |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
694
diff
changeset
|
275 printf("#0274:b %d %d %d\n",b[0],b[1],b[2]); |
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
694
diff
changeset
|
276 printf("#0275:c %d %d %d\n",c[0],c[1],c[2]); |
694 | 277 |
278 struct test t = {1,2,3}; | |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
694
diff
changeset
|
279 printf("#0278:t %d %d %d\n",t.a,t.b,t.c); |
694 | 280 |
281 struct test3 { | |
282 int a,b,c; | |
283 } *p, q, d = { | |
284 1,2,3, | |
285 }; | |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
694
diff
changeset
|
286 printf("#0285:d %d %d %d\n",d.a,d.b,d.c); |
694 | 287 p = & (struct test3) {1,2,3}; |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
694
diff
changeset
|
288 printf("#0287:p %d %d %d\n",p->a,p->b,p->c); |
694 | 289 q = (struct test3) {1,2,3}; |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
694
diff
changeset
|
290 printf("#0289:q %d %d %d\n",q.a,q.b,q.c); |
694 | 291 |
292 struct test4 { | |
293 struct test5 { | |
294 int a,b,c; | |
295 } d; | |
296 } u = { .d = {1,2,3} }; | |
297 struct test4 v = { .d = (struct test5){1,2,3} }; | |
298 | |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
694
diff
changeset
|
299 printf("#0298:u %d %d %d\n",u.d.a,u.d.b,u.d.c); |
694 | 300 |
748
c2c709727221
i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
694
diff
changeset
|
301 printf("#0300:v %d %d %d\n",v.d.a,v.d.b,v.d.c); |
694 | 302 |
303 | |
656 | 304 return 0; |
655 | 305 } |
306 | |
307 | |
308 | |
547 | 309 // end |