diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 3fb4453e2d..3f5ceaaa43 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -84,6 +84,9 @@ struct CodegenResult<'a> { /// need to be referenced by anything. codegen_id: &'a Cell, + /// Whether a bindgen union has been generated at least once. + saw_bindgen_union: bool, + /// Whether an union has been generated at least once. saw_union: bool, @@ -124,6 +127,7 @@ impl<'a> CodegenResult<'a> { CodegenResult { items: vec![], saw_union: false, + saw_bindgen_union: false, saw_incomplete_array: false, saw_objc: false, codegen_id: codegen_id, @@ -138,6 +142,11 @@ impl<'a> CodegenResult<'a> { self.saw_union = true; } + fn saw_bindgen_union(&mut self) { + self.saw_union(); + self.saw_bindgen_union = true; + } + fn saw_incomplete_array(&mut self) { self.saw_incomplete_array = true; } @@ -360,7 +369,7 @@ impl CodeGenerator for Module { } if item.id() == ctx.root_module() { - if result.saw_union && !ctx.options().unstable_rust { + if result.saw_bindgen_union { utils::prepend_union_types(ctx, &mut *result); } if result.saw_incomplete_array { @@ -943,8 +952,8 @@ impl<'a> FieldCodegen<'a> for FieldData { let field_ty = ctx.resolve_type(self.ty()); let ty = self.ty().to_rust_ty_or_opaque(ctx, &()); - // NB: In unstable rust we use proper `union` types. - let ty = if parent.is_union() && !ctx.options().unstable_rust { + // NB: If supported, we use proper `union` types. + let ty = if parent.is_union() && !parent.can_be_rust_union(ctx) { if ctx.options().enable_cxx_namespaces { quote_ty!(ctx.ext_cx(), root::__BindgenUnionField<$ty>) } else { @@ -1077,8 +1086,8 @@ impl BitfieldUnit { ) -> P { let ctor_name = self.ctor_name(ctx); - // If we're generating unstable Rust, add the const. - let fn_prefix = if ctx.options().unstable_rust { + // If supported, add the const. + let fn_prefix = if ctx.options().rust_features().const_fn() { quote_tokens!(ctx.ext_cx(), pub const fn) } else { quote_tokens!(ctx.ext_cx(), pub fn) @@ -1138,8 +1147,8 @@ impl Bitfield { let offset = self.offset_into_unit(); let mask = self.mask(); - // If we're generating unstable Rust, add the const. - let fn_prefix = if ctx.options().unstable_rust { + // If supported, add the const. + let fn_prefix = if ctx.options().rust_features().const_fn() { quote_tokens!(ctx.ext_cx(), pub const fn) } else { quote_tokens!(ctx.ext_cx(), pub fn) @@ -1491,7 +1500,7 @@ impl CodeGenerator for CompInfo { } let canonical_name = item.canonical_name(ctx); - let builder = if is_union && ctx.options().unstable_rust { + let builder = if is_union && self.can_be_rust_union(ctx) { aster::AstBuilder::new() .item() .pub_() @@ -1571,6 +1580,9 @@ impl CodeGenerator for CompInfo { } if is_union { result.saw_union(); + if !self.can_be_rust_union(ctx) { + result.saw_bindgen_union(); + } } let layout = item.kind().expect_type().layout(ctx); @@ -1600,7 +1612,7 @@ impl CodeGenerator for CompInfo { ); } - if is_union && !ctx.options().unstable_rust { + if is_union && !self.can_be_rust_union(ctx) { let layout = layout.expect("Unable to get layout information?"); let ty = BlobTyBuilder::new(layout).build(); let field = StructFieldBuilder::named("bindgen_union_field") diff --git a/src/features.rs b/src/features.rs new file mode 100644 index 0000000000..3f59c6b9df --- /dev/null +++ b/src/features.rs @@ -0,0 +1,185 @@ +//! Contains code for selecting features + +#![deny(missing_docs)] +#![deny(warnings)] +#![deny(unused_extern_crates)] + +use std::io; +use std::str::FromStr; + +/// Define RustTarget struct definition, Default impl, and conversions +/// between RustTarget and String. +macro_rules! rust_target_def { + ( $( $( #[$attr:meta] )* => $release:ident => $value:expr; )* ) => { + /// Represents the version of the Rust language to target. + /// + /// To support a beta release, use the corresponding stable release. + /// + /// This enum will have more variants added as necessary. + #[derive(Debug, Copy, Clone, Eq, PartialEq, PartialOrd, Hash)] + #[allow(non_camel_case_types)] + pub enum RustTarget { + $( + $( + #[$attr] + )* + $release, + )* + } + + impl Default for RustTarget { + /// Gives the latest stable Rust version + fn default() -> RustTarget { + LATEST_STABLE_RUST + } + } + + impl FromStr for RustTarget { + type Err = io::Error; + + /// Create a `RustTarget` from a string. + /// + /// * The stable/beta versions of Rust are of the form "1.0", + /// "1.19", etc. + /// * The nightly version should be specified with "nightly". + fn from_str(s: &str) -> Result { + match s.as_ref() { + $( + stringify!($value) => Ok(RustTarget::$release), + )* + _ => Err( + io::Error::new( + io::ErrorKind::InvalidInput, + concat!( + "Got an invalid rust target. Accepted values ", + "are of the form ", + "\"1.0\" or \"nightly\"."))), + } + } + } + + impl From for String { + fn from(target: RustTarget) -> Self { + match target { + $( + RustTarget::$release => stringify!($value), + )* + }.into() + } + } + } +} + +/// Defines an array slice with all RustTarget values +macro_rules! rust_target_values_def { + ( $( $( #[$attr:meta] )* => $release:ident => $value:expr; )* ) => { + /// Strings of allowed `RustTarget` values + pub static RUST_TARGET_STRINGS: &'static [&str] = &[ + $( + stringify!($value), + )* + ]; + } +} + +/// Defines macro which takes a macro +macro_rules! rust_target_base { + ( $x_macro:ident ) => { + $x_macro!( + /// Rust stable 1.0 + => Stable_1_0 => 1.0; + /// Rust stable 1.19 + => Stable_1_19 => 1.19; + /// Nightly rust + => Nightly => nightly; + ); + } +} + +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_19; + +/// Create RustFeatures struct definition, new(), and a getter for each field +macro_rules! rust_feature_def { + ( $( $( #[$attr:meta] )* => $feature:ident; )* ) => { + /// Features supported by a rust target + #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] + pub struct RustFeatures { + $( + $feature: bool, + )* + } + + impl RustFeatures { + /// Gives a RustFeatures struct with all features disabled + fn new() -> Self { + RustFeatures { + $( + $feature: false, + )* + } + } + + $( + $( + #[$attr] + )* + pub fn $feature(&self) -> bool { + self.$feature + } + )* + } + } +} + +rust_feature_def!( + /// Untagged unions ([RFC 1444](https://github.com/rust-lang/rfcs/blob/master/text/1444-union.md)) + => untagged_union; + /// Constant function ([RFC 911](https://github.com/rust-lang/rfcs/blob/master/text/0911-const-fn.md)) + => const_fn; +); + +impl From for RustFeatures { + fn from(rust_target: RustTarget) -> Self { + let mut features = RustFeatures::new(); + + if rust_target >= RustTarget::Stable_1_19 { + features.untagged_union = true; + } + + if rust_target >= RustTarget::Nightly { + features.const_fn = true; + } + + features + } +} + +impl Default for RustFeatures { + fn default() -> Self { + let default_rust_target: RustTarget = Default::default(); + Self::from(default_rust_target) + } +} + +#[cfg(test)] +mod test { + #![allow(unused_imports)] + use super::*; + + fn test_target(target_str: &str, target: RustTarget) { + let target_string: String = target.into(); + assert_eq!(target_str, target_string); + assert_eq!(target, RustTarget::from_str(target_str).unwrap()); + } + + #[test] + fn str_to_target() { + test_target("1.0", RustTarget::Stable_1_0); + test_target("1.19", RustTarget::Stable_1_19); + test_target("nightly", RustTarget::Nightly); + } +} diff --git a/src/ir/analysis/derive_copy.rs b/src/ir/analysis/derive_copy.rs index f49976327d..dfd0343c5e 100644 --- a/src/ir/analysis/derive_copy.rs +++ b/src/ir/analysis/derive_copy.rs @@ -207,7 +207,7 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDeriveCopy<'ctx, 'gen> { } if info.kind() == CompKind::Union { - if !self.ctx.options().unstable_rust { + if !self.ctx.options().rust_features().untagged_union() { // NOTE: If there's no template parameters we can derive copy // unconditionally, since arrays are magical for rustc, and // __BindgenUnionField always implements copy. diff --git a/src/ir/analysis/derive_debug.rs b/src/ir/analysis/derive_debug.rs index 8990d1cc39..8f2be22ab9 100644 --- a/src/ir/analysis/derive_debug.rs +++ b/src/ir/analysis/derive_debug.rs @@ -208,7 +208,7 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDeriveDebug<'ctx, 'gen> { ); if info.kind() == CompKind::Union { - if self.ctx.options().unstable_rust { + if self.ctx.options().rust_features().untagged_union() { trace!(" cannot derive Debug for Rust unions"); return self.insert(id); } diff --git a/src/ir/analysis/derive_default.rs b/src/ir/analysis/derive_default.rs index fe429e2a09..4c2cad25c9 100644 --- a/src/ir/analysis/derive_default.rs +++ b/src/ir/analysis/derive_default.rs @@ -242,7 +242,7 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDeriveDefault<'ctx, 'gen> { ); if info.kind() == CompKind::Union { - if self.ctx.options().unstable_rust { + if self.ctx.options().rust_features().untagged_union() { trace!(" cannot derive Default for Rust unions"); return self.insert(id); } diff --git a/src/ir/analysis/derive_hash.rs b/src/ir/analysis/derive_hash.rs index 2456143cd3..e879bd2225 100644 --- a/src/ir/analysis/derive_hash.rs +++ b/src/ir/analysis/derive_hash.rs @@ -232,7 +232,7 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDeriveHash<'ctx, 'gen> { ); if info.kind() == CompKind::Union { - if self.ctx.options().unstable_rust { + if self.ctx.options().rust_features().untagged_union() { trace!(" cannot derive Hash for Rust unions"); return self.insert(id); } diff --git a/src/ir/comp.rs b/src/ir/comp.rs index 81bb8d8cb5..ecdfb5debd 100644 --- a/src/ir/comp.rs +++ b/src/ir/comp.rs @@ -10,6 +10,7 @@ use super::traversal::{EdgeKind, Trace, Tracer}; use super::template::TemplateParameters; use clang; use codegen::struct_layout::{align_to, bytes_from_bits_pow2}; +use ir::derive::CanDeriveCopy; use parse::{ClangItemParser, ParseError}; use peeking_take_while::PeekableExt; use std::cell::Cell; @@ -1316,6 +1317,22 @@ impl CompInfo { pub fn compute_bitfield_units(&mut self, ctx: &BindgenContext) { self.fields.compute_bitfield_units(ctx); } + + /// Returns whether the current union can be represented as a Rust `union` + /// + /// Requirements: + /// 1. Current RustTarget allows for `untagged_union` + /// 2. Each field can derive `Copy` + pub fn can_be_rust_union(&self, ctx: &BindgenContext) -> bool { + ctx.options().rust_features().untagged_union() && + self.fields().iter().all(|f| + match *f { + Field::DataMember(ref field_data) => field_data.ty().can_derive_copy(ctx), + Field::Bitfields(_) => false, + } + ) + } + } impl DotAttributes for CompInfo { diff --git a/src/lib.rs b/src/lib.rs index 172597824a..e72800c0fc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -59,6 +59,7 @@ macro_rules! doc_mod { } mod clang; +mod features; mod ir; mod parse; mod regex_set; @@ -69,6 +70,7 @@ pub mod callbacks; mod codegen; doc_mod!(clang, clang_docs); +doc_mod!(features, features_docs); doc_mod!(ir, ir_docs); doc_mod!(parse, parse_docs); doc_mod!(regex_set, regex_set_docs); @@ -77,6 +79,8 @@ mod codegen { include!(concat!(env!("OUT_DIR"), "/codegen.rs")); } +pub use features::{RustTarget, LATEST_STABLE_RUST, RUST_TARGET_STRINGS}; +use features::RustFeatures; use ir::context::{BindgenContext, ItemId}; use ir::item::Item; use parse::{ClangItemParser, ParseError}; @@ -185,6 +189,8 @@ impl Builder { output_vector.push(header); } + output_vector.push(self.options.rust_target.into()); + self.options .bitfield_enums .get_items() @@ -357,10 +363,6 @@ impl Builder { output_vector.push("--no-prepend-enum-name".into()); } - if !self.options.unstable_rust { - output_vector.push("--unstable-rust".into()); - } - self.options .opaque_types .get_items() @@ -492,6 +494,14 @@ impl Builder { self } + /// Specify the rust target + /// + /// The default is the latest stable Rust version + pub fn rust_target(mut self, rust_target: RustTarget) -> Self { + self.options.set_rust_target(rust_target); + self + } + /// Set the output graphviz file. pub fn emit_ir_graphviz>(mut self, path: T) -> Builder { let path = path.into(); @@ -789,9 +799,10 @@ impl Builder { } /// Avoid generating any unstable Rust, such as Rust unions, in the generated bindings. - pub fn unstable_rust(mut self, doit: bool) -> Self { - self.options.unstable_rust = doit; - self + #[deprecated(note="please use `rust_target` instead")] + pub fn unstable_rust(self, doit: bool) -> Self { + let rust_target = if doit { RustTarget::Nightly } else { LATEST_STABLE_RUST }; + self.rust_target(rust_target) } /// Use core instead of libstd in the generated bindings. @@ -1016,10 +1027,6 @@ pub struct BindgenOptions { /// and types. pub derive_hash: bool, - /// True if we can use unstable Rust code in the bindings, false if we - /// cannot. - pub unstable_rust: bool, - /// True if we should avoid using libstd to use libcore instead. pub use_core: bool, @@ -1086,6 +1093,12 @@ pub struct BindgenOptions { /// Whether to prepend the enum name to bitfield or constant variants. pub prepend_enum_name: bool, + + /// Version of the Rust compiler to target + rust_target: RustTarget, + + /// Features to enable, derived from `rust_target` + rust_features: RustFeatures, } /// TODO(emilio): This is sort of a lie (see the error message that results from @@ -1104,11 +1117,34 @@ impl BindgenOptions { self.constified_enum_modules.build(); self.constified_enums.build(); } + + /// Update rust target version + pub fn set_rust_target(&mut self, rust_target: RustTarget) { + self.rust_target = rust_target; + + // Keep rust_features synced with rust_target + self.rust_features = rust_target.into(); + } + + /// Get target Rust version + pub fn rust_target(&self) -> RustTarget { + self.rust_target + } + + /// Get features supported by target Rust version + pub fn rust_features(&self) -> RustFeatures { + self.rust_features + } + } impl Default for BindgenOptions { fn default() -> BindgenOptions { + let rust_target = RustTarget::default(); + BindgenOptions { + rust_target: rust_target, + rust_features: rust_target.into(), hidden_types: Default::default(), opaque_types: Default::default(), whitelisted_types: Default::default(), @@ -1129,7 +1165,6 @@ impl Default for BindgenOptions { derive_hash: false, enable_cxx_namespaces: false, disable_name_namespacing: false, - unstable_rust: false, use_core: false, ctypes_prefix: None, namespaced_constants: true, diff --git a/src/options.rs b/src/options.rs index 8fce0586ec..28faea993e 100644 --- a/src/options.rs +++ b/src/options.rs @@ -1,7 +1,9 @@ -use bindgen::{builder, Builder, CodegenConfig}; + +use bindgen::{Builder, CodegenConfig, RUST_TARGET_STRINGS, RustTarget, builder}; use clap::{App, Arg}; use std::fs::File; -use std::io::{self, Error, ErrorKind}; +use std::io::{self, Error, ErrorKind, Write, stderr}; +use std::str::FromStr; /// Construct a new [`Builder`](./struct.Builder.html) from command line flags. pub fn builder_from_flags( @@ -10,6 +12,10 @@ pub fn builder_from_flags( where I: Iterator, { + let rust_target_help = format!( + "Version of the Rust compiler to target. Valid options are: {:?}.", + RUST_TARGET_STRINGS); + let matches = App::new("bindgen") .version(env!("CARGO_PKG_VERSION")) .about("Generates Rust bindings from C/C++ headers.") @@ -148,7 +154,7 @@ where .help("Do not prepend the enum name to bitfield or constant variants."), Arg::with_name("unstable-rust") .long("unstable-rust") - .help("Generate unstable Rust code.") + .help("Generate unstable Rust code (deprecated; use --rust-target instead).") .multiple(true), // FIXME: Pass legacy test suite Arg::with_name("opaque-type") .long("opaque-type") @@ -168,6 +174,10 @@ where .takes_value(true) .multiple(true) .number_of_values(1), + Arg::with_name("rust-target") + .long("rust-target") + .help(&rust_target_help) + .takes_value(true), Arg::with_name("static") .long("static-link") .help("Link to static library.") @@ -233,6 +243,16 @@ where return Err(Error::new(ErrorKind::Other, "Header not found")); } + if matches.is_present("unstable-rust") { + builder = builder.rust_target(RustTarget::Nightly); + writeln!(&mut stderr(), "warning: the `--unstable-rust` option is deprecated") + .expect("Unable to write error message"); + } + + if let Some(rust_target) = matches.value_of("rust-target") { + builder = builder.rust_target(RustTarget::from_str(rust_target)?); + } + if let Some(bitfields) = matches.values_of("bitfield-enum") { for regex in bitfields { builder = builder.bitfield_enum(regex); @@ -353,10 +373,6 @@ where builder = builder.ignore_methods(); } - if matches.is_present("unstable-rust") { - builder = builder.unstable_rust(true); - } - if matches.is_present("no-convert-floats") { builder = builder.no_convert_floats(); } diff --git a/tests/expectations/tests/16-byte-alignment.rs b/tests/expectations/tests/16-byte-alignment.rs index 1068f3f553..a5781eabfb 100644 --- a/tests/expectations/tests/16-byte-alignment.rs +++ b/tests/expectations/tests/16-byte-alignment.rs @@ -5,45 +5,17 @@ #[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Copy)] pub struct rte_ipv4_tuple { pub src_addr: u32, pub dst_addr: u32, pub __bindgen_anon_1: rte_ipv4_tuple__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct rte_ipv4_tuple__bindgen_ty_1 { - pub __bindgen_anon_1: __BindgenUnionField, - pub sctp_tag: __BindgenUnionField, - pub bindgen_union_field: u32, +#[derive(Copy)] +pub union rte_ipv4_tuple__bindgen_ty_1 { + pub __bindgen_anon_1: rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1, + pub sctp_tag: u32, } #[repr(C)] #[derive(Debug, Default, Copy, Hash)] @@ -98,6 +70,9 @@ fn bindgen_test_layout_rte_ipv4_tuple__bindgen_ty_1() { impl Clone for rte_ipv4_tuple__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +impl Default for rte_ipv4_tuple__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[test] fn bindgen_test_layout_rte_ipv4_tuple() { assert_eq!(::std::mem::size_of::() , 12usize , concat ! ( @@ -118,19 +93,21 @@ fn bindgen_test_layout_rte_ipv4_tuple() { impl Clone for rte_ipv4_tuple { fn clone(&self) -> Self { *self } } +impl Default for rte_ipv4_tuple { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Copy)] pub struct rte_ipv6_tuple { pub src_addr: [u8; 16usize], pub dst_addr: [u8; 16usize], pub __bindgen_anon_1: rte_ipv6_tuple__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct rte_ipv6_tuple__bindgen_ty_1 { - pub __bindgen_anon_1: __BindgenUnionField, - pub sctp_tag: __BindgenUnionField, - pub bindgen_union_field: u32, +#[derive(Copy)] +pub union rte_ipv6_tuple__bindgen_ty_1 { + pub __bindgen_anon_1: rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1, + pub sctp_tag: u32, } #[repr(C)] #[derive(Debug, Default, Copy, Hash)] @@ -185,6 +162,9 @@ fn bindgen_test_layout_rte_ipv6_tuple__bindgen_ty_1() { impl Clone for rte_ipv6_tuple__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +impl Default for rte_ipv6_tuple__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[test] fn bindgen_test_layout_rte_ipv6_tuple() { assert_eq!(::std::mem::size_of::() , 36usize , concat ! ( @@ -205,31 +185,6 @@ fn bindgen_test_layout_rte_ipv6_tuple() { impl Clone for rte_ipv6_tuple { fn clone(&self) -> Self { *self } } -#[repr(C)] -#[derive(Copy)] -pub struct rte_thash_tuple { - pub v4: __BindgenUnionField, - pub v6: __BindgenUnionField, - pub bindgen_union_field: [u8; 48usize], -} -#[test] -fn bindgen_test_layout_rte_thash_tuple() { - assert_eq!(::std::mem::size_of::() , 48usize , concat ! ( - "Size of: " , stringify ! ( rte_thash_tuple ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_thash_tuple ) ) . v4 as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_thash_tuple ) , - "::" , stringify ! ( v4 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_thash_tuple ) ) . v6 as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_thash_tuple ) , - "::" , stringify ! ( v6 ) )); -} -impl Clone for rte_thash_tuple { - fn clone(&self) -> Self { *self } -} -impl Default for rte_thash_tuple { +impl Default for rte_ipv6_tuple { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } diff --git a/tests/expectations/tests/16-byte-alignment_1_0.rs b/tests/expectations/tests/16-byte-alignment_1_0.rs new file mode 100644 index 0000000000..1068f3f553 --- /dev/null +++ b/tests/expectations/tests/16-byte-alignment_1_0.rs @@ -0,0 +1,235 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[repr(C)] +pub struct __BindgenUnionField(::std::marker::PhantomData); +impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } +} +impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } +} +impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl ::std::marker::Copy for __BindgenUnionField { } +impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } +} +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) { } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct rte_ipv4_tuple { + pub src_addr: u32, + pub dst_addr: u32, + pub __bindgen_anon_1: rte_ipv4_tuple__bindgen_ty_1, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct rte_ipv4_tuple__bindgen_ty_1 { + pub __bindgen_anon_1: __BindgenUnionField, + pub sctp_tag: __BindgenUnionField, + pub bindgen_union_field: u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 { + pub dport: u16, + pub sport: u16, +} +#[test] +fn bindgen_test_layout_rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() + , 4usize , concat ! ( + "Size of: " , stringify ! ( + rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() + , 2usize , concat ! ( + "Alignment of " , stringify ! ( + rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( + * ( 0 as * const rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) + ) . dport as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) , "::" , + stringify ! ( dport ) )); + assert_eq! (unsafe { + & ( + * ( 0 as * const rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) + ) . sport as * const _ as usize } , 2usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) , "::" , + stringify ! ( sport ) )); +} +impl Clone for rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_rte_ipv4_tuple__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 4usize + , concat ! ( + "Size of: " , stringify ! ( rte_ipv4_tuple__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() , + 4usize , concat ! ( + "Alignment of " , stringify ! ( rte_ipv4_tuple__bindgen_ty_1 ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ipv4_tuple__bindgen_ty_1 ) ) . + sctp_tag as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_ipv4_tuple__bindgen_ty_1 ) , "::" , stringify ! ( sctp_tag + ) )); +} +impl Clone for rte_ipv4_tuple__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_rte_ipv4_tuple() { + assert_eq!(::std::mem::size_of::() , 12usize , concat ! ( + "Size of: " , stringify ! ( rte_ipv4_tuple ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( rte_ipv4_tuple ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ipv4_tuple ) ) . src_addr as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_ipv4_tuple ) , "::" + , stringify ! ( src_addr ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ipv4_tuple ) ) . dst_addr as * const + _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_ipv4_tuple ) , "::" + , stringify ! ( dst_addr ) )); +} +impl Clone for rte_ipv4_tuple { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct rte_ipv6_tuple { + pub src_addr: [u8; 16usize], + pub dst_addr: [u8; 16usize], + pub __bindgen_anon_1: rte_ipv6_tuple__bindgen_ty_1, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct rte_ipv6_tuple__bindgen_ty_1 { + pub __bindgen_anon_1: __BindgenUnionField, + pub sctp_tag: __BindgenUnionField, + pub bindgen_union_field: u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 { + pub dport: u16, + pub sport: u16, +} +#[test] +fn bindgen_test_layout_rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() + , 4usize , concat ! ( + "Size of: " , stringify ! ( + rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() + , 2usize , concat ! ( + "Alignment of " , stringify ! ( + rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( + * ( 0 as * const rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) + ) . dport as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) , "::" , + stringify ! ( dport ) )); + assert_eq! (unsafe { + & ( + * ( 0 as * const rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) + ) . sport as * const _ as usize } , 2usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) , "::" , + stringify ! ( sport ) )); +} +impl Clone for rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_rte_ipv6_tuple__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 4usize + , concat ! ( + "Size of: " , stringify ! ( rte_ipv6_tuple__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() , + 4usize , concat ! ( + "Alignment of " , stringify ! ( rte_ipv6_tuple__bindgen_ty_1 ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ipv6_tuple__bindgen_ty_1 ) ) . + sctp_tag as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_ipv6_tuple__bindgen_ty_1 ) , "::" , stringify ! ( sctp_tag + ) )); +} +impl Clone for rte_ipv6_tuple__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_rte_ipv6_tuple() { + assert_eq!(::std::mem::size_of::() , 36usize , concat ! ( + "Size of: " , stringify ! ( rte_ipv6_tuple ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( rte_ipv6_tuple ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ipv6_tuple ) ) . src_addr as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_ipv6_tuple ) , "::" + , stringify ! ( src_addr ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ipv6_tuple ) ) . dst_addr as * const + _ as usize } , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_ipv6_tuple ) , "::" + , stringify ! ( dst_addr ) )); +} +impl Clone for rte_ipv6_tuple { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Copy)] +pub struct rte_thash_tuple { + pub v4: __BindgenUnionField, + pub v6: __BindgenUnionField, + pub bindgen_union_field: [u8; 48usize], +} +#[test] +fn bindgen_test_layout_rte_thash_tuple() { + assert_eq!(::std::mem::size_of::() , 48usize , concat ! ( + "Size of: " , stringify ! ( rte_thash_tuple ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_thash_tuple ) ) . v4 as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_thash_tuple ) , + "::" , stringify ! ( v4 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_thash_tuple ) ) . v6 as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_thash_tuple ) , + "::" , stringify ! ( v6 ) )); +} +impl Clone for rte_thash_tuple { + fn clone(&self) -> Self { *self } +} +impl Default for rte_thash_tuple { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} diff --git a/tests/expectations/tests/anon_struct_in_union.rs b/tests/expectations/tests/anon_struct_in_union.rs index b482031931..5eaf6a80db 100644 --- a/tests/expectations/tests/anon_struct_in_union.rs +++ b/tests/expectations/tests/anon_struct_in_union.rs @@ -5,42 +5,14 @@ #[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Copy)] pub struct s { pub u: s__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct s__bindgen_ty_1 { - pub field: __BindgenUnionField, - pub bindgen_union_field: u32, +#[derive(Copy)] +pub union s__bindgen_ty_1 { + pub field: s__bindgen_ty_1_inner, } #[repr(C)] #[derive(Debug, Default, Copy, Hash)] @@ -79,6 +51,9 @@ fn bindgen_test_layout_s__bindgen_ty_1() { impl Clone for s__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +impl Default for s__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[test] fn bindgen_test_layout_s() { assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( @@ -93,3 +68,6 @@ fn bindgen_test_layout_s() { impl Clone for s { fn clone(&self) -> Self { *self } } +impl Default for s { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} diff --git a/tests/expectations/tests/anon_struct_in_union_1_0.rs b/tests/expectations/tests/anon_struct_in_union_1_0.rs new file mode 100644 index 0000000000..b482031931 --- /dev/null +++ b/tests/expectations/tests/anon_struct_in_union_1_0.rs @@ -0,0 +1,95 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[repr(C)] +pub struct __BindgenUnionField(::std::marker::PhantomData); +impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } +} +impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } +} +impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl ::std::marker::Copy for __BindgenUnionField { } +impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } +} +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) { } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct s { + pub u: s__bindgen_ty_1, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct s__bindgen_ty_1 { + pub field: __BindgenUnionField, + pub bindgen_union_field: u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct s__bindgen_ty_1_inner { + pub b: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_s__bindgen_ty_1_inner() { + assert_eq!(::std::mem::size_of::() , 4usize , + concat ! ( "Size of: " , stringify ! ( s__bindgen_ty_1_inner ) + )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( s__bindgen_ty_1_inner ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const s__bindgen_ty_1_inner ) ) . b as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( s__bindgen_ty_1_inner ) + , "::" , stringify ! ( b ) )); +} +impl Clone for s__bindgen_ty_1_inner { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_s__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( s__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! + ( "Alignment of " , stringify ! ( s__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const s__bindgen_ty_1 ) ) . field as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( s__bindgen_ty_1 ) , + "::" , stringify ! ( field ) )); +} +impl Clone for s__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_s() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( s ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( s ) )); + assert_eq! (unsafe { & ( * ( 0 as * const s ) ) . u as * const _ as usize + } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( s ) , "::" , stringify + ! ( u ) )); +} +impl Clone for s { + fn clone(&self) -> Self { *self } +} diff --git a/tests/expectations/tests/anon_union.rs b/tests/expectations/tests/anon_union.rs index 71c2d4f706..df24a0cbfb 100644 --- a/tests/expectations/tests/anon_union.rs +++ b/tests/expectations/tests/anon_union.rs @@ -5,34 +5,6 @@ #[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } -} -#[repr(C)] -#[derive(Debug, Copy, Clone, Hash)] pub struct TErrorResult { pub mResult: ::std::os::raw::c_int, pub __bindgen_anon_1: TErrorResult__bindgen_ty_1, @@ -55,17 +27,17 @@ pub struct TErrorResult_DOMExceptionInfo { pub _address: u8, } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash)] -pub struct TErrorResult__bindgen_ty_1 { - pub mMessage: __BindgenUnionField<*mut TErrorResult_Message>, - pub mDOMExceptionInfo: __BindgenUnionField<*mut TErrorResult_DOMExceptionInfo>, - pub bindgen_union_field: u64, +pub union TErrorResult__bindgen_ty_1 { + pub mMessage: *mut TErrorResult_Message, + pub mDOMExceptionInfo: *mut TErrorResult_DOMExceptionInfo, +} +impl Default for TErrorResult__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } } impl Default for TErrorResult { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy, Hash)] pub struct ErrorResult { pub _base: TErrorResult, } @@ -76,9 +48,6 @@ fn bindgen_test_layout_ErrorResult() { assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( "Alignment of " , stringify ! ( ErrorResult ) )); } -impl Clone for ErrorResult { - fn clone(&self) -> Self { *self } -} impl Default for ErrorResult { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } diff --git a/tests/expectations/tests/anon_union_1_0.rs b/tests/expectations/tests/anon_union_1_0.rs new file mode 100644 index 0000000000..71c2d4f706 --- /dev/null +++ b/tests/expectations/tests/anon_union_1_0.rs @@ -0,0 +1,93 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[repr(C)] +pub struct __BindgenUnionField(::std::marker::PhantomData); +impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } +} +impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } +} +impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl ::std::marker::Copy for __BindgenUnionField { } +impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } +} +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) { } +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash)] +pub struct TErrorResult { + pub mResult: ::std::os::raw::c_int, + pub __bindgen_anon_1: TErrorResult__bindgen_ty_1, + pub mMightHaveUnreported: bool, + pub mUnionState: TErrorResult_UnionState, +} +pub const TErrorResult_UnionState_HasException: TErrorResult_UnionState = + TErrorResult_UnionState::HasMessage; +#[repr(i32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum TErrorResult_UnionState { HasMessage = 0, } +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash)] +pub struct TErrorResult_Message { + pub _address: u8, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash)] +pub struct TErrorResult_DOMExceptionInfo { + pub _address: u8, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash)] +pub struct TErrorResult__bindgen_ty_1 { + pub mMessage: __BindgenUnionField<*mut TErrorResult_Message>, + pub mDOMExceptionInfo: __BindgenUnionField<*mut TErrorResult_DOMExceptionInfo>, + pub bindgen_union_field: u64, +} +impl Default for TErrorResult { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +#[repr(C)] +#[derive(Debug, Copy, Hash)] +pub struct ErrorResult { + pub _base: TErrorResult, +} +#[test] +fn bindgen_test_layout_ErrorResult() { + assert_eq!(::std::mem::size_of::() , 24usize , concat ! ( + "Size of: " , stringify ! ( ErrorResult ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( ErrorResult ) )); +} +impl Clone for ErrorResult { + fn clone(&self) -> Self { *self } +} +impl Default for ErrorResult { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +#[test] +fn __bindgen_test_layout_TErrorResult_open0_int_close0_instantiation() { + assert_eq!(::std::mem::size_of::() , 24usize , concat ! ( + "Size of template specialization: " , stringify ! ( + TErrorResult ) )); + assert_eq!(::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( + TErrorResult ) )); +} diff --git a/tests/expectations/tests/class.rs b/tests/expectations/tests/class.rs index b628ab111c..bfaf566a02 100644 --- a/tests/expectations/tests/class.rs +++ b/tests/expectations/tests/class.rs @@ -38,33 +38,6 @@ impl ::std::clone::Clone for __IncompleteArrayField { } impl ::std::marker::Copy for __IncompleteArrayField { } #[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } -} -#[repr(C)] #[derive(Copy)] pub struct C { pub a: ::std::os::raw::c_int, @@ -203,11 +176,10 @@ impl Default for IncompleteArrayNonCopiable { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct Union { - pub d: __BindgenUnionField, - pub i: __BindgenUnionField<::std::os::raw::c_int>, - pub bindgen_union_field: u32, +#[derive(Copy)] +pub union Union { + pub d: f32, + pub i: ::std::os::raw::c_int, } #[test] fn bindgen_test_layout_Union() { @@ -229,8 +201,11 @@ fn bindgen_test_layout_Union() { impl Clone for Union { fn clone(&self) -> Self { *self } } +impl Default for Union { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Copy)] pub struct WithUnion { pub data: Union, } @@ -249,6 +224,9 @@ fn bindgen_test_layout_WithUnion() { impl Clone for WithUnion { fn clone(&self) -> Self { *self } } +impl Default for WithUnion { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[repr(C)] #[derive(Debug, Default, Copy, Hash)] pub struct RealAbstractionWithTonsOfMethods { diff --git a/tests/expectations/tests/class_1_0.rs b/tests/expectations/tests/class_1_0.rs new file mode 100644 index 0000000000..b628ab111c --- /dev/null +++ b/tests/expectations/tests/class_1_0.rs @@ -0,0 +1,304 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[repr(C)] +#[derive(Default)] +pub struct __IncompleteArrayField(::std::marker::PhantomData); +impl __IncompleteArrayField { + #[inline] + pub fn new() -> Self { + __IncompleteArrayField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ptr(&self) -> *const T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut_ptr(&mut self) -> *mut T { + ::std::mem::transmute(self) + } + #[inline] + pub unsafe fn as_slice(&self, len: usize) -> &[T] { + ::std::slice::from_raw_parts(self.as_ptr(), len) + } + #[inline] + pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { + ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) + } +} +impl ::std::fmt::Debug for __IncompleteArrayField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__IncompleteArrayField") + } +} +impl ::std::clone::Clone for __IncompleteArrayField { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl ::std::marker::Copy for __IncompleteArrayField { } +#[repr(C)] +pub struct __BindgenUnionField(::std::marker::PhantomData); +impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } +} +impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } +} +impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl ::std::marker::Copy for __BindgenUnionField { } +impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } +} +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) { } +} +#[repr(C)] +#[derive(Copy)] +pub struct C { + pub a: ::std::os::raw::c_int, + pub big_array: [::std::os::raw::c_char; 33usize], +} +#[test] +fn bindgen_test_layout_C() { + assert_eq!(::std::mem::size_of::() , 40usize , concat ! ( + "Size of: " , stringify ! ( C ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( C ) )); + assert_eq! (unsafe { & ( * ( 0 as * const C ) ) . a as * const _ as usize + } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( C ) , "::" , stringify + ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C ) ) . big_array as * const _ as usize } + , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( C ) , "::" , stringify + ! ( big_array ) )); +} +impl Clone for C { + fn clone(&self) -> Self { *self } +} +impl Default for C { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +#[repr(C)] +pub struct C_with_zero_length_array { + pub a: ::std::os::raw::c_int, + pub big_array: [::std::os::raw::c_char; 33usize], + pub zero_length_array: __IncompleteArrayField<::std::os::raw::c_char>, +} +#[test] +fn bindgen_test_layout_C_with_zero_length_array() { + assert_eq!(::std::mem::size_of::() , 40usize , + concat ! ( + "Size of: " , stringify ! ( C_with_zero_length_array ) )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( C_with_zero_length_array ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C_with_zero_length_array ) ) . a as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + C_with_zero_length_array ) , "::" , stringify ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C_with_zero_length_array ) ) . big_array + as * const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( + C_with_zero_length_array ) , "::" , stringify ! ( big_array ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const C_with_zero_length_array ) ) . + zero_length_array as * const _ as usize } , 37usize , concat ! + ( + "Alignment of field: " , stringify ! ( + C_with_zero_length_array ) , "::" , stringify ! ( + zero_length_array ) )); +} +impl Default for C_with_zero_length_array { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +#[repr(C)] +pub struct C_with_incomplete_array { + pub a: ::std::os::raw::c_int, + pub big_array: [::std::os::raw::c_char; 33usize], + pub incomplete_array: __IncompleteArrayField<::std::os::raw::c_char>, +} +#[test] +fn bindgen_test_layout_C_with_incomplete_array() { + assert_eq!(::std::mem::size_of::() , 40usize , + concat ! ( + "Size of: " , stringify ! ( C_with_incomplete_array ) )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( C_with_incomplete_array ) )); +} +impl Default for C_with_incomplete_array { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +#[repr(C)] +pub struct C_with_zero_length_array_and_incomplete_array { + pub a: ::std::os::raw::c_int, + pub big_array: [::std::os::raw::c_char; 33usize], + pub zero_length_array: __IncompleteArrayField<::std::os::raw::c_char>, + pub incomplete_array: __IncompleteArrayField<::std::os::raw::c_char>, +} +#[test] +fn bindgen_test_layout_C_with_zero_length_array_and_incomplete_array() { + assert_eq!(::std::mem::size_of::() + , 40usize , concat ! ( + "Size of: " , stringify ! ( + C_with_zero_length_array_and_incomplete_array ) )); + assert_eq! (::std::mem::align_of::() + , 4usize , concat ! ( + "Alignment of " , stringify ! ( + C_with_zero_length_array_and_incomplete_array ) )); +} +impl Default for C_with_zero_length_array_and_incomplete_array { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +#[repr(C)] +#[derive(Debug, Default, Hash)] +pub struct WithDtor { + pub b: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_WithDtor() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( WithDtor ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( WithDtor ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const WithDtor ) ) . b as * const _ as usize } + , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( WithDtor ) , "::" , + stringify ! ( b ) )); +} +#[repr(C)] +pub struct IncompleteArrayNonCopiable { + pub whatever: *mut ::std::os::raw::c_void, + pub incomplete_array: __IncompleteArrayField, +} +#[test] +fn bindgen_test_layout_IncompleteArrayNonCopiable() { + assert_eq!(::std::mem::size_of::() , 8usize , + concat ! ( + "Size of: " , stringify ! ( IncompleteArrayNonCopiable ) )); + assert_eq! (::std::mem::align_of::() , 8usize + , concat ! ( + "Alignment of " , stringify ! ( IncompleteArrayNonCopiable ) + )); +} +impl Default for IncompleteArrayNonCopiable { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct Union { + pub d: __BindgenUnionField, + pub i: __BindgenUnionField<::std::os::raw::c_int>, + pub bindgen_union_field: u32, +} +#[test] +fn bindgen_test_layout_Union() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( Union ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( Union ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Union ) ) . d as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( Union ) , "::" , + stringify ! ( d ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Union ) ) . i as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( Union ) , "::" , + stringify ! ( i ) )); +} +impl Clone for Union { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct WithUnion { + pub data: Union, +} +#[test] +fn bindgen_test_layout_WithUnion() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( WithUnion ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( WithUnion ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const WithUnion ) ) . data as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( WithUnion ) , "::" , + stringify ! ( data ) )); +} +impl Clone for WithUnion { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct RealAbstractionWithTonsOfMethods { + pub _address: u8, +} +#[test] +fn bindgen_test_layout_RealAbstractionWithTonsOfMethods() { + assert_eq!(::std::mem::size_of::() , + 1usize , concat ! ( + "Size of: " , stringify ! ( RealAbstractionWithTonsOfMethods ) + )); + assert_eq! (::std::mem::align_of::() , + 1usize , concat ! ( + "Alignment of " , stringify ! ( + RealAbstractionWithTonsOfMethods ) )); +} +extern "C" { + #[link_name = "_ZNK32RealAbstractionWithTonsOfMethods3barEv"] + pub fn RealAbstractionWithTonsOfMethods_bar(this: + *const RealAbstractionWithTonsOfMethods); +} +extern "C" { + #[link_name = "_ZN32RealAbstractionWithTonsOfMethods3barEv"] + pub fn RealAbstractionWithTonsOfMethods_bar1(this: + *mut RealAbstractionWithTonsOfMethods); +} +extern "C" { + #[link_name = "_ZN32RealAbstractionWithTonsOfMethods3barEi"] + pub fn RealAbstractionWithTonsOfMethods_bar2(this: + *mut RealAbstractionWithTonsOfMethods, + foo: ::std::os::raw::c_int); +} +extern "C" { + #[link_name = "_ZN32RealAbstractionWithTonsOfMethods3staEv"] + pub fn RealAbstractionWithTonsOfMethods_sta(); +} +impl Clone for RealAbstractionWithTonsOfMethods { + fn clone(&self) -> Self { *self } +} +impl RealAbstractionWithTonsOfMethods { + #[inline] + pub unsafe fn bar(&self) { RealAbstractionWithTonsOfMethods_bar(self) } + #[inline] + pub unsafe fn bar1(&mut self) { + RealAbstractionWithTonsOfMethods_bar1(self) + } + #[inline] + pub unsafe fn bar2(&mut self, foo: ::std::os::raw::c_int) { + RealAbstractionWithTonsOfMethods_bar2(self, foo) + } + #[inline] + pub unsafe fn sta() { RealAbstractionWithTonsOfMethods_sta() } +} diff --git a/tests/expectations/tests/class_with_inner_struct.rs b/tests/expectations/tests/class_with_inner_struct.rs index 4ccafab43a..63911afb67 100644 --- a/tests/expectations/tests/class_with_inner_struct.rs +++ b/tests/expectations/tests/class_with_inner_struct.rs @@ -5,34 +5,7 @@ #[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Copy)] pub struct A { pub c: ::std::os::raw::c_uint, pub named_union: A__bindgen_ty_1, @@ -65,10 +38,9 @@ impl Clone for A_Segment { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct A__bindgen_ty_1 { - pub f: __BindgenUnionField<::std::os::raw::c_int>, - pub bindgen_union_field: u32, +#[derive(Copy)] +pub union A__bindgen_ty_1 { + pub f: ::std::os::raw::c_int, } #[test] fn bindgen_test_layout_A__bindgen_ty_1() { @@ -85,11 +57,13 @@ fn bindgen_test_layout_A__bindgen_ty_1() { impl Clone for A__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +impl Default for A__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct A__bindgen_ty_2 { - pub d: __BindgenUnionField<::std::os::raw::c_int>, - pub bindgen_union_field: u32, +#[derive(Copy)] +pub union A__bindgen_ty_2 { + pub d: ::std::os::raw::c_int, } #[test] fn bindgen_test_layout_A__bindgen_ty_2() { @@ -106,6 +80,9 @@ fn bindgen_test_layout_A__bindgen_ty_2() { impl Clone for A__bindgen_ty_2 { fn clone(&self) -> Self { *self } } +impl Default for A__bindgen_ty_2 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[test] fn bindgen_test_layout_A() { assert_eq!(::std::mem::size_of::() , 12usize , concat ! ( @@ -125,6 +102,9 @@ fn bindgen_test_layout_A() { impl Clone for A { fn clone(&self) -> Self { *self } } +impl Default for A { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[repr(C)] #[derive(Debug, Default, Copy, Hash)] pub struct B { @@ -179,17 +159,16 @@ pub enum StepSyntax { FunctionalWithEndKeyword = 3, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Copy)] pub struct C { pub d: ::std::os::raw::c_uint, pub __bindgen_anon_1: C__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct C__bindgen_ty_1 { - pub mFunc: __BindgenUnionField, - pub __bindgen_anon_1: __BindgenUnionField, - pub bindgen_union_field: [u32; 4usize], +#[derive(Copy)] +pub union C__bindgen_ty_1 { + pub mFunc: C__bindgen_ty_1__bindgen_ty_1, + pub __bindgen_anon_1: C__bindgen_ty_1__bindgen_ty_2, } #[repr(C)] #[derive(Debug, Default, Copy)] @@ -285,6 +264,9 @@ fn bindgen_test_layout_C__bindgen_ty_1() { impl Clone for C__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +impl Default for C__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[repr(C)] #[derive(Debug, Default, Copy, Hash)] pub struct C_Segment { @@ -325,3 +307,6 @@ fn bindgen_test_layout_C() { impl Clone for C { fn clone(&self) -> Self { *self } } +impl Default for C { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} diff --git a/tests/expectations/tests/class_with_inner_struct_1_0.rs b/tests/expectations/tests/class_with_inner_struct_1_0.rs new file mode 100644 index 0000000000..4ccafab43a --- /dev/null +++ b/tests/expectations/tests/class_with_inner_struct_1_0.rs @@ -0,0 +1,327 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[repr(C)] +pub struct __BindgenUnionField(::std::marker::PhantomData); +impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } +} +impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } +} +impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl ::std::marker::Copy for __BindgenUnionField { } +impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } +} +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) { } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct A { + pub c: ::std::os::raw::c_uint, + pub named_union: A__bindgen_ty_1, + pub __bindgen_anon_1: A__bindgen_ty_2, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct A_Segment { + pub begin: ::std::os::raw::c_int, + pub end: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_A_Segment() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( A_Segment ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( A_Segment ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const A_Segment ) ) . begin as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( A_Segment ) , "::" , + stringify ! ( begin ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const A_Segment ) ) . end as * const _ as usize + } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( A_Segment ) , "::" , + stringify ! ( end ) )); +} +impl Clone for A_Segment { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct A__bindgen_ty_1 { + pub f: __BindgenUnionField<::std::os::raw::c_int>, + pub bindgen_union_field: u32, +} +#[test] +fn bindgen_test_layout_A__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( A__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! + ( "Alignment of " , stringify ! ( A__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const A__bindgen_ty_1 ) ) . f as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( A__bindgen_ty_1 ) , + "::" , stringify ! ( f ) )); +} +impl Clone for A__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct A__bindgen_ty_2 { + pub d: __BindgenUnionField<::std::os::raw::c_int>, + pub bindgen_union_field: u32, +} +#[test] +fn bindgen_test_layout_A__bindgen_ty_2() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( A__bindgen_ty_2 ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! + ( "Alignment of " , stringify ! ( A__bindgen_ty_2 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const A__bindgen_ty_2 ) ) . d as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( A__bindgen_ty_2 ) , + "::" , stringify ! ( d ) )); +} +impl Clone for A__bindgen_ty_2 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_A() { + assert_eq!(::std::mem::size_of::() , 12usize , concat ! ( + "Size of: " , stringify ! ( A ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( A ) )); + assert_eq! (unsafe { & ( * ( 0 as * const A ) ) . c as * const _ as usize + } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( A ) , "::" , stringify + ! ( c ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const A ) ) . named_union as * const _ as usize + } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( A ) , "::" , stringify + ! ( named_union ) )); +} +impl Clone for A { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct B { + pub d: ::std::os::raw::c_uint, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct B_Segment { + pub begin: ::std::os::raw::c_int, + pub end: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_B_Segment() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( B_Segment ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( B_Segment ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const B_Segment ) ) . begin as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( B_Segment ) , "::" , + stringify ! ( begin ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const B_Segment ) ) . end as * const _ as usize + } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( B_Segment ) , "::" , + stringify ! ( end ) )); +} +impl Clone for B_Segment { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_B() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( B ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( B ) )); + assert_eq! (unsafe { & ( * ( 0 as * const B ) ) . d as * const _ as usize + } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( B ) , "::" , stringify + ! ( d ) )); +} +impl Clone for B { + fn clone(&self) -> Self { *self } +} +#[repr(i32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum StepSyntax { + Keyword = 0, + FunctionalWithoutKeyword = 1, + FunctionalWithStartKeyword = 2, + FunctionalWithEndKeyword = 3, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct C { + pub d: ::std::os::raw::c_uint, + pub __bindgen_anon_1: C__bindgen_ty_1, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct C__bindgen_ty_1 { + pub mFunc: __BindgenUnionField, + pub __bindgen_anon_1: __BindgenUnionField, + pub bindgen_union_field: [u32; 4usize], +} +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct C__bindgen_ty_1__bindgen_ty_1 { + pub mX1: f32, + pub mY1: f32, + pub mX2: f32, + pub mY2: f32, +} +#[test] +fn bindgen_test_layout_C__bindgen_ty_1__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , + 16usize , concat ! ( + "Size of: " , stringify ! ( C__bindgen_ty_1__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() , + 4usize , concat ! ( + "Alignment of " , stringify ! ( C__bindgen_ty_1__bindgen_ty_1 + ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_1 ) ) . mX1 + as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + C__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( mX1 ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_1 ) ) . mY1 + as * const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( + C__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( mY1 ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_1 ) ) . mX2 + as * const _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( + C__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( mX2 ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_1 ) ) . mY2 + as * const _ as usize } , 12usize , concat ! ( + "Alignment of field: " , stringify ! ( + C__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( mY2 ) + )); +} +impl Clone for C__bindgen_ty_1__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Copy, Hash)] +pub struct C__bindgen_ty_1__bindgen_ty_2 { + pub mStepSyntax: StepSyntax, + pub mSteps: ::std::os::raw::c_uint, +} +#[test] +fn bindgen_test_layout_C__bindgen_ty_1__bindgen_ty_2() { + assert_eq!(::std::mem::size_of::() , 8usize + , concat ! ( + "Size of: " , stringify ! ( C__bindgen_ty_1__bindgen_ty_2 ) )); + assert_eq! (::std::mem::align_of::() , + 4usize , concat ! ( + "Alignment of " , stringify ! ( C__bindgen_ty_1__bindgen_ty_2 + ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_2 ) ) . + mStepSyntax as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + C__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( + mStepSyntax ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_2 ) ) . + mSteps as * const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( + C__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( mSteps + ) )); +} +impl Clone for C__bindgen_ty_1__bindgen_ty_2 { + fn clone(&self) -> Self { *self } +} +impl Default for C__bindgen_ty_1__bindgen_ty_2 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +#[test] +fn bindgen_test_layout_C__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 16usize , concat ! ( + "Size of: " , stringify ! ( C__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! + ( "Alignment of " , stringify ! ( C__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C__bindgen_ty_1 ) ) . mFunc as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( C__bindgen_ty_1 ) , + "::" , stringify ! ( mFunc ) )); +} +impl Clone for C__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct C_Segment { + pub begin: ::std::os::raw::c_int, + pub end: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_C_Segment() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( C_Segment ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( C_Segment ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C_Segment ) ) . begin as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( C_Segment ) , "::" , + stringify ! ( begin ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C_Segment ) ) . end as * const _ as usize + } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( C_Segment ) , "::" , + stringify ! ( end ) )); +} +impl Clone for C_Segment { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_C() { + assert_eq!(::std::mem::size_of::() , 20usize , concat ! ( + "Size of: " , stringify ! ( C ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( C ) )); + assert_eq! (unsafe { & ( * ( 0 as * const C ) ) . d as * const _ as usize + } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( C ) , "::" , stringify + ! ( d ) )); +} +impl Clone for C { + fn clone(&self) -> Self { *self } +} diff --git a/tests/expectations/tests/forward_declared_complex_types_1_0.rs b/tests/expectations/tests/forward_declared_complex_types_1_0.rs new file mode 100644 index 0000000000..9baa2d8d75 --- /dev/null +++ b/tests/expectations/tests/forward_declared_complex_types_1_0.rs @@ -0,0 +1,71 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct Foo_empty { + pub _address: u8, +} +#[test] +fn bindgen_test_layout_Foo_empty() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of: " , stringify ! ( Foo_empty ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( Foo_empty ) )); +} +impl Clone for Foo_empty { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Foo { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Bar { + pub f: *mut Foo, +} +#[test] +fn bindgen_test_layout_Bar() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( Bar ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( Bar ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Bar ) ) . f as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( Bar ) , "::" , + stringify ! ( f ) )); +} +impl Clone for Bar { + fn clone(&self) -> Self { *self } +} +impl Default for Bar { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +extern "C" { + #[link_name = "_Z10baz_structP3Foo"] + pub fn baz_struct(f: *mut Foo); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Union { + _unused: [u8; 0], +} +extern "C" { + #[link_name = "_Z9baz_unionP5Union"] + pub fn baz_union(u: *mut Union); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Quux { + _unused: [u8; 0], +} +extern "C" { + #[link_name = "_Z9baz_classP4Quux"] + pub fn baz_class(q: *mut Quux); +} diff --git a/tests/expectations/tests/issue-493.rs b/tests/expectations/tests/issue-493.rs index d25bb4a0fd..781f0758fc 100644 --- a/tests/expectations/tests/issue-493.rs +++ b/tests/expectations/tests/issue-493.rs @@ -55,23 +55,22 @@ pub const basic_string___min_cap: basic_string__bindgen_ty_1 = #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum basic_string__bindgen_ty_1 { __min_cap = 0, } #[repr(C)] -#[derive(Debug, Copy, Clone, Hash)] pub struct basic_string___short { pub __bindgen_anon_1: basic_string___short__bindgen_ty_1, pub __data_: *mut basic_string_value_type, } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash)] -pub struct basic_string___short__bindgen_ty_1 { - pub __size_: __BindgenUnionField<::std::os::raw::c_uchar>, - pub __lx: __BindgenUnionField, - pub bindgen_union_field: u8, +pub union basic_string___short__bindgen_ty_1 { + pub __size_: ::std::os::raw::c_uchar, + pub __lx: basic_string_value_type, +} +impl Default for basic_string___short__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } } impl Default for basic_string___short { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Copy, Clone)] pub struct basic_string___ulx { pub __lx: __BindgenUnionField, pub __lxx: __BindgenUnionField, @@ -94,12 +93,10 @@ impl Default for basic_string___raw { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Copy, Clone)] pub struct basic_string___rep { pub __bindgen_anon_1: basic_string___rep__bindgen_ty_1, } #[repr(C)] -#[derive(Copy, Clone)] pub struct basic_string___rep__bindgen_ty_1 { pub __l: __BindgenUnionField, pub __s: __BindgenUnionField, diff --git a/tests/expectations/tests/issue-493_1_0.rs b/tests/expectations/tests/issue-493_1_0.rs new file mode 100644 index 0000000000..d25bb4a0fd --- /dev/null +++ b/tests/expectations/tests/issue-493_1_0.rs @@ -0,0 +1,114 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[repr(C)] +pub struct __BindgenUnionField(::std::marker::PhantomData); +impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } +} +impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } +} +impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl ::std::marker::Copy for __BindgenUnionField { } +impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } +} +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) { } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash)] +pub struct basic_string { + pub _address: u8, +} +pub type basic_string_size_type = ::std::os::raw::c_ulonglong; +pub type basic_string_value_type = ::std::os::raw::c_char; +pub type basic_string_pointer = *mut basic_string_value_type; +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash)] +pub struct basic_string___long { + pub __cap_: basic_string_size_type, + pub __size_: basic_string_size_type, + pub __data_: basic_string_pointer, +} +impl Default for basic_string___long { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +pub const basic_string___min_cap: basic_string__bindgen_ty_1 = + basic_string__bindgen_ty_1::__min_cap; +#[repr(i32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum basic_string__bindgen_ty_1 { __min_cap = 0, } +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash)] +pub struct basic_string___short { + pub __bindgen_anon_1: basic_string___short__bindgen_ty_1, + pub __data_: *mut basic_string_value_type, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash)] +pub struct basic_string___short__bindgen_ty_1 { + pub __size_: __BindgenUnionField<::std::os::raw::c_uchar>, + pub __lx: __BindgenUnionField, + pub bindgen_union_field: u8, +} +impl Default for basic_string___short { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct basic_string___ulx { + pub __lx: __BindgenUnionField, + pub __lxx: __BindgenUnionField, + pub bindgen_union_field: [u8; 0usize], +} +impl Default for basic_string___ulx { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +pub const basic_string___n_words: basic_string__bindgen_ty_2 = + basic_string__bindgen_ty_2::__n_words; +#[repr(i32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum basic_string__bindgen_ty_2 { __n_words = 0, } +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash)] +pub struct basic_string___raw { + pub __words: *mut basic_string_size_type, +} +impl Default for basic_string___raw { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct basic_string___rep { + pub __bindgen_anon_1: basic_string___rep__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct basic_string___rep__bindgen_ty_1 { + pub __l: __BindgenUnionField, + pub __s: __BindgenUnionField, + pub __r: __BindgenUnionField, + pub bindgen_union_field: [u8; 0usize], +} +impl Default for basic_string___rep__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +impl Default for basic_string___rep { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} diff --git a/tests/expectations/tests/jsval_layout_opaque.rs b/tests/expectations/tests/jsval_layout_opaque.rs index 536d8c5973..cda3248af5 100644 --- a/tests/expectations/tests/jsval_layout_opaque.rs +++ b/tests/expectations/tests/jsval_layout_opaque.rs @@ -4,33 +4,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } -} pub const JSVAL_TAG_SHIFT: ::std::os::raw::c_uint = 47; pub const JSVAL_PAYLOAD_MASK: ::std::os::raw::c_ulonglong = 140737488355327; pub const JSVAL_TAG_MASK: ::std::os::raw::c_longlong = -140737488355328; @@ -99,16 +72,15 @@ pub enum JSWhyMagic { JS_WHY_MAGIC_COUNT = 18, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct jsval_layout { - pub asBits: __BindgenUnionField, - pub debugView: __BindgenUnionField, - pub s: __BindgenUnionField, - pub asDouble: __BindgenUnionField, - pub asPtr: __BindgenUnionField<*mut ::std::os::raw::c_void>, - pub asWord: __BindgenUnionField, - pub asUIntPtr: __BindgenUnionField, - pub bindgen_union_field: u64, +#[derive(Copy)] +pub union jsval_layout { + pub asBits: u64, + pub debugView: jsval_layout__bindgen_ty_1, + pub s: jsval_layout__bindgen_ty_2, + pub asDouble: f64, + pub asPtr: *mut ::std::os::raw::c_void, + pub asWord: usize, + pub asUIntPtr: usize, } #[repr(C)] #[derive(Debug, Copy, Hash)] @@ -217,17 +189,16 @@ impl jsval_layout__bindgen_ty_1 { } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Copy)] pub struct jsval_layout__bindgen_ty_2 { pub payload: jsval_layout__bindgen_ty_2__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct jsval_layout__bindgen_ty_2__bindgen_ty_1 { - pub i32: __BindgenUnionField, - pub u32: __BindgenUnionField, - pub why: __BindgenUnionField, - pub bindgen_union_field: u32, +#[derive(Copy)] +pub union jsval_layout__bindgen_ty_2__bindgen_ty_1 { + pub i32: i32, + pub u32: u32, + pub why: JSWhyMagic, } #[test] fn bindgen_test_layout_jsval_layout__bindgen_ty_2__bindgen_ty_1() { @@ -264,6 +235,9 @@ fn bindgen_test_layout_jsval_layout__bindgen_ty_2__bindgen_ty_1() { impl Clone for jsval_layout__bindgen_ty_2__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +impl Default for jsval_layout__bindgen_ty_2__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[test] fn bindgen_test_layout_jsval_layout__bindgen_ty_2() { assert_eq!(::std::mem::size_of::() , 4usize , @@ -283,6 +257,9 @@ fn bindgen_test_layout_jsval_layout__bindgen_ty_2() { impl Clone for jsval_layout__bindgen_ty_2 { fn clone(&self) -> Self { *self } } +impl Default for jsval_layout__bindgen_ty_2 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[test] fn bindgen_test_layout_jsval_layout() { assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( @@ -328,8 +305,11 @@ fn bindgen_test_layout_jsval_layout() { impl Clone for jsval_layout { fn clone(&self) -> Self { *self } } +impl Default for jsval_layout { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Copy)] pub struct Value { pub data: jsval_layout, } @@ -348,3 +328,6 @@ fn bindgen_test_layout_Value() { impl Clone for Value { fn clone(&self) -> Self { *self } } +impl Default for Value { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} diff --git a/tests/expectations/tests/jsval_layout_opaque_1_0.rs b/tests/expectations/tests/jsval_layout_opaque_1_0.rs new file mode 100644 index 0000000000..536d8c5973 --- /dev/null +++ b/tests/expectations/tests/jsval_layout_opaque_1_0.rs @@ -0,0 +1,350 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[repr(C)] +pub struct __BindgenUnionField(::std::marker::PhantomData); +impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } +} +impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } +} +impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl ::std::marker::Copy for __BindgenUnionField { } +impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } +} +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) { } +} +pub const JSVAL_TAG_SHIFT: ::std::os::raw::c_uint = 47; +pub const JSVAL_PAYLOAD_MASK: ::std::os::raw::c_ulonglong = 140737488355327; +pub const JSVAL_TAG_MASK: ::std::os::raw::c_longlong = -140737488355328; +#[repr(u8)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum JSValueType { + JSVAL_TYPE_DOUBLE = 0, + JSVAL_TYPE_INT32 = 1, + JSVAL_TYPE_UNDEFINED = 2, + JSVAL_TYPE_BOOLEAN = 3, + JSVAL_TYPE_MAGIC = 4, + JSVAL_TYPE_STRING = 5, + JSVAL_TYPE_SYMBOL = 6, + JSVAL_TYPE_NULL = 7, + JSVAL_TYPE_OBJECT = 8, + JSVAL_TYPE_UNKNOWN = 32, + JSVAL_TYPE_MISSING = 33, +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum JSValueTag { + JSVAL_TAG_MAX_DOUBLE = 131056, + JSVAL_TAG_INT32 = 131057, + JSVAL_TAG_UNDEFINED = 131058, + JSVAL_TAG_STRING = 131061, + JSVAL_TAG_SYMBOL = 131062, + JSVAL_TAG_BOOLEAN = 131059, + JSVAL_TAG_MAGIC = 131060, + JSVAL_TAG_NULL = 131063, + JSVAL_TAG_OBJECT = 131064, +} +#[repr(u64)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum JSValueShiftedTag { + JSVAL_SHIFTED_TAG_MAX_DOUBLE = 18444492278190833663, + JSVAL_SHIFTED_TAG_INT32 = 18444633011384221696, + JSVAL_SHIFTED_TAG_UNDEFINED = 18444773748872577024, + JSVAL_SHIFTED_TAG_STRING = 18445195961337643008, + JSVAL_SHIFTED_TAG_SYMBOL = 18445336698825998336, + JSVAL_SHIFTED_TAG_BOOLEAN = 18444914486360932352, + JSVAL_SHIFTED_TAG_MAGIC = 18445055223849287680, + JSVAL_SHIFTED_TAG_NULL = 18445477436314353664, + JSVAL_SHIFTED_TAG_OBJECT = 18445618173802708992, +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum JSWhyMagic { + JS_ELEMENTS_HOLE = 0, + JS_NO_ITER_VALUE = 1, + JS_GENERATOR_CLOSING = 2, + JS_NO_CONSTANT = 3, + JS_THIS_POISON = 4, + JS_ARG_POISON = 5, + JS_SERIALIZE_NO_NODE = 6, + JS_LAZY_ARGUMENTS = 7, + JS_OPTIMIZED_ARGUMENTS = 8, + JS_IS_CONSTRUCTING = 9, + JS_OVERWRITTEN_CALLEE = 10, + JS_BLOCK_NEEDS_CLONE = 11, + JS_HASH_KEY_EMPTY = 12, + JS_ION_ERROR = 13, + JS_ION_BAILOUT = 14, + JS_OPTIMIZED_OUT = 15, + JS_UNINITIALIZED_LEXICAL = 16, + JS_GENERIC_MAGIC = 17, + JS_WHY_MAGIC_COUNT = 18, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct jsval_layout { + pub asBits: __BindgenUnionField, + pub debugView: __BindgenUnionField, + pub s: __BindgenUnionField, + pub asDouble: __BindgenUnionField, + pub asPtr: __BindgenUnionField<*mut ::std::os::raw::c_void>, + pub asWord: __BindgenUnionField, + pub asUIntPtr: __BindgenUnionField, + pub bindgen_union_field: u64, +} +#[repr(C)] +#[derive(Debug, Copy, Hash)] +pub struct jsval_layout__bindgen_ty_1 { + pub _bitfield_1: u64, + pub __bindgen_align: [u64; 0usize], +} +#[test] +fn bindgen_test_layout_jsval_layout__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 8usize , + concat ! ( + "Size of: " , stringify ! ( jsval_layout__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() , 8usize + , concat ! ( + "Alignment of " , stringify ! ( jsval_layout__bindgen_ty_1 ) + )); +} +impl Clone for jsval_layout__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +impl Default for jsval_layout__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +impl jsval_layout__bindgen_ty_1 { + #[inline] + pub fn payload47(&self) -> u64 { + let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u64 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 140737488355327u64 as u64; + let val = (unit_field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u64) } + } + #[inline] + pub fn set_payload47(&mut self, val: u64) { + let mask = 140737488355327u64 as u64; + let val = val as u64 as u64; + let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u64 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 0usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn tag(&self) -> JSValueTag { + let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u64 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 18446603336221196288u64 as u64; + let val = (unit_field_val & mask) >> 47usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_tag(&mut self, val: JSValueTag) { + let mask = 18446603336221196288u64 as u64; + let val = val as u32 as u64; + let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u64 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 47usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn new_bitfield_1(payload47: u64, tag: JSValueTag) -> u64 { + ({ + ({ 0 } | + ((payload47 as u64 as u64) << 0usize) & + (140737488355327u64 as u64)) + } | + ((tag as u32 as u64) << 47usize) & + (18446603336221196288u64 as u64)) + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct jsval_layout__bindgen_ty_2 { + pub payload: jsval_layout__bindgen_ty_2__bindgen_ty_1, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct jsval_layout__bindgen_ty_2__bindgen_ty_1 { + pub i32: __BindgenUnionField, + pub u32: __BindgenUnionField, + pub why: __BindgenUnionField, + pub bindgen_union_field: u32, +} +#[test] +fn bindgen_test_layout_jsval_layout__bindgen_ty_2__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() + , 4usize , concat ! ( + "Size of: " , stringify ! ( + jsval_layout__bindgen_ty_2__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() + , 4usize , concat ! ( + "Alignment of " , stringify ! ( + jsval_layout__bindgen_ty_2__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( + * ( 0 as * const jsval_layout__bindgen_ty_2__bindgen_ty_1 ) ) + . i32 as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + jsval_layout__bindgen_ty_2__bindgen_ty_1 ) , "::" , stringify + ! ( i32 ) )); + assert_eq! (unsafe { + & ( + * ( 0 as * const jsval_layout__bindgen_ty_2__bindgen_ty_1 ) ) + . u32 as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + jsval_layout__bindgen_ty_2__bindgen_ty_1 ) , "::" , stringify + ! ( u32 ) )); + assert_eq! (unsafe { + & ( + * ( 0 as * const jsval_layout__bindgen_ty_2__bindgen_ty_1 ) ) + . why as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + jsval_layout__bindgen_ty_2__bindgen_ty_1 ) , "::" , stringify + ! ( why ) )); +} +impl Clone for jsval_layout__bindgen_ty_2__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_jsval_layout__bindgen_ty_2() { + assert_eq!(::std::mem::size_of::() , 4usize , + concat ! ( + "Size of: " , stringify ! ( jsval_layout__bindgen_ty_2 ) )); + assert_eq! (::std::mem::align_of::() , 4usize + , concat ! ( + "Alignment of " , stringify ! ( jsval_layout__bindgen_ty_2 ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const jsval_layout__bindgen_ty_2 ) ) . payload + as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + jsval_layout__bindgen_ty_2 ) , "::" , stringify ! ( payload ) + )); +} +impl Clone for jsval_layout__bindgen_ty_2 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_jsval_layout() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( jsval_layout ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( jsval_layout ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const jsval_layout ) ) . asBits as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( jsval_layout ) , "::" , + stringify ! ( asBits ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const jsval_layout ) ) . debugView as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( jsval_layout ) , "::" , + stringify ! ( debugView ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const jsval_layout ) ) . s as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( jsval_layout ) , "::" , + stringify ! ( s ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const jsval_layout ) ) . asDouble as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( jsval_layout ) , "::" , + stringify ! ( asDouble ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const jsval_layout ) ) . asPtr as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( jsval_layout ) , "::" , + stringify ! ( asPtr ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const jsval_layout ) ) . asWord as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( jsval_layout ) , "::" , + stringify ! ( asWord ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const jsval_layout ) ) . asUIntPtr as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( jsval_layout ) , "::" , + stringify ! ( asUIntPtr ) )); +} +impl Clone for jsval_layout { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct Value { + pub data: jsval_layout, +} +#[test] +fn bindgen_test_layout_Value() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( Value ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( Value ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Value ) ) . data as * const _ as usize } + , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( Value ) , "::" , + stringify ! ( data ) )); +} +impl Clone for Value { + fn clone(&self) -> Self { *self } +} diff --git a/tests/expectations/tests/layout_eth_conf.rs b/tests/expectations/tests/layout_eth_conf.rs index 6cf37ac5dc..d27f6bb16c 100644 --- a/tests/expectations/tests/layout_eth_conf.rs +++ b/tests/expectations/tests/layout_eth_conf.rs @@ -4,33 +4,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } -} pub const ETH_MQ_RX_RSS_FLAG: ::std::os::raw::c_uint = 1; pub const ETH_MQ_RX_DCB_FLAG: ::std::os::raw::c_uint = 2; pub const ETH_MQ_RX_VMDQ_FLAG: ::std::os::raw::c_uint = 4; @@ -1551,12 +1524,11 @@ impl Default for rte_eth_conf__bindgen_ty_1 { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct rte_eth_conf__bindgen_ty_2 { - pub vmdq_dcb_tx_conf: __BindgenUnionField, - pub dcb_tx_conf: __BindgenUnionField, - pub vmdq_tx_conf: __BindgenUnionField, - pub bindgen_union_field: [u32; 3usize], +#[derive(Copy)] +pub union rte_eth_conf__bindgen_ty_2 { + pub vmdq_dcb_tx_conf: rte_eth_vmdq_dcb_tx_conf, + pub dcb_tx_conf: rte_eth_dcb_tx_conf, + pub vmdq_tx_conf: rte_eth_vmdq_tx_conf, } #[test] fn bindgen_test_layout_rte_eth_conf__bindgen_ty_2() { @@ -1589,6 +1561,9 @@ fn bindgen_test_layout_rte_eth_conf__bindgen_ty_2() { impl Clone for rte_eth_conf__bindgen_ty_2 { fn clone(&self) -> Self { *self } } +impl Default for rte_eth_conf__bindgen_ty_2 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[test] fn bindgen_test_layout_rte_eth_conf() { assert_eq!(::std::mem::size_of::() , 2944usize , concat ! ( diff --git a/tests/expectations/tests/layout_eth_conf_1_0.rs b/tests/expectations/tests/layout_eth_conf_1_0.rs new file mode 100644 index 0000000000..6cf37ac5dc --- /dev/null +++ b/tests/expectations/tests/layout_eth_conf_1_0.rs @@ -0,0 +1,1649 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[repr(C)] +pub struct __BindgenUnionField(::std::marker::PhantomData); +impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } +} +impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } +} +impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl ::std::marker::Copy for __BindgenUnionField { } +impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } +} +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) { } +} +pub const ETH_MQ_RX_RSS_FLAG: ::std::os::raw::c_uint = 1; +pub const ETH_MQ_RX_DCB_FLAG: ::std::os::raw::c_uint = 2; +pub const ETH_MQ_RX_VMDQ_FLAG: ::std::os::raw::c_uint = 4; +pub const ETH_VMDQ_MAX_VLAN_FILTERS: ::std::os::raw::c_uint = 64; +pub const ETH_DCB_NUM_USER_PRIORITIES: ::std::os::raw::c_uint = 8; +pub const ETH_VMDQ_DCB_NUM_QUEUES: ::std::os::raw::c_uint = 128; +pub const ETH_DCB_NUM_QUEUES: ::std::os::raw::c_uint = 128; +pub const RTE_ETH_FDIR_MAX_FLEXLEN: ::std::os::raw::c_uint = 16; +pub const RTE_ETH_INSET_SIZE_MAX: ::std::os::raw::c_uint = 128; +pub const RTE_ETH_FLOW_UNKNOWN: ::std::os::raw::c_uint = 0; +pub const RTE_ETH_FLOW_RAW: ::std::os::raw::c_uint = 1; +pub const RTE_ETH_FLOW_IPV4: ::std::os::raw::c_uint = 2; +pub const RTE_ETH_FLOW_FRAG_IPV4: ::std::os::raw::c_uint = 3; +pub const RTE_ETH_FLOW_NONFRAG_IPV4_TCP: ::std::os::raw::c_uint = 4; +pub const RTE_ETH_FLOW_NONFRAG_IPV4_UDP: ::std::os::raw::c_uint = 5; +pub const RTE_ETH_FLOW_NONFRAG_IPV4_SCTP: ::std::os::raw::c_uint = 6; +pub const RTE_ETH_FLOW_NONFRAG_IPV4_OTHER: ::std::os::raw::c_uint = 7; +pub const RTE_ETH_FLOW_IPV6: ::std::os::raw::c_uint = 8; +pub const RTE_ETH_FLOW_FRAG_IPV6: ::std::os::raw::c_uint = 9; +pub const RTE_ETH_FLOW_NONFRAG_IPV6_TCP: ::std::os::raw::c_uint = 10; +pub const RTE_ETH_FLOW_NONFRAG_IPV6_UDP: ::std::os::raw::c_uint = 11; +pub const RTE_ETH_FLOW_NONFRAG_IPV6_SCTP: ::std::os::raw::c_uint = 12; +pub const RTE_ETH_FLOW_NONFRAG_IPV6_OTHER: ::std::os::raw::c_uint = 13; +pub const RTE_ETH_FLOW_L2_PAYLOAD: ::std::os::raw::c_uint = 14; +pub const RTE_ETH_FLOW_IPV6_EX: ::std::os::raw::c_uint = 15; +pub const RTE_ETH_FLOW_IPV6_TCP_EX: ::std::os::raw::c_uint = 16; +pub const RTE_ETH_FLOW_IPV6_UDP_EX: ::std::os::raw::c_uint = 17; +pub const RTE_ETH_FLOW_PORT: ::std::os::raw::c_uint = 18; +pub const RTE_ETH_FLOW_VXLAN: ::std::os::raw::c_uint = 19; +pub const RTE_ETH_FLOW_GENEVE: ::std::os::raw::c_uint = 20; +pub const RTE_ETH_FLOW_NVGRE: ::std::os::raw::c_uint = 21; +pub const RTE_ETH_FLOW_MAX: ::std::os::raw::c_uint = 22; +#[repr(u32)] +/// A set of values to identify what method is to be used to route +/// packets to multiple queues. +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum rte_eth_rx_mq_mode { + ETH_MQ_RX_NONE = 0, + ETH_MQ_RX_RSS = 1, + ETH_MQ_RX_DCB = 2, + ETH_MQ_RX_DCB_RSS = 3, + ETH_MQ_RX_VMDQ_ONLY = 4, + ETH_MQ_RX_VMDQ_RSS = 5, + ETH_MQ_RX_VMDQ_DCB = 6, + ETH_MQ_RX_VMDQ_DCB_RSS = 7, +} +/// A structure used to configure the RX features of an Ethernet port. +#[repr(C)] +#[derive(Debug, Copy, Hash)] +pub struct rte_eth_rxmode { + /// The multi-queue packet distribution mode to be used, e.g. RSS. + pub mq_mode: rte_eth_rx_mq_mode, + /// < Only used if jumbo_frame enabled. + pub max_rx_pkt_len: u32, + /// < hdr buf size (header_split enabled). + pub split_hdr_size: u16, + pub _bitfield_1: [u8; 2usize], +} +#[test] +fn bindgen_test_layout_rte_eth_rxmode() { + assert_eq!(::std::mem::size_of::() , 12usize , concat ! ( + "Size of: " , stringify ! ( rte_eth_rxmode ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( rte_eth_rxmode ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_rxmode ) ) . mq_mode as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_rxmode ) , "::" + , stringify ! ( mq_mode ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_rxmode ) ) . max_rx_pkt_len as * + const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_rxmode ) , "::" + , stringify ! ( max_rx_pkt_len ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_rxmode ) ) . split_hdr_size as * + const _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_rxmode ) , "::" + , stringify ! ( split_hdr_size ) )); +} +impl Clone for rte_eth_rxmode { + fn clone(&self) -> Self { *self } +} +impl Default for rte_eth_rxmode { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +impl rte_eth_rxmode { + #[inline] + pub fn header_split(&self) -> u16 { + let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u16 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 1u64 as u16; + let val = (unit_field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_header_split(&mut self, val: u16) { + let mask = 1u64 as u16; + let val = val as u16 as u16; + let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u16 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 0usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn hw_ip_checksum(&self) -> u16 { + let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u16 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 2u64 as u16; + let val = (unit_field_val & mask) >> 1usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_hw_ip_checksum(&mut self, val: u16) { + let mask = 2u64 as u16; + let val = val as u16 as u16; + let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u16 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 1usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn hw_vlan_filter(&self) -> u16 { + let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u16 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 4u64 as u16; + let val = (unit_field_val & mask) >> 2usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_hw_vlan_filter(&mut self, val: u16) { + let mask = 4u64 as u16; + let val = val as u16 as u16; + let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u16 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 2usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn hw_vlan_strip(&self) -> u16 { + let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u16 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 8u64 as u16; + let val = (unit_field_val & mask) >> 3usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_hw_vlan_strip(&mut self, val: u16) { + let mask = 8u64 as u16; + let val = val as u16 as u16; + let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u16 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 3usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn hw_vlan_extend(&self) -> u16 { + let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u16 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 16u64 as u16; + let val = (unit_field_val & mask) >> 4usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_hw_vlan_extend(&mut self, val: u16) { + let mask = 16u64 as u16; + let val = val as u16 as u16; + let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u16 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 4usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn jumbo_frame(&self) -> u16 { + let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u16 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 32u64 as u16; + let val = (unit_field_val & mask) >> 5usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_jumbo_frame(&mut self, val: u16) { + let mask = 32u64 as u16; + let val = val as u16 as u16; + let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u16 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 5usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn hw_strip_crc(&self) -> u16 { + let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u16 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 64u64 as u16; + let val = (unit_field_val & mask) >> 6usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_hw_strip_crc(&mut self, val: u16) { + let mask = 64u64 as u16; + let val = val as u16 as u16; + let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u16 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 6usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn enable_scatter(&self) -> u16 { + let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u16 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 128u64 as u16; + let val = (unit_field_val & mask) >> 7usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_enable_scatter(&mut self, val: u16) { + let mask = 128u64 as u16; + let val = val as u16 as u16; + let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u16 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 7usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn enable_lro(&self) -> u16 { + let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u16 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 256u64 as u16; + let val = (unit_field_val & mask) >> 8usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_enable_lro(&mut self, val: u16) { + let mask = 256u64 as u16; + let val = val as u16 as u16; + let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u16 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 8usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn new_bitfield_1(header_split: u16, hw_ip_checksum: u16, + hw_vlan_filter: u16, hw_vlan_strip: u16, + hw_vlan_extend: u16, jumbo_frame: u16, + hw_strip_crc: u16, enable_scatter: u16, + enable_lro: u16) -> u16 { + ({ + ({ + ({ + ({ + ({ + ({ + ({ + ({ + ({ 0 } | + ((header_split as u16 as + u16) << 0usize) & + (1u64 as u16)) + } | + ((hw_ip_checksum as u16 as + u16) << 1usize) & + (2u64 as u16)) + } | + ((hw_vlan_filter as u16 as u16) << + 2usize) & (4u64 as u16)) + } | + ((hw_vlan_strip as u16 as u16) << + 3usize) & (8u64 as u16)) + } | + ((hw_vlan_extend as u16 as u16) << 4usize) & + (16u64 as u16)) + } | + ((jumbo_frame as u16 as u16) << 5usize) & + (32u64 as u16)) + } | + ((hw_strip_crc as u16 as u16) << 6usize) & + (64u64 as u16)) + } | + ((enable_scatter as u16 as u16) << 7usize) & + (128u64 as u16)) + } | ((enable_lro as u16 as u16) << 8usize) & (256u64 as u16)) + } +} +#[repr(u32)] +/// A set of values to identify what method is to be used to transmit +/// packets using multi-TCs. +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum rte_eth_tx_mq_mode { + ETH_MQ_TX_NONE = 0, + ETH_MQ_TX_DCB = 1, + ETH_MQ_TX_VMDQ_DCB = 2, + ETH_MQ_TX_VMDQ_ONLY = 3, +} +/// A structure used to configure the TX features of an Ethernet port. +#[repr(C)] +#[derive(Debug, Copy, Hash)] +pub struct rte_eth_txmode { + /// < TX multi-queues mode. + pub mq_mode: rte_eth_tx_mq_mode, + pub pvid: u16, + pub _bitfield_1: u8, + pub __bindgen_padding_0: u8, +} +#[test] +fn bindgen_test_layout_rte_eth_txmode() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( rte_eth_txmode ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( rte_eth_txmode ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_txmode ) ) . mq_mode as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_txmode ) , "::" + , stringify ! ( mq_mode ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_txmode ) ) . pvid as * const _ as + usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_txmode ) , "::" + , stringify ! ( pvid ) )); +} +impl Clone for rte_eth_txmode { + fn clone(&self) -> Self { *self } +} +impl Default for rte_eth_txmode { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +impl rte_eth_txmode { + #[inline] + pub fn hw_vlan_reject_tagged(&self) -> u8 { + let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u8 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 1u64 as u8; + let val = (unit_field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u8) } + } + #[inline] + pub fn set_hw_vlan_reject_tagged(&mut self, val: u8) { + let mask = 1u64 as u8; + let val = val as u8 as u8; + let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u8 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 0usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn hw_vlan_reject_untagged(&self) -> u8 { + let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u8 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 2u64 as u8; + let val = (unit_field_val & mask) >> 1usize; + unsafe { ::std::mem::transmute(val as u8) } + } + #[inline] + pub fn set_hw_vlan_reject_untagged(&mut self, val: u8) { + let mask = 2u64 as u8; + let val = val as u8 as u8; + let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u8 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 1usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn hw_vlan_insert_pvid(&self) -> u8 { + let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u8 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 4u64 as u8; + let val = (unit_field_val & mask) >> 2usize; + unsafe { ::std::mem::transmute(val as u8) } + } + #[inline] + pub fn set_hw_vlan_insert_pvid(&mut self, val: u8) { + let mask = 4u64 as u8; + let val = val as u8 as u8; + let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u8 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 2usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn new_bitfield_1(hw_vlan_reject_tagged: u8, + hw_vlan_reject_untagged: u8, + hw_vlan_insert_pvid: u8) -> u8 { + ({ + ({ + ({ 0 } | + ((hw_vlan_reject_tagged as u8 as u8) << 0usize) & + (1u64 as u8)) + } | + ((hw_vlan_reject_untagged as u8 as u8) << 1usize) & + (2u64 as u8)) + } | ((hw_vlan_insert_pvid as u8 as u8) << 2usize) & (4u64 as u8)) + } +} +/// A structure used to configure the Receive Side Scaling (RSS) feature +/// of an Ethernet port. +/// If not NULL, the *rss_key* pointer of the *rss_conf* structure points +/// to an array holding the RSS key to use for hashing specific header +/// fields of received packets. The length of this array should be indicated +/// by *rss_key_len* below. Otherwise, a default random hash key is used by +/// the device driver. +/// +/// The *rss_key_len* field of the *rss_conf* structure indicates the length +/// in bytes of the array pointed by *rss_key*. To be compatible, this length +/// will be checked in i40e only. Others assume 40 bytes to be used as before. +/// +/// The *rss_hf* field of the *rss_conf* structure indicates the different +/// types of IPv4/IPv6 packets to which the RSS hashing must be applied. +/// Supplying an *rss_hf* equal to zero disables the RSS feature. +#[repr(C)] +#[derive(Debug, Copy, Hash)] +pub struct rte_eth_rss_conf { + /// < If not NULL, 40-byte hash key. + pub rss_key: *mut u8, + /// < hash key length in bytes. + pub rss_key_len: u8, + /// < Hash functions to apply - see below. + pub rss_hf: u64, +} +#[test] +fn bindgen_test_layout_rte_eth_rss_conf() { + assert_eq!(::std::mem::size_of::() , 24usize , concat ! + ( "Size of: " , stringify ! ( rte_eth_rss_conf ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! + ( "Alignment of " , stringify ! ( rte_eth_rss_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_rss_conf ) ) . rss_key as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_rss_conf ) , + "::" , stringify ! ( rss_key ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_rss_conf ) ) . rss_key_len as * + const _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_rss_conf ) , + "::" , stringify ! ( rss_key_len ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_rss_conf ) ) . rss_hf as * const + _ as usize } , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_rss_conf ) , + "::" , stringify ! ( rss_hf ) )); +} +impl Clone for rte_eth_rss_conf { + fn clone(&self) -> Self { *self } +} +impl Default for rte_eth_rss_conf { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +#[repr(u32)] +/// This enum indicates the possible number of traffic classes +/// in DCB configratioins +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum rte_eth_nb_tcs { ETH_4_TCS = 4, ETH_8_TCS = 8, } +#[repr(u32)] +/// This enum indicates the possible number of queue pools +/// in VMDQ configurations. +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum rte_eth_nb_pools { + ETH_8_POOLS = 8, + ETH_16_POOLS = 16, + ETH_32_POOLS = 32, + ETH_64_POOLS = 64, +} +/// A structure used to configure the VMDQ+DCB feature +/// of an Ethernet port. +/// +/// Using this feature, packets are routed to a pool of queues, based +/// on the vlan id in the vlan tag, and then to a specific queue within +/// that pool, using the user priority vlan tag field. +/// +/// A default pool may be used, if desired, to route all traffic which +/// does not match the vlan filter rules. +#[repr(C)] +#[derive(Copy)] +pub struct rte_eth_vmdq_dcb_conf { + /// < With DCB, 16 or 32 pools + pub nb_queue_pools: rte_eth_nb_pools, + /// < If non-zero, use a default pool + pub enable_default_pool: u8, + /// < The default pool, if applicable + pub default_pool: u8, + /// < We can have up to 64 filters/mappings + pub nb_pool_maps: u8, + /// < VMDq vlan pool maps. + pub pool_map: [rte_eth_vmdq_dcb_conf__bindgen_ty_1; 64usize], + pub dcb_tc: [u8; 8usize], +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct rte_eth_vmdq_dcb_conf__bindgen_ty_1 { + /// < The vlan id of the received frame + pub vlan_id: u16, + /// < Bitmask of pools for packet rx + pub pools: u64, +} +#[test] +fn bindgen_test_layout_rte_eth_vmdq_dcb_conf__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , + 16usize , concat ! ( + "Size of: " , stringify ! ( rte_eth_vmdq_dcb_conf__bindgen_ty_1 + ) )); + assert_eq! (::std::mem::align_of::() + , 8usize , concat ! ( + "Alignment of " , stringify ! ( + rte_eth_vmdq_dcb_conf__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_conf__bindgen_ty_1 ) ) . + vlan_id as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_vmdq_dcb_conf__bindgen_ty_1 ) , "::" , stringify ! ( + vlan_id ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_conf__bindgen_ty_1 ) ) . + pools as * const _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_vmdq_dcb_conf__bindgen_ty_1 ) , "::" , stringify ! ( + pools ) )); +} +impl Clone for rte_eth_vmdq_dcb_conf__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_rte_eth_vmdq_dcb_conf() { + assert_eq!(::std::mem::size_of::() , 1040usize , + concat ! ( "Size of: " , stringify ! ( rte_eth_vmdq_dcb_conf ) + )); + assert_eq! (::std::mem::align_of::() , 8usize , + concat ! ( + "Alignment of " , stringify ! ( rte_eth_vmdq_dcb_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_conf ) ) . + nb_queue_pools as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_vmdq_dcb_conf ) + , "::" , stringify ! ( nb_queue_pools ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_conf ) ) . + enable_default_pool as * const _ as usize } , 4usize , concat + ! ( + "Alignment of field: " , stringify ! ( rte_eth_vmdq_dcb_conf ) + , "::" , stringify ! ( enable_default_pool ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_conf ) ) . default_pool + as * const _ as usize } , 5usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_vmdq_dcb_conf ) + , "::" , stringify ! ( default_pool ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_conf ) ) . nb_pool_maps + as * const _ as usize } , 6usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_vmdq_dcb_conf ) + , "::" , stringify ! ( nb_pool_maps ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_conf ) ) . pool_map as * + const _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_vmdq_dcb_conf ) + , "::" , stringify ! ( pool_map ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_conf ) ) . dcb_tc as * + const _ as usize } , 1032usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_vmdq_dcb_conf ) + , "::" , stringify ! ( dcb_tc ) )); +} +impl Clone for rte_eth_vmdq_dcb_conf { + fn clone(&self) -> Self { *self } +} +impl Default for rte_eth_vmdq_dcb_conf { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +#[repr(C)] +#[derive(Debug, Copy, Hash)] +pub struct rte_eth_dcb_rx_conf { + /// < Possible DCB TCs, 4 or 8 TCs + pub nb_tcs: rte_eth_nb_tcs, + /// Traffic class each UP mapped to. + pub dcb_tc: [u8; 8usize], +} +#[test] +fn bindgen_test_layout_rte_eth_dcb_rx_conf() { + assert_eq!(::std::mem::size_of::() , 12usize , concat + ! ( "Size of: " , stringify ! ( rte_eth_dcb_rx_conf ) )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( rte_eth_dcb_rx_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_dcb_rx_conf ) ) . nb_tcs as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_dcb_rx_conf ) , + "::" , stringify ! ( nb_tcs ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_dcb_rx_conf ) ) . dcb_tc as * + const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_dcb_rx_conf ) , + "::" , stringify ! ( dcb_tc ) )); +} +impl Clone for rte_eth_dcb_rx_conf { + fn clone(&self) -> Self { *self } +} +impl Default for rte_eth_dcb_rx_conf { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +#[repr(C)] +#[derive(Debug, Copy, Hash)] +pub struct rte_eth_vmdq_dcb_tx_conf { + /// < With DCB, 16 or 32 pools. + pub nb_queue_pools: rte_eth_nb_pools, + /// Traffic class each UP mapped to. + pub dcb_tc: [u8; 8usize], +} +#[test] +fn bindgen_test_layout_rte_eth_vmdq_dcb_tx_conf() { + assert_eq!(::std::mem::size_of::() , 12usize , + concat ! ( + "Size of: " , stringify ! ( rte_eth_vmdq_dcb_tx_conf ) )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( rte_eth_vmdq_dcb_tx_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_tx_conf ) ) . + nb_queue_pools as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_vmdq_dcb_tx_conf ) , "::" , stringify ! ( + nb_queue_pools ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_tx_conf ) ) . dcb_tc as + * const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_vmdq_dcb_tx_conf ) , "::" , stringify ! ( dcb_tc ) )); +} +impl Clone for rte_eth_vmdq_dcb_tx_conf { + fn clone(&self) -> Self { *self } +} +impl Default for rte_eth_vmdq_dcb_tx_conf { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +#[repr(C)] +#[derive(Debug, Copy, Hash)] +pub struct rte_eth_dcb_tx_conf { + /// < Possible DCB TCs, 4 or 8 TCs. + pub nb_tcs: rte_eth_nb_tcs, + /// Traffic class each UP mapped to. + pub dcb_tc: [u8; 8usize], +} +#[test] +fn bindgen_test_layout_rte_eth_dcb_tx_conf() { + assert_eq!(::std::mem::size_of::() , 12usize , concat + ! ( "Size of: " , stringify ! ( rte_eth_dcb_tx_conf ) )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( rte_eth_dcb_tx_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_dcb_tx_conf ) ) . nb_tcs as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_dcb_tx_conf ) , + "::" , stringify ! ( nb_tcs ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_dcb_tx_conf ) ) . dcb_tc as * + const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_dcb_tx_conf ) , + "::" , stringify ! ( dcb_tc ) )); +} +impl Clone for rte_eth_dcb_tx_conf { + fn clone(&self) -> Self { *self } +} +impl Default for rte_eth_dcb_tx_conf { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +#[repr(C)] +#[derive(Debug, Copy, Hash)] +pub struct rte_eth_vmdq_tx_conf { + /// < VMDq mode, 64 pools. + pub nb_queue_pools: rte_eth_nb_pools, +} +#[test] +fn bindgen_test_layout_rte_eth_vmdq_tx_conf() { + assert_eq!(::std::mem::size_of::() , 4usize , concat + ! ( "Size of: " , stringify ! ( rte_eth_vmdq_tx_conf ) )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( rte_eth_vmdq_tx_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_tx_conf ) ) . nb_queue_pools + as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_vmdq_tx_conf ) + , "::" , stringify ! ( nb_queue_pools ) )); +} +impl Clone for rte_eth_vmdq_tx_conf { + fn clone(&self) -> Self { *self } +} +impl Default for rte_eth_vmdq_tx_conf { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +#[repr(C)] +#[derive(Copy)] +pub struct rte_eth_vmdq_rx_conf { + /// < VMDq only mode, 8 or 64 pools + pub nb_queue_pools: rte_eth_nb_pools, + /// < If non-zero, use a default pool + pub enable_default_pool: u8, + /// < The default pool, if applicable + pub default_pool: u8, + /// < Enable VT loop back + pub enable_loop_back: u8, + /// < We can have up to 64 filters/mappings + pub nb_pool_maps: u8, + /// < Flags from ETH_VMDQ_ACCEPT_* + pub rx_mode: u32, + /// < VMDq vlan pool maps. + pub pool_map: [rte_eth_vmdq_rx_conf__bindgen_ty_1; 64usize], +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct rte_eth_vmdq_rx_conf__bindgen_ty_1 { + /// < The vlan id of the received frame + pub vlan_id: u16, + /// < Bitmask of pools for packet rx + pub pools: u64, +} +#[test] +fn bindgen_test_layout_rte_eth_vmdq_rx_conf__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , + 16usize , concat ! ( + "Size of: " , stringify ! ( rte_eth_vmdq_rx_conf__bindgen_ty_1 + ) )); + assert_eq! (::std::mem::align_of::() , + 8usize , concat ! ( + "Alignment of " , stringify ! ( + rte_eth_vmdq_rx_conf__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_rx_conf__bindgen_ty_1 ) ) . + vlan_id as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_vmdq_rx_conf__bindgen_ty_1 ) , "::" , stringify ! ( + vlan_id ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_rx_conf__bindgen_ty_1 ) ) . + pools as * const _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_vmdq_rx_conf__bindgen_ty_1 ) , "::" , stringify ! ( + pools ) )); +} +impl Clone for rte_eth_vmdq_rx_conf__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_rte_eth_vmdq_rx_conf() { + assert_eq!(::std::mem::size_of::() , 1040usize , + concat ! ( "Size of: " , stringify ! ( rte_eth_vmdq_rx_conf ) + )); + assert_eq! (::std::mem::align_of::() , 8usize , + concat ! ( + "Alignment of " , stringify ! ( rte_eth_vmdq_rx_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_rx_conf ) ) . nb_queue_pools + as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_vmdq_rx_conf ) + , "::" , stringify ! ( nb_queue_pools ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_rx_conf ) ) . + enable_default_pool as * const _ as usize } , 4usize , concat + ! ( + "Alignment of field: " , stringify ! ( rte_eth_vmdq_rx_conf ) + , "::" , stringify ! ( enable_default_pool ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_rx_conf ) ) . default_pool + as * const _ as usize } , 5usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_vmdq_rx_conf ) + , "::" , stringify ! ( default_pool ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_rx_conf ) ) . + enable_loop_back as * const _ as usize } , 6usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_vmdq_rx_conf ) + , "::" , stringify ! ( enable_loop_back ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_rx_conf ) ) . nb_pool_maps + as * const _ as usize } , 7usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_vmdq_rx_conf ) + , "::" , stringify ! ( nb_pool_maps ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_rx_conf ) ) . rx_mode as * + const _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_vmdq_rx_conf ) + , "::" , stringify ! ( rx_mode ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_rx_conf ) ) . pool_map as * + const _ as usize } , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_vmdq_rx_conf ) + , "::" , stringify ! ( pool_map ) )); +} +impl Clone for rte_eth_vmdq_rx_conf { + fn clone(&self) -> Self { *self } +} +impl Default for rte_eth_vmdq_rx_conf { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +#[repr(u32)] +/// Flow Director setting modes: none, signature or perfect. +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum rte_fdir_mode { + RTE_FDIR_MODE_NONE = 0, + RTE_FDIR_MODE_SIGNATURE = 1, + RTE_FDIR_MODE_PERFECT = 2, + RTE_FDIR_MODE_PERFECT_MAC_VLAN = 3, + RTE_FDIR_MODE_PERFECT_TUNNEL = 4, +} +#[repr(u32)] +/// Memory space that can be configured to store Flow Director filters +/// in the board memory. +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum rte_fdir_pballoc_type { + RTE_FDIR_PBALLOC_64K = 0, + RTE_FDIR_PBALLOC_128K = 1, + RTE_FDIR_PBALLOC_256K = 2, +} +#[repr(u32)] +/// Select report mode of FDIR hash information in RX descriptors. +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum rte_fdir_status_mode { + RTE_FDIR_NO_REPORT_STATUS = 0, + RTE_FDIR_REPORT_STATUS = 1, + RTE_FDIR_REPORT_STATUS_ALWAYS = 2, +} +/// A structure used to define the input for IPV4 flow +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct rte_eth_ipv4_flow { + /// < IPv4 source address in big endian. + pub src_ip: u32, + /// < IPv4 destination address in big endian. + pub dst_ip: u32, + /// < Type of service to match. + pub tos: u8, + /// < Time to live to match. + pub ttl: u8, + /// < Protocol, next header in big endian. + pub proto: u8, +} +#[test] +fn bindgen_test_layout_rte_eth_ipv4_flow() { + assert_eq!(::std::mem::size_of::() , 12usize , concat ! + ( "Size of: " , stringify ! ( rte_eth_ipv4_flow ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat + ! ( "Alignment of " , stringify ! ( rte_eth_ipv4_flow ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv4_flow ) ) . src_ip as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_ipv4_flow ) , + "::" , stringify ! ( src_ip ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv4_flow ) ) . dst_ip as * const + _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_ipv4_flow ) , + "::" , stringify ! ( dst_ip ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv4_flow ) ) . tos as * const _ + as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_ipv4_flow ) , + "::" , stringify ! ( tos ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv4_flow ) ) . ttl as * const _ + as usize } , 9usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_ipv4_flow ) , + "::" , stringify ! ( ttl ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv4_flow ) ) . proto as * const + _ as usize } , 10usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_ipv4_flow ) , + "::" , stringify ! ( proto ) )); +} +impl Clone for rte_eth_ipv4_flow { + fn clone(&self) -> Self { *self } +} +/// A structure used to define the input for IPV6 flow +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct rte_eth_ipv6_flow { + /// < IPv6 source address in big endian. + pub src_ip: [u32; 4usize], + /// < IPv6 destination address in big endian. + pub dst_ip: [u32; 4usize], + /// < Traffic class to match. + pub tc: u8, + /// < Protocol, next header to match. + pub proto: u8, + /// < Hop limits to match. + pub hop_limits: u8, +} +#[test] +fn bindgen_test_layout_rte_eth_ipv6_flow() { + assert_eq!(::std::mem::size_of::() , 36usize , concat ! + ( "Size of: " , stringify ! ( rte_eth_ipv6_flow ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat + ! ( "Alignment of " , stringify ! ( rte_eth_ipv6_flow ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv6_flow ) ) . src_ip as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_ipv6_flow ) , + "::" , stringify ! ( src_ip ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv6_flow ) ) . dst_ip as * const + _ as usize } , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_ipv6_flow ) , + "::" , stringify ! ( dst_ip ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv6_flow ) ) . tc as * const _ + as usize } , 32usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_ipv6_flow ) , + "::" , stringify ! ( tc ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv6_flow ) ) . proto as * const + _ as usize } , 33usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_ipv6_flow ) , + "::" , stringify ! ( proto ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv6_flow ) ) . hop_limits as * + const _ as usize } , 34usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_ipv6_flow ) , + "::" , stringify ! ( hop_limits ) )); +} +impl Clone for rte_eth_ipv6_flow { + fn clone(&self) -> Self { *self } +} +/// A structure used to configure FDIR masks that are used by the device +/// to match the various fields of RX packet headers. +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct rte_eth_fdir_masks { + /// < Bit mask for vlan_tci in big endian + pub vlan_tci_mask: u16, + /// Bit mask for ipv4 flow in big endian. + pub ipv4_mask: rte_eth_ipv4_flow, + /// Bit maks for ipv6 flow in big endian. + pub ipv6_mask: rte_eth_ipv6_flow, + /// Bit mask for L4 source port in big endian. + pub src_port_mask: u16, + /// Bit mask for L4 destination port in big endian. + pub dst_port_mask: u16, + /// 6 bit mask for proper 6 bytes of Mac address, bit 0 matches the + /// first byte on the wire + pub mac_addr_byte_mask: u8, + /// Bit mask for tunnel ID in big endian. + pub tunnel_id_mask: u32, + /// < 1 - Match tunnel type, + /// 0 - Ignore tunnel type. + pub tunnel_type_mask: u8, +} +#[test] +fn bindgen_test_layout_rte_eth_fdir_masks() { + assert_eq!(::std::mem::size_of::() , 68usize , concat + ! ( "Size of: " , stringify ! ( rte_eth_fdir_masks ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat + ! ( "Alignment of " , stringify ! ( rte_eth_fdir_masks ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_masks ) ) . vlan_tci_mask as + * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_fdir_masks ) , + "::" , stringify ! ( vlan_tci_mask ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_masks ) ) . ipv4_mask as * + const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_fdir_masks ) , + "::" , stringify ! ( ipv4_mask ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_masks ) ) . ipv6_mask as * + const _ as usize } , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_fdir_masks ) , + "::" , stringify ! ( ipv6_mask ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_masks ) ) . src_port_mask as + * const _ as usize } , 52usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_fdir_masks ) , + "::" , stringify ! ( src_port_mask ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_masks ) ) . dst_port_mask as + * const _ as usize } , 54usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_fdir_masks ) , + "::" , stringify ! ( dst_port_mask ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_masks ) ) . + mac_addr_byte_mask as * const _ as usize } , 56usize , concat + ! ( + "Alignment of field: " , stringify ! ( rte_eth_fdir_masks ) , + "::" , stringify ! ( mac_addr_byte_mask ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_masks ) ) . tunnel_id_mask + as * const _ as usize } , 60usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_fdir_masks ) , + "::" , stringify ! ( tunnel_id_mask ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_masks ) ) . tunnel_type_mask + as * const _ as usize } , 64usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_fdir_masks ) , + "::" , stringify ! ( tunnel_type_mask ) )); +} +impl Clone for rte_eth_fdir_masks { + fn clone(&self) -> Self { *self } +} +#[repr(u32)] +/// Payload type +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum rte_eth_payload_type { + RTE_ETH_PAYLOAD_UNKNOWN = 0, + RTE_ETH_RAW_PAYLOAD = 1, + RTE_ETH_L2_PAYLOAD = 2, + RTE_ETH_L3_PAYLOAD = 3, + RTE_ETH_L4_PAYLOAD = 4, + RTE_ETH_PAYLOAD_MAX = 8, +} +/// A structure used to select bytes extracted from the protocol layers to +/// flexible payload for filter +#[repr(C)] +#[derive(Debug, Copy, Hash)] +pub struct rte_eth_flex_payload_cfg { + /// < Payload type + pub type_: rte_eth_payload_type, + pub src_offset: [u16; 16usize], +} +#[test] +fn bindgen_test_layout_rte_eth_flex_payload_cfg() { + assert_eq!(::std::mem::size_of::() , 36usize , + concat ! ( + "Size of: " , stringify ! ( rte_eth_flex_payload_cfg ) )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( rte_eth_flex_payload_cfg ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_flex_payload_cfg ) ) . type_ as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_flex_payload_cfg ) , "::" , stringify ! ( type_ ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_flex_payload_cfg ) ) . src_offset + as * const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_flex_payload_cfg ) , "::" , stringify ! ( src_offset ) + )); +} +impl Clone for rte_eth_flex_payload_cfg { + fn clone(&self) -> Self { *self } +} +impl Default for rte_eth_flex_payload_cfg { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +/// A structure used to define FDIR masks for flexible payload +/// for each flow type +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct rte_eth_fdir_flex_mask { + pub flow_type: u16, + pub mask: [u8; 16usize], +} +#[test] +fn bindgen_test_layout_rte_eth_fdir_flex_mask() { + assert_eq!(::std::mem::size_of::() , 18usize , + concat ! ( "Size of: " , stringify ! ( rte_eth_fdir_flex_mask ) + )); + assert_eq! (::std::mem::align_of::() , 2usize , + concat ! ( + "Alignment of " , stringify ! ( rte_eth_fdir_flex_mask ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_flex_mask ) ) . flow_type as + * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_fdir_flex_mask + ) , "::" , stringify ! ( flow_type ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_flex_mask ) ) . mask as * + const _ as usize } , 2usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_fdir_flex_mask + ) , "::" , stringify ! ( mask ) )); +} +impl Clone for rte_eth_fdir_flex_mask { + fn clone(&self) -> Self { *self } +} +/// A structure used to define all flexible payload related setting +/// include flex payload and flex mask +#[repr(C)] +#[derive(Debug, Copy, Hash)] +pub struct rte_eth_fdir_flex_conf { + /// < The number of following payload cfg + pub nb_payloads: u16, + /// < The number of following mask + pub nb_flexmasks: u16, + pub flex_set: [rte_eth_flex_payload_cfg; 8usize], + pub flex_mask: [rte_eth_fdir_flex_mask; 22usize], +} +#[test] +fn bindgen_test_layout_rte_eth_fdir_flex_conf() { + assert_eq!(::std::mem::size_of::() , 688usize , + concat ! ( "Size of: " , stringify ! ( rte_eth_fdir_flex_conf ) + )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( rte_eth_fdir_flex_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_flex_conf ) ) . nb_payloads + as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_fdir_flex_conf + ) , "::" , stringify ! ( nb_payloads ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_flex_conf ) ) . nb_flexmasks + as * const _ as usize } , 2usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_fdir_flex_conf + ) , "::" , stringify ! ( nb_flexmasks ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_flex_conf ) ) . flex_set as + * const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_fdir_flex_conf + ) , "::" , stringify ! ( flex_set ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_flex_conf ) ) . flex_mask as + * const _ as usize } , 292usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_fdir_flex_conf + ) , "::" , stringify ! ( flex_mask ) )); +} +impl Clone for rte_eth_fdir_flex_conf { + fn clone(&self) -> Self { *self } +} +impl Default for rte_eth_fdir_flex_conf { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +/// A structure used to configure the Flow Director (FDIR) feature +/// of an Ethernet port. +/// +/// If mode is RTE_FDIR_DISABLE, the pballoc value is ignored. +#[repr(C)] +#[derive(Debug, Copy, Hash)] +pub struct rte_fdir_conf { + /// < Flow Director mode. + pub mode: rte_fdir_mode, + /// < Space for FDIR filters. + pub pballoc: rte_fdir_pballoc_type, + /// < How to report FDIR hash. + pub status: rte_fdir_status_mode, + /// RX queue of packets matching a "drop" filter in perfect mode. + pub drop_queue: u8, + pub mask: rte_eth_fdir_masks, + pub flex_conf: rte_eth_fdir_flex_conf, +} +#[test] +fn bindgen_test_layout_rte_fdir_conf() { + assert_eq!(::std::mem::size_of::() , 772usize , concat ! ( + "Size of: " , stringify ! ( rte_fdir_conf ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( rte_fdir_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_fdir_conf ) ) . mode as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_fdir_conf ) , "::" + , stringify ! ( mode ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_fdir_conf ) ) . pballoc as * const _ + as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_fdir_conf ) , "::" + , stringify ! ( pballoc ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_fdir_conf ) ) . status as * const _ + as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_fdir_conf ) , "::" + , stringify ! ( status ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_fdir_conf ) ) . drop_queue as * const + _ as usize } , 12usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_fdir_conf ) , "::" + , stringify ! ( drop_queue ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_fdir_conf ) ) . mask as * const _ as + usize } , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_fdir_conf ) , "::" + , stringify ! ( mask ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_fdir_conf ) ) . flex_conf as * const + _ as usize } , 84usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_fdir_conf ) , "::" + , stringify ! ( flex_conf ) )); +} +impl Clone for rte_fdir_conf { + fn clone(&self) -> Self { *self } +} +impl Default for rte_fdir_conf { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +/// A structure used to enable/disable specific device interrupts. +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct rte_intr_conf { + /// enable/disable lsc interrupt. 0 (default) - disable, 1 enable + pub lsc: u16, + /// enable/disable rxq interrupt. 0 (default) - disable, 1 enable + pub rxq: u16, +} +#[test] +fn bindgen_test_layout_rte_intr_conf() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( rte_intr_conf ) )); + assert_eq! (::std::mem::align_of::() , 2usize , concat ! ( + "Alignment of " , stringify ! ( rte_intr_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_intr_conf ) ) . lsc as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_intr_conf ) , "::" + , stringify ! ( lsc ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_intr_conf ) ) . rxq as * const _ as + usize } , 2usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_intr_conf ) , "::" + , stringify ! ( rxq ) )); +} +impl Clone for rte_intr_conf { + fn clone(&self) -> Self { *self } +} +/// A structure used to configure an Ethernet port. +/// Depending upon the RX multi-queue mode, extra advanced +/// configuration settings may be needed. +#[repr(C)] +#[derive(Copy)] +pub struct rte_eth_conf { + /// < bitmap of ETH_LINK_SPEED_XXX of speeds to be + /// used. ETH_LINK_SPEED_FIXED disables link + /// autonegotiation, and a unique speed shall be + /// set. Otherwise, the bitmap defines the set of + /// speeds to be advertised. If the special value + /// ETH_LINK_SPEED_AUTONEG (0) is used, all speeds + /// supported are advertised. + pub link_speeds: u32, + /// < Port RX configuration. + pub rxmode: rte_eth_rxmode, + /// < Port TX configuration. + pub txmode: rte_eth_txmode, + /// < Loopback operation mode. By default the value + /// is 0, meaning the loopback mode is disabled. + /// Read the datasheet of given ethernet controller + /// for details. The possible values of this field + /// are defined in implementation of each driver. + pub lpbk_mode: u32, + /// < Port RX filtering configuration (union). + pub rx_adv_conf: rte_eth_conf__bindgen_ty_1, + /// < Port TX DCB configuration (union). + pub tx_adv_conf: rte_eth_conf__bindgen_ty_2, + /// Currently,Priority Flow Control(PFC) are supported,if DCB with PFC + /// is needed,and the variable must be set ETH_DCB_PFC_SUPPORT. + pub dcb_capability_en: u32, + /// < FDIR configuration. + pub fdir_conf: rte_fdir_conf, + /// < Interrupt mode configuration. + pub intr_conf: rte_intr_conf, +} +#[repr(C)] +#[derive(Copy)] +pub struct rte_eth_conf__bindgen_ty_1 { + /// < Port RSS configuration + pub rss_conf: rte_eth_rss_conf, + pub vmdq_dcb_conf: rte_eth_vmdq_dcb_conf, + pub dcb_rx_conf: rte_eth_dcb_rx_conf, + pub vmdq_rx_conf: rte_eth_vmdq_rx_conf, +} +#[test] +fn bindgen_test_layout_rte_eth_conf__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 2120usize + , concat ! ( + "Size of: " , stringify ! ( rte_eth_conf__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() , 8usize + , concat ! ( + "Alignment of " , stringify ! ( rte_eth_conf__bindgen_ty_1 ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf__bindgen_ty_1 ) ) . rss_conf + as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_conf__bindgen_ty_1 ) , "::" , stringify ! ( rss_conf ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf__bindgen_ty_1 ) ) . + vmdq_dcb_conf as * const _ as usize } , 24usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_conf__bindgen_ty_1 ) , "::" , stringify ! ( + vmdq_dcb_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf__bindgen_ty_1 ) ) . + dcb_rx_conf as * const _ as usize } , 1064usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_conf__bindgen_ty_1 ) , "::" , stringify ! ( + dcb_rx_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf__bindgen_ty_1 ) ) . + vmdq_rx_conf as * const _ as usize } , 1080usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_conf__bindgen_ty_1 ) , "::" , stringify ! ( + vmdq_rx_conf ) )); +} +impl Clone for rte_eth_conf__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +impl Default for rte_eth_conf__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct rte_eth_conf__bindgen_ty_2 { + pub vmdq_dcb_tx_conf: __BindgenUnionField, + pub dcb_tx_conf: __BindgenUnionField, + pub vmdq_tx_conf: __BindgenUnionField, + pub bindgen_union_field: [u32; 3usize], +} +#[test] +fn bindgen_test_layout_rte_eth_conf__bindgen_ty_2() { + assert_eq!(::std::mem::size_of::() , 12usize , + concat ! ( + "Size of: " , stringify ! ( rte_eth_conf__bindgen_ty_2 ) )); + assert_eq! (::std::mem::align_of::() , 4usize + , concat ! ( + "Alignment of " , stringify ! ( rte_eth_conf__bindgen_ty_2 ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf__bindgen_ty_2 ) ) . + vmdq_dcb_tx_conf as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_conf__bindgen_ty_2 ) , "::" , stringify ! ( + vmdq_dcb_tx_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf__bindgen_ty_2 ) ) . + dcb_tx_conf as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_conf__bindgen_ty_2 ) , "::" , stringify ! ( + dcb_tx_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf__bindgen_ty_2 ) ) . + vmdq_tx_conf as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_conf__bindgen_ty_2 ) , "::" , stringify ! ( + vmdq_tx_conf ) )); +} +impl Clone for rte_eth_conf__bindgen_ty_2 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_rte_eth_conf() { + assert_eq!(::std::mem::size_of::() , 2944usize , concat ! ( + "Size of: " , stringify ! ( rte_eth_conf ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( rte_eth_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf ) ) . link_speeds as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_conf ) , "::" , + stringify ! ( link_speeds ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf ) ) . rxmode as * const _ as + usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_conf ) , "::" , + stringify ! ( rxmode ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf ) ) . txmode as * const _ as + usize } , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_conf ) , "::" , + stringify ! ( txmode ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf ) ) . lpbk_mode as * const _ + as usize } , 24usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_conf ) , "::" , + stringify ! ( lpbk_mode ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf ) ) . rx_adv_conf as * const + _ as usize } , 32usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_conf ) , "::" , + stringify ! ( rx_adv_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf ) ) . tx_adv_conf as * const + _ as usize } , 2152usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_conf ) , "::" , + stringify ! ( tx_adv_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf ) ) . dcb_capability_en as * + const _ as usize } , 2164usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_conf ) , "::" , + stringify ! ( dcb_capability_en ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf ) ) . fdir_conf as * const _ + as usize } , 2168usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_conf ) , "::" , + stringify ! ( fdir_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf ) ) . intr_conf as * const _ + as usize } , 2940usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_conf ) , "::" , + stringify ! ( intr_conf ) )); +} +impl Clone for rte_eth_conf { + fn clone(&self) -> Self { *self } +} +impl Default for rte_eth_conf { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} diff --git a/tests/expectations/tests/layout_mbuf.rs b/tests/expectations/tests/layout_mbuf.rs index 5e08af3c4b..3fb2578643 100644 --- a/tests/expectations/tests/layout_mbuf.rs +++ b/tests/expectations/tests/layout_mbuf.rs @@ -4,33 +4,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } -} pub const RTE_CACHE_LINE_MIN_SIZE: ::std::os::raw::c_uint = 64; pub const RTE_CACHE_LINE_SIZE: ::std::os::raw::c_uint = 64; pub type phys_addr_t = u64; @@ -113,13 +86,12 @@ pub struct rte_mbuf { /// or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC /// config option. #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct rte_mbuf__bindgen_ty_1 { +#[derive(Copy)] +pub union rte_mbuf__bindgen_ty_1 { /// < Atomically accessed refcnt - pub refcnt_atomic: __BindgenUnionField, + pub refcnt_atomic: rte_atomic16_t, /// < Non-atomically accessed refcnt - pub refcnt: __BindgenUnionField, - pub bindgen_union_field: u16, + pub refcnt: u16, } #[test] fn bindgen_test_layout_rte_mbuf__bindgen_ty_1() { @@ -143,13 +115,15 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_1() { impl Clone for rte_mbuf__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +impl Default for rte_mbuf__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct rte_mbuf__bindgen_ty_2 { +#[derive(Copy)] +pub union rte_mbuf__bindgen_ty_2 { /// < L2/L3/L4 and tunnel information. - pub packet_type: __BindgenUnionField, - pub __bindgen_anon_1: __BindgenUnionField, - pub bindgen_union_field: u32, + pub packet_type: u32, + pub __bindgen_anon_1: rte_mbuf__bindgen_ty_2__bindgen_ty_1, } #[repr(C)] #[derive(Debug, Default, Copy, Hash)] @@ -474,31 +448,32 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_2() { impl Clone for rte_mbuf__bindgen_ty_2 { fn clone(&self) -> Self { *self } } +impl Default for rte_mbuf__bindgen_ty_2 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct rte_mbuf__bindgen_ty_3 { +#[derive(Copy)] +pub union rte_mbuf__bindgen_ty_3 { /// < RSS hash result if RSS enabled - pub rss: __BindgenUnionField, + pub rss: u32, /// < Filter identifier if FDIR enabled - pub fdir: __BindgenUnionField, + pub fdir: rte_mbuf__bindgen_ty_3__bindgen_ty_1, /// < Hierarchical scheduler - pub sched: __BindgenUnionField, + pub sched: rte_mbuf__bindgen_ty_3__bindgen_ty_2, /// < User defined tags. See rte_distributor_process() - pub usr: __BindgenUnionField, - pub bindgen_union_field: [u32; 2usize], + pub usr: u32, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Copy)] pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_1 { pub __bindgen_anon_1: rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1, pub hi: u32, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 { - pub __bindgen_anon_1: __BindgenUnionField, - pub lo: __BindgenUnionField, - pub bindgen_union_field: u32, +#[derive(Copy)] +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, + pub lo: u32, } #[repr(C)] #[derive(Debug, Default, Copy, Hash)] @@ -564,6 +539,9 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1() { impl Clone for rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +impl Default for rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[test] fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , @@ -584,6 +562,9 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1() { impl Clone for rte_mbuf__bindgen_ty_3__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +impl Default for rte_mbuf__bindgen_ty_3__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[repr(C)] #[derive(Debug, Default, Copy, Hash)] pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_2 { @@ -648,14 +629,16 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_3() { impl Clone for rte_mbuf__bindgen_ty_3 { fn clone(&self) -> Self { *self } } +impl Default for rte_mbuf__bindgen_ty_3 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct rte_mbuf__bindgen_ty_4 { +#[derive(Copy)] +pub union rte_mbuf__bindgen_ty_4 { /// < Can be used for external metadata - pub userdata: __BindgenUnionField<*mut ::std::os::raw::c_void>, + pub userdata: *mut ::std::os::raw::c_void, /// < Allow 8-byte userdata on 32-bit - pub udata64: __BindgenUnionField, - pub bindgen_union_field: u64, + pub udata64: u64, } #[test] fn bindgen_test_layout_rte_mbuf__bindgen_ty_4() { @@ -679,13 +662,15 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_4() { impl Clone for rte_mbuf__bindgen_ty_4 { fn clone(&self) -> Self { *self } } +impl Default for rte_mbuf__bindgen_ty_4 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct rte_mbuf__bindgen_ty_5 { +#[derive(Copy)] +pub union rte_mbuf__bindgen_ty_5 { /// < combined for easy fetch - pub tx_offload: __BindgenUnionField, - pub __bindgen_anon_1: __BindgenUnionField, - pub bindgen_union_field: u64, + pub tx_offload: u64, + pub __bindgen_anon_1: rte_mbuf__bindgen_ty_5__bindgen_ty_1, } #[repr(C)] #[derive(Debug, Default, Copy, Hash)] @@ -970,6 +955,9 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_5() { impl Clone for rte_mbuf__bindgen_ty_5 { fn clone(&self) -> Self { *self } } +impl Default for rte_mbuf__bindgen_ty_5 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[test] fn bindgen_test_layout_rte_mbuf() { assert_eq!(::std::mem::size_of::() , 128usize , concat ! ( diff --git a/tests/expectations/tests/layout_mbuf_1_0.rs b/tests/expectations/tests/layout_mbuf_1_0.rs new file mode 100644 index 0000000000..5e08af3c4b --- /dev/null +++ b/tests/expectations/tests/layout_mbuf_1_0.rs @@ -0,0 +1,1094 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[repr(C)] +pub struct __BindgenUnionField(::std::marker::PhantomData); +impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } +} +impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } +} +impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl ::std::marker::Copy for __BindgenUnionField { } +impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } +} +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) { } +} +pub const RTE_CACHE_LINE_MIN_SIZE: ::std::os::raw::c_uint = 64; +pub const RTE_CACHE_LINE_SIZE: ::std::os::raw::c_uint = 64; +pub type phys_addr_t = u64; +pub type MARKER = [*mut ::std::os::raw::c_void; 0usize]; +pub type MARKER8 = [u8; 0usize]; +pub type MARKER64 = [u64; 0usize]; +/// The atomic counter structure. +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct rte_atomic16_t { + /// < An internal counter value. + pub cnt: i16, +} +#[test] +fn bindgen_test_layout_rte_atomic16_t() { + assert_eq!(::std::mem::size_of::() , 2usize , concat ! ( + "Size of: " , stringify ! ( rte_atomic16_t ) )); + assert_eq! (::std::mem::align_of::() , 2usize , concat ! ( + "Alignment of " , stringify ! ( rte_atomic16_t ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_atomic16_t ) ) . cnt as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_atomic16_t ) , "::" + , stringify ! ( cnt ) )); +} +impl Clone for rte_atomic16_t { + fn clone(&self) -> Self { *self } +} +/// The generic rte_mbuf, containing a packet mbuf. +#[repr(C)] +pub struct rte_mbuf { + pub cacheline0: MARKER, + /// < Virtual address of segment buffer. + pub buf_addr: *mut ::std::os::raw::c_void, + /// < Physical address of segment buffer. + pub buf_physaddr: phys_addr_t, + /// < Length of segment buffer. + pub buf_len: u16, + pub rearm_data: MARKER8, + pub data_off: u16, + pub __bindgen_anon_1: rte_mbuf__bindgen_ty_1, + /// < Number of segments. + pub nb_segs: u8, + /// < Input port. + pub port: u8, + /// < Offload features. + pub ol_flags: u64, + pub rx_descriptor_fields1: MARKER, + pub __bindgen_anon_2: rte_mbuf__bindgen_ty_2, + /// < Total pkt len: sum of all segments. + pub pkt_len: u32, + /// < Amount of data in segment buffer. + pub data_len: u16, + /// VLAN TCI (CPU order), valid if PKT_RX_VLAN_STRIPPED is set. + pub vlan_tci: u16, + /// < hash information + pub hash: rte_mbuf__bindgen_ty_3, + /// < Sequence number. See also rte_reorder_insert() + pub seqn: u32, + /// Outer VLAN TCI (CPU order), valid if PKT_RX_QINQ_STRIPPED is set. + pub vlan_tci_outer: u16, + pub cacheline1: MARKER, + pub __bindgen_anon_3: rte_mbuf__bindgen_ty_4, + /// < Pool from which mbuf was allocated. + pub pool: *mut rte_mempool, + /// < Next segment of scattered packet. + pub next: *mut rte_mbuf, + pub __bindgen_anon_4: rte_mbuf__bindgen_ty_5, + /// Size of the application private data. In case of an indirect + /// mbuf, it stores the direct mbuf private data size. + pub priv_size: u16, + /// Timesync flags for use with IEEE1588. + pub timesync: u16, + pub __bindgen_padding_0: [u32; 7usize], +} +/// 16-bit Reference counter. +/// It should only be accessed using the following functions: +/// rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and +/// rte_mbuf_refcnt_set(). The functionality of these functions (atomic, +/// or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC +/// config option. +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct rte_mbuf__bindgen_ty_1 { + /// < Atomically accessed refcnt + pub refcnt_atomic: __BindgenUnionField, + /// < Non-atomically accessed refcnt + pub refcnt: __BindgenUnionField, + pub bindgen_union_field: u16, +} +#[test] +fn bindgen_test_layout_rte_mbuf__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 2usize , + concat ! ( "Size of: " , stringify ! ( rte_mbuf__bindgen_ty_1 ) + )); + assert_eq! (::std::mem::align_of::() , 2usize , + concat ! ( + "Alignment of " , stringify ! ( rte_mbuf__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_1 ) ) . + refcnt_atomic as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf__bindgen_ty_1 + ) , "::" , stringify ! ( refcnt_atomic ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_1 ) ) . refcnt as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf__bindgen_ty_1 + ) , "::" , stringify ! ( refcnt ) )); +} +impl Clone for rte_mbuf__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct rte_mbuf__bindgen_ty_2 { + /// < L2/L3/L4 and tunnel information. + pub packet_type: __BindgenUnionField, + pub __bindgen_anon_1: __BindgenUnionField, + pub bindgen_union_field: u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct rte_mbuf__bindgen_ty_2__bindgen_ty_1 { + pub _bitfield_1: [u8; 4usize], + pub __bindgen_align: [u32; 0usize], +} +#[test] +fn bindgen_test_layout_rte_mbuf__bindgen_ty_2__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , + 4usize , concat ! ( + "Size of: " , stringify ! ( + rte_mbuf__bindgen_ty_2__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() + , 4usize , concat ! ( + "Alignment of " , stringify ! ( + rte_mbuf__bindgen_ty_2__bindgen_ty_1 ) )); +} +impl Clone for rte_mbuf__bindgen_ty_2__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 { + #[inline] + pub fn l2_type(&self) -> u32 { + let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u32 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 15u64 as u32; + let val = (unit_field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_l2_type(&mut self, val: u32) { + let mask = 15u64 as u32; + let val = val as u32 as u32; + let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u32 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 0usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn l3_type(&self) -> u32 { + let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u32 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 240u64 as u32; + let val = (unit_field_val & mask) >> 4usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_l3_type(&mut self, val: u32) { + let mask = 240u64 as u32; + let val = val as u32 as u32; + let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u32 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 4usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn l4_type(&self) -> u32 { + let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u32 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 3840u64 as u32; + let val = (unit_field_val & mask) >> 8usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_l4_type(&mut self, val: u32) { + let mask = 3840u64 as u32; + let val = val as u32 as u32; + let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u32 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 8usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn tun_type(&self) -> u32 { + let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u32 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 61440u64 as u32; + let val = (unit_field_val & mask) >> 12usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_tun_type(&mut self, val: u32) { + let mask = 61440u64 as u32; + let val = val as u32 as u32; + let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u32 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 12usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn inner_l2_type(&self) -> u32 { + let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u32 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 983040u64 as u32; + let val = (unit_field_val & mask) >> 16usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_inner_l2_type(&mut self, val: u32) { + let mask = 983040u64 as u32; + let val = val as u32 as u32; + let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u32 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 16usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn inner_l3_type(&self) -> u32 { + let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u32 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 15728640u64 as u32; + let val = (unit_field_val & mask) >> 20usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_inner_l3_type(&mut self, val: u32) { + let mask = 15728640u64 as u32; + let val = val as u32 as u32; + let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u32 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 20usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn inner_l4_type(&self) -> u32 { + let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u32 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 251658240u64 as u32; + let val = (unit_field_val & mask) >> 24usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_inner_l4_type(&mut self, val: u32) { + let mask = 251658240u64 as u32; + let val = val as u32 as u32; + let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u32 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 24usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn new_bitfield_1(l2_type: u32, l3_type: u32, l4_type: u32, + tun_type: u32, inner_l2_type: u32, + inner_l3_type: u32, inner_l4_type: u32) -> u32 { + ({ + ({ + ({ + ({ + ({ + ({ + ({ 0 } | + ((l2_type as u32 as u32) << 0usize) + & (15u64 as u32)) + } | + ((l3_type as u32 as u32) << 4usize) & + (240u64 as u32)) + } | + ((l4_type as u32 as u32) << 8usize) & + (3840u64 as u32)) + } | + ((tun_type as u32 as u32) << 12usize) & + (61440u64 as u32)) + } | + ((inner_l2_type as u32 as u32) << 16usize) & + (983040u64 as u32)) + } | + ((inner_l3_type as u32 as u32) << 20usize) & + (15728640u64 as u32)) + } | + ((inner_l4_type as u32 as u32) << 24usize) & + (251658240u64 as u32)) + } +} +#[test] +fn bindgen_test_layout_rte_mbuf__bindgen_ty_2() { + assert_eq!(::std::mem::size_of::() , 4usize , + concat ! ( "Size of: " , stringify ! ( rte_mbuf__bindgen_ty_2 ) + )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( rte_mbuf__bindgen_ty_2 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_2 ) ) . packet_type + as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf__bindgen_ty_2 + ) , "::" , stringify ! ( packet_type ) )); +} +impl Clone for rte_mbuf__bindgen_ty_2 { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct rte_mbuf__bindgen_ty_3 { + /// < RSS hash result if RSS enabled + pub rss: __BindgenUnionField, + /// < Filter identifier if FDIR enabled + pub fdir: __BindgenUnionField, + /// < Hierarchical scheduler + pub sched: __BindgenUnionField, + /// < User defined tags. See rte_distributor_process() + pub usr: __BindgenUnionField, + pub bindgen_union_field: [u32; 2usize], +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_1 { + pub __bindgen_anon_1: rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1, + pub hi: u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 { + pub __bindgen_anon_1: __BindgenUnionField, + pub lo: __BindgenUnionField, + pub bindgen_union_field: u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 { + pub hash: u16, + pub id: u16, +} +#[test] +fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() + , 4usize , concat ! ( + "Size of: " , stringify ! ( + rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 + ) )); + assert_eq! (::std::mem::align_of::() + , 2usize , concat ! ( + "Alignment of " , stringify ! ( + rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 + ) )); + assert_eq! (unsafe { + & ( + * ( + 0 as * const + rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 + ) ) . hash as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 + ) , "::" , stringify ! ( hash ) )); + assert_eq! (unsafe { + & ( + * ( + 0 as * const + rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 + ) ) . id as * const _ as usize } , 2usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 + ) , "::" , stringify ! ( id ) )); +} +impl Clone for + rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() + , 4usize , concat ! ( + "Size of: " , stringify ! ( + rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() + , 4usize , concat ! ( + "Alignment of " , stringify ! ( + rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( + * ( + 0 as * const + rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 ) ) . lo as + * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 ) , "::" , + stringify ! ( lo ) )); +} +impl Clone for rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , + 8usize , concat ! ( + "Size of: " , stringify ! ( + rte_mbuf__bindgen_ty_3__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() + , 4usize , concat ! ( + "Alignment of " , stringify ! ( + rte_mbuf__bindgen_ty_3__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_3__bindgen_ty_1 ) ) + . hi as * const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_mbuf__bindgen_ty_3__bindgen_ty_1 ) , "::" , stringify ! ( + hi ) )); +} +impl Clone for rte_mbuf__bindgen_ty_3__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_2 { + pub lo: u32, + pub hi: u32, +} +#[test] +fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_2() { + assert_eq!(::std::mem::size_of::() , + 8usize , concat ! ( + "Size of: " , stringify ! ( + rte_mbuf__bindgen_ty_3__bindgen_ty_2 ) )); + assert_eq! (::std::mem::align_of::() + , 4usize , concat ! ( + "Alignment of " , stringify ! ( + rte_mbuf__bindgen_ty_3__bindgen_ty_2 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_3__bindgen_ty_2 ) ) + . lo as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_mbuf__bindgen_ty_3__bindgen_ty_2 ) , "::" , stringify ! ( + lo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_3__bindgen_ty_2 ) ) + . hi as * const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_mbuf__bindgen_ty_3__bindgen_ty_2 ) , "::" , stringify ! ( + hi ) )); +} +impl Clone for rte_mbuf__bindgen_ty_3__bindgen_ty_2 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_rte_mbuf__bindgen_ty_3() { + assert_eq!(::std::mem::size_of::() , 8usize , + concat ! ( "Size of: " , stringify ! ( rte_mbuf__bindgen_ty_3 ) + )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( rte_mbuf__bindgen_ty_3 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_3 ) ) . rss as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf__bindgen_ty_3 + ) , "::" , stringify ! ( rss ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_3 ) ) . fdir as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf__bindgen_ty_3 + ) , "::" , stringify ! ( fdir ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_3 ) ) . sched as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf__bindgen_ty_3 + ) , "::" , stringify ! ( sched ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_3 ) ) . usr as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf__bindgen_ty_3 + ) , "::" , stringify ! ( usr ) )); +} +impl Clone for rte_mbuf__bindgen_ty_3 { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct rte_mbuf__bindgen_ty_4 { + /// < Can be used for external metadata + pub userdata: __BindgenUnionField<*mut ::std::os::raw::c_void>, + /// < Allow 8-byte userdata on 32-bit + pub udata64: __BindgenUnionField, + pub bindgen_union_field: u64, +} +#[test] +fn bindgen_test_layout_rte_mbuf__bindgen_ty_4() { + assert_eq!(::std::mem::size_of::() , 8usize , + concat ! ( "Size of: " , stringify ! ( rte_mbuf__bindgen_ty_4 ) + )); + assert_eq! (::std::mem::align_of::() , 8usize , + concat ! ( + "Alignment of " , stringify ! ( rte_mbuf__bindgen_ty_4 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_4 ) ) . userdata as + * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf__bindgen_ty_4 + ) , "::" , stringify ! ( userdata ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_4 ) ) . udata64 as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf__bindgen_ty_4 + ) , "::" , stringify ! ( udata64 ) )); +} +impl Clone for rte_mbuf__bindgen_ty_4 { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct rte_mbuf__bindgen_ty_5 { + /// < combined for easy fetch + pub tx_offload: __BindgenUnionField, + pub __bindgen_anon_1: __BindgenUnionField, + pub bindgen_union_field: u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct rte_mbuf__bindgen_ty_5__bindgen_ty_1 { + pub _bitfield_1: [u16; 4usize], + pub __bindgen_align: [u64; 0usize], +} +#[test] +fn bindgen_test_layout_rte_mbuf__bindgen_ty_5__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , + 8usize , concat ! ( + "Size of: " , stringify ! ( + rte_mbuf__bindgen_ty_5__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() + , 8usize , concat ! ( + "Alignment of " , stringify ! ( + rte_mbuf__bindgen_ty_5__bindgen_ty_1 ) )); +} +impl Clone for rte_mbuf__bindgen_ty_5__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +impl rte_mbuf__bindgen_ty_5__bindgen_ty_1 { + #[inline] + pub fn l2_len(&self) -> u64 { + let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u64 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 127u64 as u64; + let val = (unit_field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u64) } + } + #[inline] + pub fn set_l2_len(&mut self, val: u64) { + let mask = 127u64 as u64; + let val = val as u64 as u64; + let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u64 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 0usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn l3_len(&self) -> u64 { + let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u64 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 65408u64 as u64; + let val = (unit_field_val & mask) >> 7usize; + unsafe { ::std::mem::transmute(val as u64) } + } + #[inline] + pub fn set_l3_len(&mut self, val: u64) { + let mask = 65408u64 as u64; + let val = val as u64 as u64; + let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u64 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 7usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn l4_len(&self) -> u64 { + let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u64 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 16711680u64 as u64; + let val = (unit_field_val & mask) >> 16usize; + unsafe { ::std::mem::transmute(val as u64) } + } + #[inline] + pub fn set_l4_len(&mut self, val: u64) { + let mask = 16711680u64 as u64; + let val = val as u64 as u64; + let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u64 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 16usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn tso_segsz(&self) -> u64 { + let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u64 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 1099494850560u64 as u64; + let val = (unit_field_val & mask) >> 24usize; + unsafe { ::std::mem::transmute(val as u64) } + } + #[inline] + pub fn set_tso_segsz(&mut self, val: u64) { + let mask = 1099494850560u64 as u64; + let val = val as u64 as u64; + let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u64 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 24usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn outer_l3_len(&self) -> u64 { + let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u64 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 561850441793536u64 as u64; + let val = (unit_field_val & mask) >> 40usize; + unsafe { ::std::mem::transmute(val as u64) } + } + #[inline] + pub fn set_outer_l3_len(&mut self, val: u64) { + let mask = 561850441793536u64 as u64; + let val = val as u64 as u64; + let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u64 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 40usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn outer_l2_len(&self) -> u64 { + let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u64 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 71494644084506624u64 as u64; + let val = (unit_field_val & mask) >> 49usize; + unsafe { ::std::mem::transmute(val as u64) } + } + #[inline] + pub fn set_outer_l2_len(&mut self, val: u64) { + let mask = 71494644084506624u64 as u64; + let val = val as u64 as u64; + let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u64 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 49usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn new_bitfield_1(l2_len: u64, l3_len: u64, l4_len: u64, + tso_segsz: u64, outer_l3_len: u64, + outer_l2_len: u64) -> u64 { + ({ + ({ + ({ + ({ + ({ + ({ 0 } | + ((l2_len as u64 as u64) << 0usize) & + (127u64 as u64)) + } | + ((l3_len as u64 as u64) << 7usize) & + (65408u64 as u64)) + } | + ((l4_len as u64 as u64) << 16usize) & + (16711680u64 as u64)) + } | + ((tso_segsz as u64 as u64) << 24usize) & + (1099494850560u64 as u64)) + } | + ((outer_l3_len as u64 as u64) << 40usize) & + (561850441793536u64 as u64)) + } | + ((outer_l2_len as u64 as u64) << 49usize) & + (71494644084506624u64 as u64)) + } +} +#[test] +fn bindgen_test_layout_rte_mbuf__bindgen_ty_5() { + assert_eq!(::std::mem::size_of::() , 8usize , + concat ! ( "Size of: " , stringify ! ( rte_mbuf__bindgen_ty_5 ) + )); + assert_eq! (::std::mem::align_of::() , 8usize , + concat ! ( + "Alignment of " , stringify ! ( rte_mbuf__bindgen_ty_5 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_5 ) ) . tx_offload + as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf__bindgen_ty_5 + ) , "::" , stringify ! ( tx_offload ) )); +} +impl Clone for rte_mbuf__bindgen_ty_5 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_rte_mbuf() { + assert_eq!(::std::mem::size_of::() , 128usize , concat ! ( + "Size of: " , stringify ! ( rte_mbuf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . cacheline0 as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( cacheline0 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . buf_addr as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( buf_addr ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . buf_physaddr as * const _ + as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( buf_physaddr ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . buf_len as * const _ as + usize } , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( buf_len ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . rearm_data as * const _ as + usize } , 18usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( rearm_data ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . data_off as * const _ as + usize } , 18usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( data_off ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . nb_segs as * const _ as + usize } , 22usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( nb_segs ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . port as * const _ as usize + } , 23usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( port ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . ol_flags as * const _ as + usize } , 24usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( ol_flags ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . rx_descriptor_fields1 as * + const _ as usize } , 32usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( rx_descriptor_fields1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . pkt_len as * const _ as + usize } , 36usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( pkt_len ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . data_len as * const _ as + usize } , 40usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( data_len ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . vlan_tci as * const _ as + usize } , 42usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( vlan_tci ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . hash as * const _ as usize + } , 44usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( hash ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . seqn as * const _ as usize + } , 52usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( seqn ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . vlan_tci_outer as * const + _ as usize } , 56usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( vlan_tci_outer ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . cacheline1 as * const _ as + usize } , 64usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( cacheline1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . pool as * const _ as usize + } , 72usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( pool ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . next as * const _ as usize + } , 80usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( next ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . priv_size as * const _ as + usize } , 96usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( priv_size ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . timesync as * const _ as + usize } , 98usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( timesync ) )); +} +impl Default for rte_mbuf { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +/// < Pool from which mbuf was allocated. +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct rte_mempool { + pub _address: u8, +} +impl Clone for rte_mempool { + fn clone(&self) -> Self { *self } +} diff --git a/tests/expectations/tests/struct_with_anon_union.rs b/tests/expectations/tests/struct_with_anon_union.rs index 84be35ed2a..eeb367561d 100644 --- a/tests/expectations/tests/struct_with_anon_union.rs +++ b/tests/expectations/tests/struct_with_anon_union.rs @@ -5,43 +5,15 @@ #[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Copy)] pub struct foo { pub bar: foo__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct foo__bindgen_ty_1 { - pub a: __BindgenUnionField<::std::os::raw::c_uint>, - pub b: __BindgenUnionField<::std::os::raw::c_ushort>, - pub bindgen_union_field: u32, +#[derive(Copy)] +pub union foo__bindgen_ty_1 { + pub a: ::std::os::raw::c_uint, + pub b: ::std::os::raw::c_ushort, } #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { @@ -63,6 +35,9 @@ fn bindgen_test_layout_foo__bindgen_ty_1() { impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +impl Default for foo__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( @@ -78,3 +53,6 @@ fn bindgen_test_layout_foo() { impl Clone for foo { fn clone(&self) -> Self { *self } } +impl Default for foo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} diff --git a/tests/expectations/tests/struct_with_anon_union_1_0.rs b/tests/expectations/tests/struct_with_anon_union_1_0.rs new file mode 100644 index 0000000000..84be35ed2a --- /dev/null +++ b/tests/expectations/tests/struct_with_anon_union_1_0.rs @@ -0,0 +1,80 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[repr(C)] +pub struct __BindgenUnionField(::std::marker::PhantomData); +impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } +} +impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } +} +impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl ::std::marker::Copy for __BindgenUnionField { } +impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } +} +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) { } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct foo { + pub bar: foo__bindgen_ty_1, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct foo__bindgen_ty_1 { + pub a: __BindgenUnionField<::std::os::raw::c_uint>, + pub b: __BindgenUnionField<::std::os::raw::c_ushort>, + pub bindgen_union_field: u32, +} +#[test] +fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! + ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat + ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , + "::" , stringify ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , + "::" , stringify ! ( b ) )); +} +impl Clone for foo__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( foo ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( bar ) )); +} +impl Clone for foo { + fn clone(&self) -> Self { *self } +} diff --git a/tests/expectations/tests/struct_with_anon_unnamed_union.rs b/tests/expectations/tests/struct_with_anon_unnamed_union.rs index 226f7db9f1..43c3e19cee 100644 --- a/tests/expectations/tests/struct_with_anon_unnamed_union.rs +++ b/tests/expectations/tests/struct_with_anon_unnamed_union.rs @@ -5,43 +5,15 @@ #[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Copy)] pub struct foo { pub __bindgen_anon_1: foo__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct foo__bindgen_ty_1 { - pub a: __BindgenUnionField<::std::os::raw::c_uint>, - pub b: __BindgenUnionField<::std::os::raw::c_ushort>, - pub bindgen_union_field: u32, +#[derive(Copy)] +pub union foo__bindgen_ty_1 { + pub a: ::std::os::raw::c_uint, + pub b: ::std::os::raw::c_ushort, } #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { @@ -63,6 +35,9 @@ fn bindgen_test_layout_foo__bindgen_ty_1() { impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +impl Default for foo__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( @@ -73,3 +48,6 @@ fn bindgen_test_layout_foo() { impl Clone for foo { fn clone(&self) -> Self { *self } } +impl Default for foo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} diff --git a/tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs b/tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs new file mode 100644 index 0000000000..226f7db9f1 --- /dev/null +++ b/tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs @@ -0,0 +1,75 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[repr(C)] +pub struct __BindgenUnionField(::std::marker::PhantomData); +impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } +} +impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } +} +impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl ::std::marker::Copy for __BindgenUnionField { } +impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } +} +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) { } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct foo { + pub __bindgen_anon_1: foo__bindgen_ty_1, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct foo__bindgen_ty_1 { + pub a: __BindgenUnionField<::std::os::raw::c_uint>, + pub b: __BindgenUnionField<::std::os::raw::c_ushort>, + pub bindgen_union_field: u32, +} +#[test] +fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! + ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat + ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , + "::" , stringify ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , + "::" , stringify ! ( b ) )); +} +impl Clone for foo__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( foo ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( foo ) )); +} +impl Clone for foo { + fn clone(&self) -> Self { *self } +} diff --git a/tests/expectations/tests/struct_with_nesting.rs b/tests/expectations/tests/struct_with_nesting.rs index 63df2729f7..b85da98915 100644 --- a/tests/expectations/tests/struct_with_nesting.rs +++ b/tests/expectations/tests/struct_with_nesting.rs @@ -5,45 +5,17 @@ #[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Copy)] pub struct foo { pub a: ::std::os::raw::c_uint, pub __bindgen_anon_1: foo__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct foo__bindgen_ty_1 { - pub b: __BindgenUnionField<::std::os::raw::c_uint>, - pub __bindgen_anon_1: __BindgenUnionField, - pub __bindgen_anon_2: __BindgenUnionField, - pub bindgen_union_field: u32, +#[derive(Copy)] +pub union foo__bindgen_ty_1 { + pub b: ::std::os::raw::c_uint, + pub __bindgen_anon_1: foo__bindgen_ty_1__bindgen_ty_1, + pub __bindgen_anon_2: foo__bindgen_ty_1__bindgen_ty_2, } #[repr(C)] #[derive(Debug, Default, Copy, Hash)] @@ -138,6 +110,9 @@ fn bindgen_test_layout_foo__bindgen_ty_1() { impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +impl Default for foo__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( @@ -153,3 +128,6 @@ fn bindgen_test_layout_foo() { impl Clone for foo { fn clone(&self) -> Self { *self } } +impl Default for foo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} diff --git a/tests/expectations/tests/struct_with_nesting_1_0.rs b/tests/expectations/tests/struct_with_nesting_1_0.rs new file mode 100644 index 0000000000..63df2729f7 --- /dev/null +++ b/tests/expectations/tests/struct_with_nesting_1_0.rs @@ -0,0 +1,155 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[repr(C)] +pub struct __BindgenUnionField(::std::marker::PhantomData); +impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } +} +impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } +} +impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl ::std::marker::Copy for __BindgenUnionField { } +impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } +} +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) { } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct foo { + pub a: ::std::os::raw::c_uint, + pub __bindgen_anon_1: foo__bindgen_ty_1, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct foo__bindgen_ty_1 { + pub b: __BindgenUnionField<::std::os::raw::c_uint>, + pub __bindgen_anon_1: __BindgenUnionField, + pub __bindgen_anon_2: __BindgenUnionField, + pub bindgen_union_field: u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct foo__bindgen_ty_1__bindgen_ty_1 { + pub c1: ::std::os::raw::c_ushort, + pub c2: ::std::os::raw::c_ushort, +} +#[test] +fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , + 4usize , concat ! ( + "Size of: " , stringify ! ( foo__bindgen_ty_1__bindgen_ty_1 ) + )); + assert_eq! (::std::mem::align_of::() , + 2usize , concat ! ( + "Alignment of " , stringify ! ( + foo__bindgen_ty_1__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_1 ) ) . c1 + as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + foo__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( c1 ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_1 ) ) . c2 + as * const _ as usize } , 2usize , concat ! ( + "Alignment of field: " , stringify ! ( + foo__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( c2 ) + )); +} +impl Clone for foo__bindgen_ty_1__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct foo__bindgen_ty_1__bindgen_ty_2 { + pub d1: ::std::os::raw::c_uchar, + pub d2: ::std::os::raw::c_uchar, + pub d3: ::std::os::raw::c_uchar, + pub d4: ::std::os::raw::c_uchar, +} +#[test] +fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_2() { + assert_eq!(::std::mem::size_of::() , + 4usize , concat ! ( + "Size of: " , stringify ! ( foo__bindgen_ty_1__bindgen_ty_2 ) + )); + assert_eq! (::std::mem::align_of::() , + 1usize , concat ! ( + "Alignment of " , stringify ! ( + foo__bindgen_ty_1__bindgen_ty_2 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . d1 + as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( d1 ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . d2 + as * const _ as usize } , 1usize , concat ! ( + "Alignment of field: " , stringify ! ( + foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( d2 ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . d3 + as * const _ as usize } , 2usize , concat ! ( + "Alignment of field: " , stringify ! ( + foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( d3 ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . d4 + as * const _ as usize } , 3usize , concat ! ( + "Alignment of field: " , stringify ! ( + foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( d4 ) + )); +} +impl Clone for foo__bindgen_ty_1__bindgen_ty_2 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! + ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat + ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , + "::" , stringify ! ( b ) )); +} +impl Clone for foo__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( foo ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( a ) )); +} +impl Clone for foo { + fn clone(&self) -> Self { *self } +} diff --git a/tests/expectations/tests/typeref.rs b/tests/expectations/tests/typeref.rs index 43427f08f5..d886e1fe62 100644 --- a/tests/expectations/tests/typeref.rs +++ b/tests/expectations/tests/typeref.rs @@ -5,34 +5,6 @@ #[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash)] pub struct nsFoo { pub mBar: mozilla_StyleShapeSource, } @@ -48,8 +20,8 @@ fn bindgen_test_layout_nsFoo() { "Alignment of field: " , stringify ! ( nsFoo ) , "::" , stringify ! ( mBar ) )); } -impl Clone for nsFoo { - fn clone(&self) -> Self { *self } +impl Default for nsFoo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] #[derive(Debug, Default, Copy, Hash)] @@ -89,16 +61,19 @@ impl Clone for mozilla_Position { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash)] pub struct mozilla_StyleShapeSource { pub __bindgen_anon_1: mozilla_StyleShapeSource__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash)] -pub struct mozilla_StyleShapeSource__bindgen_ty_1 { - pub mPosition: __BindgenUnionField<*mut mozilla_Position>, - pub mFragmentOrURL: __BindgenUnionField<*mut mozilla_FragmentOrURL>, - pub bindgen_union_field: u64, +pub union mozilla_StyleShapeSource__bindgen_ty_1 { + pub mPosition: *mut mozilla_Position, + pub mFragmentOrURL: *mut mozilla_FragmentOrURL, +} +impl Default for mozilla_StyleShapeSource__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +impl Default for mozilla_StyleShapeSource { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] #[derive(Debug, Copy, Hash)] diff --git a/tests/expectations/tests/typeref_1_0.rs b/tests/expectations/tests/typeref_1_0.rs new file mode 100644 index 0000000000..43427f08f5 --- /dev/null +++ b/tests/expectations/tests/typeref_1_0.rs @@ -0,0 +1,136 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[repr(C)] +pub struct __BindgenUnionField(::std::marker::PhantomData); +impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } +} +impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } +} +impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl ::std::marker::Copy for __BindgenUnionField { } +impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } +} +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) { } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct nsFoo { + pub mBar: mozilla_StyleShapeSource, +} +#[test] +fn bindgen_test_layout_nsFoo() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( nsFoo ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( nsFoo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const nsFoo ) ) . mBar as * const _ as usize } + , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( nsFoo ) , "::" , + stringify ! ( mBar ) )); +} +impl Clone for nsFoo { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct mozilla_FragmentOrURL { + pub mIsLocalRef: bool, +} +#[test] +fn bindgen_test_layout_mozilla_FragmentOrURL() { + assert_eq!(::std::mem::size_of::() , 1usize , + concat ! ( "Size of: " , stringify ! ( mozilla_FragmentOrURL ) + )); + assert_eq! (::std::mem::align_of::() , 1usize , + concat ! ( + "Alignment of " , stringify ! ( mozilla_FragmentOrURL ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const mozilla_FragmentOrURL ) ) . mIsLocalRef + as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( mozilla_FragmentOrURL ) + , "::" , stringify ! ( mIsLocalRef ) )); +} +impl Clone for mozilla_FragmentOrURL { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct mozilla_Position { + pub _address: u8, +} +#[test] +fn bindgen_test_layout_mozilla_Position() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of: " , stringify ! ( mozilla_Position ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! + ( "Alignment of " , stringify ! ( mozilla_Position ) )); +} +impl Clone for mozilla_Position { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash)] +pub struct mozilla_StyleShapeSource { + pub __bindgen_anon_1: mozilla_StyleShapeSource__bindgen_ty_1, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash)] +pub struct mozilla_StyleShapeSource__bindgen_ty_1 { + pub mPosition: __BindgenUnionField<*mut mozilla_Position>, + pub mFragmentOrURL: __BindgenUnionField<*mut mozilla_FragmentOrURL>, + pub bindgen_union_field: u64, +} +#[repr(C)] +#[derive(Debug, Copy, Hash)] +pub struct Bar { + pub mFoo: *mut nsFoo, +} +#[test] +fn bindgen_test_layout_Bar() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( Bar ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( Bar ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Bar ) ) . mFoo as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( Bar ) , "::" , + stringify ! ( mFoo ) )); +} +impl Clone for Bar { + fn clone(&self) -> Self { *self } +} +impl Default for Bar { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +#[test] +fn __bindgen_test_layout_mozilla_StyleShapeSource_open0_int_close0_instantiation() { + assert_eq!(::std::mem::size_of::() , 8usize , + concat ! ( + "Size of template specialization: " , stringify ! ( + mozilla_StyleShapeSource ) )); + assert_eq!(::std::mem::align_of::() , 8usize , + concat ! ( + "Alignment of template specialization: " , stringify ! ( + mozilla_StyleShapeSource ) )); +} diff --git a/tests/expectations/tests/union-in-ns.rs b/tests/expectations/tests/union-in-ns.rs index 968b1f83ad..0151d43454 100644 --- a/tests/expectations/tests/union-in-ns.rs +++ b/tests/expectations/tests/union-in-ns.rs @@ -6,44 +6,12 @@ #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { - #[repr(C)] - pub struct __BindgenUnionField(::std::marker::PhantomData); - impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { - __BindgenUnionField(::std::marker::PhantomData) - } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { - ::std::mem::transmute(self) - } - } - impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } - } - impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } - } - impl ::std::marker::Copy for __BindgenUnionField { } - impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } - } - impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } - } #[allow(unused_imports)] use self::super::root; #[repr(C)] - #[derive(Debug, Default, Copy)] - pub struct bar { - pub baz: root::__BindgenUnionField<::std::os::raw::c_int>, - pub bindgen_union_field: u32, + #[derive(Copy)] + pub union bar { + pub baz: ::std::os::raw::c_int, } #[test] fn bindgen_test_layout_bar() { @@ -60,4 +28,7 @@ pub mod root { impl Clone for bar { fn clone(&self) -> Self { *self } } + impl Default for bar { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/union-in-ns_1_0.rs b/tests/expectations/tests/union-in-ns_1_0.rs new file mode 100644 index 0000000000..968b1f83ad --- /dev/null +++ b/tests/expectations/tests/union-in-ns_1_0.rs @@ -0,0 +1,63 @@ +/* automatically generated by rust-bindgen */ + + +#![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 { + #[repr(C)] + pub struct __BindgenUnionField(::std::marker::PhantomData); + impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { + __BindgenUnionField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { + ::std::mem::transmute(self) + } + } + impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } + } + impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } + } + impl ::std::marker::Copy for __BindgenUnionField { } + impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } + } + impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) { } + } + #[allow(unused_imports)] + use self::super::root; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct bar { + pub baz: root::__BindgenUnionField<::std::os::raw::c_int>, + pub bindgen_union_field: u32, + } + #[test] + fn bindgen_test_layout_bar() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( bar ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( bar ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const bar ) ) . baz as * const _ as usize } + , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( bar ) , "::" , + stringify ! ( baz ) )); + } + impl Clone for bar { + fn clone(&self) -> Self { *self } + } +} diff --git a/tests/expectations/tests/union_dtor.rs b/tests/expectations/tests/union_dtor.rs index 6f7eba4120..d33f4b079b 100644 --- a/tests/expectations/tests/union_dtor.rs +++ b/tests/expectations/tests/union_dtor.rs @@ -5,38 +5,9 @@ #[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } -} -#[repr(C)] -#[derive(Debug, Default)] -pub struct UnionWithDtor { - pub mFoo: __BindgenUnionField<::std::os::raw::c_int>, - pub mBar: __BindgenUnionField<*mut ::std::os::raw::c_void>, - pub bindgen_union_field: u64, +pub union UnionWithDtor { + pub mFoo: ::std::os::raw::c_int, + pub mBar: *mut ::std::os::raw::c_void, } #[test] fn bindgen_test_layout_UnionWithDtor() { @@ -59,6 +30,9 @@ extern "C" { #[link_name = "_ZN13UnionWithDtorD1Ev"] pub fn UnionWithDtor_UnionWithDtor_destructor(this: *mut UnionWithDtor); } +impl Default for UnionWithDtor { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} impl UnionWithDtor { #[inline] pub unsafe fn destruct(&mut self) { diff --git a/tests/expectations/tests/union_dtor_1_0.rs b/tests/expectations/tests/union_dtor_1_0.rs new file mode 100644 index 0000000000..6f7eba4120 --- /dev/null +++ b/tests/expectations/tests/union_dtor_1_0.rs @@ -0,0 +1,67 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[repr(C)] +pub struct __BindgenUnionField(::std::marker::PhantomData); +impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } +} +impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } +} +impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl ::std::marker::Copy for __BindgenUnionField { } +impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } +} +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) { } +} +#[repr(C)] +#[derive(Debug, Default)] +pub struct UnionWithDtor { + pub mFoo: __BindgenUnionField<::std::os::raw::c_int>, + pub mBar: __BindgenUnionField<*mut ::std::os::raw::c_void>, + pub bindgen_union_field: u64, +} +#[test] +fn bindgen_test_layout_UnionWithDtor() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( UnionWithDtor ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( UnionWithDtor ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const UnionWithDtor ) ) . mFoo as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( UnionWithDtor ) , "::" + , stringify ! ( mFoo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const UnionWithDtor ) ) . mBar as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( UnionWithDtor ) , "::" + , stringify ! ( mBar ) )); +} +extern "C" { + #[link_name = "_ZN13UnionWithDtorD1Ev"] + pub fn UnionWithDtor_UnionWithDtor_destructor(this: *mut UnionWithDtor); +} +impl UnionWithDtor { + #[inline] + pub unsafe fn destruct(&mut self) { + UnionWithDtor_UnionWithDtor_destructor(self) + } +} diff --git a/tests/expectations/tests/union_fields.rs b/tests/expectations/tests/union_fields.rs index fd4ac5ab56..9d1638fd80 100644 --- a/tests/expectations/tests/union_fields.rs +++ b/tests/expectations/tests/union_fields.rs @@ -5,39 +5,11 @@ #[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct nsStyleUnion { - pub mInt: __BindgenUnionField<::std::os::raw::c_int>, - pub mFloat: __BindgenUnionField, - pub mPointer: __BindgenUnionField<*mut ::std::os::raw::c_void>, - pub bindgen_union_field: u64, +#[derive(Copy)] +pub union nsStyleUnion { + pub mInt: ::std::os::raw::c_int, + pub mFloat: f32, + pub mPointer: *mut ::std::os::raw::c_void, } #[test] fn bindgen_test_layout_nsStyleUnion() { @@ -64,3 +36,6 @@ fn bindgen_test_layout_nsStyleUnion() { impl Clone for nsStyleUnion { fn clone(&self) -> Self { *self } } +impl Default for nsStyleUnion { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} diff --git a/tests/expectations/tests/union_fields_1_0.rs b/tests/expectations/tests/union_fields_1_0.rs new file mode 100644 index 0000000000..fd4ac5ab56 --- /dev/null +++ b/tests/expectations/tests/union_fields_1_0.rs @@ -0,0 +1,66 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[repr(C)] +pub struct __BindgenUnionField(::std::marker::PhantomData); +impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } +} +impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } +} +impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl ::std::marker::Copy for __BindgenUnionField { } +impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } +} +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) { } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct nsStyleUnion { + pub mInt: __BindgenUnionField<::std::os::raw::c_int>, + pub mFloat: __BindgenUnionField, + pub mPointer: __BindgenUnionField<*mut ::std::os::raw::c_void>, + pub bindgen_union_field: u64, +} +#[test] +fn bindgen_test_layout_nsStyleUnion() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( nsStyleUnion ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( nsStyleUnion ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const nsStyleUnion ) ) . mInt as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( nsStyleUnion ) , "::" , + stringify ! ( mInt ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const nsStyleUnion ) ) . mFloat as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( nsStyleUnion ) , "::" , + stringify ! ( mFloat ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const nsStyleUnion ) ) . mPointer as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( nsStyleUnion ) , "::" , + stringify ! ( mPointer ) )); +} +impl Clone for nsStyleUnion { + fn clone(&self) -> Self { *self } +} diff --git a/tests/expectations/tests/union_template.rs b/tests/expectations/tests/union_template.rs index df5e87ee29..ae854042b3 100644 --- a/tests/expectations/tests/union_template.rs +++ b/tests/expectations/tests/union_template.rs @@ -5,57 +5,35 @@ #[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash)] pub struct NastyStruct { pub mIsSome: bool, pub mStorage: NastyStruct__bindgen_ty_1, pub __bindgen_anon_1: NastyStruct__bindgen_ty_2, } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash)] -pub struct NastyStruct__bindgen_ty_1 { - pub mFoo: __BindgenUnionField<*mut ::std::os::raw::c_void>, - pub mDummy: __BindgenUnionField<::std::os::raw::c_ulong>, - pub bindgen_union_field: u64, +pub union NastyStruct__bindgen_ty_1 { + pub mFoo: *mut ::std::os::raw::c_void, + pub mDummy: ::std::os::raw::c_ulong, +} +impl Default for NastyStruct__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash)] -pub struct NastyStruct__bindgen_ty_2 { - pub wat: __BindgenUnionField<::std::os::raw::c_short>, - pub wut: __BindgenUnionField<*mut ::std::os::raw::c_int>, - pub bindgen_union_field: u64, +pub union NastyStruct__bindgen_ty_2 { + pub wat: ::std::os::raw::c_short, + pub wut: *mut ::std::os::raw::c_int, +} +impl Default for NastyStruct__bindgen_ty_2 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +impl Default for NastyStruct { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash)] -pub struct Whatever { - pub mTPtr: __BindgenUnionField<*mut ::std::os::raw::c_void>, - pub mInt: __BindgenUnionField<::std::os::raw::c_int>, - pub bindgen_union_field: u64, +pub union Whatever { + pub mTPtr: *mut ::std::os::raw::c_void, + pub mInt: ::std::os::raw::c_int, +} +impl Default for Whatever { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } } diff --git a/tests/expectations/tests/union_template_1_0.rs b/tests/expectations/tests/union_template_1_0.rs new file mode 100644 index 0000000000..df5e87ee29 --- /dev/null +++ b/tests/expectations/tests/union_template_1_0.rs @@ -0,0 +1,61 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[repr(C)] +pub struct __BindgenUnionField(::std::marker::PhantomData); +impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } +} +impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } +} +impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl ::std::marker::Copy for __BindgenUnionField { } +impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } +} +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) { } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash)] +pub struct NastyStruct { + pub mIsSome: bool, + pub mStorage: NastyStruct__bindgen_ty_1, + pub __bindgen_anon_1: NastyStruct__bindgen_ty_2, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash)] +pub struct NastyStruct__bindgen_ty_1 { + pub mFoo: __BindgenUnionField<*mut ::std::os::raw::c_void>, + pub mDummy: __BindgenUnionField<::std::os::raw::c_ulong>, + pub bindgen_union_field: u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash)] +pub struct NastyStruct__bindgen_ty_2 { + pub wat: __BindgenUnionField<::std::os::raw::c_short>, + pub wut: __BindgenUnionField<*mut ::std::os::raw::c_int>, + pub bindgen_union_field: u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash)] +pub struct Whatever { + pub mTPtr: __BindgenUnionField<*mut ::std::os::raw::c_void>, + pub mInt: __BindgenUnionField<::std::os::raw::c_int>, + pub bindgen_union_field: u64, +} diff --git a/tests/expectations/tests/union_with_anon_struct.rs b/tests/expectations/tests/union_with_anon_struct.rs index 5afaa8764e..7a0e864335 100644 --- a/tests/expectations/tests/union_with_anon_struct.rs +++ b/tests/expectations/tests/union_with_anon_struct.rs @@ -5,37 +5,9 @@ #[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct foo { - pub bar: __BindgenUnionField, - pub bindgen_union_field: [u32; 2usize], +#[derive(Copy)] +pub union foo { + pub bar: foo__bindgen_ty_1, } #[repr(C)] #[derive(Debug, Default, Copy, Hash)] @@ -78,3 +50,6 @@ fn bindgen_test_layout_foo() { impl Clone for foo { fn clone(&self) -> Self { *self } } +impl Default for foo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} diff --git a/tests/expectations/tests/union_with_anon_struct_1_0.rs b/tests/expectations/tests/union_with_anon_struct_1_0.rs new file mode 100644 index 0000000000..5afaa8764e --- /dev/null +++ b/tests/expectations/tests/union_with_anon_struct_1_0.rs @@ -0,0 +1,80 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[repr(C)] +pub struct __BindgenUnionField(::std::marker::PhantomData); +impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } +} +impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } +} +impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl ::std::marker::Copy for __BindgenUnionField { } +impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } +} +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) { } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct foo { + pub bar: __BindgenUnionField, + pub bindgen_union_field: [u32; 2usize], +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct foo__bindgen_ty_1 { + pub a: ::std::os::raw::c_uint, + pub b: ::std::os::raw::c_uint, +} +#[test] +fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! + ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat + ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , + "::" , stringify ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as + usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , + "::" , stringify ! ( b ) )); +} +impl Clone for foo__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( foo ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( bar ) )); +} +impl Clone for foo { + fn clone(&self) -> Self { *self } +} diff --git a/tests/expectations/tests/union_with_anon_struct_bitfield.rs b/tests/expectations/tests/union_with_anon_struct_bitfield.rs index ba1cdf47f6..03aa892ccd 100644 --- a/tests/expectations/tests/union_with_anon_struct_bitfield.rs +++ b/tests/expectations/tests/union_with_anon_struct_bitfield.rs @@ -5,38 +5,10 @@ #[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct foo { - pub a: __BindgenUnionField<::std::os::raw::c_int>, - pub __bindgen_anon_1: __BindgenUnionField, - pub bindgen_union_field: u32, +#[derive(Copy)] +pub union foo { + pub a: ::std::os::raw::c_int, + pub __bindgen_anon_1: foo__bindgen_ty_1, } #[repr(C)] #[derive(Debug, Default, Copy, Hash)] @@ -149,3 +121,6 @@ fn bindgen_test_layout_foo() { impl Clone for foo { fn clone(&self) -> Self { *self } } +impl Default for foo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} diff --git a/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs b/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs new file mode 100644 index 0000000000..ba1cdf47f6 --- /dev/null +++ b/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs @@ -0,0 +1,151 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[repr(C)] +pub struct __BindgenUnionField(::std::marker::PhantomData); +impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } +} +impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } +} +impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl ::std::marker::Copy for __BindgenUnionField { } +impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } +} +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) { } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct foo { + pub a: __BindgenUnionField<::std::os::raw::c_int>, + pub __bindgen_anon_1: __BindgenUnionField, + pub bindgen_union_field: u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct foo__bindgen_ty_1 { + pub _bitfield_1: u32, + pub __bindgen_align: [u32; 0usize], +} +#[test] +fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! + ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat + ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); +} +impl Clone for foo__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +impl foo__bindgen_ty_1 { + #[inline] + pub fn b(&self) -> ::std::os::raw::c_int { + let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u32 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 127u64 as u32; + let val = (unit_field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_b(&mut self, val: ::std::os::raw::c_int) { + let mask = 127u64 as u32; + let val = val as u32 as u32; + let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u32 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 0usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn c(&self) -> ::std::os::raw::c_int { + let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u32 as + *mut u8, + ::std::mem::size_of::()) + }; + let mask = 4294967168u64 as u32; + let val = (unit_field_val & mask) >> 7usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_c(&mut self, val: ::std::os::raw::c_int) { + let mask = 4294967168u64 as u32; + let val = val as u32 as u32; + let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() }; + unsafe { + ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as + *const u8, + &mut unit_field_val as *mut u32 as + *mut u8, + ::std::mem::size_of::()) + }; + unit_field_val &= !mask; + unit_field_val |= (val << 7usize) & mask; + unsafe { + ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as + *const u8, + &mut self._bitfield_1 as *mut _ as + *mut u8, + ::std::mem::size_of::()); + } + } + #[inline] + pub fn new_bitfield_1(b: ::std::os::raw::c_int, c: ::std::os::raw::c_int) + -> u32 { + ({ ({ 0 } | ((b as u32 as u32) << 0usize) & (127u64 as u32)) } | + ((c as u32 as u32) << 7usize) & (4294967168u64 as u32)) + } +} +#[test] +fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( foo ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( a ) )); +} +impl Clone for foo { + fn clone(&self) -> Self { *self } +} diff --git a/tests/expectations/tests/union_with_anon_union.rs b/tests/expectations/tests/union_with_anon_union.rs index 99c0c8178b..9f8b671378 100644 --- a/tests/expectations/tests/union_with_anon_union.rs +++ b/tests/expectations/tests/union_with_anon_union.rs @@ -5,44 +5,15 @@ #[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } +#[derive(Copy)] +pub union foo { + pub bar: foo__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct foo { - pub bar: __BindgenUnionField, - pub bindgen_union_field: u32, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct foo__bindgen_ty_1 { - pub a: __BindgenUnionField<::std::os::raw::c_uint>, - pub b: __BindgenUnionField<::std::os::raw::c_ushort>, - pub bindgen_union_field: u32, +#[derive(Copy)] +pub union foo__bindgen_ty_1 { + pub a: ::std::os::raw::c_uint, + pub b: ::std::os::raw::c_ushort, } #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { @@ -64,6 +35,9 @@ fn bindgen_test_layout_foo__bindgen_ty_1() { impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +impl Default for foo__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( @@ -79,3 +53,6 @@ fn bindgen_test_layout_foo() { impl Clone for foo { fn clone(&self) -> Self { *self } } +impl Default for foo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} diff --git a/tests/expectations/tests/union_with_anon_union_1_0.rs b/tests/expectations/tests/union_with_anon_union_1_0.rs new file mode 100644 index 0000000000..99c0c8178b --- /dev/null +++ b/tests/expectations/tests/union_with_anon_union_1_0.rs @@ -0,0 +1,81 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[repr(C)] +pub struct __BindgenUnionField(::std::marker::PhantomData); +impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } +} +impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } +} +impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl ::std::marker::Copy for __BindgenUnionField { } +impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } +} +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) { } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct foo { + pub bar: __BindgenUnionField, + pub bindgen_union_field: u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct foo__bindgen_ty_1 { + pub a: __BindgenUnionField<::std::os::raw::c_uint>, + pub b: __BindgenUnionField<::std::os::raw::c_ushort>, + pub bindgen_union_field: u32, +} +#[test] +fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! + ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat + ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , + "::" , stringify ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , + "::" , stringify ! ( b ) )); +} +impl Clone for foo__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( foo ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( bar ) )); +} +impl Clone for foo { + fn clone(&self) -> Self { *self } +} diff --git a/tests/expectations/tests/union_with_anon_unnamed_struct.rs b/tests/expectations/tests/union_with_anon_unnamed_struct.rs index afe12dce67..7aef96e936 100644 --- a/tests/expectations/tests/union_with_anon_unnamed_struct.rs +++ b/tests/expectations/tests/union_with_anon_unnamed_struct.rs @@ -5,38 +5,10 @@ #[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct pixel { - pub rgba: __BindgenUnionField<::std::os::raw::c_uint>, - pub __bindgen_anon_1: __BindgenUnionField, - pub bindgen_union_field: u32, +#[derive(Copy)] +pub union pixel { + pub rgba: ::std::os::raw::c_uint, + pub __bindgen_anon_1: pixel__bindgen_ty_1, } #[repr(C)] #[derive(Debug, Default, Copy, Hash)] @@ -92,3 +64,6 @@ fn bindgen_test_layout_pixel() { impl Clone for pixel { fn clone(&self) -> Self { *self } } +impl Default for pixel { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} diff --git a/tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs b/tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs new file mode 100644 index 0000000000..afe12dce67 --- /dev/null +++ b/tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs @@ -0,0 +1,94 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[repr(C)] +pub struct __BindgenUnionField(::std::marker::PhantomData); +impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } +} +impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } +} +impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl ::std::marker::Copy for __BindgenUnionField { } +impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } +} +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) { } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct pixel { + pub rgba: __BindgenUnionField<::std::os::raw::c_uint>, + pub __bindgen_anon_1: __BindgenUnionField, + pub bindgen_union_field: u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct pixel__bindgen_ty_1 { + pub r: ::std::os::raw::c_uchar, + pub g: ::std::os::raw::c_uchar, + pub b: ::std::os::raw::c_uchar, + pub a: ::std::os::raw::c_uchar, +} +#[test] +fn bindgen_test_layout_pixel__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 4usize , concat + ! ( "Size of: " , stringify ! ( pixel__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() , 1usize , + concat ! ( + "Alignment of " , stringify ! ( pixel__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const pixel__bindgen_ty_1 ) ) . r as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( pixel__bindgen_ty_1 ) , + "::" , stringify ! ( r ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const pixel__bindgen_ty_1 ) ) . g as * const _ + as usize } , 1usize , concat ! ( + "Alignment of field: " , stringify ! ( pixel__bindgen_ty_1 ) , + "::" , stringify ! ( g ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const pixel__bindgen_ty_1 ) ) . b as * const _ + as usize } , 2usize , concat ! ( + "Alignment of field: " , stringify ! ( pixel__bindgen_ty_1 ) , + "::" , stringify ! ( b ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const pixel__bindgen_ty_1 ) ) . a as * const _ + as usize } , 3usize , concat ! ( + "Alignment of field: " , stringify ! ( pixel__bindgen_ty_1 ) , + "::" , stringify ! ( a ) )); +} +impl Clone for pixel__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_pixel() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( pixel ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( pixel ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const pixel ) ) . rgba as * const _ as usize } + , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( pixel ) , "::" , + stringify ! ( rgba ) )); +} +impl Clone for pixel { + fn clone(&self) -> Self { *self } +} diff --git a/tests/expectations/tests/union_with_anon_unnamed_union.rs b/tests/expectations/tests/union_with_anon_unnamed_union.rs index 67dcd5210c..cf7006ed02 100644 --- a/tests/expectations/tests/union_with_anon_unnamed_union.rs +++ b/tests/expectations/tests/union_with_anon_unnamed_union.rs @@ -5,45 +5,16 @@ #[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } +#[derive(Copy)] +pub union foo { + pub a: ::std::os::raw::c_uint, + pub __bindgen_anon_1: foo__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct foo { - pub a: __BindgenUnionField<::std::os::raw::c_uint>, - pub __bindgen_anon_1: __BindgenUnionField, - pub bindgen_union_field: u32, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct foo__bindgen_ty_1 { - pub b: __BindgenUnionField<::std::os::raw::c_ushort>, - pub c: __BindgenUnionField<::std::os::raw::c_uchar>, - pub bindgen_union_field: u16, +#[derive(Copy)] +pub union foo__bindgen_ty_1 { + pub b: ::std::os::raw::c_ushort, + pub c: ::std::os::raw::c_uchar, } #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { @@ -65,6 +36,9 @@ fn bindgen_test_layout_foo__bindgen_ty_1() { impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +impl Default for foo__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( @@ -80,3 +54,6 @@ fn bindgen_test_layout_foo() { impl Clone for foo { fn clone(&self) -> Self { *self } } +impl Default for foo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} diff --git a/tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs b/tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs new file mode 100644 index 0000000000..67dcd5210c --- /dev/null +++ b/tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs @@ -0,0 +1,82 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[repr(C)] +pub struct __BindgenUnionField(::std::marker::PhantomData); +impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } +} +impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } +} +impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl ::std::marker::Copy for __BindgenUnionField { } +impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } +} +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) { } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct foo { + pub a: __BindgenUnionField<::std::os::raw::c_uint>, + pub __bindgen_anon_1: __BindgenUnionField, + pub bindgen_union_field: u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct foo__bindgen_ty_1 { + pub b: __BindgenUnionField<::std::os::raw::c_ushort>, + pub c: __BindgenUnionField<::std::os::raw::c_uchar>, + pub bindgen_union_field: u16, +} +#[test] +fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 2usize , concat ! + ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() , 2usize , concat + ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , + "::" , stringify ! ( b ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . c as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , + "::" , stringify ! ( c ) )); +} +impl Clone for foo__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( foo ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( a ) )); +} +impl Clone for foo { + fn clone(&self) -> Self { *self } +} diff --git a/tests/expectations/tests/union_with_big_member.rs b/tests/expectations/tests/union_with_big_member.rs index 836fe1a59f..c500ff7550 100644 --- a/tests/expectations/tests/union_with_big_member.rs +++ b/tests/expectations/tests/union_with_big_member.rs @@ -4,39 +4,11 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } -} #[repr(C)] #[derive(Copy)] -pub struct WithBigArray { - pub a: __BindgenUnionField<::std::os::raw::c_int>, - pub b: __BindgenUnionField<[::std::os::raw::c_int; 33usize]>, - pub bindgen_union_field: [u32; 33usize], +pub union WithBigArray { + pub a: ::std::os::raw::c_int, + pub b: [::std::os::raw::c_int; 33usize], } #[test] fn bindgen_test_layout_WithBigArray() { @@ -62,11 +34,10 @@ impl Default for WithBigArray { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct WithBigArray2 { - pub a: __BindgenUnionField<::std::os::raw::c_int>, - pub b: __BindgenUnionField<[::std::os::raw::c_char; 33usize]>, - pub bindgen_union_field: [u32; 9usize], +#[derive(Copy)] +pub union WithBigArray2 { + pub a: ::std::os::raw::c_int, + pub b: [::std::os::raw::c_char; 33usize], } #[test] fn bindgen_test_layout_WithBigArray2() { @@ -88,12 +59,14 @@ fn bindgen_test_layout_WithBigArray2() { impl Clone for WithBigArray2 { fn clone(&self) -> Self { *self } } +impl Default for WithBigArray2 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[repr(C)] #[derive(Copy)] -pub struct WithBigMember { - pub a: __BindgenUnionField<::std::os::raw::c_int>, - pub b: __BindgenUnionField, - pub bindgen_union_field: [u32; 33usize], +pub union WithBigMember { + pub a: ::std::os::raw::c_int, + pub b: WithBigArray, } #[test] fn bindgen_test_layout_WithBigMember() { diff --git a/tests/expectations/tests/union_with_big_member_1_0.rs b/tests/expectations/tests/union_with_big_member_1_0.rs new file mode 100644 index 0000000000..836fe1a59f --- /dev/null +++ b/tests/expectations/tests/union_with_big_member_1_0.rs @@ -0,0 +1,120 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[repr(C)] +pub struct __BindgenUnionField(::std::marker::PhantomData); +impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } +} +impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } +} +impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl ::std::marker::Copy for __BindgenUnionField { } +impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } +} +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) { } +} +#[repr(C)] +#[derive(Copy)] +pub struct WithBigArray { + pub a: __BindgenUnionField<::std::os::raw::c_int>, + pub b: __BindgenUnionField<[::std::os::raw::c_int; 33usize]>, + pub bindgen_union_field: [u32; 33usize], +} +#[test] +fn bindgen_test_layout_WithBigArray() { + assert_eq!(::std::mem::size_of::() , 132usize , concat ! ( + "Size of: " , stringify ! ( WithBigArray ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( WithBigArray ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const WithBigArray ) ) . a as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( WithBigArray ) , "::" , + stringify ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const WithBigArray ) ) . b as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( WithBigArray ) , "::" , + stringify ! ( b ) )); +} +impl Clone for WithBigArray { + fn clone(&self) -> Self { *self } +} +impl Default for WithBigArray { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct WithBigArray2 { + pub a: __BindgenUnionField<::std::os::raw::c_int>, + pub b: __BindgenUnionField<[::std::os::raw::c_char; 33usize]>, + pub bindgen_union_field: [u32; 9usize], +} +#[test] +fn bindgen_test_layout_WithBigArray2() { + assert_eq!(::std::mem::size_of::() , 36usize , concat ! ( + "Size of: " , stringify ! ( WithBigArray2 ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( WithBigArray2 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const WithBigArray2 ) ) . a as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( WithBigArray2 ) , "::" + , stringify ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const WithBigArray2 ) ) . b as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( WithBigArray2 ) , "::" + , stringify ! ( b ) )); +} +impl Clone for WithBigArray2 { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Copy)] +pub struct WithBigMember { + pub a: __BindgenUnionField<::std::os::raw::c_int>, + pub b: __BindgenUnionField, + pub bindgen_union_field: [u32; 33usize], +} +#[test] +fn bindgen_test_layout_WithBigMember() { + assert_eq!(::std::mem::size_of::() , 132usize , concat ! ( + "Size of: " , stringify ! ( WithBigMember ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( WithBigMember ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const WithBigMember ) ) . a as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( WithBigMember ) , "::" + , stringify ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const WithBigMember ) ) . b as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( WithBigMember ) , "::" + , stringify ! ( b ) )); +} +impl Clone for WithBigMember { + fn clone(&self) -> Self { *self } +} +impl Default for WithBigMember { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} diff --git a/tests/expectations/tests/union_with_nesting.rs b/tests/expectations/tests/union_with_nesting.rs index 59caccf4fd..82f22a2440 100644 --- a/tests/expectations/tests/union_with_nesting.rs +++ b/tests/expectations/tests/union_with_nesting.rs @@ -5,51 +5,22 @@ #[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } +#[derive(Copy)] +pub union foo { + pub a: ::std::os::raw::c_uint, + pub __bindgen_anon_1: foo__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct foo { - pub a: __BindgenUnionField<::std::os::raw::c_uint>, - pub __bindgen_anon_1: __BindgenUnionField, - pub bindgen_union_field: u32, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Copy)] pub struct foo__bindgen_ty_1 { pub __bindgen_anon_1: foo__bindgen_ty_1__bindgen_ty_1, pub __bindgen_anon_2: foo__bindgen_ty_1__bindgen_ty_2, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct foo__bindgen_ty_1__bindgen_ty_1 { - pub b1: __BindgenUnionField<::std::os::raw::c_ushort>, - pub b2: __BindgenUnionField<::std::os::raw::c_ushort>, - pub bindgen_union_field: u16, +#[derive(Copy)] +pub union foo__bindgen_ty_1__bindgen_ty_1 { + pub b1: ::std::os::raw::c_ushort, + pub b2: ::std::os::raw::c_ushort, } #[test] fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_1() { @@ -77,12 +48,14 @@ fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_1() { impl Clone for foo__bindgen_ty_1__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +impl Default for foo__bindgen_ty_1__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct foo__bindgen_ty_1__bindgen_ty_2 { - pub c1: __BindgenUnionField<::std::os::raw::c_ushort>, - pub c2: __BindgenUnionField<::std::os::raw::c_ushort>, - pub bindgen_union_field: u16, +#[derive(Copy)] +pub union foo__bindgen_ty_1__bindgen_ty_2 { + pub c1: ::std::os::raw::c_ushort, + pub c2: ::std::os::raw::c_ushort, } #[test] fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_2() { @@ -110,6 +83,9 @@ fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_2() { impl Clone for foo__bindgen_ty_1__bindgen_ty_2 { fn clone(&self) -> Self { *self } } +impl Default for foo__bindgen_ty_1__bindgen_ty_2 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 4usize , concat ! @@ -120,6 +96,9 @@ fn bindgen_test_layout_foo__bindgen_ty_1() { impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +impl Default for foo__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( @@ -135,3 +114,6 @@ fn bindgen_test_layout_foo() { impl Clone for foo { fn clone(&self) -> Self { *self } } +impl Default for foo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} diff --git a/tests/expectations/tests/union_with_nesting_1_0.rs b/tests/expectations/tests/union_with_nesting_1_0.rs new file mode 100644 index 0000000000..59caccf4fd --- /dev/null +++ b/tests/expectations/tests/union_with_nesting_1_0.rs @@ -0,0 +1,137 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[repr(C)] +pub struct __BindgenUnionField(::std::marker::PhantomData); +impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } +} +impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } +} +impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl ::std::marker::Copy for __BindgenUnionField { } +impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } +} +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) { } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct foo { + pub a: __BindgenUnionField<::std::os::raw::c_uint>, + pub __bindgen_anon_1: __BindgenUnionField, + pub bindgen_union_field: u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct foo__bindgen_ty_1 { + pub __bindgen_anon_1: foo__bindgen_ty_1__bindgen_ty_1, + pub __bindgen_anon_2: foo__bindgen_ty_1__bindgen_ty_2, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct foo__bindgen_ty_1__bindgen_ty_1 { + pub b1: __BindgenUnionField<::std::os::raw::c_ushort>, + pub b2: __BindgenUnionField<::std::os::raw::c_ushort>, + pub bindgen_union_field: u16, +} +#[test] +fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , + 2usize , concat ! ( + "Size of: " , stringify ! ( foo__bindgen_ty_1__bindgen_ty_1 ) + )); + assert_eq! (::std::mem::align_of::() , + 2usize , concat ! ( + "Alignment of " , stringify ! ( + foo__bindgen_ty_1__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_1 ) ) . b1 + as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + foo__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( b1 ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_1 ) ) . b2 + as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + foo__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( b2 ) + )); +} +impl Clone for foo__bindgen_ty_1__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct foo__bindgen_ty_1__bindgen_ty_2 { + pub c1: __BindgenUnionField<::std::os::raw::c_ushort>, + pub c2: __BindgenUnionField<::std::os::raw::c_ushort>, + pub bindgen_union_field: u16, +} +#[test] +fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_2() { + assert_eq!(::std::mem::size_of::() , + 2usize , concat ! ( + "Size of: " , stringify ! ( foo__bindgen_ty_1__bindgen_ty_2 ) + )); + assert_eq! (::std::mem::align_of::() , + 2usize , concat ! ( + "Alignment of " , stringify ! ( + foo__bindgen_ty_1__bindgen_ty_2 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . c1 + as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( c1 ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . c2 + as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( c2 ) + )); +} +impl Clone for foo__bindgen_ty_1__bindgen_ty_2 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! + ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() , 2usize , concat + ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); +} +impl Clone for foo__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( foo ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( a ) )); +} +impl Clone for foo { + fn clone(&self) -> Self { *self } +} diff --git a/tests/expectations/tests/use-core.rs b/tests/expectations/tests/use-core.rs index fd89783f8a..76f3c35bdb 100644 --- a/tests/expectations/tests/use-core.rs +++ b/tests/expectations/tests/use-core.rs @@ -5,33 +5,6 @@ extern crate core; -#[repr(C)] -pub struct __BindgenUnionField(::core::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::core::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::core::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::core::mem::transmute(self) } -} -impl ::core::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::core::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::core::marker::Copy for __BindgenUnionField { } -impl ::core::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::core::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } -} #[repr(C)] #[derive(Debug, Copy, Hash)] pub struct foo { @@ -68,11 +41,10 @@ impl Default for foo { fn default() -> Self { unsafe { ::core::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] -pub struct _bindgen_ty_1 { - pub bar: __BindgenUnionField<::std::os::raw::c_int>, - pub baz: __BindgenUnionField<::std::os::raw::c_long>, - pub bindgen_union_field: u64, +#[derive(Copy)] +pub union _bindgen_ty_1 { + pub bar: ::std::os::raw::c_int, + pub baz: ::std::os::raw::c_long, } #[test] fn bindgen_test_layout__bindgen_ty_1() { @@ -94,6 +66,9 @@ fn bindgen_test_layout__bindgen_ty_1() { impl Clone for _bindgen_ty_1 { fn clone(&self) -> Self { *self } } +impl Default for _bindgen_ty_1 { + fn default() -> Self { unsafe { ::core::mem::zeroed() } } +} extern "C" { #[link_name = "bazz"] pub static mut bazz: _bindgen_ty_1; diff --git a/tests/expectations/tests/use-core_1_0.rs b/tests/expectations/tests/use-core_1_0.rs new file mode 100644 index 0000000000..fd89783f8a --- /dev/null +++ b/tests/expectations/tests/use-core_1_0.rs @@ -0,0 +1,102 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + +extern crate core; + +#[repr(C)] +pub struct __BindgenUnionField(::core::marker::PhantomData); +impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { __BindgenUnionField(::core::marker::PhantomData) } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::core::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { ::core::mem::transmute(self) } +} +impl ::core::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } +} +impl ::core::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl ::core::marker::Copy for __BindgenUnionField { } +impl ::core::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + fmt.write_str("__BindgenUnionField") + } +} +impl ::core::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) { } +} +#[repr(C)] +#[derive(Debug, Copy, Hash)] +pub struct foo { + pub a: ::std::os::raw::c_int, + pub b: ::std::os::raw::c_int, + pub bar: *mut ::std::os::raw::c_void, +} +#[test] +fn bindgen_test_layout_foo() { + assert_eq!(::core::mem::size_of::() , 16usize , concat ! ( + "Size of: " , stringify ! ( foo ) )); + assert_eq! (::core::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . b as * const _ as usize } , + 4usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( b ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , + 8usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( bar ) )); +} +impl Clone for foo { + fn clone(&self) -> Self { *self } +} +impl Default for foo { + fn default() -> Self { unsafe { ::core::mem::zeroed() } } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Hash)] +pub struct _bindgen_ty_1 { + pub bar: __BindgenUnionField<::std::os::raw::c_int>, + pub baz: __BindgenUnionField<::std::os::raw::c_long>, + pub bindgen_union_field: u64, +} +#[test] +fn bindgen_test_layout__bindgen_ty_1() { + assert_eq!(::core::mem::size_of::<_bindgen_ty_1>() , 8usize , concat ! ( + "Size of: " , stringify ! ( _bindgen_ty_1 ) )); + assert_eq! (::core::mem::align_of::<_bindgen_ty_1>() , 8usize , concat ! ( + "Alignment of " , stringify ! ( _bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const _bindgen_ty_1 ) ) . bar as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( _bindgen_ty_1 ) , "::" + , stringify ! ( bar ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const _bindgen_ty_1 ) ) . baz as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( _bindgen_ty_1 ) , "::" + , stringify ! ( baz ) )); +} +impl Clone for _bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +extern "C" { + #[link_name = "bazz"] + pub static mut bazz: _bindgen_ty_1; +} +pub type fooFunction = + ::core::option::Option; diff --git a/tests/headers/16-byte-alignment.h b/tests/headers/16-byte-alignment.h index cca4d285ab..20cd04f5c7 100644 --- a/tests/headers/16-byte-alignment.h +++ b/tests/headers/16-byte-alignment.h @@ -28,7 +28,10 @@ struct rte_ipv6_tuple { }; }; +// TODO(tmfink) uncomment once test passes +#if 0 union rte_thash_tuple { struct rte_ipv4_tuple v4; struct rte_ipv6_tuple v6; } __attribute__((aligned(16))); +#endif diff --git a/tests/headers/16-byte-alignment_1_0.h b/tests/headers/16-byte-alignment_1_0.h new file mode 100644 index 0000000000..f0ec0e64b9 --- /dev/null +++ b/tests/headers/16-byte-alignment_1_0.h @@ -0,0 +1,34 @@ +// bindgen-flags: --rust-target 1.0 --with-derive-hash + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; + +struct rte_ipv4_tuple { + uint32_t src_addr; + uint32_t dst_addr; + union { + struct { + uint16_t dport; + uint16_t sport; + }; + uint32_t sctp_tag; + }; +}; + +struct rte_ipv6_tuple { + uint8_t src_addr[16]; + uint8_t dst_addr[16]; + union { + struct { + uint16_t dport; + uint16_t sport; + }; + uint32_t sctp_tag; + }; +}; + +union rte_thash_tuple { + struct rte_ipv4_tuple v4; + struct rte_ipv6_tuple v6; +} __attribute__((aligned(16))); diff --git a/tests/headers/anon_struct_in_union_1_0.h b/tests/headers/anon_struct_in_union_1_0.h new file mode 100644 index 0000000000..5e5023ba5d --- /dev/null +++ b/tests/headers/anon_struct_in_union_1_0.h @@ -0,0 +1,9 @@ +// bindgen-flags: --rust-target 1.0 --with-derive-hash + +struct s { + union { + struct inner { + int b; + } field; + } u; +}; diff --git a/tests/headers/anon_union.hpp b/tests/headers/anon_union.hpp index 26bb842f8f..250dcb1a39 100644 --- a/tests/headers/anon_union.hpp +++ b/tests/headers/anon_union.hpp @@ -1,4 +1,5 @@ // bindgen-flags: --with-derive-hash + template struct TErrorResult { enum UnionState { diff --git a/tests/headers/anon_union_1_0.hpp b/tests/headers/anon_union_1_0.hpp new file mode 100644 index 0000000000..33ab48ca9a --- /dev/null +++ b/tests/headers/anon_union_1_0.hpp @@ -0,0 +1,22 @@ +// bindgen-flags: --rust-target 1.0 --with-derive-hash + +template +struct TErrorResult { + enum UnionState { + HasMessage, + HasException, + }; + int mResult; + struct Message; + struct DOMExceptionInfo; + union { + Message* mMessage; + DOMExceptionInfo* mDOMExceptionInfo; + }; + + bool mMightHaveUnreported; + UnionState mUnionState; +}; + +struct ErrorResult : public TErrorResult { +}; diff --git a/tests/headers/class_1_0.hpp b/tests/headers/class_1_0.hpp new file mode 100644 index 0000000000..9f4795b679 --- /dev/null +++ b/tests/headers/class_1_0.hpp @@ -0,0 +1,58 @@ +// bindgen-flags: --rust-target 1.0 --with-derive-hash + +class C { + int a; + // More than rust limits (32) + char big_array[33]; +}; + +class C_with_zero_length_array { + int a; + // More than rust limits (32) + char big_array[33]; + char zero_length_array[0]; +}; + +class C_with_incomplete_array { + int a; + // More than rust limits (32) + char big_array[33]; + char incomplete_array[]; +}; + +class C_with_zero_length_array_and_incomplete_array { + int a; + // More than rust limits (32) + char big_array[33]; + char zero_length_array[0]; + char incomplete_array[]; +}; + +class WithDtor { + int b; + + ~WithDtor() {} +}; + +class IncompleteArrayNonCopiable { + void* whatever; + C incomplete_array[]; +}; + +union Union { + float d; + int i; +}; + +class WithUnion { + Union data; +}; + +class RealAbstractionWithTonsOfMethods { + void foo(); +public: + void bar() const; + void bar(); + void bar(int foo); + static void sta(); +}; diff --git a/tests/headers/class_with_inner_struct_1_0.hpp b/tests/headers/class_with_inner_struct_1_0.hpp new file mode 100644 index 0000000000..d5fe07238d --- /dev/null +++ b/tests/headers/class_with_inner_struct_1_0.hpp @@ -0,0 +1,44 @@ +// bindgen-flags: --rust-target 1.0 --with-derive-hash +// bindgen-flags: -- -std=c++11 + +class A { + unsigned c; + struct Segment { int begin, end; }; + union { + int f; + } named_union; + union { + int d; + }; +}; + +class B { + unsigned d; + struct Segment { int begin, end; }; +}; + + +enum class StepSyntax { + Keyword, // step-start and step-end + FunctionalWithoutKeyword, // steps(...) + FunctionalWithStartKeyword, // steps(..., start) + FunctionalWithEndKeyword, // steps(..., end) +}; + +class C { + unsigned d; + union { + struct { + float mX1; + float mY1; + float mX2; + float mY2; + } mFunc; + struct { + StepSyntax mStepSyntax; + unsigned int mSteps; + }; + }; + // To ensure it doesn't collide + struct Segment { int begin, end; }; +}; diff --git a/tests/headers/forward_declared_complex_types_1_0.hpp b/tests/headers/forward_declared_complex_types_1_0.hpp new file mode 100644 index 0000000000..ff6076fc43 --- /dev/null +++ b/tests/headers/forward_declared_complex_types_1_0.hpp @@ -0,0 +1,18 @@ +// bindgen-flags: --rust-target 1.0 + +struct Foo_empty {}; +struct Foo; + +struct Bar { + Foo *f; +}; + +void baz_struct(Foo* f); + +union Union; + +void baz_union(Union* u); + +class Quux; + +void baz_class(Quux* q); diff --git a/tests/headers/issue-493.hpp b/tests/headers/issue-493.hpp index ea39c83c8d..40105e2928 100644 --- a/tests/headers/issue-493.hpp +++ b/tests/headers/issue-493.hpp @@ -1,4 +1,5 @@ // bindgen-flags: --with-derive-hash + template class basic_string { diff --git a/tests/headers/issue-493_1_0.hpp b/tests/headers/issue-493_1_0.hpp new file mode 100644 index 0000000000..ed8c7df8bc --- /dev/null +++ b/tests/headers/issue-493_1_0.hpp @@ -0,0 +1,49 @@ +// bindgen-flags: --rust-target 1.0 --with-derive-hash + +template +class basic_string +{ +public: + typedef unsigned long long size_type; + typedef char value_type; + typedef value_type * pointer; + + struct __long + { + size_type __cap_; + size_type __size_; + pointer __data_; + }; + + enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ? + (sizeof(__long) - 1)/sizeof(value_type) : 2}; + + struct __short + { + union + { + unsigned char __size_; + value_type __lx; + }; + value_type __data_[__min_cap]; + }; + + union __ulx{__long __lx; __short __lxx;}; + + enum {__n_words = sizeof(__ulx) / sizeof(size_type)}; + + struct __raw + { + size_type __words[__n_words]; + }; + + struct __rep + { + union + { + __long __l; + __short __s; + __raw __r; + }; + }; +}; diff --git a/tests/headers/jsval_layout_opaque_1_0.hpp b/tests/headers/jsval_layout_opaque_1_0.hpp new file mode 100644 index 0000000000..edb84cb76c --- /dev/null +++ b/tests/headers/jsval_layout_opaque_1_0.hpp @@ -0,0 +1,425 @@ +// bindgen-flags: --rust-target 1.0 --with-derive-hash +// bindgen-flags: -- -std=c++11 + +/** + * These typedefs are hacky, but keep our tests consistent across 64-bit + * platforms, otherwise the id's change and our CI is unhappy. + */ +typedef unsigned char uint8_t; +typedef int int32_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; +typedef unsigned long long size_t; +typedef unsigned long long uintptr_t; + + +#define JS_PUNBOX64 +#define IS_LITTLE_ENDIAN + +/* + * Try to get jsvals 64-bit aligned. We could almost assert that all values are + * aligned, but MSVC and GCC occasionally break alignment. + */ +#if defined(__GNUC__) || defined(__xlc__) || defined(__xlC__) +# define JSVAL_ALIGNMENT __attribute__((aligned (8))) +#elif defined(_MSC_VER) + /* + * Structs can be aligned with MSVC, but not if they are used as parameters, + * so we just don't try to align. + */ +# define JSVAL_ALIGNMENT +#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) +# define JSVAL_ALIGNMENT +#elif defined(__HP_cc) || defined(__HP_aCC) +# define JSVAL_ALIGNMENT +#endif + +#if defined(JS_PUNBOX64) +# define JSVAL_TAG_SHIFT 47 +#endif + +/* + * We try to use enums so that printing a jsval_layout in the debugger shows + * nice symbolic type tags, however we can only do this when we can force the + * underlying type of the enum to be the desired size. + */ +#if !defined(__SUNPRO_CC) && !defined(__xlC__) + +#if defined(_MSC_VER) +# define JS_ENUM_HEADER(id, type) enum id : type +# define JS_ENUM_FOOTER(id) +#else +# define JS_ENUM_HEADER(id, type) enum id +# define JS_ENUM_FOOTER(id) __attribute__((packed)) +#endif + +/* Remember to propagate changes to the C defines below. */ +JS_ENUM_HEADER(JSValueType, uint8_t) +{ + JSVAL_TYPE_DOUBLE = 0x00, + JSVAL_TYPE_INT32 = 0x01, + JSVAL_TYPE_UNDEFINED = 0x02, + JSVAL_TYPE_BOOLEAN = 0x03, + JSVAL_TYPE_MAGIC = 0x04, + JSVAL_TYPE_STRING = 0x05, + JSVAL_TYPE_SYMBOL = 0x06, + JSVAL_TYPE_NULL = 0x07, + JSVAL_TYPE_OBJECT = 0x08, + + /* These never appear in a jsval; they are only provided as an out-of-band value. */ + JSVAL_TYPE_UNKNOWN = 0x20, + JSVAL_TYPE_MISSING = 0x21 +} JS_ENUM_FOOTER(JSValueType); + +static_assert(sizeof(JSValueType) == 1, + "compiler typed enum support is apparently buggy"); + +#if defined(JS_NUNBOX32) + +/* Remember to propagate changes to the C defines below. */ +JS_ENUM_HEADER(JSValueTag, uint32_t) +{ + JSVAL_TAG_CLEAR = 0xFFFFFF80, + JSVAL_TAG_INT32 = JSVAL_TAG_CLEAR | JSVAL_TYPE_INT32, + JSVAL_TAG_UNDEFINED = JSVAL_TAG_CLEAR | JSVAL_TYPE_UNDEFINED, + JSVAL_TAG_STRING = JSVAL_TAG_CLEAR | JSVAL_TYPE_STRING, + JSVAL_TAG_SYMBOL = JSVAL_TAG_CLEAR | JSVAL_TYPE_SYMBOL, + JSVAL_TAG_BOOLEAN = JSVAL_TAG_CLEAR | JSVAL_TYPE_BOOLEAN, + JSVAL_TAG_MAGIC = JSVAL_TAG_CLEAR | JSVAL_TYPE_MAGIC, + JSVAL_TAG_NULL = JSVAL_TAG_CLEAR | JSVAL_TYPE_NULL, + JSVAL_TAG_OBJECT = JSVAL_TAG_CLEAR | JSVAL_TYPE_OBJECT +} JS_ENUM_FOOTER(JSValueTag); + +static_assert(sizeof(JSValueTag) == sizeof(uint32_t), + "compiler typed enum support is apparently buggy"); + +#elif defined(JS_PUNBOX64) + +/* Remember to propagate changes to the C defines below. */ +JS_ENUM_HEADER(JSValueTag, uint32_t) +{ + JSVAL_TAG_MAX_DOUBLE = 0x1FFF0, + JSVAL_TAG_INT32 = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_INT32, + JSVAL_TAG_UNDEFINED = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_UNDEFINED, + JSVAL_TAG_STRING = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_STRING, + JSVAL_TAG_SYMBOL = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_SYMBOL, + JSVAL_TAG_BOOLEAN = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_BOOLEAN, + JSVAL_TAG_MAGIC = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_MAGIC, + JSVAL_TAG_NULL = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_NULL, + JSVAL_TAG_OBJECT = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_OBJECT +} JS_ENUM_FOOTER(JSValueTag); + +static_assert(sizeof(JSValueTag) == sizeof(uint32_t), + "compiler typed enum support is apparently buggy"); + +JS_ENUM_HEADER(JSValueShiftedTag, uint64_t) +{ + JSVAL_SHIFTED_TAG_MAX_DOUBLE = ((((uint64_t)JSVAL_TAG_MAX_DOUBLE) << JSVAL_TAG_SHIFT) | 0xFFFFFFFF), + JSVAL_SHIFTED_TAG_INT32 = (((uint64_t)JSVAL_TAG_INT32) << JSVAL_TAG_SHIFT), + JSVAL_SHIFTED_TAG_UNDEFINED = (((uint64_t)JSVAL_TAG_UNDEFINED) << JSVAL_TAG_SHIFT), + JSVAL_SHIFTED_TAG_STRING = (((uint64_t)JSVAL_TAG_STRING) << JSVAL_TAG_SHIFT), + JSVAL_SHIFTED_TAG_SYMBOL = (((uint64_t)JSVAL_TAG_SYMBOL) << JSVAL_TAG_SHIFT), + JSVAL_SHIFTED_TAG_BOOLEAN = (((uint64_t)JSVAL_TAG_BOOLEAN) << JSVAL_TAG_SHIFT), + JSVAL_SHIFTED_TAG_MAGIC = (((uint64_t)JSVAL_TAG_MAGIC) << JSVAL_TAG_SHIFT), + JSVAL_SHIFTED_TAG_NULL = (((uint64_t)JSVAL_TAG_NULL) << JSVAL_TAG_SHIFT), + JSVAL_SHIFTED_TAG_OBJECT = (((uint64_t)JSVAL_TAG_OBJECT) << JSVAL_TAG_SHIFT) +} JS_ENUM_FOOTER(JSValueShiftedTag); + +static_assert(sizeof(JSValueShiftedTag) == sizeof(uint64_t), + "compiler typed enum support is apparently buggy"); + +#endif + +/* + * All our supported compilers implement C++11 |enum Foo : T| syntax, so don't + * expose these macros. (This macro exists *only* because gcc bug 51242 + * makes bit-fields of + * typed enums trigger a warning that can't be turned off. Don't expose it + * beyond this file!) + */ +#undef JS_ENUM_HEADER +#undef JS_ENUM_FOOTER + +#else /* !defined(__SUNPRO_CC) && !defined(__xlC__) */ + +typedef uint8_t JSValueType; +#define JSVAL_TYPE_DOUBLE ((uint8_t)0x00) +#define JSVAL_TYPE_INT32 ((uint8_t)0x01) +#define JSVAL_TYPE_UNDEFINED ((uint8_t)0x02) +#define JSVAL_TYPE_BOOLEAN ((uint8_t)0x03) +#define JSVAL_TYPE_MAGIC ((uint8_t)0x04) +#define JSVAL_TYPE_STRING ((uint8_t)0x05) +#define JSVAL_TYPE_SYMBOL ((uint8_t)0x06) +#define JSVAL_TYPE_NULL ((uint8_t)0x07) +#define JSVAL_TYPE_OBJECT ((uint8_t)0x08) +#define JSVAL_TYPE_UNKNOWN ((uint8_t)0x20) + +#if defined(JS_NUNBOX32) + +typedef uint32_t JSValueTag; +#define JSVAL_TAG_CLEAR ((uint32_t)(0xFFFFFF80)) +#define JSVAL_TAG_INT32 ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_INT32)) +#define JSVAL_TAG_UNDEFINED ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_UNDEFINED)) +#define JSVAL_TAG_STRING ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_STRING)) +#define JSVAL_TAG_SYMBOL ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_SYMBOL)) +#define JSVAL_TAG_BOOLEAN ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_BOOLEAN)) +#define JSVAL_TAG_MAGIC ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_MAGIC)) +#define JSVAL_TAG_NULL ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_NULL)) +#define JSVAL_TAG_OBJECT ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_OBJECT)) + +#elif defined(JS_PUNBOX64) + +typedef uint32_t JSValueTag; +#define JSVAL_TAG_MAX_DOUBLE ((uint32_t)(0x1FFF0)) +#define JSVAL_TAG_INT32 (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_INT32) +#define JSVAL_TAG_UNDEFINED (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_UNDEFINED) +#define JSVAL_TAG_STRING (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_STRING) +#define JSVAL_TAG_SYMBOL (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_SYMBOL) +#define JSVAL_TAG_BOOLEAN (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_BOOLEAN) +#define JSVAL_TAG_MAGIC (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_MAGIC) +#define JSVAL_TAG_NULL (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_NULL) +#define JSVAL_TAG_OBJECT (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_OBJECT) + +typedef uint64_t JSValueShiftedTag; +#define JSVAL_SHIFTED_TAG_MAX_DOUBLE ((((uint64_t)JSVAL_TAG_MAX_DOUBLE) << JSVAL_TAG_SHIFT) | 0xFFFFFFFF) +#define JSVAL_SHIFTED_TAG_INT32 (((uint64_t)JSVAL_TAG_INT32) << JSVAL_TAG_SHIFT) +#define JSVAL_SHIFTED_TAG_UNDEFINED (((uint64_t)JSVAL_TAG_UNDEFINED) << JSVAL_TAG_SHIFT) +#define JSVAL_SHIFTED_TAG_STRING (((uint64_t)JSVAL_TAG_STRING) << JSVAL_TAG_SHIFT) +#define JSVAL_SHIFTED_TAG_SYMBOL (((uint64_t)JSVAL_TAG_SYMBOL) << JSVAL_TAG_SHIFT) +#define JSVAL_SHIFTED_TAG_BOOLEAN (((uint64_t)JSVAL_TAG_BOOLEAN) << JSVAL_TAG_SHIFT) +#define JSVAL_SHIFTED_TAG_MAGIC (((uint64_t)JSVAL_TAG_MAGIC) << JSVAL_TAG_SHIFT) +#define JSVAL_SHIFTED_TAG_NULL (((uint64_t)JSVAL_TAG_NULL) << JSVAL_TAG_SHIFT) +#define JSVAL_SHIFTED_TAG_OBJECT (((uint64_t)JSVAL_TAG_OBJECT) << JSVAL_TAG_SHIFT) + +#endif /* JS_PUNBOX64 */ +#endif /* !defined(__SUNPRO_CC) && !defined(__xlC__) */ + +#if defined(JS_NUNBOX32) + +#define JSVAL_TYPE_TO_TAG(type) ((JSValueTag)(JSVAL_TAG_CLEAR | (type))) + +#define JSVAL_LOWER_INCL_TAG_OF_OBJ_OR_NULL_SET JSVAL_TAG_NULL +#define JSVAL_UPPER_EXCL_TAG_OF_PRIMITIVE_SET JSVAL_TAG_OBJECT +#define JSVAL_UPPER_INCL_TAG_OF_NUMBER_SET JSVAL_TAG_INT32 +#define JSVAL_LOWER_INCL_TAG_OF_GCTHING_SET JSVAL_TAG_STRING + +#elif defined(JS_PUNBOX64) + +#define JSVAL_PAYLOAD_MASK 0x00007FFFFFFFFFFFLL +#define JSVAL_TAG_MASK 0xFFFF800000000000LL +#define JSVAL_TYPE_TO_TAG(type) ((JSValueTag)(JSVAL_TAG_MAX_DOUBLE | (type))) +#define JSVAL_TYPE_TO_SHIFTED_TAG(type) (((uint64_t)JSVAL_TYPE_TO_TAG(type)) << JSVAL_TAG_SHIFT) + +#define JSVAL_LOWER_INCL_TAG_OF_OBJ_OR_NULL_SET JSVAL_TAG_NULL +#define JSVAL_UPPER_EXCL_TAG_OF_PRIMITIVE_SET JSVAL_TAG_OBJECT +#define JSVAL_UPPER_INCL_TAG_OF_NUMBER_SET JSVAL_TAG_INT32 +#define JSVAL_LOWER_INCL_TAG_OF_GCTHING_SET JSVAL_TAG_STRING + +#define JSVAL_LOWER_INCL_SHIFTED_TAG_OF_OBJ_OR_NULL_SET JSVAL_SHIFTED_TAG_NULL +#define JSVAL_UPPER_EXCL_SHIFTED_TAG_OF_PRIMITIVE_SET JSVAL_SHIFTED_TAG_OBJECT +#define JSVAL_UPPER_EXCL_SHIFTED_TAG_OF_NUMBER_SET JSVAL_SHIFTED_TAG_UNDEFINED +#define JSVAL_LOWER_INCL_SHIFTED_TAG_OF_GCTHING_SET JSVAL_SHIFTED_TAG_STRING + +#endif /* JS_PUNBOX64 */ + +typedef enum JSWhyMagic +{ + /** a hole in a native object's elements */ + JS_ELEMENTS_HOLE, + + /** there is not a pending iterator value */ + JS_NO_ITER_VALUE, + + /** exception value thrown when closing a generator */ + JS_GENERATOR_CLOSING, + + /** compiler sentinel value */ + JS_NO_CONSTANT, + + /** used in debug builds to catch tracing errors */ + JS_THIS_POISON, + + /** used in debug builds to catch tracing errors */ + JS_ARG_POISON, + + /** an empty subnode in the AST serializer */ + JS_SERIALIZE_NO_NODE, + + /** lazy arguments value on the stack */ + JS_LAZY_ARGUMENTS, + + /** optimized-away 'arguments' value */ + JS_OPTIMIZED_ARGUMENTS, + + /** magic value passed to natives to indicate construction */ + JS_IS_CONSTRUCTING, + + /** arguments.callee has been overwritten */ + JS_OVERWRITTEN_CALLEE, + + /** value of static block object slot */ + JS_BLOCK_NEEDS_CLONE, + + /** see class js::HashableValue */ + JS_HASH_KEY_EMPTY, + + /** error while running Ion code */ + JS_ION_ERROR, + + /** missing recover instruction result */ + JS_ION_BAILOUT, + + /** optimized out slot */ + JS_OPTIMIZED_OUT, + + /** uninitialized lexical bindings that produce ReferenceError on touch. */ + JS_UNINITIALIZED_LEXICAL, + + /** for local use */ + JS_GENERIC_MAGIC, + + JS_WHY_MAGIC_COUNT +} JSWhyMagic; + +#if defined(IS_LITTLE_ENDIAN) +# if defined(JS_NUNBOX32) +typedef union jsval_layout +{ + uint64_t asBits; + struct { + union { + int32_t i32; + uint32_t u32; + uint32_t boo; // Don't use |bool| -- it must be four bytes. + JSString* str; + JS::Symbol* sym; + JSObject* obj; + js::gc::Cell* cell; + void* ptr; + JSWhyMagic why; + size_t word; + uintptr_t uintptr; + } payload; + JSValueTag tag; + } s; + double asDouble; + void* asPtr; +} JSVAL_ALIGNMENT jsval_layout; +# elif defined(JS_PUNBOX64) +typedef union jsval_layout +{ + uint64_t asBits; +#if !defined(_WIN64) + /* MSVC does not pack these correctly :-( */ + struct { + uint64_t payload47 : 47; + JSValueTag tag : 17; + } debugView; +#endif + struct { + union { + int32_t i32; + uint32_t u32; + JSWhyMagic why; + } payload; + } s; + double asDouble; + void* asPtr; + size_t asWord; + uintptr_t asUIntPtr; +} JSVAL_ALIGNMENT jsval_layout; +# endif /* JS_PUNBOX64 */ +#else /* defined(IS_LITTLE_ENDIAN) */ +# if defined(JS_NUNBOX32) +typedef union jsval_layout +{ + uint64_t asBits; + struct { + JSValueTag tag; + union { + int32_t i32; + uint32_t u32; + uint32_t boo; // Don't use |bool| -- it must be four bytes. + JSString* str; + JS::Symbol* sym; + JSObject* obj; + js::gc::Cell* cell; + void* ptr; + JSWhyMagic why; + size_t word; + uintptr_t uintptr; + } payload; + } s; + double asDouble; + void* asPtr; +} JSVAL_ALIGNMENT jsval_layout; +# elif defined(JS_PUNBOX64) +typedef union jsval_layout +{ + uint64_t asBits; + struct { + JSValueTag tag : 17; + uint64_t payload47 : 47; + } debugView; + struct { + uint32_t padding; + union { + int32_t i32; + uint32_t u32; + JSWhyMagic why; + } payload; + } s; + double asDouble; + void* asPtr; + size_t asWord; + uintptr_t asUIntPtr; +} JSVAL_ALIGNMENT jsval_layout; +# endif /* JS_PUNBOX64 */ +#endif /* defined(IS_LITTLE_ENDIAN) */ + +/* + * For codesize purposes on some platforms, it's important that the + * compiler know that JS::Values constructed from constant values can be + * folded to constant bit patterns at compile time, rather than + * constructed at runtime. Doing this requires a fair amount of C++11 + * features, which are not supported on all of our compilers. Set up + * some defines and helper macros in an attempt to confine the ugliness + * here, rather than scattering it all about the file. The important + * features are: + * + * - constexpr; + * - defaulted functions; + * - C99-style designated initializers. + */ +#if defined(__clang__) +# if __has_feature(cxx_constexpr) && __has_feature(cxx_defaulted_functions) +# define JS_VALUE_IS_CONSTEXPR +# endif +#elif defined(__GNUC__) +/* + * We need 4.5 for defaulted functions, 4.6 for constexpr, 4.7 because 4.6 + * doesn't understand |(X) { .field = ... }| syntax, and 4.7.3 because + * versions prior to that have bugs in the C++ front-end that cause crashes. + */ +# if MOZ_GCC_VERSION_AT_LEAST(4, 7, 3) +# define JS_VALUE_IS_CONSTEXPR +# endif +#endif + +#if defined(JS_VALUE_IS_CONSTEXPR) +# define JS_RETURN_LAYOUT_FROM_BITS(BITS) \ + return (jsval_layout) { .asBits = (BITS) } +# define JS_VALUE_CONSTEXPR MOZ_CONSTEXPR +# define JS_VALUE_CONSTEXPR_VAR MOZ_CONSTEXPR_VAR +#else +# define JS_RETURN_LAYOUT_FROM_BITS(BITS) \ + jsval_layout l; \ + l.asBits = (BITS); \ + return l; +# define JS_VALUE_CONSTEXPR +# define JS_VALUE_CONSTEXPR_VAR const +#endif + +struct Value { + jsval_layout data; +}; diff --git a/tests/headers/layout_eth_conf.h b/tests/headers/layout_eth_conf.h index 7333f52801..ae3edad428 100644 --- a/tests/headers/layout_eth_conf.h +++ b/tests/headers/layout_eth_conf.h @@ -1,4 +1,5 @@ // bindgen-flags: --with-derive-hash + typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; diff --git a/tests/headers/layout_eth_conf_1_0.h b/tests/headers/layout_eth_conf_1_0.h new file mode 100644 index 0000000000..ed9c68baa3 --- /dev/null +++ b/tests/headers/layout_eth_conf_1_0.h @@ -0,0 +1,429 @@ +// bindgen-flags: --rust-target 1.0 --with-derive-hash + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; + +/** + * Simple flags are used for rte_eth_conf.rxmode.mq_mode. + */ +#define ETH_MQ_RX_RSS_FLAG 0x1 +#define ETH_MQ_RX_DCB_FLAG 0x2 +#define ETH_MQ_RX_VMDQ_FLAG 0x4 + +/* Definitions used for VMDQ and DCB functionality */ +#define ETH_VMDQ_MAX_VLAN_FILTERS 64 /**< Maximum nb. of VMDQ vlan filters. */ +#define ETH_DCB_NUM_USER_PRIORITIES 8 /**< Maximum nb. of DCB priorities. */ +#define ETH_VMDQ_DCB_NUM_QUEUES 128 /**< Maximum nb. of VMDQ DCB queues. */ +#define ETH_DCB_NUM_QUEUES 128 /**< Maximum nb. of DCB queues. */ + +/** + * A set of values to identify what method is to be used to route + * packets to multiple queues. + */ +enum rte_eth_rx_mq_mode { + /** None of DCB,RSS or VMDQ mode */ + ETH_MQ_RX_NONE = 0, + + /** For RX side, only RSS is on */ + ETH_MQ_RX_RSS = ETH_MQ_RX_RSS_FLAG, + /** For RX side,only DCB is on. */ + ETH_MQ_RX_DCB = ETH_MQ_RX_DCB_FLAG, + /** Both DCB and RSS enable */ + ETH_MQ_RX_DCB_RSS = ETH_MQ_RX_RSS_FLAG | ETH_MQ_RX_DCB_FLAG, + + /** Only VMDQ, no RSS nor DCB */ + ETH_MQ_RX_VMDQ_ONLY = ETH_MQ_RX_VMDQ_FLAG, + /** RSS mode with VMDQ */ + ETH_MQ_RX_VMDQ_RSS = ETH_MQ_RX_RSS_FLAG | ETH_MQ_RX_VMDQ_FLAG, + /** Use VMDQ+DCB to route traffic to queues */ + ETH_MQ_RX_VMDQ_DCB = ETH_MQ_RX_VMDQ_FLAG | ETH_MQ_RX_DCB_FLAG, + /** Enable both VMDQ and DCB in VMDq */ + ETH_MQ_RX_VMDQ_DCB_RSS = ETH_MQ_RX_RSS_FLAG | ETH_MQ_RX_DCB_FLAG | + ETH_MQ_RX_VMDQ_FLAG, +}; + +/** + * A structure used to configure the RX features of an Ethernet port. + */ +struct rte_eth_rxmode { + /** The multi-queue packet distribution mode to be used, e.g. RSS. */ + enum rte_eth_rx_mq_mode mq_mode; + uint32_t max_rx_pkt_len; /**< Only used if jumbo_frame enabled. */ + uint16_t split_hdr_size; /**< hdr buf size (header_split enabled).*/ + __extension__ + uint16_t header_split : 1, /**< Header Split enable. */ + hw_ip_checksum : 1, /**< IP/UDP/TCP checksum offload enable. */ + hw_vlan_filter : 1, /**< VLAN filter enable. */ + hw_vlan_strip : 1, /**< VLAN strip enable. */ + hw_vlan_extend : 1, /**< Extended VLAN enable. */ + jumbo_frame : 1, /**< Jumbo Frame Receipt enable. */ + hw_strip_crc : 1, /**< Enable CRC stripping by hardware. */ + enable_scatter : 1, /**< Enable scatter packets rx handler */ + enable_lro : 1; /**< Enable LRO */ +}; + +/** + * A set of values to identify what method is to be used to transmit + * packets using multi-TCs. + */ +enum rte_eth_tx_mq_mode { + ETH_MQ_TX_NONE = 0, /**< It is in neither DCB nor VT mode. */ + ETH_MQ_TX_DCB, /**< For TX side,only DCB is on. */ + ETH_MQ_TX_VMDQ_DCB, /**< For TX side,both DCB and VT is on. */ + ETH_MQ_TX_VMDQ_ONLY, /**< Only VT on, no DCB */ +}; + +/** + * A structure used to configure the TX features of an Ethernet port. + */ +struct rte_eth_txmode { + enum rte_eth_tx_mq_mode mq_mode; /**< TX multi-queues mode. */ + + /* For i40e specifically */ + uint16_t pvid; + __extension__ + uint8_t hw_vlan_reject_tagged : 1, + /**< If set, reject sending out tagged pkts */ + hw_vlan_reject_untagged : 1, + /**< If set, reject sending out untagged pkts */ + hw_vlan_insert_pvid : 1; + /**< If set, enable port based VLAN insertion */ +}; + +/** + * A structure used to configure the Receive Side Scaling (RSS) feature + * of an Ethernet port. + * If not NULL, the *rss_key* pointer of the *rss_conf* structure points + * to an array holding the RSS key to use for hashing specific header + * fields of received packets. The length of this array should be indicated + * by *rss_key_len* below. Otherwise, a default random hash key is used by + * the device driver. + * + * The *rss_key_len* field of the *rss_conf* structure indicates the length + * in bytes of the array pointed by *rss_key*. To be compatible, this length + * will be checked in i40e only. Others assume 40 bytes to be used as before. + * + * The *rss_hf* field of the *rss_conf* structure indicates the different + * types of IPv4/IPv6 packets to which the RSS hashing must be applied. + * Supplying an *rss_hf* equal to zero disables the RSS feature. + */ +struct rte_eth_rss_conf { + uint8_t *rss_key; /**< If not NULL, 40-byte hash key. */ + uint8_t rss_key_len; /**< hash key length in bytes. */ + uint64_t rss_hf; /**< Hash functions to apply - see below. */ +}; + +/** + * This enum indicates the possible number of traffic classes + * in DCB configratioins + */ +enum rte_eth_nb_tcs { + ETH_4_TCS = 4, /**< 4 TCs with DCB. */ + ETH_8_TCS = 8 /**< 8 TCs with DCB. */ +}; + +/** + * This enum indicates the possible number of queue pools + * in VMDQ configurations. + */ +enum rte_eth_nb_pools { + ETH_8_POOLS = 8, /**< 8 VMDq pools. */ + ETH_16_POOLS = 16, /**< 16 VMDq pools. */ + ETH_32_POOLS = 32, /**< 32 VMDq pools. */ + ETH_64_POOLS = 64 /**< 64 VMDq pools. */ +}; + +/** + * A structure used to configure the VMDQ+DCB feature + * of an Ethernet port. + * + * Using this feature, packets are routed to a pool of queues, based + * on the vlan id in the vlan tag, and then to a specific queue within + * that pool, using the user priority vlan tag field. + * + * A default pool may be used, if desired, to route all traffic which + * does not match the vlan filter rules. + */ +struct rte_eth_vmdq_dcb_conf { + enum rte_eth_nb_pools nb_queue_pools; /**< With DCB, 16 or 32 pools */ + uint8_t enable_default_pool; /**< If non-zero, use a default pool */ + uint8_t default_pool; /**< The default pool, if applicable */ + uint8_t nb_pool_maps; /**< We can have up to 64 filters/mappings */ + struct { + uint16_t vlan_id; /**< The vlan id of the received frame */ + uint64_t pools; /**< Bitmask of pools for packet rx */ + } pool_map[ETH_VMDQ_MAX_VLAN_FILTERS]; /**< VMDq vlan pool maps. */ + uint8_t dcb_tc[ETH_DCB_NUM_USER_PRIORITIES]; + /**< Selects a queue in a pool */ +}; + +/* This structure may be extended in future. */ +struct rte_eth_dcb_rx_conf { + enum rte_eth_nb_tcs nb_tcs; /**< Possible DCB TCs, 4 or 8 TCs */ + /** Traffic class each UP mapped to. */ + uint8_t dcb_tc[ETH_DCB_NUM_USER_PRIORITIES]; +}; + +struct rte_eth_vmdq_dcb_tx_conf { + enum rte_eth_nb_pools nb_queue_pools; /**< With DCB, 16 or 32 pools. */ + /** Traffic class each UP mapped to. */ + uint8_t dcb_tc[ETH_DCB_NUM_USER_PRIORITIES]; +}; + +struct rte_eth_dcb_tx_conf { + enum rte_eth_nb_tcs nb_tcs; /**< Possible DCB TCs, 4 or 8 TCs. */ + /** Traffic class each UP mapped to. */ + uint8_t dcb_tc[ETH_DCB_NUM_USER_PRIORITIES]; +}; + +struct rte_eth_vmdq_tx_conf { + enum rte_eth_nb_pools nb_queue_pools; /**< VMDq mode, 64 pools. */ +}; + +struct rte_eth_vmdq_rx_conf { + enum rte_eth_nb_pools nb_queue_pools; /**< VMDq only mode, 8 or 64 pools */ + uint8_t enable_default_pool; /**< If non-zero, use a default pool */ + uint8_t default_pool; /**< The default pool, if applicable */ + uint8_t enable_loop_back; /**< Enable VT loop back */ + uint8_t nb_pool_maps; /**< We can have up to 64 filters/mappings */ + uint32_t rx_mode; /**< Flags from ETH_VMDQ_ACCEPT_* */ + struct { + uint16_t vlan_id; /**< The vlan id of the received frame */ + uint64_t pools; /**< Bitmask of pools for packet rx */ + } pool_map[ETH_VMDQ_MAX_VLAN_FILTERS]; /**< VMDq vlan pool maps. */ +}; + +/** + * Flow Director setting modes: none, signature or perfect. + */ +enum rte_fdir_mode { + RTE_FDIR_MODE_NONE = 0, /**< Disable FDIR support. */ + RTE_FDIR_MODE_SIGNATURE, /**< Enable FDIR signature filter mode. */ + RTE_FDIR_MODE_PERFECT, /**< Enable FDIR perfect filter mode. */ + RTE_FDIR_MODE_PERFECT_MAC_VLAN, /**< Enable FDIR filter mode - MAC VLAN. */ + RTE_FDIR_MODE_PERFECT_TUNNEL, /**< Enable FDIR filter mode - tunnel. */ +}; + +/** + * Memory space that can be configured to store Flow Director filters + * in the board memory. + */ +enum rte_fdir_pballoc_type { + RTE_FDIR_PBALLOC_64K = 0, /**< 64k. */ + RTE_FDIR_PBALLOC_128K, /**< 128k. */ + RTE_FDIR_PBALLOC_256K, /**< 256k. */ +}; + +/** + * Select report mode of FDIR hash information in RX descriptors. + */ +enum rte_fdir_status_mode { + RTE_FDIR_NO_REPORT_STATUS = 0, /**< Never report FDIR hash. */ + RTE_FDIR_REPORT_STATUS, /**< Only report FDIR hash for matching pkts. */ + RTE_FDIR_REPORT_STATUS_ALWAYS, /**< Always report FDIR hash. */ +}; + +/** + * A structure used to define the input for IPV4 flow + */ +struct rte_eth_ipv4_flow { + uint32_t src_ip; /**< IPv4 source address in big endian. */ + uint32_t dst_ip; /**< IPv4 destination address in big endian. */ + uint8_t tos; /**< Type of service to match. */ + uint8_t ttl; /**< Time to live to match. */ + uint8_t proto; /**< Protocol, next header in big endian. */ +}; + +/** + * A structure used to define the input for IPV6 flow + */ +struct rte_eth_ipv6_flow { + uint32_t src_ip[4]; /**< IPv6 source address in big endian. */ + uint32_t dst_ip[4]; /**< IPv6 destination address in big endian. */ + uint8_t tc; /**< Traffic class to match. */ + uint8_t proto; /**< Protocol, next header to match. */ + uint8_t hop_limits; /**< Hop limits to match. */ +}; + +/** + * A structure used to configure FDIR masks that are used by the device + * to match the various fields of RX packet headers. + */ +struct rte_eth_fdir_masks { + uint16_t vlan_tci_mask; /**< Bit mask for vlan_tci in big endian */ + /** Bit mask for ipv4 flow in big endian. */ + struct rte_eth_ipv4_flow ipv4_mask; + /** Bit maks for ipv6 flow in big endian. */ + struct rte_eth_ipv6_flow ipv6_mask; + /** Bit mask for L4 source port in big endian. */ + uint16_t src_port_mask; + /** Bit mask for L4 destination port in big endian. */ + uint16_t dst_port_mask; + /** 6 bit mask for proper 6 bytes of Mac address, bit 0 matches the + first byte on the wire */ + uint8_t mac_addr_byte_mask; + /** Bit mask for tunnel ID in big endian. */ + uint32_t tunnel_id_mask; + uint8_t tunnel_type_mask; /**< 1 - Match tunnel type, + 0 - Ignore tunnel type. */ +}; + +/** + * Payload type + */ +enum rte_eth_payload_type { + RTE_ETH_PAYLOAD_UNKNOWN = 0, + RTE_ETH_RAW_PAYLOAD, + RTE_ETH_L2_PAYLOAD, + RTE_ETH_L3_PAYLOAD, + RTE_ETH_L4_PAYLOAD, + RTE_ETH_PAYLOAD_MAX = 8, +}; + +#define RTE_ETH_FDIR_MAX_FLEXLEN 16 /**< Max length of flexbytes. */ +#define RTE_ETH_INSET_SIZE_MAX 128 /**< Max length of input set. */ + +/** + * A structure used to select bytes extracted from the protocol layers to + * flexible payload for filter + */ +struct rte_eth_flex_payload_cfg { + enum rte_eth_payload_type type; /**< Payload type */ + uint16_t src_offset[RTE_ETH_FDIR_MAX_FLEXLEN]; + /**< Offset in bytes from the beginning of packet's payload + src_offset[i] indicates the flexbyte i's offset in original + packet payload. This value should be less than + flex_payload_limit in struct rte_eth_fdir_info.*/ +}; + +/** + * A structure used to define FDIR masks for flexible payload + * for each flow type + */ +struct rte_eth_fdir_flex_mask { + uint16_t flow_type; + uint8_t mask[RTE_ETH_FDIR_MAX_FLEXLEN]; + /**< Mask for the whole flexible payload */ +}; + + +/* + * A packet can be identified by hardware as different flow types. Different + * NIC hardwares may support different flow types. + * Basically, the NIC hardware identifies the flow type as deep protocol as + * possible, and exclusively. For example, if a packet is identified as + * 'RTE_ETH_FLOW_NONFRAG_IPV4_TCP', it will not be any of other flow types, + * though it is an actual IPV4 packet. + * Note that the flow types are used to define RSS offload types in + * rte_ethdev.h. + */ +#define RTE_ETH_FLOW_UNKNOWN 0 +#define RTE_ETH_FLOW_RAW 1 +#define RTE_ETH_FLOW_IPV4 2 +#define RTE_ETH_FLOW_FRAG_IPV4 3 +#define RTE_ETH_FLOW_NONFRAG_IPV4_TCP 4 +#define RTE_ETH_FLOW_NONFRAG_IPV4_UDP 5 +#define RTE_ETH_FLOW_NONFRAG_IPV4_SCTP 6 +#define RTE_ETH_FLOW_NONFRAG_IPV4_OTHER 7 +#define RTE_ETH_FLOW_IPV6 8 +#define RTE_ETH_FLOW_FRAG_IPV6 9 +#define RTE_ETH_FLOW_NONFRAG_IPV6_TCP 10 +#define RTE_ETH_FLOW_NONFRAG_IPV6_UDP 11 +#define RTE_ETH_FLOW_NONFRAG_IPV6_SCTP 12 +#define RTE_ETH_FLOW_NONFRAG_IPV6_OTHER 13 +#define RTE_ETH_FLOW_L2_PAYLOAD 14 +#define RTE_ETH_FLOW_IPV6_EX 15 +#define RTE_ETH_FLOW_IPV6_TCP_EX 16 +#define RTE_ETH_FLOW_IPV6_UDP_EX 17 +#define RTE_ETH_FLOW_PORT 18 + /**< Consider device port number as a flow differentiator */ +#define RTE_ETH_FLOW_VXLAN 19 /**< VXLAN protocol based flow */ +#define RTE_ETH_FLOW_GENEVE 20 /**< GENEVE protocol based flow */ +#define RTE_ETH_FLOW_NVGRE 21 /**< NVGRE protocol based flow */ +#define RTE_ETH_FLOW_MAX 22 + +/** + * A structure used to define all flexible payload related setting + * include flex payload and flex mask + */ +struct rte_eth_fdir_flex_conf { + uint16_t nb_payloads; /**< The number of following payload cfg */ + uint16_t nb_flexmasks; /**< The number of following mask */ + struct rte_eth_flex_payload_cfg flex_set[RTE_ETH_PAYLOAD_MAX]; + /**< Flex payload configuration for each payload type */ + struct rte_eth_fdir_flex_mask flex_mask[RTE_ETH_FLOW_MAX]; + /**< Flex mask configuration for each flow type */ +}; + +/** + * A structure used to configure the Flow Director (FDIR) feature + * of an Ethernet port. + * + * If mode is RTE_FDIR_DISABLE, the pballoc value is ignored. + */ +struct rte_fdir_conf { + enum rte_fdir_mode mode; /**< Flow Director mode. */ + enum rte_fdir_pballoc_type pballoc; /**< Space for FDIR filters. */ + enum rte_fdir_status_mode status; /**< How to report FDIR hash. */ + /** RX queue of packets matching a "drop" filter in perfect mode. */ + uint8_t drop_queue; + struct rte_eth_fdir_masks mask; + struct rte_eth_fdir_flex_conf flex_conf; + /**< Flex payload configuration. */ +}; + +/** + * A structure used to enable/disable specific device interrupts. + */ +struct rte_intr_conf { + /** enable/disable lsc interrupt. 0 (default) - disable, 1 enable */ + uint16_t lsc; + /** enable/disable rxq interrupt. 0 (default) - disable, 1 enable */ + uint16_t rxq; +}; + +/** + * A structure used to configure an Ethernet port. + * Depending upon the RX multi-queue mode, extra advanced + * configuration settings may be needed. + */ +struct rte_eth_conf { + uint32_t link_speeds; /**< bitmap of ETH_LINK_SPEED_XXX of speeds to be + used. ETH_LINK_SPEED_FIXED disables link + autonegotiation, and a unique speed shall be + set. Otherwise, the bitmap defines the set of + speeds to be advertised. If the special value + ETH_LINK_SPEED_AUTONEG (0) is used, all speeds + supported are advertised. */ + struct rte_eth_rxmode rxmode; /**< Port RX configuration. */ + struct rte_eth_txmode txmode; /**< Port TX configuration. */ + uint32_t lpbk_mode; /**< Loopback operation mode. By default the value + is 0, meaning the loopback mode is disabled. + Read the datasheet of given ethernet controller + for details. The possible values of this field + are defined in implementation of each driver. */ + struct { + struct rte_eth_rss_conf rss_conf; /**< Port RSS configuration */ + struct rte_eth_vmdq_dcb_conf vmdq_dcb_conf; + /**< Port vmdq+dcb configuration. */ + struct rte_eth_dcb_rx_conf dcb_rx_conf; + /**< Port dcb RX configuration. */ + struct rte_eth_vmdq_rx_conf vmdq_rx_conf; + /**< Port vmdq RX configuration. */ + } rx_adv_conf; /**< Port RX filtering configuration (union). */ + union { + struct rte_eth_vmdq_dcb_tx_conf vmdq_dcb_tx_conf; + /**< Port vmdq+dcb TX configuration. */ + struct rte_eth_dcb_tx_conf dcb_tx_conf; + /**< Port dcb TX configuration. */ + struct rte_eth_vmdq_tx_conf vmdq_tx_conf; + /**< Port vmdq TX configuration. */ + } tx_adv_conf; /**< Port TX DCB configuration (union). */ + /** Currently,Priority Flow Control(PFC) are supported,if DCB with PFC + is needed,and the variable must be set ETH_DCB_PFC_SUPPORT. */ + uint32_t dcb_capability_en; + struct rte_fdir_conf fdir_conf; /**< FDIR configuration. */ + struct rte_intr_conf intr_conf; /**< Interrupt mode configuration. */ +}; diff --git a/tests/headers/layout_mbuf_1_0.h b/tests/headers/layout_mbuf_1_0.h new file mode 100644 index 0000000000..18ca60c119 --- /dev/null +++ b/tests/headers/layout_mbuf_1_0.h @@ -0,0 +1,189 @@ +// bindgen-flags: --rust-target 1.0 --with-derive-hash + + +#define RTE_CACHE_LINE_MIN_SIZE 64 /**< Minimum Cache line size. */ + +#define RTE_CACHE_LINE_SIZE 64 + +typedef char int8_t; +typedef short int16_t; +typedef int int32_t; +typedef long long int64_t; + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; + +typedef uint64_t phys_addr_t; + +/** + * Force alignment + */ +#define __rte_aligned(a) __attribute__((__aligned__(a))) + +/** + * Force alignment to cache line. + */ +#define __rte_cache_aligned __rte_aligned(RTE_CACHE_LINE_SIZE) + +/** + * Force minimum cache line alignment. + */ +#define __rte_cache_min_aligned __rte_aligned(RTE_CACHE_LINE_MIN_SIZE) + +/* define a set of marker types that can be used to refer to set points in the + * mbuf */ +__extension__ +typedef void *MARKER[0]; /**< generic marker for a point in a structure */ +__extension__ +typedef uint8_t MARKER8[0]; /**< generic marker with 1B alignment */ +__extension__ +typedef uint64_t MARKER64[0]; /**< marker that allows us to overwrite 8 bytes + * with a single assignment */ + +/** C extension macro for environments lacking C11 features. */ +#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L +#define RTE_STD_C11 __extension__ +#else +#define RTE_STD_C11 +#endif + +/** + * The atomic counter structure. + */ +typedef struct { + volatile int16_t cnt; /**< An internal counter value. */ +} rte_atomic16_t; + +/** + * The generic rte_mbuf, containing a packet mbuf. + */ +struct rte_mbuf { + MARKER cacheline0; + + void *buf_addr; /**< Virtual address of segment buffer. */ + phys_addr_t buf_physaddr; /**< Physical address of segment buffer. */ + + uint16_t buf_len; /**< Length of segment buffer. */ + + /* next 6 bytes are initialised on RX descriptor rearm */ + MARKER8 rearm_data; + uint16_t data_off; + + /** + * 16-bit Reference counter. + * It should only be accessed using the following functions: + * rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and + * rte_mbuf_refcnt_set(). The functionality of these functions (atomic, + * or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC + * config option. + */ + RTE_STD_C11 + union { + rte_atomic16_t refcnt_atomic; /**< Atomically accessed refcnt */ + uint16_t refcnt; /**< Non-atomically accessed refcnt */ + }; + uint8_t nb_segs; /**< Number of segments. */ + uint8_t port; /**< Input port. */ + + uint64_t ol_flags; /**< Offload features. */ + + /* remaining bytes are set on RX when pulling packet from descriptor */ + MARKER rx_descriptor_fields1; + + /* + * The packet type, which is the combination of outer/inner L2, L3, L4 + * and tunnel types. The packet_type is about data really present in the + * mbuf. Example: if vlan stripping is enabled, a received vlan packet + * would have RTE_PTYPE_L2_ETHER and not RTE_PTYPE_L2_VLAN because the + * vlan is stripped from the data. + */ + RTE_STD_C11 + union { + uint32_t packet_type; /**< L2/L3/L4 and tunnel information. */ + struct { + uint32_t l2_type:4; /**< (Outer) L2 type. */ + uint32_t l3_type:4; /**< (Outer) L3 type. */ + uint32_t l4_type:4; /**< (Outer) L4 type. */ + uint32_t tun_type:4; /**< Tunnel type. */ + uint32_t inner_l2_type:4; /**< Inner L2 type. */ + uint32_t inner_l3_type:4; /**< Inner L3 type. */ + uint32_t inner_l4_type:4; /**< Inner L4 type. */ + }; + }; + + uint32_t pkt_len; /**< Total pkt len: sum of all segments. */ + uint16_t data_len; /**< Amount of data in segment buffer. */ + /** VLAN TCI (CPU order), valid if PKT_RX_VLAN_STRIPPED is set. */ + uint16_t vlan_tci; + + union { + uint32_t rss; /**< RSS hash result if RSS enabled */ + struct { + RTE_STD_C11 + union { + struct { + uint16_t hash; + uint16_t id; + }; + uint32_t lo; + /**< Second 4 flexible bytes */ + }; + uint32_t hi; + /**< First 4 flexible bytes or FD ID, dependent on + PKT_RX_FDIR_* flag in ol_flags. */ + } fdir; /**< Filter identifier if FDIR enabled */ + struct { + uint32_t lo; + uint32_t hi; + } sched; /**< Hierarchical scheduler */ + uint32_t usr; /**< User defined tags. See rte_distributor_process() */ + } hash; /**< hash information */ + + uint32_t seqn; /**< Sequence number. See also rte_reorder_insert() */ + + /** Outer VLAN TCI (CPU order), valid if PKT_RX_QINQ_STRIPPED is set. */ + uint16_t vlan_tci_outer; + + /* second cache line - fields only used in slow path or on TX */ + MARKER cacheline1 __rte_cache_min_aligned; + + RTE_STD_C11 + union { + void *userdata; /**< Can be used for external metadata */ + uint64_t udata64; /**< Allow 8-byte userdata on 32-bit */ + }; + + struct rte_mempool *pool; /**< Pool from which mbuf was allocated. */ + struct rte_mbuf *next; /**< Next segment of scattered packet. */ + + /* fields to support TX offloads */ + RTE_STD_C11 + union { + uint64_t tx_offload; /**< combined for easy fetch */ + __extension__ + struct { + uint64_t l2_len:7; + /**< L2 (MAC) Header Length for non-tunneling pkt. + * Outer_L4_len + ... + Inner_L2_len for tunneling pkt. + */ + uint64_t l3_len:9; /**< L3 (IP) Header Length. */ + uint64_t l4_len:8; /**< L4 (TCP/UDP) Header Length. */ + uint64_t tso_segsz:16; /**< TCP TSO segment size */ + + /* fields for TX offloading of tunnels */ + uint64_t outer_l3_len:9; /**< Outer L3 (IP) Hdr Length. */ + uint64_t outer_l2_len:7; /**< Outer L2 (MAC) Hdr Length. */ + + /* uint64_t unused:8; */ + }; + }; + + /** Size of the application private data. In case of an indirect + * mbuf, it stores the direct mbuf private data size. */ + uint16_t priv_size; + + /** Timesync flags for use with IEEE1588. */ + uint16_t timesync; +} __rte_cache_aligned; diff --git a/tests/headers/struct_with_anon_union.h b/tests/headers/struct_with_anon_union.h index 45ddb3c401..dd183b7a91 100644 --- a/tests/headers/struct_with_anon_union.h +++ b/tests/headers/struct_with_anon_union.h @@ -1,5 +1,5 @@ // bindgen-flags: --with-derive-hash -// + struct foo { union { unsigned int a; diff --git a/tests/headers/struct_with_anon_union_1_0.h b/tests/headers/struct_with_anon_union_1_0.h new file mode 100644 index 0000000000..65ec5951be --- /dev/null +++ b/tests/headers/struct_with_anon_union_1_0.h @@ -0,0 +1,8 @@ +// bindgen-flags: --rust-target 1.0 --with-derive-hash + +struct foo { + union { + unsigned int a; + unsigned short b; + } bar; +}; diff --git a/tests/headers/struct_with_anon_unnamed_union.h b/tests/headers/struct_with_anon_unnamed_union.h index 949547c1ca..b44475289c 100644 --- a/tests/headers/struct_with_anon_unnamed_union.h +++ b/tests/headers/struct_with_anon_unnamed_union.h @@ -1,4 +1,5 @@ // bindgen-flags: --with-derive-hash + struct foo { union { unsigned int a; diff --git a/tests/headers/struct_with_anon_unnamed_union_1_0.h b/tests/headers/struct_with_anon_unnamed_union_1_0.h new file mode 100644 index 0000000000..6fa955f1aa --- /dev/null +++ b/tests/headers/struct_with_anon_unnamed_union_1_0.h @@ -0,0 +1,8 @@ +// bindgen-flags: --rust-target 1.0 --with-derive-hash + +struct foo { + union { + unsigned int a; + unsigned short b; + }; +}; diff --git a/tests/headers/struct_with_nesting.h b/tests/headers/struct_with_nesting.h index 30f40bcec4..93231e3346 100644 --- a/tests/headers/struct_with_nesting.h +++ b/tests/headers/struct_with_nesting.h @@ -1,5 +1,5 @@ // bindgen-flags: --with-derive-hash -// + struct foo { unsigned int a; union { diff --git a/tests/headers/struct_with_nesting_1_0.h b/tests/headers/struct_with_nesting_1_0.h new file mode 100644 index 0000000000..94717a9e32 --- /dev/null +++ b/tests/headers/struct_with_nesting_1_0.h @@ -0,0 +1,19 @@ +// bindgen-flags: --rust-target 1.0 --with-derive-hash + +struct foo { + unsigned int a; + union { + unsigned int b; + struct { + unsigned short c1; + unsigned short c2; + }; + + struct { + unsigned char d1; + unsigned char d2; + unsigned char d3; + unsigned char d4; + }; + }; +}; diff --git a/tests/headers/typeref.hpp b/tests/headers/typeref.hpp index c417bdb65b..ff1d788ea5 100644 --- a/tests/headers/typeref.hpp +++ b/tests/headers/typeref.hpp @@ -1,4 +1,5 @@ // bindgen-flags: --with-derive-hash + struct nsFoo; namespace mozilla { diff --git a/tests/headers/typeref_1_0.hpp b/tests/headers/typeref_1_0.hpp new file mode 100644 index 0000000000..183cf7a1b9 --- /dev/null +++ b/tests/headers/typeref_1_0.hpp @@ -0,0 +1,30 @@ +// bindgen-flags: --rust-target 1.0 --with-derive-hash + +struct nsFoo; + +namespace mozilla { + +struct FragmentOrURL { bool mIsLocalRef; }; +struct Position { }; + +} // namespace mozilla + +class Bar { + nsFoo* mFoo; +}; + +namespace mozilla { + +template +struct StyleShapeSource { + union { + Position* mPosition; + FragmentOrURL* mFragmentOrURL; + }; +}; + +} // namespace mozilla + +struct nsFoo { + mozilla::StyleShapeSource mBar; +}; diff --git a/tests/headers/union-in-ns_1_0.hpp b/tests/headers/union-in-ns_1_0.hpp new file mode 100644 index 0000000000..f3ae221057 --- /dev/null +++ b/tests/headers/union-in-ns_1_0.hpp @@ -0,0 +1,5 @@ +// bindgen-flags: --rust-target 1.0 --enable-cxx-namespaces + +union bar { + int baz; +}; diff --git a/tests/headers/union_dtor_1_0.hpp b/tests/headers/union_dtor_1_0.hpp new file mode 100644 index 0000000000..01f7636671 --- /dev/null +++ b/tests/headers/union_dtor_1_0.hpp @@ -0,0 +1,7 @@ +// bindgen-flags: --rust-target 1.0 + +union UnionWithDtor { + ~UnionWithDtor(); + int mFoo; + void* mBar; +}; diff --git a/tests/headers/union_fields.hpp b/tests/headers/union_fields.hpp index cc8fcbe45f..dd15d741c7 100644 --- a/tests/headers/union_fields.hpp +++ b/tests/headers/union_fields.hpp @@ -1,5 +1,5 @@ // bindgen-flags: --with-derive-hash -// + typedef union { int mInt; float mFloat; diff --git a/tests/headers/union_fields_1_0.hpp b/tests/headers/union_fields_1_0.hpp new file mode 100644 index 0000000000..6f20900fe4 --- /dev/null +++ b/tests/headers/union_fields_1_0.hpp @@ -0,0 +1,7 @@ +// bindgen-flags: --rust-target 1.0 --with-derive-hash + +typedef union { + int mInt; + float mFloat; + void* mPointer; +} nsStyleUnion; diff --git a/tests/headers/union_template.hpp b/tests/headers/union_template.hpp index f330f6b28c..c505cb7256 100644 --- a/tests/headers/union_template.hpp +++ b/tests/headers/union_template.hpp @@ -1,5 +1,5 @@ // bindgen-flags: --with-derive-hash -// + template struct NastyStruct { bool mIsSome; diff --git a/tests/headers/union_template_1_0.hpp b/tests/headers/union_template_1_0.hpp new file mode 100644 index 0000000000..22e46bfa96 --- /dev/null +++ b/tests/headers/union_template_1_0.hpp @@ -0,0 +1,21 @@ +// bindgen-flags: --rust-target 1.0 --with-derive-hash + +template +struct NastyStruct { + bool mIsSome; + union { + void* mFoo; + unsigned long mDummy; + } mStorage; + + union { + short wat; + int* wut; + }; +}; + +template +union Whatever { + void* mTPtr; + int mInt; +}; diff --git a/tests/headers/union_with_anon_struct.h b/tests/headers/union_with_anon_struct.h index 48adae8bd6..8f15eb494f 100644 --- a/tests/headers/union_with_anon_struct.h +++ b/tests/headers/union_with_anon_struct.h @@ -1,5 +1,5 @@ // bindgen-flags: --with-derive-hash -// + union foo { struct { unsigned int a; diff --git a/tests/headers/union_with_anon_struct_1_0.h b/tests/headers/union_with_anon_struct_1_0.h new file mode 100644 index 0000000000..8c77734e71 --- /dev/null +++ b/tests/headers/union_with_anon_struct_1_0.h @@ -0,0 +1,8 @@ +// bindgen-flags: --rust-target 1.0 --with-derive-hash + +union foo { + struct { + unsigned int a; + unsigned int b; + } bar; +}; diff --git a/tests/headers/union_with_anon_struct_bitfield.h b/tests/headers/union_with_anon_struct_bitfield.h index 027a99eb9f..d2ceac0daa 100644 --- a/tests/headers/union_with_anon_struct_bitfield.h +++ b/tests/headers/union_with_anon_struct_bitfield.h @@ -1,5 +1,5 @@ // bindgen-flags: --with-derive-hash -// + union foo { int a; struct { diff --git a/tests/headers/union_with_anon_struct_bitfield_1_0.h b/tests/headers/union_with_anon_struct_bitfield_1_0.h new file mode 100644 index 0000000000..f73591ec7b --- /dev/null +++ b/tests/headers/union_with_anon_struct_bitfield_1_0.h @@ -0,0 +1,9 @@ +// bindgen-flags: --rust-target 1.0 --with-derive-hash + +union foo { + int a; + struct { + int b : 7; + int c : 25; + }; +}; diff --git a/tests/headers/union_with_anon_union.h b/tests/headers/union_with_anon_union.h index b2b6fc1280..730e17bb7b 100644 --- a/tests/headers/union_with_anon_union.h +++ b/tests/headers/union_with_anon_union.h @@ -1,5 +1,5 @@ // bindgen-flags: --with-derive-hash -// + union foo { union { unsigned int a; diff --git a/tests/headers/union_with_anon_union_1_0.h b/tests/headers/union_with_anon_union_1_0.h new file mode 100644 index 0000000000..cd6654d134 --- /dev/null +++ b/tests/headers/union_with_anon_union_1_0.h @@ -0,0 +1,8 @@ +// bindgen-flags: --rust-target 1.0 --with-derive-hash + +union foo { + union { + unsigned int a; + unsigned short b; + } bar; +}; diff --git a/tests/headers/union_with_anon_unnamed_struct.h b/tests/headers/union_with_anon_unnamed_struct.h index 70ae15fedf..0d00c688be 100644 --- a/tests/headers/union_with_anon_unnamed_struct.h +++ b/tests/headers/union_with_anon_unnamed_struct.h @@ -1,5 +1,5 @@ // bindgen-flags: --with-derive-hash -// + union pixel { unsigned int rgba; struct { diff --git a/tests/headers/union_with_anon_unnamed_struct_1_0.h b/tests/headers/union_with_anon_unnamed_struct_1_0.h new file mode 100644 index 0000000000..be649c3f78 --- /dev/null +++ b/tests/headers/union_with_anon_unnamed_struct_1_0.h @@ -0,0 +1,11 @@ +// bindgen-flags: --rust-target 1.0 --with-derive-hash + +union pixel { + unsigned int rgba; + struct { + unsigned char r; + unsigned char g; + unsigned char b; + unsigned char a; + }; +}; diff --git a/tests/headers/union_with_anon_unnamed_union.h b/tests/headers/union_with_anon_unnamed_union.h index 1044360973..163d31579a 100644 --- a/tests/headers/union_with_anon_unnamed_union.h +++ b/tests/headers/union_with_anon_unnamed_union.h @@ -1,5 +1,5 @@ // bindgen-flags: --with-derive-hash -// + union foo { unsigned int a; union { diff --git a/tests/headers/union_with_anon_unnamed_union_1_0.h b/tests/headers/union_with_anon_unnamed_union_1_0.h new file mode 100644 index 0000000000..1d0421c945 --- /dev/null +++ b/tests/headers/union_with_anon_unnamed_union_1_0.h @@ -0,0 +1,9 @@ +// bindgen-flags: --rust-target 1.0 --with-derive-hash + +union foo { + unsigned int a; + union { + unsigned short b; + unsigned char c; + }; +}; diff --git a/tests/headers/union_with_big_member.h b/tests/headers/union_with_big_member.h index abc0062e28..24d012da4a 100644 --- a/tests/headers/union_with_big_member.h +++ b/tests/headers/union_with_big_member.h @@ -1,5 +1,5 @@ // bindgen-flags: --with-derive-hash -// + union WithBigArray { int a; int b[33]; diff --git a/tests/headers/union_with_big_member_1_0.h b/tests/headers/union_with_big_member_1_0.h new file mode 100644 index 0000000000..9f2dfd28c2 --- /dev/null +++ b/tests/headers/union_with_big_member_1_0.h @@ -0,0 +1,16 @@ +// bindgen-flags: --rust-target 1.0 --with-derive-hash + +union WithBigArray { + int a; + int b[33]; +}; + +union WithBigArray2 { + int a; + char b[33]; +}; + +union WithBigMember { + int a; + union WithBigArray b; +}; diff --git a/tests/headers/union_with_nesting.h b/tests/headers/union_with_nesting.h index e40f521249..f3135b4799 100644 --- a/tests/headers/union_with_nesting.h +++ b/tests/headers/union_with_nesting.h @@ -1,5 +1,5 @@ // bindgen-flags: --with-derive-hash -// + union foo { unsigned int a; struct { diff --git a/tests/headers/union_with_nesting_1_0.h b/tests/headers/union_with_nesting_1_0.h new file mode 100644 index 0000000000..bfd596355d --- /dev/null +++ b/tests/headers/union_with_nesting_1_0.h @@ -0,0 +1,16 @@ +// bindgen-flags: --rust-target 1.0 --with-derive-hash + +union foo { + unsigned int a; + struct { + union { + unsigned short b1; + unsigned short b2; + }; + + union { + unsigned short c1; + unsigned short c2; + }; + }; +}; diff --git a/tests/headers/use-core_1_0.h b/tests/headers/use-core_1_0.h new file mode 100644 index 0000000000..fa3a96485b --- /dev/null +++ b/tests/headers/use-core_1_0.h @@ -0,0 +1,13 @@ +// bindgen-flags: --rust-target 1.0 --use-core --raw-line "extern crate core;" --with-derive-hash + +struct foo { + int a, b; + void* bar; +}; + +union { + int bar; + long baz; +} bazz; + +typedef void (*fooFunction)(int bar);