@@ -43,10 +43,17 @@ fn bindgen_test_layout_rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1() {
43
43
)
44
44
) ;
45
45
assert_eq ! (
46
- unsafe {
47
- & ( * ( :: std:: ptr:: null:: <rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1>(
48
- ) ) )
49
- . dport as * const _ as usize
46
+ {
47
+ let struct_instance = unsafe {
48
+ std:: mem:: zeroed:: <rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1>( )
49
+ } ;
50
+ let struct_ptr = & struct_instance
51
+ as * const rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1;
52
+ let field_ptr = std:: ptr:: addr_of!( struct_instance. dport) ;
53
+ let struct_address = struct_ptr as usize ;
54
+ let field_address = field_ptr as usize ;
55
+ std:: mem:: forget( struct_instance) ;
56
+ field_address. checked_sub( struct_address) . unwrap( )
50
57
} ,
51
58
0usize ,
52
59
concat!(
@@ -57,10 +64,17 @@ fn bindgen_test_layout_rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1() {
57
64
)
58
65
) ;
59
66
assert_eq ! (
60
- unsafe {
61
- & ( * ( :: std:: ptr:: null:: <rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1>(
62
- ) ) )
63
- . sport as * const _ as usize
67
+ {
68
+ let struct_instance = unsafe {
69
+ std:: mem:: zeroed:: <rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1>( )
70
+ } ;
71
+ let struct_ptr = & struct_instance
72
+ as * const rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1;
73
+ let field_ptr = std:: ptr:: addr_of!( struct_instance. sport) ;
74
+ let struct_address = struct_ptr as usize ;
75
+ let field_address = field_ptr as usize ;
76
+ std:: mem:: forget( struct_instance) ;
77
+ field_address. checked_sub( struct_address) . unwrap( )
64
78
} ,
65
79
2usize ,
66
80
concat!(
@@ -83,19 +97,6 @@ fn bindgen_test_layout_rte_ipv4_tuple__bindgen_ty_1() {
83
97
4usize ,
84
98
concat!( "Alignment of " , stringify!( rte_ipv4_tuple__bindgen_ty_1) )
85
99
) ;
86
- assert_eq ! (
87
- unsafe {
88
- & ( * ( :: std:: ptr:: null:: <rte_ipv4_tuple__bindgen_ty_1>( ) ) ) . sctp_tag
89
- as * const _ as usize
90
- } ,
91
- 0usize ,
92
- concat!(
93
- "Offset of field: " ,
94
- stringify!( rte_ipv4_tuple__bindgen_ty_1) ,
95
- "::" ,
96
- stringify!( sctp_tag)
97
- )
98
- ) ;
99
100
}
100
101
impl Default for rte_ipv4_tuple__bindgen_ty_1 {
101
102
fn default ( ) -> Self {
@@ -119,9 +120,15 @@ fn bindgen_test_layout_rte_ipv4_tuple() {
119
120
concat!( "Alignment of " , stringify!( rte_ipv4_tuple) )
120
121
) ;
121
122
assert_eq ! (
122
- unsafe {
123
- & ( * ( :: std:: ptr:: null:: <rte_ipv4_tuple>( ) ) ) . src_addr as * const _
124
- as usize
123
+ {
124
+ let struct_instance =
125
+ unsafe { std:: mem:: zeroed:: <rte_ipv4_tuple>( ) } ;
126
+ let struct_ptr = & struct_instance as * const rte_ipv4_tuple;
127
+ let field_ptr = std:: ptr:: addr_of!( struct_instance. src_addr) ;
128
+ let struct_address = struct_ptr as usize ;
129
+ let field_address = field_ptr as usize ;
130
+ std:: mem:: forget( struct_instance) ;
131
+ field_address. checked_sub( struct_address) . unwrap( )
125
132
} ,
126
133
0usize ,
127
134
concat!(
@@ -132,9 +139,15 @@ fn bindgen_test_layout_rte_ipv4_tuple() {
132
139
)
133
140
) ;
134
141
assert_eq ! (
135
- unsafe {
136
- & ( * ( :: std:: ptr:: null:: <rte_ipv4_tuple>( ) ) ) . dst_addr as * const _
137
- as usize
142
+ {
143
+ let struct_instance =
144
+ unsafe { std:: mem:: zeroed:: <rte_ipv4_tuple>( ) } ;
145
+ let struct_ptr = & struct_instance as * const rte_ipv4_tuple;
146
+ let field_ptr = std:: ptr:: addr_of!( struct_instance. dst_addr) ;
147
+ let struct_address = struct_ptr as usize ;
148
+ let field_address = field_ptr as usize ;
149
+ std:: mem:: forget( struct_instance) ;
150
+ field_address. checked_sub( struct_address) . unwrap( )
138
151
} ,
139
152
4usize ,
140
153
concat!(
@@ -192,10 +205,17 @@ fn bindgen_test_layout_rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1() {
192
205
)
193
206
) ;
194
207
assert_eq ! (
195
- unsafe {
196
- & ( * ( :: std:: ptr:: null:: <rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1>(
197
- ) ) )
198
- . dport as * const _ as usize
208
+ {
209
+ let struct_instance = unsafe {
210
+ std:: mem:: zeroed:: <rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1>( )
211
+ } ;
212
+ let struct_ptr = & struct_instance
213
+ as * const rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1;
214
+ let field_ptr = std:: ptr:: addr_of!( struct_instance. dport) ;
215
+ let struct_address = struct_ptr as usize ;
216
+ let field_address = field_ptr as usize ;
217
+ std:: mem:: forget( struct_instance) ;
218
+ field_address. checked_sub( struct_address) . unwrap( )
199
219
} ,
200
220
0usize ,
201
221
concat!(
@@ -206,10 +226,17 @@ fn bindgen_test_layout_rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1() {
206
226
)
207
227
) ;
208
228
assert_eq ! (
209
- unsafe {
210
- & ( * ( :: std:: ptr:: null:: <rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1>(
211
- ) ) )
212
- . sport as * const _ as usize
229
+ {
230
+ let struct_instance = unsafe {
231
+ std:: mem:: zeroed:: <rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1>( )
232
+ } ;
233
+ let struct_ptr = & struct_instance
234
+ as * const rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1;
235
+ let field_ptr = std:: ptr:: addr_of!( struct_instance. sport) ;
236
+ let struct_address = struct_ptr as usize ;
237
+ let field_address = field_ptr as usize ;
238
+ std:: mem:: forget( struct_instance) ;
239
+ field_address. checked_sub( struct_address) . unwrap( )
213
240
} ,
214
241
2usize ,
215
242
concat!(
@@ -232,19 +259,6 @@ fn bindgen_test_layout_rte_ipv6_tuple__bindgen_ty_1() {
232
259
4usize ,
233
260
concat!( "Alignment of " , stringify!( rte_ipv6_tuple__bindgen_ty_1) )
234
261
) ;
235
- assert_eq ! (
236
- unsafe {
237
- & ( * ( :: std:: ptr:: null:: <rte_ipv6_tuple__bindgen_ty_1>( ) ) ) . sctp_tag
238
- as * const _ as usize
239
- } ,
240
- 0usize ,
241
- concat!(
242
- "Offset of field: " ,
243
- stringify!( rte_ipv6_tuple__bindgen_ty_1) ,
244
- "::" ,
245
- stringify!( sctp_tag)
246
- )
247
- ) ;
248
262
}
249
263
impl Default for rte_ipv6_tuple__bindgen_ty_1 {
250
264
fn default ( ) -> Self {
@@ -268,9 +282,15 @@ fn bindgen_test_layout_rte_ipv6_tuple() {
268
282
concat!( "Alignment of " , stringify!( rte_ipv6_tuple) )
269
283
) ;
270
284
assert_eq ! (
271
- unsafe {
272
- & ( * ( :: std:: ptr:: null:: <rte_ipv6_tuple>( ) ) ) . src_addr as * const _
273
- as usize
285
+ {
286
+ let struct_instance =
287
+ unsafe { std:: mem:: zeroed:: <rte_ipv6_tuple>( ) } ;
288
+ let struct_ptr = & struct_instance as * const rte_ipv6_tuple;
289
+ let field_ptr = std:: ptr:: addr_of!( struct_instance. src_addr) ;
290
+ let struct_address = struct_ptr as usize ;
291
+ let field_address = field_ptr as usize ;
292
+ std:: mem:: forget( struct_instance) ;
293
+ field_address. checked_sub( struct_address) . unwrap( )
274
294
} ,
275
295
0usize ,
276
296
concat!(
@@ -281,9 +301,15 @@ fn bindgen_test_layout_rte_ipv6_tuple() {
281
301
)
282
302
) ;
283
303
assert_eq ! (
284
- unsafe {
285
- & ( * ( :: std:: ptr:: null:: <rte_ipv6_tuple>( ) ) ) . dst_addr as * const _
286
- as usize
304
+ {
305
+ let struct_instance =
306
+ unsafe { std:: mem:: zeroed:: <rte_ipv6_tuple>( ) } ;
307
+ let struct_ptr = & struct_instance as * const rte_ipv6_tuple;
308
+ let field_ptr = std:: ptr:: addr_of!( struct_instance. dst_addr) ;
309
+ let struct_address = struct_ptr as usize ;
310
+ let field_address = field_ptr as usize ;
311
+ std:: mem:: forget( struct_instance) ;
312
+ field_address. checked_sub( struct_address) . unwrap( )
287
313
} ,
288
314
16usize ,
289
315
concat!(
@@ -322,30 +348,6 @@ fn bindgen_test_layout_rte_thash_tuple() {
322
348
16usize ,
323
349
concat!( "Alignment of " , stringify!( rte_thash_tuple) )
324
350
) ;
325
- assert_eq ! (
326
- unsafe {
327
- & ( * ( :: std:: ptr:: null:: <rte_thash_tuple>( ) ) ) . v4 as * const _ as usize
328
- } ,
329
- 0usize ,
330
- concat!(
331
- "Offset of field: " ,
332
- stringify!( rte_thash_tuple) ,
333
- "::" ,
334
- stringify!( v4)
335
- )
336
- ) ;
337
- assert_eq ! (
338
- unsafe {
339
- & ( * ( :: std:: ptr:: null:: <rte_thash_tuple>( ) ) ) . v6 as * const _ as usize
340
- } ,
341
- 0usize ,
342
- concat!(
343
- "Offset of field: " ,
344
- stringify!( rte_thash_tuple) ,
345
- "::" ,
346
- stringify!( v6)
347
- )
348
- ) ;
349
351
}
350
352
impl Default for rte_thash_tuple {
351
353
fn default ( ) -> Self {
0 commit comments