@@ -15,11 +15,72 @@ 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
+ pub mBConstBool : B < bool > ,
39
+ pub mBConstChar : B < u16 > ,
40
+ }
41
+ #[ test]
42
+ fn bindgen_test_layout_C ( ) {
43
+ assert_eq ! ( :: std:: mem:: size_of:: <C >( ) , 32usize , concat ! (
44
+ "Size of: " , stringify ! ( C ) ) ) ;
45
+ assert_eq ! ( :: std:: mem:: align_of:: <C >( ) , 8usize , concat ! (
46
+ "Alignment of " , stringify ! ( C ) ) ) ;
47
+ assert_eq ! ( unsafe { & ( * ( 0 as * const C ) ) . mB as * const _ as usize
48
+ } , 0usize , concat ! (
49
+ "Alignment of field: " , stringify ! ( C ) , "::" , stringify
50
+ ! ( mB ) ) ) ;
51
+ assert_eq ! ( unsafe {
52
+ & ( * ( 0 as * const C ) ) . mBConstPtr as * const _ as usize
53
+ } , 8usize , concat ! (
54
+ "Alignment of field: " , stringify ! ( C ) , "::" , stringify
55
+ ! ( mBConstPtr ) ) ) ;
56
+ assert_eq ! ( unsafe {
57
+ & ( * ( 0 as * const C ) ) . mBConst as * const _ as usize } ,
58
+ 16usize , concat ! (
59
+ "Alignment of field: " , stringify ! ( C ) , "::" , stringify
60
+ ! ( mBConst ) ) ) ;
61
+ assert_eq ! ( unsafe {
62
+ & ( * ( 0 as * const C ) ) . mBVolatile as * const _ as usize
63
+ } , 20usize , concat ! (
64
+ "Alignment of field: " , stringify ! ( C ) , "::" , stringify
65
+ ! ( mBVolatile ) ) ) ;
66
+ assert_eq ! ( unsafe {
67
+ & ( * ( 0 as * const C ) ) . mBConstBool as * const _ as usize
68
+ } , 24usize , concat ! (
69
+ "Alignment of field: " , stringify ! ( C ) , "::" , stringify
70
+ ! ( mBConstBool ) ) ) ;
71
+ assert_eq ! ( unsafe {
72
+ & ( * ( 0 as * const C ) ) . mBConstChar as * const _ as usize
73
+ } , 26usize , concat ! (
74
+ "Alignment of field: " , stringify ! ( C ) , "::" , stringify
75
+ ! ( mBConstChar ) ) ) ;
76
+ }
77
+ impl Clone for C {
78
+ fn clone ( & self ) -> Self { * self }
79
+ }
80
+ impl Default for C {
81
+ fn default ( ) -> Self { unsafe { :: std:: mem:: zeroed ( ) } }
82
+ }
83
+ #[ repr( C ) ]
23
84
#[ derive( Debug ) ]
24
85
pub struct D {
25
86
pub m_foo : D_MyFoo ,
@@ -245,6 +306,68 @@ fn __bindgen_test_layout_Foo_open0_int_int_close0_instantiation() {
245
306
Foo <:: std:: os:: raw:: c_int> ) ) ) ;
246
307
}
247
308
#[ test]
309
+ fn __bindgen_test_layout_B_open0_unsigned_int_close0_instantiation ( ) {
310
+ assert_eq ! ( :: std:: mem:: size_of:: <B <:: std:: os:: raw:: c_uint>>( ) , 4usize ,
311
+ concat ! (
312
+ "Size of template specialization: " , stringify ! (
313
+ B <:: std:: os:: raw:: c_uint> ) ) ) ;
314
+ assert_eq ! ( :: std:: mem:: align_of:: <B <:: std:: os:: raw:: c_uint>>( ) , 4usize ,
315
+ concat ! (
316
+ "Alignment of template specialization: " , stringify ! (
317
+ B <:: std:: os:: raw:: c_uint> ) ) ) ;
318
+ }
319
+ #[ test]
320
+ fn __bindgen_test_layout_B_open0__bindgen_ty_id_113_close0_instantiation ( ) {
321
+ assert_eq ! ( :: std:: mem:: size_of:: <B <* const :: std:: os:: raw:: c_int>>( ) ,
322
+ 8usize , concat ! (
323
+ "Size of template specialization: " , stringify ! (
324
+ B <* const :: std:: os:: raw:: c_int> ) ) ) ;
325
+ assert_eq ! ( :: std:: mem:: align_of:: <B <* const :: std:: os:: raw:: c_int>>( ) ,
326
+ 8usize , concat ! (
327
+ "Alignment of template specialization: " , stringify ! (
328
+ B <* const :: std:: os:: raw:: c_int> ) ) ) ;
329
+ }
330
+ #[ test]
331
+ fn __bindgen_test_layout_B_open0_const_int_close0_instantiation ( ) {
332
+ assert_eq ! ( :: std:: mem:: size_of:: <B <:: std:: os:: raw:: c_int>>( ) , 4usize ,
333
+ concat ! (
334
+ "Size of template specialization: " , stringify ! (
335
+ B <:: std:: os:: raw:: c_int> ) ) ) ;
336
+ assert_eq ! ( :: std:: mem:: align_of:: <B <:: std:: os:: raw:: c_int>>( ) , 4usize ,
337
+ concat ! (
338
+ "Alignment of template specialization: " , stringify ! (
339
+ B <:: std:: os:: raw:: c_int> ) ) ) ;
340
+ }
341
+ #[ test]
342
+ fn __bindgen_test_layout_B_open0_volatile_int_close0_instantiation ( ) {
343
+ assert_eq ! ( :: std:: mem:: size_of:: <B <:: std:: os:: raw:: c_int>>( ) , 4usize ,
344
+ concat ! (
345
+ "Size of template specialization: " , stringify ! (
346
+ B <:: std:: os:: raw:: c_int> ) ) ) ;
347
+ assert_eq ! ( :: std:: mem:: align_of:: <B <:: std:: os:: raw:: c_int>>( ) , 4usize ,
348
+ concat ! (
349
+ "Alignment of template specialization: " , stringify ! (
350
+ B <:: std:: os:: raw:: c_int> ) ) ) ;
351
+ }
352
+ #[ test]
353
+ fn __bindgen_test_layout_B_open0_const_bool_close0_instantiation ( ) {
354
+ assert_eq ! ( :: std:: mem:: size_of:: <B <bool >>( ) , 1usize , concat ! (
355
+ "Size of template specialization: " , stringify ! ( B <bool > )
356
+ ) ) ;
357
+ assert_eq ! ( :: std:: mem:: align_of:: <B <bool >>( ) , 1usize , concat ! (
358
+ "Alignment of template specialization: " , stringify ! (
359
+ B <bool > ) ) ) ;
360
+ }
361
+ #[ test]
362
+ fn __bindgen_test_layout_B_open0_const_char16_t_close0_instantiation ( ) {
363
+ assert_eq ! ( :: std:: mem:: size_of:: <B <u16 >>( ) , 2usize , concat ! (
364
+ "Size of template specialization: " , stringify ! ( B <u16 > )
365
+ ) ) ;
366
+ assert_eq ! ( :: std:: mem:: align_of:: <B <u16 >>( ) , 2usize , concat ! (
367
+ "Alignment of template specialization: " , stringify ! ( B <u16 >
368
+ ) ) ) ;
369
+ }
370
+ #[ test]
248
371
fn __bindgen_test_layout_Foo_open0_int_int_close0_instantiation_1 ( ) {
249
372
assert_eq ! ( :: std:: mem:: size_of:: <Foo <:: std:: os:: raw:: c_int>>( ) , 24usize ,
250
373
concat ! (
@@ -256,7 +379,7 @@ fn __bindgen_test_layout_Foo_open0_int_int_close0_instantiation_1() {
256
379
Foo <:: std:: os:: raw:: c_int> ) ) ) ;
257
380
}
258
381
#[ test]
259
- fn __bindgen_test_layout_Rooted_open0__bindgen_ty_id_108_close0_instantiation ( ) {
382
+ fn __bindgen_test_layout_Rooted_open0__bindgen_ty_id_144_close0_instantiation ( ) {
260
383
assert_eq ! ( :: std:: mem:: size_of:: <Rooted <* mut :: std:: os:: raw:: c_void>>( ) ,
261
384
24usize , concat ! (
262
385
"Size of template specialization: " , stringify ! (
@@ -267,7 +390,7 @@ fn __bindgen_test_layout_Rooted_open0__bindgen_ty_id_108_close0_instantiation()
267
390
Rooted <* mut :: std:: os:: raw:: c_void> ) ) ) ;
268
391
}
269
392
#[ test]
270
- fn __bindgen_test_layout_Rooted_open0__bindgen_ty_id_114_close0_instantiation ( ) {
393
+ fn __bindgen_test_layout_Rooted_open0__bindgen_ty_id_150_close0_instantiation ( ) {
271
394
assert_eq ! ( :: std:: mem:: size_of:: <Rooted <* mut :: std:: os:: raw:: c_void>>( ) ,
272
395
24usize , concat ! (
273
396
"Size of template specialization: " , stringify ! (
0 commit comments