diff options
36 files changed, 201 insertions, 73 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 031efe67..fbbf29c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,53 +9,56 @@ - [Removed](#removed) - [Fixed](#fixed) - [Security](#security) -- [0.47.3](#0473) +- [0.48.0](#0480) - [Changed](#changed-1) -- [0.47.2](#0472) - [Fixed](#fixed-1) -- [0.47.1](#0471) +- [0.47.3](#0473) - [Changed](#changed-2) +- [0.47.2](#0472) - [Fixed](#fixed-2) -- [0.47.0](#0470) +- [0.47.1](#0471) - [Changed](#changed-3) - [Fixed](#fixed-3) +- [0.47.0](#0470) + - [Changed](#changed-4) + - [Fixed](#fixed-4) - [0.33.1 .. 0.46.0](#0331--0460) - [Added](#added-1) - [Removed](#removed-1) - - [Changed](#changed-4) - - [Fixed](#fixed-4) -- [0.33.1](#0331) + - [Changed](#changed-5) - [Fixed](#fixed-5) +- [0.33.1](#0331) + - [Fixed](#fixed-6) - [0.33.0](#0330) - [Added](#added-2) - - [Changed](#changed-5) + - [Changed](#changed-6) - [Deprecated](#deprecated-1) - [Removed](#removed-2) - - [Fixed](#fixed-6) + - [Fixed](#fixed-7) - [Security](#security-1) - [0.32.2](#0322) - - [Fixed](#fixed-7) -- [0.32.1](#0321) - [Fixed](#fixed-8) +- [0.32.1](#0321) + - [Fixed](#fixed-9) - [0.32.0](#0320) - [Added](#added-3) - - [Changed](#changed-6) - - [Fixed](#fixed-9) + - [Changed](#changed-7) + - [Fixed](#fixed-10) - [0.31.0](#0310) - [Added](#added-4) - - [Changed](#changed-7) + - [Changed](#changed-8) - [Deprecated](#deprecated-2) - [Removed](#removed-3) - - [Fixed](#fixed-10) + - [Fixed](#fixed-11) - [0.30.0](#0300) - [Added](#added-5) - - [Changed](#changed-8) + - [Changed](#changed-9) - [Deprecated](#deprecated-3) - - [Fixed](#fixed-11) + - [Fixed](#fixed-12) - [0.29.0](#0290) - [Added](#added-6) - - [Changed](#changed-9) - - [Fixed](#fixed-12) + - [Changed](#changed-10) + - [Fixed](#fixed-13) <!-- END doctoc generated TOC please keep comment here to allow auto update --> @@ -101,7 +104,12 @@ Released 2019/03/04 * Default rust target was changed to 1.33, which means that bindgen can get much more often the layout of structs right. [#1529][] +## Fixed + +* Bindgen will output repr(align) just when needed for unions. [#1498][] + [#1529]: https://github.com/rust-lang-nursery/rust-bindgen/issues/1529 +[#1498]: https://github.com/rust-lang-nursery/rust-bindgen/issues/1498 -------------------------------------------------------------------------------- diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 2d71942c..d7f98c13 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -1589,6 +1589,7 @@ impl CodeGenerator for CompInfo { // TODO(emilio): It'd be nice to unify this with the struct path // above somehow. let layout = layout.expect("Unable to get layout information?"); + struct_layout.saw_union(layout); if struct_layout.requires_explicit_align(layout) { explicit_align = Some(layout.align); @@ -1600,8 +1601,6 @@ impl CodeGenerator for CompInfo { _bindgen_union_align: #ty , } } else { - struct_layout.saw_union(layout); - quote! { pub bindgen_union_field: #ty , } diff --git a/src/codegen/struct_layout.rs b/src/codegen/struct_layout.rs index 921ab215..29d281aa 100644 --- a/src/codegen/struct_layout.rs +++ b/src/codegen/struct_layout.rs @@ -85,9 +85,9 @@ impl<'a> StructLayoutTracker<'a> { name: &'a str, ) -> Self { StructLayoutTracker { - name: name, - ctx: ctx, - comp: comp, + name, + ctx, + comp, is_packed: comp.is_packed(ctx, &ty.layout(ctx)), latest_offset: 0, padding_count: 0, diff --git a/tests/expectations/tests/16-byte-alignment.rs b/tests/expectations/tests/16-byte-alignment.rs index 9f19d212..3a9e8998 100644 --- a/tests/expectations/tests/16-byte-alignment.rs +++ b/tests/expectations/tests/16-byte-alignment.rs @@ -15,7 +15,6 @@ pub struct rte_ipv4_tuple { pub __bindgen_anon_1: rte_ipv4_tuple__bindgen_ty_1, } #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union rte_ipv4_tuple__bindgen_ty_1 { pub __bindgen_anon_1: rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1, @@ -149,7 +148,6 @@ pub struct rte_ipv6_tuple { pub __bindgen_anon_1: rte_ipv6_tuple__bindgen_ty_1, } #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union rte_ipv6_tuple__bindgen_ty_1 { pub __bindgen_anon_1: rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1, diff --git a/tests/expectations/tests/anon_struct_in_union.rs b/tests/expectations/tests/anon_struct_in_union.rs index 40c56b9a..5b5ed43c 100644 --- a/tests/expectations/tests/anon_struct_in_union.rs +++ b/tests/expectations/tests/anon_struct_in_union.rs @@ -13,7 +13,6 @@ pub struct s { pub u: s__bindgen_ty_1, } #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union s__bindgen_ty_1 { pub field: s__bindgen_ty_1_inner, diff --git a/tests/expectations/tests/anon_union.rs b/tests/expectations/tests/anon_union.rs index c086e738..a9b60292 100644 --- a/tests/expectations/tests/anon_union.rs +++ b/tests/expectations/tests/anon_union.rs @@ -33,7 +33,6 @@ pub struct TErrorResult_DOMExceptionInfo { _unused: [u8; 0], } #[repr(C)] -#[repr(align(8))] pub union TErrorResult__bindgen_ty_1 { pub mMessage: *mut TErrorResult_Message, pub mDOMExceptionInfo: *mut TErrorResult_DOMExceptionInfo, diff --git a/tests/expectations/tests/class.rs b/tests/expectations/tests/class.rs index 3fda629b..f52f0f85 100644 --- a/tests/expectations/tests/class.rs +++ b/tests/expectations/tests/class.rs @@ -335,7 +335,6 @@ impl Default for IncompleteArrayNonCopiable { } } #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union Union { pub d: f32, diff --git a/tests/expectations/tests/class_with_inner_struct.rs b/tests/expectations/tests/class_with_inner_struct.rs index d055cfbc..577dec6f 100644 --- a/tests/expectations/tests/class_with_inner_struct.rs +++ b/tests/expectations/tests/class_with_inner_struct.rs @@ -54,7 +54,6 @@ fn bindgen_test_layout_A_Segment() { ); } #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union A__bindgen_ty_1 { pub f: ::std::os::raw::c_int, @@ -89,7 +88,6 @@ impl Default for A__bindgen_ty_1 { } } #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union A__bindgen_ty_2 { pub d: ::std::os::raw::c_int, @@ -233,7 +231,6 @@ pub struct C { pub __bindgen_anon_1: C__bindgen_ty_1, } #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union C__bindgen_ty_1 { pub mFunc: C__bindgen_ty_1__bindgen_ty_1, diff --git a/tests/expectations/tests/derive-debug-mangle-name.rs b/tests/expectations/tests/derive-debug-mangle-name.rs index ca9e7e21..9c72fbbd 100644 --- a/tests/expectations/tests/derive-debug-mangle-name.rs +++ b/tests/expectations/tests/derive-debug-mangle-name.rs @@ -15,7 +15,6 @@ pub struct perf_event_attr { pub __bindgen_anon_1: perf_event_attr__bindgen_ty_1, } #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union perf_event_attr__bindgen_ty_1 { pub b: ::std::os::raw::c_int, diff --git a/tests/expectations/tests/derive-partialeq-anonfield.rs b/tests/expectations/tests/derive-partialeq-anonfield.rs index 1d38b0b6..b5cb1593 100644 --- a/tests/expectations/tests/derive-partialeq-anonfield.rs +++ b/tests/expectations/tests/derive-partialeq-anonfield.rs @@ -14,7 +14,6 @@ pub struct rte_mbuf { pub __bindgen_anon_1: rte_mbuf__bindgen_ty_1, } #[repr(C)] -#[repr(align(1))] #[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_1 { _bindgen_union_align: [u8; 0usize], diff --git a/tests/expectations/tests/derive-partialeq-pointer.rs b/tests/expectations/tests/derive-partialeq-pointer.rs index ea1b88a2..2ac23c81 100644 --- a/tests/expectations/tests/derive-partialeq-pointer.rs +++ b/tests/expectations/tests/derive-partialeq-pointer.rs @@ -41,7 +41,6 @@ pub struct c { pub __bindgen_anon_1: c__bindgen_ty_1, } #[repr(C)] -#[repr(align(1))] #[derive(Copy, Clone)] pub union c__bindgen_ty_1 { _bindgen_union_align: u8, diff --git a/tests/expectations/tests/derive-partialeq-union.rs b/tests/expectations/tests/derive-partialeq-union.rs index 5adbca1f..a271f410 100644 --- a/tests/expectations/tests/derive-partialeq-union.rs +++ b/tests/expectations/tests/derive-partialeq-union.rs @@ -9,7 +9,6 @@ /// Deriving PartialEq for rust unions is not supported. #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union ShouldNotDerivePartialEq { pub a: ::std::os::raw::c_char, diff --git a/tests/expectations/tests/issue-1285.rs b/tests/expectations/tests/issue-1285.rs index 666f6175..77df620b 100644 --- a/tests/expectations/tests/issue-1285.rs +++ b/tests/expectations/tests/issue-1285.rs @@ -12,7 +12,6 @@ pub struct foo { pub bar: foo__bindgen_ty_1, } #[repr(C)] -#[repr(align(4))] pub union foo__bindgen_ty_1 { pub a: ::std::os::raw::c_uint, pub b: ::std::os::raw::c_ushort, diff --git a/tests/expectations/tests/issue-1498.rs b/tests/expectations/tests/issue-1498.rs new file mode 100644 index 00000000..0f9ef680 --- /dev/null +++ b/tests/expectations/tests/issue-1498.rs @@ -0,0 +1,153 @@ +/* automatically generated by rust-bindgen */ + +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] + +#[repr(C, packed)] +#[derive(Copy, Clone)] +pub struct rte_memseg { + ///< Start physical address. + pub phys_addr: u64, + pub __bindgen_anon_1: rte_memseg__bindgen_ty_1, + ///< Length of the segment. + pub len: usize, + ///< The pagesize of underlying memory + pub hugepage_sz: u64, + ///< NUMA socket ID. + pub socket_id: i32, + ///< Number of channels. + pub nchannel: u32, + ///< Number of ranks. + pub nrank: u32, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union rte_memseg__bindgen_ty_1 { + ///< Start virtual address. + pub addr: *mut ::std::os::raw::c_void, + ///< Makes sure addr is always 64 bits + pub addr_64: u64, + _bindgen_union_align: u64, +} +#[test] +fn bindgen_test_layout_rte_memseg__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<rte_memseg__bindgen_ty_1>(), + 8usize, + concat!("Size of: ", stringify!(rte_memseg__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<rte_memseg__bindgen_ty_1>(), + 8usize, + concat!("Alignment of ", stringify!(rte_memseg__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<rte_memseg__bindgen_ty_1>())).addr as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_memseg__bindgen_ty_1), + "::", + stringify!(addr) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<rte_memseg__bindgen_ty_1>())).addr_64 as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_memseg__bindgen_ty_1), + "::", + stringify!(addr_64) + ) + ); +} +impl Default for rte_memseg__bindgen_ty_1 { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[test] +fn bindgen_test_layout_rte_memseg() { + assert_eq!( + ::std::mem::size_of::<rte_memseg>(), + 44usize, + concat!("Size of: ", stringify!(rte_memseg)) + ); + assert_eq!( + ::std::mem::align_of::<rte_memseg>(), + 1usize, + concat!("Alignment of ", stringify!(rte_memseg)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<rte_memseg>())).phys_addr as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_memseg), + "::", + stringify!(phys_addr) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<rte_memseg>())).len as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_memseg), + "::", + stringify!(len) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<rte_memseg>())).hugepage_sz as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rte_memseg), + "::", + stringify!(hugepage_sz) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<rte_memseg>())).socket_id as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(rte_memseg), + "::", + stringify!(socket_id) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<rte_memseg>())).nchannel as *const _ as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(rte_memseg), + "::", + stringify!(nchannel) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<rte_memseg>())).nrank as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(rte_memseg), + "::", + stringify!(nrank) + ) + ); +} +impl Default for rte_memseg { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} diff --git a/tests/expectations/tests/issue-493.rs b/tests/expectations/tests/issue-493.rs index 02ed7ed7..e7e5c557 100644 --- a/tests/expectations/tests/issue-493.rs +++ b/tests/expectations/tests/issue-493.rs @@ -83,7 +83,6 @@ pub struct basic_string___short { pub __data_: *mut basic_string_value_type, } #[repr(C)] -#[repr(align(1))] pub union basic_string___short__bindgen_ty_1 { pub __size_: ::std::os::raw::c_uchar, pub __lx: basic_string_value_type, diff --git a/tests/expectations/tests/jsval_layout_opaque.rs b/tests/expectations/tests/jsval_layout_opaque.rs index 9ea5e5c0..aa0420aa 100644 --- a/tests/expectations/tests/jsval_layout_opaque.rs +++ b/tests/expectations/tests/jsval_layout_opaque.rs @@ -176,7 +176,6 @@ pub enum JSWhyMagic { JS_WHY_MAGIC_COUNT = 18, } #[repr(C)] -#[repr(align(8))] #[derive(Copy, Clone)] pub union jsval_layout { pub asBits: u64, @@ -259,7 +258,6 @@ pub struct jsval_layout__bindgen_ty_2 { pub payload: jsval_layout__bindgen_ty_2__bindgen_ty_1, } #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union jsval_layout__bindgen_ty_2__bindgen_ty_1 { pub i32: i32, diff --git a/tests/expectations/tests/layout_eth_conf.rs b/tests/expectations/tests/layout_eth_conf.rs index 734839fc..5582c7de 100644 --- a/tests/expectations/tests/layout_eth_conf.rs +++ b/tests/expectations/tests/layout_eth_conf.rs @@ -1830,7 +1830,6 @@ impl Default for rte_eth_conf__bindgen_ty_1 { } } #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union rte_eth_conf__bindgen_ty_2 { pub vmdq_dcb_tx_conf: rte_eth_vmdq_dcb_tx_conf, diff --git a/tests/expectations/tests/layout_mbuf.rs b/tests/expectations/tests/layout_mbuf.rs index 8bfda72d..6ed1d130 100644 --- a/tests/expectations/tests/layout_mbuf.rs +++ b/tests/expectations/tests/layout_mbuf.rs @@ -180,7 +180,6 @@ pub struct rte_mbuf { /// or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC /// config option. #[repr(C)] -#[repr(align(2))] #[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_1 { ///< Atomically accessed refcnt @@ -230,7 +229,6 @@ impl Default for rte_mbuf__bindgen_ty_1 { } } #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_2 { ///< L2/L3/L4 and tunnel information. @@ -415,7 +413,6 @@ impl Default for rte_mbuf__bindgen_ty_2 { } } #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_3 { ///< RSS hash result if RSS enabled @@ -435,7 +432,6 @@ pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_1 { pub hi: u32, } #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 { pub __bindgen_anon_1: rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1, @@ -672,7 +668,6 @@ impl Default for rte_mbuf__bindgen_ty_3 { } } #[repr(C)] -#[repr(align(8))] #[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_4 { ///< Can be used for external metadata @@ -720,7 +715,6 @@ impl Default for rte_mbuf__bindgen_ty_4 { } } #[repr(C)] -#[repr(align(8))] #[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_5 { ///< combined for easy fetch diff --git a/tests/expectations/tests/struct_with_anon_union.rs b/tests/expectations/tests/struct_with_anon_union.rs index 2279853f..d0328d34 100644 --- a/tests/expectations/tests/struct_with_anon_union.rs +++ b/tests/expectations/tests/struct_with_anon_union.rs @@ -13,7 +13,6 @@ pub struct foo { pub bar: foo__bindgen_ty_1, } #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union foo__bindgen_ty_1 { pub a: ::std::os::raw::c_uint, diff --git a/tests/expectations/tests/struct_with_anon_unnamed_union.rs b/tests/expectations/tests/struct_with_anon_unnamed_union.rs index 90ee13e4..abb0bd3f 100644 --- a/tests/expectations/tests/struct_with_anon_unnamed_union.rs +++ b/tests/expectations/tests/struct_with_anon_unnamed_union.rs @@ -13,7 +13,6 @@ pub struct foo { pub __bindgen_anon_1: foo__bindgen_ty_1, } #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union foo__bindgen_ty_1 { pub a: ::std::os::raw::c_uint, diff --git a/tests/expectations/tests/struct_with_nesting.rs b/tests/expectations/tests/struct_with_nesting.rs index ddbbe778..73787d86 100644 --- a/tests/expectations/tests/struct_with_nesting.rs +++ b/tests/expectations/tests/struct_with_nesting.rs @@ -14,7 +14,6 @@ pub struct foo { pub __bindgen_anon_1: foo__bindgen_ty_1, } #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union foo__bindgen_ty_1 { pub b: ::std::os::raw::c_uint, diff --git a/tests/expectations/tests/typeref.rs b/tests/expectations/tests/typeref.rs index b0f1290d..3a76d514 100644 --- a/tests/expectations/tests/typeref.rs +++ b/tests/expectations/tests/typeref.rs @@ -60,7 +60,6 @@ pub struct mozilla_StyleShapeSource { pub __bindgen_anon_1: mozilla_StyleShapeSource__bindgen_ty_1, } #[repr(C)] -#[repr(align(8))] pub union mozilla_StyleShapeSource__bindgen_ty_1 { pub mPosition: *mut mozilla_Position, pub mFragmentOrURL: *mut mozilla_FragmentOrURL, diff --git a/tests/expectations/tests/union-in-ns.rs b/tests/expectations/tests/union-in-ns.rs index c3b541a2..b0d3ac9c 100644 --- a/tests/expectations/tests/union-in-ns.rs +++ b/tests/expectations/tests/union-in-ns.rs @@ -12,7 +12,6 @@ pub mod root { #[allow(unused_imports)] use self::super::root; #[repr(C)] - #[repr(align(4))] #[derive(Copy, Clone)] pub union bar { pub baz: ::std::os::raw::c_int, diff --git a/tests/expectations/tests/union_bitfield.rs b/tests/expectations/tests/union_bitfield.rs index d3a94b10..d6f52ef5 100644 --- a/tests/expectations/tests/union_bitfield.rs +++ b/tests/expectations/tests/union_bitfield.rs @@ -90,7 +90,6 @@ where } } #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union U4 { pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>, @@ -138,7 +137,6 @@ impl U4 { } } #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union B { pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize], u32>, diff --git a/tests/expectations/tests/union_dtor.rs b/tests/expectations/tests/union_dtor.rs index ee6e4e22..1a3ad716 100644 --- a/tests/expectations/tests/union_dtor.rs +++ b/tests/expectations/tests/union_dtor.rs @@ -8,7 +8,6 @@ )] #[repr(C)] -#[repr(align(8))] pub union UnionWithDtor { pub mFoo: ::std::os::raw::c_int, pub mBar: *mut ::std::os::raw::c_void, diff --git a/tests/expectations/tests/union_fields.rs b/tests/expectations/tests/union_fields.rs index 40e374cf..e6f4e229 100644 --- a/tests/expectations/tests/union_fields.rs +++ b/tests/expectations/tests/union_fields.rs @@ -8,7 +8,6 @@ )] #[repr(C)] -#[repr(align(8))] #[derive(Copy, Clone)] pub union nsStyleUnion { pub mInt: ::std::os::raw::c_int, diff --git a/tests/expectations/tests/union_template.rs b/tests/expectations/tests/union_template.rs index eea3b0e5..a8af8b9c 100644 --- a/tests/expectations/tests/union_template.rs +++ b/tests/expectations/tests/union_template.rs @@ -14,7 +14,6 @@ pub struct NastyStruct { pub __bindgen_anon_1: NastyStruct__bindgen_ty_2, } #[repr(C)] -#[repr(align(8))] pub union NastyStruct__bindgen_ty_1 { pub mFoo: *mut ::std::os::raw::c_void, pub mDummy: ::std::os::raw::c_ulong, @@ -26,7 +25,6 @@ impl Default for NastyStruct__bindgen_ty_1 { } } #[repr(C)] -#[repr(align(8))] pub union NastyStruct__bindgen_ty_2 { pub wat: ::std::os::raw::c_short, pub wut: *mut ::std::os::raw::c_int, @@ -43,7 +41,6 @@ impl Default for NastyStruct { } } #[repr(C)] -#[repr(align(8))] pub union Whatever { pub mTPtr: *mut ::std::os::raw::c_void, pub mInt: ::std::os::raw::c_int, diff --git a/tests/expectations/tests/union_with_anon_struct.rs b/tests/expectations/tests/union_with_anon_struct.rs index ede6acf0..a1451332 100644 --- a/tests/expectations/tests/union_with_anon_struct.rs +++ b/tests/expectations/tests/union_with_anon_struct.rs @@ -8,7 +8,6 @@ )] #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union foo { pub bar: foo__bindgen_ty_1, diff --git a/tests/expectations/tests/union_with_anon_struct_bitfield.rs b/tests/expectations/tests/union_with_anon_struct_bitfield.rs index d08a7ff8..f97f122c 100644 --- a/tests/expectations/tests/union_with_anon_struct_bitfield.rs +++ b/tests/expectations/tests/union_with_anon_struct_bitfield.rs @@ -90,7 +90,6 @@ where } } #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union foo { pub a: ::std::os::raw::c_int, diff --git a/tests/expectations/tests/union_with_anon_union.rs b/tests/expectations/tests/union_with_anon_union.rs index df1b34f8..aa2abc86 100644 --- a/tests/expectations/tests/union_with_anon_union.rs +++ b/tests/expectations/tests/union_with_anon_union.rs @@ -8,14 +8,12 @@ )] #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union foo { pub bar: foo__bindgen_ty_1, _bindgen_union_align: u32, } #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union foo__bindgen_ty_1 { pub a: ::std::os::raw::c_uint, diff --git a/tests/expectations/tests/union_with_anon_unnamed_struct.rs b/tests/expectations/tests/union_with_anon_unnamed_struct.rs index 79f6624b..a1267b39 100644 --- a/tests/expectations/tests/union_with_anon_unnamed_struct.rs +++ b/tests/expectations/tests/union_with_anon_unnamed_struct.rs @@ -8,7 +8,6 @@ )] #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union pixel { pub rgba: ::std::os::raw::c_uint, diff --git a/tests/expectations/tests/union_with_anon_unnamed_union.rs b/tests/expectations/tests/union_with_anon_unnamed_union.rs index c81afa1f..c6272c13 100644 --- a/tests/expectations/tests/union_with_anon_unnamed_union.rs +++ b/tests/expectations/tests/union_with_anon_unnamed_union.rs @@ -8,7 +8,6 @@ )] #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union foo { pub a: ::std::os::raw::c_uint, @@ -16,7 +15,6 @@ pub union foo { _bindgen_union_align: u32, } #[repr(C)] -#[repr(align(2))] #[derive(Copy, Clone)] pub union foo__bindgen_ty_1 { pub b: ::std::os::raw::c_ushort, diff --git a/tests/expectations/tests/union_with_big_member.rs b/tests/expectations/tests/union_with_big_member.rs index 40eed80b..c31a69f9 100644 --- a/tests/expectations/tests/union_with_big_member.rs +++ b/tests/expectations/tests/union_with_big_member.rs @@ -8,7 +8,6 @@ )] #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union WithBigArray { pub a: ::std::os::raw::c_int, @@ -54,7 +53,6 @@ impl Default for WithBigArray { } } #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union WithBigArray2 { pub a: ::std::os::raw::c_int, @@ -100,7 +98,6 @@ impl Default for WithBigArray2 { } } #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union WithBigMember { pub a: ::std::os::raw::c_int, diff --git a/tests/expectations/tests/union_with_nesting.rs b/tests/expectations/tests/union_with_nesting.rs index e11aff2e..0a4fd91c 100644 --- a/tests/expectations/tests/union_with_nesting.rs +++ b/tests/expectations/tests/union_with_nesting.rs @@ -8,7 +8,6 @@ )] #[repr(C)] -#[repr(align(4))] #[derive(Copy, Clone)] pub union foo { pub a: ::std::os::raw::c_uint, @@ -22,7 +21,6 @@ pub struct foo__bindgen_ty_1 { pub __bindgen_anon_2: foo__bindgen_ty_1__bindgen_ty_2, } #[repr(C)] -#[repr(align(2))] #[derive(Copy, Clone)] pub union foo__bindgen_ty_1__bindgen_ty_1 { pub b1: ::std::os::raw::c_ushort, @@ -72,7 +70,6 @@ impl Default for foo__bindgen_ty_1__bindgen_ty_1 { } } #[repr(C)] -#[repr(align(2))] #[derive(Copy, Clone)] pub union foo__bindgen_ty_1__bindgen_ty_2 { pub c1: ::std::os::raw::c_ushort, diff --git a/tests/expectations/tests/use-core.rs b/tests/expectations/tests/use-core.rs index 133065e0..563258a0 100644 --- a/tests/expectations/tests/use-core.rs +++ b/tests/expectations/tests/use-core.rs @@ -50,7 +50,6 @@ impl Default for foo { } } #[repr(C)] -#[repr(align(8))] #[derive(Copy, Clone)] pub union _bindgen_ty_1 { pub bar: ::std::os::raw::c_int, diff --git a/tests/headers/issue-1498.h b/tests/headers/issue-1498.h new file mode 100644 index 00000000..aceabbd2 --- /dev/null +++ b/tests/headers/issue-1498.h @@ -0,0 +1,17 @@ +typedef unsigned long uint64_t; +typedef uint64_t size_t; +typedef unsigned uint32_t; +typedef int int32_t; + +struct rte_memseg { + uint64_t phys_addr; /**< Start physical address. */ + union { + void *addr; /**< Start virtual address. */ + uint64_t addr_64; /**< Makes sure addr is always 64 bits */ + }; + size_t len; /**< Length of the segment. */ + uint64_t hugepage_sz; /**< The pagesize of underlying memory */ + int32_t socket_id; /**< NUMA socket ID. */ + uint32_t nchannel; /**< Number of channels. */ + uint32_t nrank; /**< Number of ranks. */ +} __attribute__((__packed__)); |