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 {
|
|
13 int a;
|
|
14 int b;
|
|
15 int c;
|
|
16 int d;
|
542
|
17 struct hoge {
|
|
18 int k;
|
|
19 int j;
|
|
20 } m;
|
448
|
21 int e;
|
|
22 } temp1 = {
|
|
23 // 101,
|
|
24 // 102,
|
|
25 // 103,
|
|
26 // 104,
|
|
27 // 105,
|
|
28 .e = 5,
|
|
29 .a = 3
|
|
30 };
|
|
31
|
|
32 struct temp temp3 = {
|
|
33 .c = (int)&b,
|
|
34 .d = -10,
|
|
35 .a = (int)b
|
|
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
|
656
|
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
|
573
|
132 printf("#0166:%d %d\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
|
573
|
150 printf("#0184:%d %d\n",fl.oif,fl.uli_u.ports.dport);
|
|
151 printf("#0185:%d %d\n",fl.iif,fl.nl_u.ip4_u.saddr);
|
548
|
152 }
|
|
153
|
656
|
154 INLINE void
|
547
|
155 linux_kernel()
|
|
156 {
|
548
|
157 ip_route_connect0(1,2,3,4,5,6,7);
|
547
|
158 ip_route_connect(1,2,3,4,5,6,7);
|
548
|
159 ip_route_connect(11,12,13,14,15,16,17);
|
547
|
160 }
|
|
161
|
608
|
162 struct st_child {
|
|
163 int a,b;
|
|
164 char c;
|
|
165 };
|
|
166
|
|
167 struct st_parent{
|
|
168 char ch;
|
|
169 struct st_child s1;
|
|
170 int i,j;
|
|
171 };
|
|
172
|
656
|
173 INLINE void
|
608
|
174 main7()
|
|
175 {
|
|
176 struct st_parent st1 = {'A',{1,2,'E'},5,6};
|
|
177 struct st_child st2 = {10,11,'F'};
|
|
178 printf("st1.ch = %c\n",st1.ch);
|
|
179 printf("st1.s1.a = %d\n",st1.s1.a);
|
|
180 printf("st1.s1.b = %d\n",st1.s1.b);
|
|
181 printf("st1.s1.c = %c\n",st1.s1.c);
|
|
182 printf("st1.i = %d\n",st1.i);
|
|
183 printf("st1.j = %d\n\n",st1.j);
|
|
184
|
|
185 printf("st2.a = %d\n",st2.a);
|
|
186 printf("st2.b = %d\n",st2.b);
|
|
187 printf("st2.c = %c\n",st2.c);
|
|
188
|
|
189 return;
|
|
190
|
|
191 }
|
|
192
|
655
|
193
|
|
194
|
|
195 struct arg { int hage, fuga; int aho; };
|
|
196
|
656
|
197 INLINE void f(struct arg h) {
|
655
|
198 printf("%d %d %d\n",h.hage,h.fuga,h.aho);
|
|
199 }
|
|
200
|
656
|
201 INLINE int main8() {
|
655
|
202 f((struct arg){.fuga = 3,.aho=5});
|
656
|
203 printf("%d\n",((struct arg){.aho=120, .hage=55}).aho);
|
|
204 }
|
|
205
|
|
206 int
|
|
207 main()
|
|
208 {
|
|
209 struct temp temp2 = { .c = 5, .e=99 };
|
|
210 #ifdef WRONG
|
|
211 struct temp temp5 = { 1,2,3,4,5,6,7,8};
|
|
212 struct temp temp6 = { 1,2,3,4,5,6};
|
|
213 #else
|
|
214 struct temp temp5 = { 1,2,3,4,5,6,7};
|
|
215 struct temp temp6 = { 1,2,3,4,5,6,7};
|
|
216 struct temp temp8 = { 1,2,3,4,{5,6},7};
|
|
217 #endif
|
|
218 struct temp temp11 = {
|
|
219 .m = (struct hoge){},
|
|
220 .c = (int)&b,
|
|
221 };
|
|
222 struct temp temp12 = {
|
|
223 .m = (struct hoge){1,3},
|
|
224 .c = (int)&temp4,
|
|
225 };
|
|
226
|
|
227 printf("#0070:1: %d\n",temp1.a);
|
|
228 printf("#0071:1: %d\n",temp1.e);
|
|
229 printf("#0072:1: %d\n",temp1.b);
|
|
230 printf("#0073:2: %d\n",temp2.c);
|
|
231 printf("#0074:2: %d\n",temp2.e);
|
|
232 printf("#0075:2: %d\n",temp2.b);
|
|
233 printf("#0076:2: %d\n",(void*)temp3.c==b);
|
|
234 printf("#0077:2: %d\n",temp3.c==(int)b);
|
|
235 printf("#0078:2: %d\n",temp3.a==(int)&b);
|
|
236 printf("#0079:2: %d\n",temp4.m.j);
|
|
237 printf("#0080:2: %d\n",temp5.m.j);
|
|
238 printf("#0081:2: %d\n",temp11.m.j);
|
|
239 printf("#0082:2: %d\n",temp12.m.k);
|
|
240 printf("#0083:2: %d\n",temp12.m.j);
|
|
241 printf("#0084:2: %d\n",temp11.c==(int)&b);
|
|
242 printf("#0085:2: %d\n",temp8.e);
|
|
243 printf("#0086:2: %d\n",temp6.e);
|
|
244 main7();
|
|
245 main8();
|
|
246 linux_kernel();
|
|
247 return 0;
|
655
|
248 }
|
|
249
|
|
250
|
|
251
|
547
|
252 // end
|