@@ -15,11 +15,60 @@ pub struct Foo<T> {
15
15
impl < T > Default for Foo < T > {
16
16
fn default ( ) -> Self { unsafe { :: std:: mem:: zeroed ( ) } }
17
17
}
18
+ #[ repr( C ) ]
19
+ #[ derive( Debug , Copy , Clone ) ]
20
+ pub struct B < T > {
21
+ pub m_member : T ,
22
+ pub _phantom_0 : :: std:: marker:: PhantomData < :: std:: cell:: UnsafeCell < T > > ,
23
+ }
24
+ impl < T > Default for B < T > {
25
+ fn default ( ) -> Self { unsafe { :: std:: mem:: zeroed ( ) } }
26
+ }
18
27
extern "C" {
19
28
#[ link_name = "_Z3bar3FooIiiE" ]
20
29
pub fn bar ( foo : Foo < :: std:: os:: raw:: c_int > ) ;
21
30
}
22
31
#[ repr( C ) ]
32
+ #[ derive( Debug , Copy ) ]
33
+ pub struct C {
34
+ pub mB : B < :: std:: os:: raw:: c_uint > ,
35
+ pub mBConstPtr : B < * const :: std:: os:: raw:: c_int > ,
36
+ pub mBConst : B < :: std:: os:: raw:: c_int > ,
37
+ pub mBVolatile : B < :: std:: os:: raw:: c_int > ,
38
+ }
39
+ #[ test]
40
+ fn bindgen_test_layout_C ( ) {
41
+ assert_eq ! ( :: std:: mem:: size_of:: <C >( ) , 24usize , concat ! (
42
+ "Size of: " , stringify ! ( C ) ) ) ;
43
+ assert_eq ! ( :: std:: mem:: align_of:: <C >( ) , 8usize , concat ! (
44
+ "Alignment of " , stringify ! ( C ) ) ) ;
45
+ assert_eq ! ( unsafe { & ( * ( 0 as * const C ) ) . mB as * const _ as usize
46
+ } , 0usize , concat ! (
47
+ "Alignment of field: " , stringify ! ( C ) , "::" , stringify
48
+ ! ( mB ) ) ) ;
49
+ assert_eq ! ( unsafe {
50
+ & ( * ( 0 as * const C ) ) . mBConstPtr as * const _ as usize
51
+ } , 8usize , concat ! (
52
+ "Alignment of field: " , stringify ! ( C ) , "::" , stringify
53
+ ! ( mBConstPtr ) ) ) ;
54
+ assert_eq ! ( unsafe {
55
+ & ( * ( 0 as * const C ) ) . mBConst as * const _ as usize } ,
56
+ 16usize , concat ! (
57
+ "Alignment of field: " , stringify ! ( C ) , "::" , stringify
58
+ ! ( mBConst ) ) ) ;
59
+ assert_eq ! ( unsafe {
60
+ & ( * ( 0 as * const C ) ) . mBVolatile as * const _ as usize
61
+ } , 20usize , concat ! (
62
+ "Alignment of field: " , stringify ! ( C ) , "::" , stringify
63
+ ! ( mBVolatile ) ) ) ;
64
+ }
65
+ impl Clone for C {
66
+ fn clone ( & self ) -> Self { * self }
67
+ }
68
+ impl Default for C {
69
+ fn default ( ) -> Self { unsafe { :: std:: mem:: zeroed ( ) } }
70
+ }
71
+ #[ repr( C ) ]
23
72
#[ derive( Debug ) ]
24
73
pub struct D {
25
74
pub m_foo : D_MyFoo ,
@@ -245,6 +294,50 @@ fn __bindgen_test_layout_Foo_open0_int_int_close0_instantiation() {
245
294
Foo <:: std:: os:: raw:: c_int> ) ) ) ;
246
295
}
247
296
#[ test]
297
+ fn __bindgen_test_layout_B_open0_unsigned_int_close0_instantiation ( ) {
298
+ assert_eq ! ( :: std:: mem:: size_of:: <B <:: std:: os:: raw:: c_uint>>( ) , 4usize ,
299
+ concat ! (
300
+ "Size of template specialization: " , stringify ! (
301
+ B <:: std:: os:: raw:: c_uint> ) ) ) ;
302
+ assert_eq ! ( :: std:: mem:: align_of:: <B <:: std:: os:: raw:: c_uint>>( ) , 4usize ,
303
+ concat ! (
304
+ "Alignment of template specialization: " , stringify ! (
305
+ B <:: std:: os:: raw:: c_uint> ) ) ) ;
306
+ }
307
+ #[ test]
308
+ fn __bindgen_test_layout_B_open0__bindgen_ty_id_111_close0_instantiation ( ) {
309
+ assert_eq ! ( :: std:: mem:: size_of:: <B <* const :: std:: os:: raw:: c_int>>( ) ,
310
+ 8usize , concat ! (
311
+ "Size of template specialization: " , stringify ! (
312
+ B <* const :: std:: os:: raw:: c_int> ) ) ) ;
313
+ assert_eq ! ( :: std:: mem:: align_of:: <B <* const :: std:: os:: raw:: c_int>>( ) ,
314
+ 8usize , concat ! (
315
+ "Alignment of template specialization: " , stringify ! (
316
+ B <* const :: std:: os:: raw:: c_int> ) ) ) ;
317
+ }
318
+ #[ test]
319
+ fn __bindgen_test_layout_B_open0_int_close0_instantiation ( ) {
320
+ assert_eq ! ( :: std:: mem:: size_of:: <B <:: std:: os:: raw:: c_int>>( ) , 4usize ,
321
+ concat ! (
322
+ "Size of template specialization: " , stringify ! (
323
+ B <:: std:: os:: raw:: c_int> ) ) ) ;
324
+ assert_eq ! ( :: std:: mem:: align_of:: <B <:: std:: os:: raw:: c_int>>( ) , 4usize ,
325
+ concat ! (
326
+ "Alignment of template specialization: " , stringify ! (
327
+ B <:: std:: os:: raw:: c_int> ) ) ) ;
328
+ }
329
+ #[ test]
330
+ fn __bindgen_test_layout_B_open0_int_close0_instantiation_1 ( ) {
331
+ assert_eq ! ( :: std:: mem:: size_of:: <B <:: std:: os:: raw:: c_int>>( ) , 4usize ,
332
+ concat ! (
333
+ "Size of template specialization: " , stringify ! (
334
+ B <:: std:: os:: raw:: c_int> ) ) ) ;
335
+ assert_eq ! ( :: std:: mem:: align_of:: <B <:: std:: os:: raw:: c_int>>( ) , 4usize ,
336
+ concat ! (
337
+ "Alignment of template specialization: " , stringify ! (
338
+ B <:: std:: os:: raw:: c_int> ) ) ) ;
339
+ }
340
+ #[ test]
248
341
fn __bindgen_test_layout_Foo_open0_int_int_close0_instantiation_1 ( ) {
249
342
assert_eq ! ( :: std:: mem:: size_of:: <Foo <:: std:: os:: raw:: c_int>>( ) , 24usize ,
250
343
concat ! (
@@ -256,7 +349,7 @@ fn __bindgen_test_layout_Foo_open0_int_int_close0_instantiation_1() {
256
349
Foo <:: std:: os:: raw:: c_int> ) ) ) ;
257
350
}
258
351
#[ test]
259
- fn __bindgen_test_layout_Rooted_open0__bindgen_ty_id_108_close0_instantiation ( ) {
352
+ fn __bindgen_test_layout_Rooted_open0__bindgen_ty_id_134_close0_instantiation ( ) {
260
353
assert_eq ! ( :: std:: mem:: size_of:: <Rooted <* mut :: std:: os:: raw:: c_void>>( ) ,
261
354
24usize , concat ! (
262
355
"Size of template specialization: " , stringify ! (
@@ -267,7 +360,7 @@ fn __bindgen_test_layout_Rooted_open0__bindgen_ty_id_108_close0_instantiation()
267
360
Rooted <* mut :: std:: os:: raw:: c_void> ) ) ) ;
268
361
}
269
362
#[ test]
270
- fn __bindgen_test_layout_Rooted_open0__bindgen_ty_id_114_close0_instantiation ( ) {
363
+ fn __bindgen_test_layout_Rooted_open0__bindgen_ty_id_140_close0_instantiation ( ) {
271
364
assert_eq ! ( :: std:: mem:: size_of:: <Rooted <* mut :: std:: os:: raw:: c_void>>( ) ,
272
365
24usize , concat ! (
273
366
"Size of template specialization: " , stringify ! (
0 commit comments