summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2019-03-04 03:55:18 +0100
committerGitHub <noreply@github.com>2019-03-04 03:55:18 +0100
commit3a6864cf9a76916c002c41a8ae813d9f8bd9853e (patch)
treee0335d4c4de7b34e141f055b32fa3a22ecd55771
parent1cd830127489b19a58143c300667d045b447a62d (diff)
parenta43cc2afcd69cbaa2f699ee3d4b9c804576ffad7 (diff)
Merge pull request #1530 from emilio/rustup
Update default rust target to 1.33.
-rw-r--r--CHANGELOG.md60
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml2
-rwxr-xr-xbindgen-integration/src/lib.rs2
-rw-r--r--src/codegen/mod.rs3
-rw-r--r--src/codegen/struct_layout.rs6
-rw-r--r--src/features.rs2
-rw-r--r--tests/expectations/tests/16-byte-alignment.rs17
-rw-r--r--tests/expectations/tests/annotation_hide.rs1
-rw-r--r--tests/expectations/tests/anon_struct_in_union.rs9
-rw-r--r--tests/expectations/tests/bitfield-enum-basic.rs8
-rw-r--r--tests/expectations/tests/bitfield-large.rs73
-rw-r--r--tests/expectations/tests/bitfield_align.rs10
-rw-r--r--tests/expectations/tests/bitfield_align_2.rs2
-rw-r--r--tests/expectations/tests/bitfield_large_overflow.rs10
-rw-r--r--tests/expectations/tests/bitfield_method_mangling.rs2
-rw-r--r--tests/expectations/tests/class_with_inner_struct.rs7
-rw-r--r--tests/expectations/tests/convert-floats.rs2
-rw-r--r--tests/expectations/tests/derive-debug-mangle-name.rs13
-rw-r--r--tests/expectations/tests/derive-debug-opaque.rs10
-rw-r--r--tests/expectations/tests/derive-partialeq-anonfield.rs15
-rw-r--r--tests/expectations/tests/derive-partialeq-pointer.rs9
-rw-r--r--tests/expectations/tests/doggo-or-null.rs1
-rw-r--r--tests/expectations/tests/enum-default-bitfield.rs9
-rw-r--r--tests/expectations/tests/enum-doc-bitfield.rs2
-rw-r--r--tests/expectations/tests/issue-1198-alias-rust-bitfield-enum.rs11
-rw-r--r--tests/expectations/tests/issue-1285.rs7
-rw-r--r--tests/expectations/tests/issue-1498.rs153
-rw-r--r--tests/expectations/tests/issue-493.rs7
-rw-r--r--tests/expectations/tests/issue-537.rs39
-rw-r--r--tests/expectations/tests/issue-648-derive-debug-with-padding.rs12
-rw-r--r--tests/expectations/tests/issue-739-pointer-wide-bitfield.rs2
-rw-r--r--tests/expectations/tests/issue-801-opaque-sloppiness.rs8
-rw-r--r--tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs10
-rw-r--r--tests/expectations/tests/issue-816.rs2
-rw-r--r--tests/expectations/tests/jsval_layout_opaque.rs2
-rw-r--r--tests/expectations/tests/layout.rs9
-rw-r--r--tests/expectations/tests/layout_align.rs4
-rw-r--r--tests/expectations/tests/layout_array.rs18
-rw-r--r--tests/expectations/tests/layout_array_too_long.rs6
-rw-r--r--tests/expectations/tests/layout_kni_mbuf.rs6
-rw-r--r--tests/expectations/tests/layout_large_align_field.rs18
-rw-r--r--tests/expectations/tests/layout_mbuf.rs10
-rw-r--r--tests/expectations/tests/libclang-3.8/error-E0600-cannot-apply-unary-negation-to-u32.rs1
-rw-r--r--tests/expectations/tests/libclang-3.9/error-E0600-cannot-apply-unary-negation-to-u32.rs1
-rw-r--r--tests/expectations/tests/libclang-4/error-E0600-cannot-apply-unary-negation-to-u32.rs1
-rw-r--r--tests/expectations/tests/libclang-5/call-conv-field.rs12
-rw-r--r--tests/expectations/tests/libclang-5/error-E0600-cannot-apply-unary-negation-to-u32.rs1
-rw-r--r--tests/expectations/tests/no-hash-opaque.rs10
-rw-r--r--tests/expectations/tests/no-partialeq-opaque.rs10
-rw-r--r--tests/expectations/tests/no_copy_opaque.rs10
-rw-r--r--tests/expectations/tests/opaque-tracing.rs10
-rw-r--r--tests/expectations/tests/opaque_in_struct.rs1
-rw-r--r--tests/expectations/tests/opaque_pointer.rs1
-rw-r--r--tests/expectations/tests/struct_with_anon_union.rs9
-rw-r--r--tests/expectations/tests/struct_with_anon_unnamed_union.rs9
-rw-r--r--tests/expectations/tests/struct_with_nesting.rs9
-rw-r--r--tests/expectations/tests/typeref.rs9
-rw-r--r--tests/expectations/tests/union-in-ns.rs9
-rw-r--r--tests/expectations/tests/union_dtor.rs9
-rw-r--r--tests/expectations/tests/union_fields.rs9
-rw-r--r--tests/expectations/tests/union_template.rs9
-rw-r--r--tests/expectations/tests/union_with_anon_struct.rs9
-rw-r--r--tests/expectations/tests/union_with_anon_struct_bitfield.rs2
-rw-r--r--tests/expectations/tests/union_with_anon_union.rs9
-rw-r--r--tests/expectations/tests/union_with_anon_unnamed_struct.rs9
-rw-r--r--tests/expectations/tests/union_with_anon_unnamed_union.rs9
-rw-r--r--tests/expectations/tests/union_with_big_member.rs9
-rw-r--r--tests/expectations/tests/union_with_nesting.rs9
-rw-r--r--tests/expectations/tests/unknown_attr.rs15
-rw-r--r--tests/expectations/tests/use-core.rs8
-rw-r--r--tests/headers/error-E0600-cannot-apply-unary-negation-to-u32.h2
-rw-r--r--tests/headers/issue-1498.h17
-rw-r--r--tests/headers/layout.h6
74 files changed, 680 insertions, 155 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9c2d3280..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 -->
@@ -89,6 +92,25 @@ Released YYYY/MM/DD
* TODO (or remove section if none)
+
+--------------------------------------------------------------------------------
+
+# 0.48.0
+
+Released 2019/03/04
+
+## Changed
+
+* 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
+
--------------------------------------------------------------------------------
# 0.47.3
diff --git a/Cargo.lock b/Cargo.lock
index 4634e28e..34e54e9b 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -49,7 +49,7 @@ dependencies = [
[[package]]
name = "bindgen"
-version = "0.47.3"
+version = "0.48.0"
dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"cexpr 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/Cargo.toml b/Cargo.toml
index bebbbffe..7e0b014b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,7 +14,7 @@ readme = "README.md"
repository = "https://github.com/rust-lang/rust-bindgen"
documentation = "https://docs.rs/bindgen"
homepage = "https://rust-lang.github.io/rust-bindgen/"
-version = "0.47.3"
+version = "0.48.0"
build = "build.rs"
include = [
diff --git a/bindgen-integration/src/lib.rs b/bindgen-integration/src/lib.rs
index 04617ff3..8374e208 100755
--- a/bindgen-integration/src/lib.rs
+++ b/bindgen-integration/src/lib.rs
@@ -179,7 +179,6 @@ fn test_bitfield_constructors() {
let mut second = bindings::bitfields::Second {
_bitfield_1: bindings::bitfields::Second::new_bitfield_1(1337, true),
- __bindgen_align: [],
};
assert!(unsafe { second.assert(1337, true) });
@@ -189,7 +188,6 @@ fn test_bitfield_constructors() {
false,
bindings::bitfields::ItemKind::ITEM_KIND_TRES,
),
- __bindgen_align: [],
};
assert!(unsafe {
third.assert(42, false, bindings::bitfields::ItemKind::ITEM_KIND_TRES)
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/src/features.rs b/src/features.rs
index b5a63402..50759c31 100644
--- a/src/features.rs
+++ b/src/features.rs
@@ -114,7 +114,7 @@ rust_target_base!(rust_target_def);
rust_target_base!(rust_target_values_def);
/// Latest stable release of Rust
-pub const LATEST_STABLE_RUST: RustTarget = RustTarget::Stable_1_21;
+pub const LATEST_STABLE_RUST: RustTarget = RustTarget::Stable_1_33;
/// Create RustFeatures struct definition, new(), and a getter for each field
macro_rules! rust_feature_def {
diff --git a/tests/expectations/tests/16-byte-alignment.rs b/tests/expectations/tests/16-byte-alignment.rs
index 84383c35..3a9e8998 100644
--- a/tests/expectations/tests/16-byte-alignment.rs
+++ b/tests/expectations/tests/16-byte-alignment.rs
@@ -1,8 +1,11 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Copy, Clone)]
@@ -271,11 +274,12 @@ impl Default for rte_ipv6_tuple {
}
}
#[repr(C)]
+#[repr(align(16))]
#[derive(Copy, Clone)]
pub union rte_thash_tuple {
pub v4: rte_ipv4_tuple,
pub v6: rte_ipv6_tuple,
- _bindgen_union_align: [u8; 48usize],
+ _bindgen_union_align: [u128; 3usize],
}
#[test]
fn bindgen_test_layout_rte_thash_tuple() {
@@ -285,6 +289,11 @@ fn bindgen_test_layout_rte_thash_tuple() {
concat!("Size of: ", stringify!(rte_thash_tuple))
);
assert_eq!(
+ ::std::mem::align_of::<rte_thash_tuple>(),
+ 16usize,
+ concat!("Alignment of ", stringify!(rte_thash_tuple))
+ );
+ assert_eq!(
unsafe { &(*(::std::ptr::null::<rte_thash_tuple>())).v4 as *const _ as usize },
0usize,
concat!(
diff --git a/tests/expectations/tests/annotation_hide.rs b/tests/expectations/tests/annotation_hide.rs
index d59ed05c..49a771ac 100644
--- a/tests/expectations/tests/annotation_hide.rs
+++ b/tests/expectations/tests/annotation_hide.rs
@@ -9,6 +9,7 @@
/// <div rustbindgen opaque></div>
#[repr(C)]
+#[repr(align(4))]
#[derive(Debug, Default, Copy, Clone)]
pub struct D {
pub _bindgen_opaque_blob: u32,
diff --git a/tests/expectations/tests/anon_struct_in_union.rs b/tests/expectations/tests/anon_struct_in_union.rs
index 6916d5af..5b5ed43c 100644
--- a/tests/expectations/tests/anon_struct_in_union.rs
+++ b/tests/expectations/tests/anon_struct_in_union.rs
@@ -1,8 +1,11 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Copy, Clone)]
diff --git a/tests/expectations/tests/bitfield-enum-basic.rs b/tests/expectations/tests/bitfield-enum-basic.rs
index 2142776e..7a3dd356 100644
--- a/tests/expectations/tests/bitfield-enum-basic.rs
+++ b/tests/expectations/tests/bitfield-enum-basic.rs
@@ -45,7 +45,7 @@ impl ::std::ops::BitAndAssign for Foo {
self.0 &= rhs.0;
}
}
-#[repr(C)]
+#[repr(transparent)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct Foo(pub i32);
impl Buz {
@@ -86,7 +86,7 @@ impl ::std::ops::BitAndAssign for Buz {
self.0 &= rhs.0;
}
}
-#[repr(C)]
+#[repr(transparent)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct Buz(pub i8);
pub const NS_FOO: _bindgen_ty_1 = _bindgen_ty_1(1);
@@ -117,7 +117,7 @@ impl ::std::ops::BitAndAssign for _bindgen_ty_1 {
self.0 &= rhs.0;
}
}
-#[repr(C)]
+#[repr(transparent)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct _bindgen_ty_1(pub u32);
#[repr(C)]
@@ -153,7 +153,7 @@ impl ::std::ops::BitAndAssign for Dummy__bindgen_ty_1 {
self.0 &= rhs.0;
}
}
-#[repr(C)]
+#[repr(transparent)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct Dummy__bindgen_ty_1(pub u32);
#[test]
diff --git a/tests/expectations/tests/bitfield-large.rs b/tests/expectations/tests/bitfield-large.rs
index 408c2a0e..1791cd32 100644
--- a/tests/expectations/tests/bitfield-large.rs
+++ b/tests/expectations/tests/bitfield-large.rs
@@ -90,6 +90,7 @@ where
}
}
#[repr(C)]
+#[repr(align(16))]
#[derive(Debug, Default, Copy, Clone)]
pub struct HasBigBitfield {
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 16usize], u64>,
@@ -101,8 +102,37 @@ fn bindgen_test_layout_HasBigBitfield() {
16usize,
concat!("Size of: ", stringify!(HasBigBitfield))
);
+ assert_eq!(
+ ::std::mem::align_of::<HasBigBitfield>(),
+ 16usize,
+ concat!("Alignment of ", stringify!(HasBigBitfield))
+ );
+}
+impl HasBigBitfield {
+ #[inline]
+ pub fn x(&self) -> i128 {
+ unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 128u8) as u128) }
+ }
+ #[inline]
+ pub fn set_x(&mut self, val: i128) {
+ unsafe {
+ let val: u128 = ::std::mem::transmute(val);
+ self._bitfield_1.set(0usize, 128u8, val as u64)
+ }
+ }
+ #[inline]
+ pub fn new_bitfield_1(x: i128) -> __BindgenBitfieldUnit<[u8; 16usize], u64> {
+ let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 16usize], u64> =
+ Default::default();
+ __bindgen_bitfield_unit.set(0usize, 128u8, {
+ let x: u128 = unsafe { ::std::mem::transmute(x) };
+ x as u64
+ });
+ __bindgen_bitfield_unit
+ }
}
#[repr(C)]
+#[repr(align(16))]
#[derive(Debug, Default, Copy, Clone)]
pub struct HasTwoBigBitfields {
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 16usize], u64>,
@@ -114,4 +144,47 @@ fn bindgen_test_layout_HasTwoBigBitfields() {
16usize,
concat!("Size of: ", stringify!(HasTwoBigBitfields))
);
+ assert_eq!(
+ ::std::mem::align_of::<HasTwoBigBitfields>(),
+ 16usize,
+ concat!("Alignment of ", stringify!(HasTwoBigBitfields))
+ );
+}
+impl HasTwoBigBitfields {
+ #[inline]
+ pub fn x(&self) -> i128 {
+ unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 80u8) as u128) }
+ }
+ #[inline]
+ pub fn set_x(&mut self, val: i128) {
+ unsafe {
+ let val: u128 = ::std::mem::transmute(val);
+ self._bitfield_1.set(0usize, 80u8, val as u64)
+ }
+ }
+ #[inline]
+ pub fn y(&self) -> i128 {
+ unsafe { ::std::mem::transmute(self._bitfield_1.get(80usize, 48u8) as u128) }
+ }
+ #[inline]
+ pub fn set_y(&mut self, val: i128) {
+ unsafe {
+ let val: u128 = ::std::mem::transmute(val);
+ self._bitfield_1.set(80usize, 48u8, val as u64)
+ }
+ }
+ #[inline]
+ pub fn new_bitfield_1(x: i128, y: i128) -> __BindgenBitfieldUnit<[u8; 16usize], u64> {
+ let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 16usize], u64> =
+ Default::default();
+ __bindgen_bitfield_unit.set(0usize, 80u8, {
+ let x: u128 = unsafe { ::std::mem::transmute(x) };
+ x as u64
+ });
+ __bindgen_bitfield_unit.set(80usize, 48u8, {
+ let y: u128 = unsafe { ::std::mem::transmute(y) };
+ y as u64
+ });
+ __bindgen_bitfield_unit
+ }
}
diff --git a/tests/expectations/tests/bitfield_align.rs b/tests/expectations/tests/bitfield_align.rs
index c7758c5a..35e9479b 100644
--- a/tests/expectations/tests/bitfield_align.rs
+++ b/tests/expectations/tests/bitfield_align.rs
@@ -90,12 +90,12 @@ where
}
}
#[repr(C)]
+#[repr(align(4))]
#[derive(Debug, Default, Copy, Clone)]
pub struct A {
pub x: ::std::os::raw::c_uchar,
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize], u8>,
pub y: ::std::os::raw::c_uchar,
- pub __bindgen_align: [u32; 0usize],
}
#[test]
fn bindgen_test_layout_A() {
@@ -290,10 +290,10 @@ impl A {
}
}
#[repr(C)]
+#[repr(align(4))]
#[derive(Debug, Default, Copy, Clone)]
pub struct B {
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize], u32>,
- pub __bindgen_align: [u32; 0usize],
}
#[test]
fn bindgen_test_layout_B() {
@@ -421,11 +421,11 @@ impl C {
}
}
#[repr(C)]
+#[repr(align(2))]
#[derive(Debug, Default, Copy, Clone)]
pub struct Date1 {
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 3usize], u8>,
pub __bindgen_padding_0: u8,
- pub __bindgen_align: [u16; 0usize],
}
#[test]
fn bindgen_test_layout_Date1() {
@@ -514,10 +514,10 @@ impl Date1 {
}
}
#[repr(C)]
+#[repr(align(2))]
#[derive(Debug, Default, Copy, Clone)]
pub struct Date2 {
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize], u8>,
- pub __bindgen_align: [u16; 0usize],
}
#[test]
fn bindgen_test_layout_Date2() {
@@ -622,11 +622,11 @@ impl Date2 {
}
}
#[repr(C)]
+#[repr(align(2))]
#[derive(Debug, Default, Copy, Clone)]
pub struct Date3 {
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 3usize], u8>,
pub byte: ::std::os::raw::c_uchar,
- pub __bindgen_align: [u16; 0usize],
}
#[test]
fn bindgen_test_layout_Date3() {
diff --git a/tests/expectations/tests/bitfield_align_2.rs b/tests/expectations/tests/bitfield_align_2.rs
index 39ab0eef..6f93397f 100644
--- a/tests/expectations/tests/bitfield_align_2.rs
+++ b/tests/expectations/tests/bitfield_align_2.rs
@@ -98,10 +98,10 @@ pub enum MyEnum {
FOUR = 3,
}
#[repr(C)]
+#[repr(align(8))]
#[derive(Debug, Copy, Clone)]
pub struct TaggedPtr {
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 8usize], u64>,
- pub __bindgen_align: [u64; 0usize],
}
#[test]
fn bindgen_test_layout_TaggedPtr() {
diff --git a/tests/expectations/tests/bitfield_large_overflow.rs b/tests/expectations/tests/bitfield_large_overflow.rs
index e5b254cf..7df5b937 100644
--- a/tests/expectations/tests/bitfield_large_overflow.rs
+++ b/tests/expectations/tests/bitfield_large_overflow.rs
@@ -1,10 +1,14 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
+#[repr(align(8))]
#[derive(Debug, Default, Copy, Clone)]
pub struct _bindgen_ty_1 {
pub _bindgen_opaque_blob: [u64; 10usize],
diff --git a/tests/expectations/tests/bitfield_method_mangling.rs b/tests/expectations/tests/bitfield_method_mangling.rs
index 0089d2c7..8ebb778d 100644
--- a/tests/expectations/tests/bitfield_method_mangling.rs
+++ b/tests/expectations/tests/bitfield_method_mangling.rs
@@ -90,10 +90,10 @@ where
}
}
#[repr(C)]
+#[repr(align(4))]
#[derive(Debug, Default, Copy, Clone)]
pub struct mach_msg_type_descriptor_t {
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize], u32>,
- pub __bindgen_align: [u32; 0usize],
}
#[test]
fn bindgen_test_layout_mach_msg_type_descriptor_t() {
diff --git a/tests/expectations/tests/class_with_inner_struct.rs b/tests/expectations/tests/class_with_inner_struct.rs
index 265d7c5b..577dec6f 100644
--- a/tests/expectations/tests/class_with_inner_struct.rs
+++ b/tests/expectations/tests/class_with_inner_struct.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Copy, Clone)]
diff --git a/tests/expectations/tests/convert-floats.rs b/tests/expectations/tests/convert-floats.rs
index e6abee16..325fc267 100644
--- a/tests/expectations/tests/convert-floats.rs
+++ b/tests/expectations/tests/convert-floats.rs
@@ -19,7 +19,7 @@ pub struct foo {
pub bar: ::std::os::raw::c_float,
pub baz: ::std::os::raw::c_float,
pub bazz: ::std::os::raw::c_double,
- pub bazzz: *mut f64,
+ pub bazzz: *mut u128,
pub complexFloat: __BindgenComplex<::std::os::raw::c_float>,
pub complexDouble: __BindgenComplex<::std::os::raw::c_double>,
}
diff --git a/tests/expectations/tests/derive-debug-mangle-name.rs b/tests/expectations/tests/derive-debug-mangle-name.rs
index fbf518bd..9c72fbbd 100644
--- a/tests/expectations/tests/derive-debug-mangle-name.rs
+++ b/tests/expectations/tests/derive-debug-mangle-name.rs
@@ -1,8 +1,11 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Copy, Clone)]
@@ -104,9 +107,7 @@ impl ::std::fmt::Debug for perf_event_attr {
write!(
f,
"perf_event_attr {{ type: {:?}, a: {:?}, __bindgen_anon_1: {:?} }}",
- self.type_,
- self.a,
- self.__bindgen_anon_1
+ self.type_, self.a, self.__bindgen_anon_1
)
}
}
diff --git a/tests/expectations/tests/derive-debug-opaque.rs b/tests/expectations/tests/derive-debug-opaque.rs
index d7f8878b..bc7d9fd6 100644
--- a/tests/expectations/tests/derive-debug-opaque.rs
+++ b/tests/expectations/tests/derive-debug-opaque.rs
@@ -1,10 +1,14 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
+#[repr(align(4))]
pub struct Opaque {
pub _bindgen_opaque_blob: [u32; 41usize],
}
diff --git a/tests/expectations/tests/derive-partialeq-anonfield.rs b/tests/expectations/tests/derive-partialeq-anonfield.rs
index 73972d70..b5cb1593 100644
--- a/tests/expectations/tests/derive-partialeq-anonfield.rs
+++ b/tests/expectations/tests/derive-partialeq-anonfield.rs
@@ -1,10 +1,14 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
+#[repr(align(64))]
#[derive(Copy, Clone)]
pub struct rte_mbuf {
pub __bindgen_anon_1: rte_mbuf__bindgen_ty_1,
@@ -39,6 +43,11 @@ fn bindgen_test_layout_rte_mbuf() {
0usize,
concat!("Size of: ", stringify!(rte_mbuf))
);
+ assert_eq!(
+ ::std::mem::align_of::<rte_mbuf>(),
+ 64usize,
+ concat!("Alignment of ", stringify!(rte_mbuf))
+ );
}
impl Default for rte_mbuf {
fn default() -> Self {
diff --git a/tests/expectations/tests/derive-partialeq-pointer.rs b/tests/expectations/tests/derive-partialeq-pointer.rs
index 4ce1a3fe..2ac23c81 100644
--- a/tests/expectations/tests/derive-partialeq-pointer.rs
+++ b/tests/expectations/tests/derive-partialeq-pointer.rs
@@ -1,8 +1,11 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
diff --git a/tests/expectations/tests/doggo-or-null.rs b/tests/expectations/tests/doggo-or-null.rs
index 5a7aa86f..21688914 100644
--- a/tests/expectations/tests/doggo-or-null.rs
+++ b/tests/expectations/tests/doggo-or-null.rs
@@ -55,6 +55,7 @@ fn bindgen_test_layout_Null() {
/// probably emit an opaque struct for opaque unions... but until then, we have
/// this test to make sure that opaque unions don't derive and still compile.
#[repr(C)]
+#[repr(align(4))]
#[derive(Copy, Clone)]
pub union DoggoOrNull {
pub _bindgen_opaque_blob: u32,
diff --git a/tests/expectations/tests/enum-default-bitfield.rs b/tests/expectations/tests/enum-default-bitfield.rs
index 19172d0b..a5ba04ef 100644
--- a/tests/expectations/tests/enum-default-bitfield.rs
+++ b/tests/expectations/tests/enum-default-bitfield.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
impl Foo {
pub const Bar: Foo = Foo(0);
@@ -34,7 +39,7 @@ impl ::std::ops::BitAndAssign for Foo {
self.0 &= rhs.0;
}
}
-#[repr(C)]
+#[repr(transparent)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct Foo(pub u32);
pub mod Neg {
diff --git a/tests/expectations/tests/enum-doc-bitfield.rs b/tests/expectations/tests/enum-doc-bitfield.rs
index 9ebfc10e..5fe668be 100644
--- a/tests/expectations/tests/enum-doc-bitfield.rs
+++ b/tests/expectations/tests/enum-doc-bitfield.rs
@@ -60,7 +60,7 @@ impl ::std::ops::BitAndAssign for B {
self.0 &= rhs.0;
}
}
-#[repr(C)]
+#[repr(transparent)]
/// Document enum
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct B(pub u32);
diff --git a/tests/expectations/tests/issue-1198-alias-rust-bitfield-enum.rs b/tests/expectations/tests/issue-1198-alias-rust-bitfield-enum.rs
index 8c70625e..8c58b232 100644
--- a/tests/expectations/tests/issue-1198-alias-rust-bitfield-enum.rs
+++ b/tests/expectations/tests/issue-1198-alias-rust-bitfield-enum.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
impl MyDupeEnum {
pub const A: MyDupeEnum = MyDupeEnum(0);
@@ -37,7 +42,7 @@ impl ::std::ops::BitAndAssign for MyDupeEnum {
self.0 &= rhs.0;
}
}
-#[repr(C)]
+#[repr(transparent)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct MyDupeEnum(pub u32);
impl MyOtherDupeEnum {
@@ -75,6 +80,6 @@ impl ::std::ops::BitAndAssign for MyOtherDupeEnum {
self.0 &= rhs.0;
}
}
-#[repr(C)]
+#[repr(transparent)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct MyOtherDupeEnum(pub u32);
diff --git a/tests/expectations/tests/issue-1285.rs b/tests/expectations/tests/issue-1285.rs
index 7b2c0ae9..77df620b 100644
--- a/tests/expectations/tests/issue-1285.rs
+++ b/tests/expectations/tests/issue-1285.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
pub struct foo {
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 c13101d0..e7e5c557 100644
--- a/tests/expectations/tests/issue-493.rs
+++ b/tests/expectations/tests/issue-493.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
diff --git a/tests/expectations/tests/issue-537.rs b/tests/expectations/tests/issue-537.rs
index 94c6dd3b..aaaa9f19 100644
--- a/tests/expectations/tests/issue-537.rs
+++ b/tests/expectations/tests/issue-537.rs
@@ -39,10 +39,10 @@ fn bindgen_test_layout_AlignedToOne() {
}
/// This should be opaque because although we can see the attributes, Rust before
/// 1.33 doesn't have `#[repr(packed(N))]`.
-#[repr(C)]
+#[repr(C, packed(2))]
#[derive(Debug, Default, Copy, Clone)]
pub struct AlignedToTwo {
- pub _bindgen_opaque_blob: [u16; 2usize],
+ pub i: ::std::os::raw::c_int,
}
#[test]
fn bindgen_test_layout_AlignedToTwo() {
@@ -56,6 +56,16 @@ fn bindgen_test_layout_AlignedToTwo() {
2usize,
concat!("Alignment of ", stringify!(AlignedToTwo))
);
+ assert_eq!(
+ unsafe { &(*(::std::ptr::null::<AlignedToTwo>())).i as *const _ as usize },
+ 0usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(AlignedToTwo),
+ "::",
+ stringify!(i)
+ )
+ );
}
/// This should not be opaque because although `libclang` doesn't give us the
/// `#pragma pack(1)`, we can detect that alignment is 1 and add
@@ -102,10 +112,11 @@ fn bindgen_test_layout_PackedToOne() {
/// In this case, even if we can detect the weird alignment triggered by
/// `#pragma pack(2)`, we can't do anything about it because Rust before 1.33
/// doesn't have `#[repr(packed(N))]`. Therefore, we must make it opaque.
-#[repr(C)]
+#[repr(C, packed(2))]
#[derive(Debug, Default, Copy, Clone)]
pub struct PackedToTwo {
- pub _bindgen_opaque_blob: [u16; 4usize],
+ pub x: ::std::os::raw::c_int,
+ pub y: ::std::os::raw::c_int,
}
#[test]
fn bindgen_test_layout_PackedToTwo() {
@@ -119,4 +130,24 @@ fn bindgen_test_layout_PackedToTwo() {
2usize,
concat!("Alignment of ", stringify!(PackedToTwo))
);
+ assert_eq!(
+ unsafe { &(*(::std::ptr::null::<PackedToTwo>())).x as *const _ as usize },
+ 0usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(PackedToTwo),
+ "::",
+ stringify!(x)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(::std::ptr::null::<PackedToTwo>())).y as *const _ as usize },
+ 4usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(PackedToTwo),
+ "::",
+ stringify!(y)
+ )
+ );
}
diff --git a/tests/expectations/tests/issue-648-derive-debug-with-padding.rs b/tests/expectations/tests/issue-648-derive-debug-with-padding.rs
index ddd85455..15f02094 100644
--- a/tests/expectations/tests/issue-648-derive-debug-with-padding.rs
+++ b/tests/expectations/tests/issue-648-derive-debug-with-padding.rs
@@ -12,6 +12,7 @@
/// up with the reight alignment, we're waiting on `#[repr(align="N")]` to land
/// in rustc).
#[repr(C)]
+#[repr(align(64))]
#[derive(Copy, Clone)]
pub struct NoDebug {
pub c: ::std::os::raw::c_char,
@@ -25,6 +26,11 @@ fn bindgen_test_layout_NoDebug() {
concat!("Size of: ", stringify!(NoDebug))
);
assert_eq!(
+ ::std::mem::align_of::<NoDebug>(),
+ 64usize,
+ concat!("Alignment of ", stringify!(NoDebug))
+ );
+ assert_eq!(
unsafe { &(*(::std::ptr::null::<NoDebug>())).c as *const _ as usize },
0usize,
concat!(
@@ -50,6 +56,7 @@ impl ::std::cmp::PartialEq for NoDebug {
/// we determine Debug derive-ability before we compute padding, which happens at
/// codegen. (Again, we expect to get the alignment wrong for similar reasons.)
#[repr(C)]
+#[repr(align(64))]
#[derive(Copy, Clone)]
pub struct ShouldDeriveDebugButDoesNot {
pub c: [::std::os::raw::c_char; 32usize],
@@ -64,6 +71,11 @@ fn bindgen_test_layout_ShouldDeriveDebugButDoesNot() {
concat!("Size of: ", stringify!(ShouldDeriveDebugButDoesNot))
);
assert_eq!(
+ ::std::mem::align_of::<ShouldDeriveDebugButDoesNot>(),
+ 64usize,
+ concat!("Alignment of ", stringify!(ShouldDeriveDebugButDoesNot))
+ );
+ assert_eq!(
unsafe { &(*(::std::ptr::null::<ShouldDeriveDebugButDoesNot>())).c as *const _ as usize },
0usize,
concat!(
diff --git a/tests/expectations/tests/issue-739-pointer-wide-bitfield.rs b/tests/expectations/tests/issue-739-pointer-wide-bitfield.rs
index ce006656..ca56ccce 100644
--- a/tests/expectations/tests/issue-739-pointer-wide-bitfield.rs
+++ b/tests/expectations/tests/issue-739-pointer-wide-bitfield.rs
@@ -90,10 +90,10 @@ where
}
}
#[repr(C)]
+#[repr(align(8))]
#[derive(Debug, Default, Copy, Clone)]
pub struct Foo {
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 32usize], u64>,
- pub __bindgen_align: [u64; 0usize],
}
#[test]
fn bindgen_test_layout_Foo() {
diff --git a/tests/expectations/tests/issue-801-opaque-sloppiness.rs b/tests/expectations/tests/issue-801-opaque-sloppiness.rs
index 76deebba..f6356c49 100644
--- a/tests/expectations/tests/issue-801-opaque-sloppiness.rs
+++ b/tests/expectations/tests/issue-801-opaque-sloppiness.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
@@ -8,6 +13,7 @@ pub struct A {
_unused: [u8; 0],
}
#[repr(C)]
+#[repr(align(1))]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct B {
pub _bindgen_opaque_blob: u8,
diff --git a/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs b/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs
index 0b1c020d..798a9f8f 100644
--- a/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs
+++ b/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs
@@ -1,8 +1,11 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
@@ -59,6 +62,7 @@ fn bindgen_test_layout_SuchWow() {
);
}
#[repr(C)]
+#[repr(align(1))]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Opaque {
pub _bindgen_opaque_blob: u8,
diff --git a/tests/expectations/tests/issue-816.rs b/tests/expectations/tests/issue-816.rs
index d7be76ce..b5e30fbe 100644
--- a/tests/expectations/tests/issue-816.rs
+++ b/tests/expectations/tests/issue-816.rs
@@ -90,10 +90,10 @@ where
}
}
#[repr(C)]
+#[repr(align(4))]
#[derive(Debug, Default, Copy, Clone)]
pub struct capabilities {
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 16usize], u8>,
- pub __bindgen_align: [u32; 0usize],
}
#[test]
fn bindgen_test_layout_capabilities() {
diff --git a/tests/expectations/tests/jsval_layout_opaque.rs b/tests/expectations/tests/jsval_layout_opaque.rs
index 00b4301c..aa0420aa 100644
--- a/tests/expectations/tests/jsval_layout_opaque.rs
+++ b/tests/expectations/tests/jsval_layout_opaque.rs
@@ -188,10 +188,10 @@ pub union jsval_layout {
_bindgen_union_align: u64,
}
#[repr(C)]
+#[repr(align(8))]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct jsval_layout__bindgen_ty_1 {
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 8usize], u64>,
- pub __bindgen_align: [u64; 0usize],
}
#[test]
fn bindgen_test_layout_jsval_layout__bindgen_ty_1() {
diff --git a/tests/expectations/tests/layout.rs b/tests/expectations/tests/layout.rs
index 2790446c..3053122d 100644
--- a/tests/expectations/tests/layout.rs
+++ b/tests/expectations/tests/layout.rs
@@ -1,8 +1,11 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
pub struct header {
diff --git a/tests/expectations/tests/layout_align.rs b/tests/expectations/tests/layout_align.rs
index 39fb2948..e655b9dc 100644
--- a/tests/expectations/tests/layout_align.rs
+++ b/tests/expectations/tests/layout_align.rs
@@ -126,6 +126,7 @@ impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
}
}
#[repr(C)]
+#[repr(align(8))]
#[derive(Debug)]
pub struct rte_kni_fifo {
///< Next position to be written
@@ -138,7 +139,6 @@ pub struct rte_kni_fifo {
pub elem_size: ::std::os::raw::c_uint,
///< The buffer contains mbuf pointers
pub buffer: __IncompleteArrayField<*mut ::std::os::raw::c_void>,
- pub __bindgen_align: [u64; 0usize],
}
#[test]
fn bindgen_test_layout_rte_kni_fifo() {
@@ -159,13 +159,13 @@ impl Default for rte_kni_fifo {
}
}
#[repr(C)]
+#[repr(align(8))]
#[derive(Debug, Default, Copy, Clone)]
pub struct rte_eth_link {
///< ETH_SPEED_NUM_
pub link_speed: u32,
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>,
pub __bindgen_padding_0: [u8; 3usize],
- pub __bindgen_align: [u64; 0usize],
}
#[test]
fn bindgen_test_layout_rte_eth_link() {
diff --git a/tests/expectations/tests/layout_array.rs b/tests/expectations/tests/layout_array.rs
index 2fd93c4a..0da08871 100644
--- a/tests/expectations/tests/layout_array.rs
+++ b/tests/expectations/tests/layout_array.rs
@@ -49,6 +49,7 @@ pub type rte_mempool_get_count =
::std::option::Option<unsafe extern "C" fn(mp: *const rte_mempool) -> ::std::os::raw::c_uint>;
/// Structure defining mempool operations structure
#[repr(C)]
+#[repr(align(64))]
#[derive(Copy, Clone)]
pub struct rte_mempool_ops {
///< Name of mempool ops struct.
@@ -73,6 +74,11 @@ fn bindgen_test_layout_rte_mempool_ops() {
concat!("Size of: ", stringify!(rte_mempool_ops))
);
assert_eq!(
+ ::std::mem::align_of::<rte_mempool_ops>(),
+ 64usize,
+ concat!("Alignment of ", stringify!(rte_mempool_ops))
+ );
+ assert_eq!(
unsafe { &(*(::std::ptr::null::<rte_mempool_ops>())).name as *const _ as usize },
0usize,
concat!(
@@ -186,6 +192,7 @@ fn bindgen_test_layout_rte_spinlock_t() {
/// any function pointers stored directly in the mempool struct would not be.
/// This results in us simply having "ops_index" in the mempool struct.
#[repr(C)]
+#[repr(align(64))]
#[derive(Copy, Clone)]
pub struct rte_mempool_ops_table {
///< Spinlock for add/delete.
@@ -204,6 +211,11 @@ fn bindgen_test_layout_rte_mempool_ops_table() {
concat!("Size of: ", stringify!(rte_mempool_ops_table))
);
assert_eq!(
+ ::std::mem::align_of::<rte_mempool_ops_table>(),
+ 64usize,
+ concat!("Alignment of ", stringify!(rte_mempool_ops_table))
+ );
+ assert_eq!(
unsafe { &(*(::std::ptr::null::<rte_mempool_ops_table>())).sl as *const _ as usize },
0usize,
concat!(
@@ -241,6 +253,7 @@ impl Default for rte_mempool_ops_table {
}
/// Structure to hold malloc heap
#[repr(C)]
+#[repr(align(64))]
#[derive(Copy, Clone)]
pub struct malloc_heap {
pub lock: rte_spinlock_t,
@@ -291,6 +304,11 @@ fn bindgen_test_layout_malloc_heap() {
concat!("Size of: ", stringify!(malloc_heap))
);
assert_eq!(
+ ::std::mem::align_of::<malloc_heap>(),
+ 64usize,
+ concat!("Alignment of ", stringify!(malloc_heap))
+ );
+ assert_eq!(
unsafe { &(*(::std::ptr::null::<malloc_heap>())).lock as *const _ as usize },
0usize,
concat!(
diff --git a/tests/expectations/tests/layout_array_too_long.rs b/tests/expectations/tests/layout_array_too_long.rs
index 91c74d4b..27dd96ff 100644
--- a/tests/expectations/tests/layout_array_too_long.rs
+++ b/tests/expectations/tests/layout_array_too_long.rs
@@ -140,6 +140,7 @@ fn bindgen_test_layout_ip_frag_key() {
/// @internal Fragmented packet to reassemble.
/// First two entries in the frags[] array are for the last and first fragments.
#[repr(C)]
+#[repr(align(64))]
#[derive(Copy, Clone)]
pub struct ip_frag_pkt {
///< LRU list
@@ -214,6 +215,11 @@ fn bindgen_test_layout_ip_frag_pkt() {
concat!("Size of: ", stringify!(ip_frag_pkt))
);
assert_eq!(
+ ::std::mem::align_of::<ip_frag_pkt>(),
+ 64usize,
+ concat!("Alignment of ", stringify!(ip_frag_pkt))
+ );
+ assert_eq!(
unsafe { &(*(::std::ptr::null::<ip_frag_pkt>())).lru as *const _ as usize },
0usize,
concat!(
diff --git a/tests/expectations/tests/layout_kni_mbuf.rs b/tests/expectations/tests/layout_kni_mbuf.rs
index cd456881..fd8047ae 100644
--- a/tests/expectations/tests/layout_kni_mbuf.rs
+++ b/tests/expectations/tests/layout_kni_mbuf.rs
@@ -10,6 +10,7 @@
pub const RTE_CACHE_LINE_MIN_SIZE: u32 = 64;
pub const RTE_CACHE_LINE_SIZE: u32 = 64;
#[repr(C)]
+#[repr(align(64))]
#[derive(Copy, Clone)]
pub struct rte_kni_mbuf {
pub buf_addr: *mut ::std::os::raw::c_void,
@@ -42,6 +43,11 @@ fn bindgen_test_layout_rte_kni_mbuf() {
concat!("Size of: ", stringify!(rte_kni_mbuf))
);
assert_eq!(
+ ::std::mem::align_of::<rte_kni_mbuf>(),
+ 64usize,
+ concat!("Alignment of ", stringify!(rte_kni_mbuf))
+ );
+ assert_eq!(
unsafe { &(*(::std::ptr::null::<rte_kni_mbuf>())).buf_addr as *const _ as usize },
0usize,
concat!(
diff --git a/tests/expectations/tests/layout_large_align_field.rs b/tests/expectations/tests/layout_large_align_field.rs
index 8b7be4ca..4c10223c 100644
--- a/tests/expectations/tests/layout_large_align_field.rs
+++ b/tests/expectations/tests/layout_large_align_field.rs
@@ -176,6 +176,7 @@ fn bindgen_test_layout_ip_frag_key() {
/// @internal Fragmented packet to reassemble.
/// First two entries in the frags[] array are for the last and first fragments.
#[repr(C)]
+#[repr(align(64))]
#[derive(Copy, Clone)]
pub struct ip_frag_pkt {
///< LRU list
@@ -250,6 +251,11 @@ fn bindgen_test_layout_ip_frag_pkt() {
concat!("Size of: ", stringify!(ip_frag_pkt))
);
assert_eq!(
+ ::std::mem::align_of::<ip_frag_pkt>(),
+ 64usize,
+ concat!("Alignment of ", stringify!(ip_frag_pkt))
+ );
+ assert_eq!(
unsafe { &(*(::std::ptr::null::<ip_frag_pkt>())).lru as *const _ as usize },
0usize,
concat!(
@@ -371,6 +377,7 @@ impl Default for ip_pkt_list {
}
/// fragmentation table statistics
#[repr(C)]
+#[repr(align(64))]
#[derive(Copy, Clone)]
pub struct ip_frag_tbl_stat {
///< total # of find/insert attempts.
@@ -395,6 +402,11 @@ fn bindgen_test_layout_ip_frag_tbl_stat() {
concat!("Size of: ", stringify!(ip_frag_tbl_stat))
);
assert_eq!(
+ ::std::mem::align_of::<ip_frag_tbl_stat>(),
+ 64usize,
+ concat!("Alignment of ", stringify!(ip_frag_tbl_stat))
+ );
+ assert_eq!(
unsafe { &(*(::std::ptr::null::<ip_frag_tbl_stat>())).find_num as *const _ as usize },
0usize,
concat!(
@@ -462,6 +474,7 @@ impl Default for ip_frag_tbl_stat {
}
/// fragmentation table
#[repr(C)]
+#[repr(align(64))]
pub struct rte_ip_frag_tbl {
///< ttl for table entries.
pub max_cycles: u64,
@@ -495,6 +508,11 @@ fn bindgen_test_layout_rte_ip_frag_tbl() {
concat!("Size of: ", stringify!(rte_ip_frag_tbl))
);
assert_eq!(
+ ::std::mem::align_of::<rte_ip_frag_tbl>(),
+ 64usize,
+ concat!("Alignment of ", stringify!(rte_ip_frag_tbl))
+ );
+ assert_eq!(
unsafe { &(*(::std::ptr::null::<rte_ip_frag_tbl>())).max_cycles as *const _ as usize },
0usize,
concat!(
diff --git a/tests/expectations/tests/layout_mbuf.rs b/tests/expectations/tests/layout_mbuf.rs
index 83dfb946..6ed1d130 100644
--- a/tests/expectations/tests/layout_mbuf.rs
+++ b/tests/expectations/tests/layout_mbuf.rs
@@ -127,6 +127,7 @@ fn bindgen_test_layout_rte_atomic16_t() {
}
/// The generic rte_mbuf, containing a packet mbuf.
#[repr(C)]
+#[repr(align(64))]
pub struct rte_mbuf {
pub cacheline0: MARKER,
///< Virtual address of segment buffer.
@@ -236,10 +237,10 @@ pub union rte_mbuf__bindgen_ty_2 {
_bindgen_union_align: u32,
}
#[repr(C)]
+#[repr(align(4))]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct rte_mbuf__bindgen_ty_2__bindgen_ty_1 {
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize], u8>,
- pub __bindgen_align: [u32; 0usize],
}
#[test]
fn bindgen_test_layout_rte_mbuf__bindgen_ty_2__bindgen_ty_1() {
@@ -722,10 +723,10 @@ pub union rte_mbuf__bindgen_ty_5 {
_bindgen_union_align: u64,
}
#[repr(C)]
+#[repr(align(8))]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct rte_mbuf__bindgen_ty_5__bindgen_ty_1 {
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 8usize], u16>,
- pub __bindgen_align: [u64; 0usize],
}
#[test]
fn bindgen_test_layout_rte_mbuf__bindgen_ty_5__bindgen_ty_1() {
@@ -889,6 +890,11 @@ fn bindgen_test_layout_rte_mbuf() {
concat!("Size of: ", stringify!(rte_mbuf))
);
assert_eq!(
+ ::std::mem::align_of::<rte_mbuf>(),
+ 64usize,
+ concat!("Alignment of ", stringify!(rte_mbuf))
+ );
+ assert_eq!(
unsafe { &(*(::std::ptr::null::<rte_mbuf>())).cacheline0 as *const _ as usize },
0usize,
concat!(
diff --git a/tests/expectations/tests/libclang-3.8/error-E0600-cannot-apply-unary-negation-to-u32.rs b/tests/expectations/tests/libclang-3.8/error-E0600-cannot-apply-unary-negation-to-u32.rs
index 68eab7a2..04833a65 100644
--- a/tests/expectations/tests/libclang-3.8/error-E0600-cannot-apply-unary-negation-to-u32.rs
+++ b/tests/expectations/tests/libclang-3.8/error-E0600-cannot-apply-unary-negation-to-u32.rs
@@ -6,5 +6,6 @@
non_camel_case_types,
non_upper_case_globals
)]
+#![allow(overflowing_literals)]
pub const a: u32 = 18446744073709551611;
diff --git a/tests/expectations/tests/libclang-3.9/error-E0600-cannot-apply-unary-negation-to-u32.rs b/tests/expectations/tests/libclang-3.9/error-E0600-cannot-apply-unary-negation-to-u32.rs
index 68eab7a2..04833a65 100644
--- a/tests/expectations/tests/libclang-3.9/error-E0600-cannot-apply-unary-negation-to-u32.rs
+++ b/tests/expectations/tests/libclang-3.9/error-E0600-cannot-apply-unary-negation-to-u32.rs
@@ -6,5 +6,6 @@
non_camel_case_types,
non_upper_case_globals
)]
+#![allow(overflowing_literals)]
pub const a: u32 = 18446744073709551611;
diff --git a/tests/expectations/tests/libclang-4/error-E0600-cannot-apply-unary-negation-to-u32.rs b/tests/expectations/tests/libclang-4/error-E0600-cannot-apply-unary-negation-to-u32.rs
index 7ad2fc1c..ce5d0362 100644
--- a/tests/expectations/tests/libclang-4/error-E0600-cannot-apply-unary-negation-to-u32.rs
+++ b/tests/expectations/tests/libclang-4/error-E0600-cannot-apply-unary-negation-to-u32.rs
@@ -6,5 +6,6 @@
non_camel_case_types,
non_upper_case_globals
)]
+#![allow(overflowing_literals)]
pub const a: u32 = 4294967291;
diff --git a/tests/expectations/tests/libclang-5/call-conv-field.rs b/tests/expectations/tests/libclang-5/call-conv-field.rs
index 295a23f9..e167e5eb 100644
--- a/tests/expectations/tests/libclang-5/call-conv-field.rs
+++ b/tests/expectations/tests/libclang-5/call-conv-field.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#![cfg(not(test))]
#[repr(C)]
@@ -20,6 +25,11 @@ fn bindgen_test_layout_JNINativeInterface_() {
concat!("Size of: ", stringify!(JNINativeInterface_))
);
assert_eq!(
+ ::std::mem::align_of::<JNINativeInterface_>(),
+ 8usize,
+ concat!("Alignment of ", stringify!(JNINativeInterface_))
+ );
+ assert_eq!(
unsafe { &(*(::std::ptr::null::<JNINativeInterface_>())).GetVersion as *const _ as usize },
0usize,
concat!(
diff --git a/tests/expectations/tests/libclang-5/error-E0600-cannot-apply-unary-negation-to-u32.rs b/tests/expectations/tests/libclang-5/error-E0600-cannot-apply-unary-negation-to-u32.rs
index 7ad2fc1c..ce5d0362 100644
--- a/tests/expectations/tests/libclang-5/error-E0600-cannot-apply-unary-negation-to-u32.rs
+++ b/tests/expectations/tests/libclang-5/error-E0600-cannot-apply-unary-negation-to-u32.rs
@@ -6,5 +6,6 @@
non_camel_case_types,
non_upper_case_globals
)]
+#![allow(overflowing_literals)]
pub const a: u32 = 4294967291;
diff --git a/tests/expectations/tests/no-hash-opaque.rs b/tests/expectations/tests/no-hash-opaque.rs
index c4211c71..427a3d34 100644
--- a/tests/expectations/tests/no-hash-opaque.rs
+++ b/tests/expectations/tests/no-hash-opaque.rs
@@ -1,10 +1,14 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
+#[repr(align(4))]
#[derive(Debug, Default, Copy, Clone)]
pub struct NoHash {
pub _bindgen_opaque_blob: u32,
diff --git a/tests/expectations/tests/no-partialeq-opaque.rs b/tests/expectations/tests/no-partialeq-opaque.rs
index 1a794162..5bf2d121 100644
--- a/tests/expectations/tests/no-partialeq-opaque.rs
+++ b/tests/expectations/tests/no-partialeq-opaque.rs
@@ -1,10 +1,14 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
+#[repr(align(4))]
#[derive(Debug, Default, Copy, Clone)]
pub struct NoPartialEq {
pub _bindgen_opaque_blob: u32,
diff --git a/tests/expectations/tests/no_copy_opaque.rs b/tests/expectations/tests/no_copy_opaque.rs
index 8de90cd4..6659a95a 100644
--- a/tests/expectations/tests/no_copy_opaque.rs
+++ b/tests/expectations/tests/no_copy_opaque.rs
@@ -1,10 +1,14 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
+#[repr(align(4))]
#[derive(Debug, Default)]
pub struct NoCopy {
pub _bindgen_opaque_blob: u32,
diff --git a/tests/expectations/tests/opaque-tracing.rs b/tests/expectations/tests/opaque-tracing.rs
index 87d91f3c..6bba6245 100644
--- a/tests/expectations/tests/opaque-tracing.rs
+++ b/tests/expectations/tests/opaque-tracing.rs
@@ -1,14 +1,18 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
extern "C" {
#[link_name = "\u{1}_Z3fooP9Container"]
pub fn foo(c: *mut Container);
}
#[repr(C)]
+#[repr(align(4))]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Container {
pub _bindgen_opaque_blob: [u32; 2usize],
diff --git a/tests/expectations/tests/opaque_in_struct.rs b/tests/expectations/tests/opaque_in_struct.rs
index 590c5fdc..9301f7ab 100644
--- a/tests/expectations/tests/opaque_in_struct.rs
+++ b/tests/expectations/tests/opaque_in_struct.rs
@@ -9,6 +9,7 @@
/// <div rustbindgen opaque>
#[repr(C)]
+#[repr(align(4))]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct opaque {
pub _bindgen_opaque_blob: u32,
diff --git a/tests/expectations/tests/opaque_pointer.rs b/tests/expectations/tests/opaque_pointer.rs
index c44a2440..3ec96214 100644
--- a/tests/expectations/tests/opaque_pointer.rs
+++ b/tests/expectations/tests/opaque_pointer.rs
@@ -9,6 +9,7 @@
/// <div rustbindgen opaque></div>
#[repr(C)]
+#[repr(align(4))]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct OtherOpaque {
pub _bindgen_opaque_blob: u32,
diff --git a/tests/expectations/tests/struct_with_anon_union.rs b/tests/expectations/tests/struct_with_anon_union.rs
index f7ddb358..d0328d34 100644
--- a/tests/expectations/tests/struct_with_anon_union.rs
+++ b/tests/expectations/tests/struct_with_anon_union.rs
@@ -1,8 +1,11 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Copy, Clone)]
diff --git a/tests/expectations/tests/struct_with_anon_unnamed_union.rs b/tests/expectations/tests/struct_with_anon_unnamed_union.rs
index 37890019..abb0bd3f 100644
--- a/tests/expectations/tests/struct_with_anon_unnamed_union.rs
+++ b/tests/expectations/tests/struct_with_anon_unnamed_union.rs
@@ -1,8 +1,11 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Copy, Clone)]
diff --git a/tests/expectations/tests/struct_with_nesting.rs b/tests/expectations/tests/struct_with_nesting.rs
index f56c44a5..73787d86 100644
--- a/tests/expectations/tests/struct_with_nesting.rs
+++ b/tests/expectations/tests/struct_with_nesting.rs
@@ -1,8 +1,11 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Copy, Clone)]
diff --git a/tests/expectations/tests/typeref.rs b/tests/expectations/tests/typeref.rs
index d533b9fb..3a76d514 100644
--- a/tests/expectations/tests/typeref.rs
+++ b/tests/expectations/tests/typeref.rs
@@ -1,8 +1,11 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
diff --git a/tests/expectations/tests/union-in-ns.rs b/tests/expectations/tests/union-in-ns.rs
index ee4ac07c..b0d3ac9c 100644
--- a/tests/expectations/tests/union-in-ns.rs
+++ b/tests/expectations/tests/union-in-ns.rs
@@ -1,8 +1,11 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
pub mod root {
diff --git a/tests/expectations/tests/union_dtor.rs b/tests/expectations/tests/union_dtor.rs
index 69359e64..1a3ad716 100644
--- a/tests/expectations/tests/union_dtor.rs
+++ b/tests/expectations/tests/union_dtor.rs
@@ -1,8 +1,11 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
pub union UnionWithDtor {
diff --git a/tests/expectations/tests/union_fields.rs b/tests/expectations/tests/union_fields.rs
index 38657d05..e6f4e229 100644
--- a/tests/expectations/tests/union_fields.rs
+++ b/tests/expectations/tests/union_fields.rs
@@ -1,8 +1,11 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Copy, Clone)]
diff --git a/tests/expectations/tests/union_template.rs b/tests/expectations/tests/union_template.rs
index 515d5688..a8af8b9c 100644
--- a/tests/expectations/tests/union_template.rs
+++ b/tests/expectations/tests/union_template.rs
@@ -1,8 +1,11 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
pub struct NastyStruct {
diff --git a/tests/expectations/tests/union_with_anon_struct.rs b/tests/expectations/tests/union_with_anon_struct.rs
index dbffb17c..a1451332 100644
--- a/tests/expectations/tests/union_with_anon_struct.rs
+++ b/tests/expectations/tests/union_with_anon_struct.rs
@@ -1,8 +1,11 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Copy, Clone)]
diff --git a/tests/expectations/tests/union_with_anon_struct_bitfield.rs b/tests/expectations/tests/union_with_anon_struct_bitfield.rs
index e41fc973..f97f122c 100644
--- a/tests/expectations/tests/union_with_anon_struct_bitfield.rs
+++ b/tests/expectations/tests/union_with_anon_struct_bitfield.rs
@@ -97,10 +97,10 @@ pub union foo {
_bindgen_union_align: u32,
}
#[repr(C)]
+#[repr(align(4))]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct foo__bindgen_ty_1 {
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize], u32>,
- pub __bindgen_align: [u32; 0usize],
}
#[test]
fn bindgen_test_layout_foo__bindgen_ty_1() {
diff --git a/tests/expectations/tests/union_with_anon_union.rs b/tests/expectations/tests/union_with_anon_union.rs
index 43581d8b..aa2abc86 100644
--- a/tests/expectations/tests/union_with_anon_union.rs
+++ b/tests/expectations/tests/union_with_anon_union.rs
@@ -1,8 +1,11 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Copy, Clone)]
diff --git a/tests/expectations/tests/union_with_anon_unnamed_struct.rs b/tests/expectations/tests/union_with_anon_unnamed_struct.rs
index 738aade3..a1267b39 100644
--- a/tests/expectations/tests/union_with_anon_unnamed_struct.rs
+++ b/tests/expectations/tests/union_with_anon_unnamed_struct.rs
@@ -1,8 +1,11 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Copy, Clone)]
diff --git a/tests/expectations/tests/union_with_anon_unnamed_union.rs b/tests/expectations/tests/union_with_anon_unnamed_union.rs
index 35c90285..c6272c13 100644
--- a/tests/expectations/tests/union_with_anon_unnamed_union.rs
+++ b/tests/expectations/tests/union_with_anon_unnamed_union.rs
@@ -1,8 +1,11 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Copy, Clone)]
diff --git a/tests/expectations/tests/union_with_big_member.rs b/tests/expectations/tests/union_with_big_member.rs
index 64ce4d0f..c31a69f9 100644
--- a/tests/expectations/tests/union_with_big_member.rs
+++ b/tests/expectations/tests/union_with_big_member.rs
@@ -1,8 +1,11 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Copy, Clone)]
diff --git a/tests/expectations/tests/union_with_nesting.rs b/tests/expectations/tests/union_with_nesting.rs
index 631005f8..0a4fd91c 100644
--- a/tests/expectations/tests/union_with_nesting.rs
+++ b/tests/expectations/tests/union_with_nesting.rs
@@ -1,8 +1,11 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Copy, Clone)]
diff --git a/tests/expectations/tests/unknown_attr.rs b/tests/expectations/tests/unknown_attr.rs
index 5040465f..a11f105a 100644
--- a/tests/expectations/tests/unknown_attr.rs
+++ b/tests/expectations/tests/unknown_attr.rs
@@ -1,10 +1,14 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
+#[repr(align(16))]
#[derive(Debug, Default, Copy, Clone)]
pub struct max_align_t {
pub __clang_max_align_nonce1: ::std::os::raw::c_longlong,
@@ -20,6 +24,11 @@ fn bindgen_test_layout_max_align_t() {
concat!("Size of: ", stringify!(max_align_t))
);
assert_eq!(
+ ::std::mem::align_of::<max_align_t>(),
+ 16usize,
+ concat!("Alignment of ", stringify!(max_align_t))
+ );
+ assert_eq!(
unsafe {
&(*(::std::ptr::null::<max_align_t>())).__clang_max_align_nonce1 as *const _ as usize
},
diff --git a/tests/expectations/tests/use-core.rs b/tests/expectations/tests/use-core.rs
index d4e53ef1..563258a0 100644
--- a/tests/expectations/tests/use-core.rs
+++ b/tests/expectations/tests/use-core.rs
@@ -1,7 +1,11 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
extern crate core;
diff --git a/tests/headers/error-E0600-cannot-apply-unary-negation-to-u32.h b/tests/headers/error-E0600-cannot-apply-unary-negation-to-u32.h
index c9189952..4c342c0e 100644
--- a/tests/headers/error-E0600-cannot-apply-unary-negation-to-u32.h
+++ b/tests/headers/error-E0600-cannot-apply-unary-negation-to-u32.h
@@ -1,3 +1,5 @@
+// bindgen-flags: --raw-line "#![allow(overflowing_literals)]"
+
typedef unsigned int uint32_t;
uint32_t a = 18446744073709551611;
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__));
diff --git a/tests/headers/layout.h b/tests/headers/layout.h
index d1822a04..b290ee85 100644
--- a/tests/headers/layout.h
+++ b/tests/headers/layout.h
@@ -1,6 +1,10 @@
+// bindgen-flags: --rust-target 1.21
+//
+// FIXME: https://github.com/rust-lang/rust-bindgen/issues/1498
+
struct header
{
char proto;
unsigned int size __attribute__ ((packed));
unsigned char data[] __attribute__ ((aligned(8)));
-} __attribute__ ((aligned, packed)); \ No newline at end of file
+} __attribute__ ((aligned, packed));