diff --git a/src/clang.rs b/src/clang.rs index 4a46b694e3..ffe9d5d04d 100644 --- a/src/clang.rs +++ b/src/clang.rs @@ -499,6 +499,17 @@ impl Cursor { unsafe { clang_CXXField_isMutable(self.x) != 0 } } + /// Get the offset of the field represented by the Cursor. + pub fn offset_of_field(&self) -> Result { + let offset = unsafe { clang_Cursor_getOffsetOfField(self.x) }; + + if offset < 0 { + Err(LayoutError::from(offset as i32)) + } else { + Ok(offset as usize) + } + } + /// Is this cursor's referent a member function that is declared `static`? pub fn method_is_static(&self) -> bool { unsafe { clang_CXXMethod_isStatic(self.x) != 0 } diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 3b0882afcb..f4da014ef8 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -1,6 +1,8 @@ mod helpers; +mod struct_layout; use self::helpers::{BlobTyBuilder, attributes}; +use self::struct_layout::StructLayoutTracker; use aster; use ir::annotations::FieldAccessorKind; @@ -21,6 +23,7 @@ use ir::var::Var; use std::borrow::Cow; use std::cell::Cell; +use std::cmp; use std::collections::{HashSet, VecDeque}; use std::collections::hash_map::{Entry, HashMap}; use std::fmt::Write; @@ -723,9 +726,9 @@ impl<'a> Bitfield<'a> { fn codegen_fields(self, ctx: &BindgenContext, fields: &mut Vec, - methods: &mut Vec) { + methods: &mut Vec) + -> Layout { use aster::struct_field::StructFieldBuilder; - use std::cmp; let mut total_width = self.fields .iter() .fold(0u32, |acc, f| acc + f.bitfield().unwrap()); @@ -736,10 +739,9 @@ impl<'a> Bitfield<'a> { debug_assert_eq!(total_width % 8, 0); let total_width_in_bytes = total_width as usize / 8; - let bitfield_type = - BlobTyBuilder::new(Layout::new(total_width_in_bytes, - total_width_in_bytes)) - .build(); + let bitfield_layout = Layout::new(total_width_in_bytes, + total_width_in_bytes); + let bitfield_type = BlobTyBuilder::new(bitfield_layout).build(); let field_name = format!("_bitfield_{}", self.index); let field_ident = ctx.ext_cx().ident_of(&field_name); let field = StructFieldBuilder::named(&field_name) @@ -805,6 +807,8 @@ impl<'a> Bitfield<'a> { methods.extend(items.into_iter()); offset += width; } + + bitfield_layout } } @@ -940,6 +944,7 @@ impl CodeGenerator for CompInfo { // Also, we need to generate the vtable in such a way it "inherits" from // the parent too. let mut fields = vec![]; + let mut struct_layout = StructLayoutTracker::new(ctx, self); if self.needs_explicit_vtable(ctx) { let vtable = Vtable::new(item.id(), self.methods(), self.base_members()); @@ -951,6 +956,8 @@ impl CodeGenerator for CompInfo { .pub_() .build_ty(vtable_type); + struct_layout.saw_vtable(); + fields.push(vtable_field); } @@ -985,6 +992,8 @@ impl CodeGenerator for CompInfo { format!("_base_{}", i) }; + struct_layout.saw_base(base_ty); + let field = StructFieldBuilder::named(field_name) .pub_() .build_ty(inner); @@ -1039,8 +1048,12 @@ impl CodeGenerator for CompInfo { let bitfield_fields = mem::replace(&mut current_bitfield_fields, vec![]); bitfield_count += 1; - Bitfield::new(bitfield_count, bitfield_fields) + let bitfield_layout = Bitfield::new(bitfield_count, + bitfield_fields) .codegen_fields(ctx, &mut fields, &mut methods); + + struct_layout.saw_bitfield(bitfield_layout); + current_bitfield_width = None; current_bitfield_layout = None; } @@ -1100,6 +1113,11 @@ impl CodeGenerator for CompInfo { } }; + if let Some(padding_field) = + struct_layout.pad_field(&field_name, field_ty, field.offset()) { + fields.push(padding_field); + } + let is_private = field.annotations() .private_fields() .unwrap_or(fields_should_be_private); @@ -1192,8 +1210,11 @@ impl CodeGenerator for CompInfo { let bitfield_fields = mem::replace(&mut current_bitfield_fields, vec![]); bitfield_count += 1; - Bitfield::new(bitfield_count, bitfield_fields) + let bitfield_layout = Bitfield::new(bitfield_count, + bitfield_fields) .codegen_fields(ctx, &mut fields, &mut methods); + + struct_layout.saw_bitfield(bitfield_layout); } debug_assert!(current_bitfield_fields.is_empty()); @@ -1203,6 +1224,9 @@ impl CodeGenerator for CompInfo { let field = StructFieldBuilder::named("bindgen_union_field") .pub_() .build_ty(ty); + + struct_layout.saw_union(layout); + fields.push(field); } @@ -1227,6 +1251,16 @@ impl CodeGenerator for CompInfo { warn!("Opaque type without layout! Expect dragons!"); } } + } else if !is_union && !self.is_unsized(ctx) { + if let Some(padding_field) = + layout.and_then(|layout| struct_layout.pad_struct(layout)) { + fields.push(padding_field); + } + + if let Some(align_field) = + layout.and_then(|layout| struct_layout.align_struct(layout)) { + fields.push(align_field); + } } // C requires every struct to be addressable, so what C compilers do is @@ -1296,7 +1330,7 @@ impl CodeGenerator for CompInfo { canonical_name); } - if applicable_template_args.is_empty() && !self.found_unknown_attr() { + if applicable_template_args.is_empty() { for var in self.inner_vars() { ctx.resolve_item(*var) .codegen(ctx, result, whitelisted_items, &()); @@ -1313,11 +1347,57 @@ impl CodeGenerator for CompInfo { ::$prefix::mem::align_of::<$ident>()); let size = layout.size; let align = layout.align; + + let check_struct_align = if align > mem::size_of::<*mut ()>() { + // FIXME when [RFC 1358](https://github.com/rust-lang/rust/issues/33626) ready + None + } else { + quote_item!(ctx.ext_cx(), + assert_eq!($align_of_expr, $align); + ) + }; + + // FIXME when [issue #465](https://github.com/servo/rust-bindgen/issues/465) ready + let too_many_base_vtables = self.base_members() + .iter() + .filter(|base| ctx.resolve_type(base.ty).has_vtable(ctx)) + .count() > + 1; + + let should_skip_field_offset_checks = item.is_opaque(ctx) || + too_many_base_vtables; + + let check_field_offset = if should_skip_field_offset_checks { + None + } else { + let type_name = ctx.rust_ident(&canonical_name); + + let asserts = self.fields() + .iter() + .filter(|field| field.bitfield().is_none()) + .flat_map(|field| { + field.name().and_then(|name| { + field.offset().and_then(|offset| { + let field_offset = offset / 8; + let field_name = ctx.rust_ident(name); + + quote_item!(ctx.ext_cx(), + assert_eq!(unsafe { &(*(0 as *const $type_name)).$field_name as *const _ as usize }, $field_offset); + ) + }) + }) + }).collect::>>(); + + Some(asserts) + }; + let item = quote_item!(ctx.ext_cx(), #[test] fn $fn_name() { assert_eq!($size_of_expr, $size); - assert_eq!($align_of_expr, $align); + + $check_struct_align + $check_field_offset }) .unwrap(); result.push(item); @@ -2278,22 +2358,20 @@ impl CodeGenerator for ObjCInterface { // Collect the actual used argument names let arg_names: Vec<_> = fn_args.iter() - .map(|ref arg| { - match arg.pat.node { - ast::PatKind::Ident(_, ref spanning, _) => { - spanning.node.name.as_str().to_string() - } - _ => { - panic!("odd argument!"); - } + .map(|ref arg| match arg.pat.node { + ast::PatKind::Ident(_, ref spanning, _) => { + spanning.node.name.as_str().to_string() + } + _ => { + panic!("odd argument!"); } }) .collect(); let methods_and_args = ctx.rust_ident(&method.format_method_call(&arg_names)); - let body = - quote_stmt!(ctx.ext_cx(), msg_send![self, $methods_and_args]) + let body = quote_stmt!(ctx.ext_cx(), + msg_send![self, $methods_and_args]) .unwrap(); let block = ast::Block { stmts: vec![body], @@ -2729,5 +2807,4 @@ mod utils { } }).collect::>() } - } diff --git a/src/codegen/struct_layout.rs b/src/codegen/struct_layout.rs new file mode 100644 index 0000000000..3006a31ab3 --- /dev/null +++ b/src/codegen/struct_layout.rs @@ -0,0 +1,193 @@ +//! Helpers for code generation that need struct layout + +use super::helpers::BlobTyBuilder; + +use aster::struct_field::StructFieldBuilder; + +use ir::comp::CompInfo; +use ir::context::BindgenContext; +use ir::layout::Layout; +use ir::ty::Type; +use std::cmp; +use std::mem; + +use syntax::ast; + +/// Trace the layout of struct. +pub struct StructLayoutTracker<'a, 'ctx: 'a> { + ctx: &'a BindgenContext<'ctx>, + comp: &'a CompInfo, + latest_offset: usize, + padding_count: usize, + latest_field_layout: Option, + max_field_align: usize, +} + +impl<'a, 'ctx> StructLayoutTracker<'a, 'ctx> { + pub fn new(ctx: &'a BindgenContext<'ctx>, comp: &'a CompInfo) -> Self { + StructLayoutTracker { + ctx: ctx, + comp: comp, + latest_offset: 0, + padding_count: 0, + latest_field_layout: None, + max_field_align: 0, + } + } + + pub fn saw_vtable(&mut self) { + let ptr_size = mem::size_of::<*mut ()>(); + self.latest_offset += ptr_size; + self.latest_field_layout = Some(Layout::new(ptr_size, ptr_size)); + self.max_field_align = ptr_size; + } + + pub fn saw_base(&mut self, base_ty: &Type) { + self.align_to_latest_field(); + + if let Some(layout) = base_ty.layout(self.ctx) { + self.latest_offset += self.padding_bytes(layout) + layout.size; + self.latest_field_layout = Some(layout); + self.max_field_align = cmp::max(self.max_field_align, layout.align); + } + } + + pub fn saw_bitfield(&mut self, layout: Layout) { + self.align_to_latest_field(); + + self.latest_offset += self.padding_bytes(layout) + layout.size; + self.latest_field_layout = Some(layout); + self.max_field_align = cmp::max(self.max_field_align, layout.align); + } + + pub fn saw_union(&mut self, layout: Layout) { + self.align_to_latest_field(); + + self.latest_offset += self.padding_bytes(layout) + layout.size; + self.latest_field_layout = Some(layout); + self.max_field_align = cmp::max(self.max_field_align, layout.align); + } + + pub fn pad_field(&mut self, + field_name: &str, + field_ty: &Type, + field_offset: Option) + -> Option { + field_ty.layout(self.ctx).and_then(|field_layout| { + self.align_to_latest_field(); + + let padding_layout = if self.comp.packed() { + None + } else { + let calculated_layout = field_ty.as_comp() + .and_then(|comp| comp.calc_layout(self.ctx)) + .unwrap_or(field_layout); + + let align = cmp::min(calculated_layout.align, mem::size_of::<*mut ()>()); + + let (padding_bytes, need_padding) = match field_offset { + Some(offset) if offset / 8 > self.latest_offset => { + (offset / 8 - self.latest_offset, true) + } + _ => { + (self.padding_bytes(field_layout), (self.latest_offset % field_layout.align) != 0) + } + }; + + self.latest_offset += padding_bytes; + + debug!("align field {} to {}/{} with {} padding bytes {:?}, calculated {:?}", + field_name, + self.latest_offset, + field_offset.unwrap_or(0) / 8, + padding_bytes, + field_layout, + calculated_layout); + + if need_padding && + (padding_bytes > calculated_layout.align || + field_layout.align > mem::size_of::<*mut ()>()) { + Some(Layout::new(padding_bytes, align)) + } else { + None + } + }; + + self.latest_offset += field_ty.calc_size(self.ctx).unwrap_or(field_layout.size); + + self.latest_field_layout = Some(field_layout); + self.max_field_align = cmp::max(self.max_field_align, field_layout.align); + + padding_layout.map(|layout| self.padding_field(layout)) + }) + } + + pub fn pad_struct(&mut self, layout: Layout) -> Option { + if layout.size < self.latest_offset { + warn!("calculate struct layout incorrect, too more {} bytes", + self.latest_offset - layout.size); + + None + } else { + let padding_bytes = layout.size - self.latest_offset; + let struct_align = cmp::min(layout.align, + mem::size_of::<*mut ()>()); + + if padding_bytes > struct_align || + (layout.align > mem::size_of::<*mut ()>() && padding_bytes > 0) { + let padding_align = if self.comp.packed() { + 1 + } else { + cmp::min(1 << padding_bytes.trailing_zeros(), + mem::size_of::<*mut ()>()) + }; + + Some(self.padding_field(Layout::new(padding_bytes, padding_align))) + } else { + None + } + } + } + + pub fn align_struct(&self, layout: Layout) -> Option { + if self.max_field_align < layout.align && + layout.align <= mem::size_of::<*mut ()>() { + let ty = BlobTyBuilder::new(Layout::new(0, layout.align)).build(); + + Some(StructFieldBuilder::named("__bindgen_align") + .pub_() + .build_ty(ty)) + } else { + None + } + } + + fn padding_bytes(&self, layout: Layout) -> usize { + if self.latest_offset % layout.align == 0 { + 0 + } else { + layout.align - (self.latest_offset % layout.align) + } + } + + fn padding_field(&mut self, layout: Layout) -> ast::StructField { + let ty = BlobTyBuilder::new(layout).build(); + let padding_count = self.padding_count; + + self.padding_count += 1; + + let padding_field_name = format!("__bindgen_padding_{}", padding_count); + + self.max_field_align = cmp::max(self.max_field_align, layout.align); + + StructFieldBuilder::named(padding_field_name).pub_().build_ty(ty) + } + + fn align_to_latest_field(&mut self) { + if self.comp.packed() { + // skip to align field when packed + } else if let Some(layout) = self.latest_field_layout { + self.latest_offset += self.padding_bytes(layout); + } + } +} diff --git a/src/ir/comp.rs b/src/ir/comp.rs index 34bd7a541c..53efd278bf 100644 --- a/src/ir/comp.rs +++ b/src/ir/comp.rs @@ -102,6 +102,8 @@ pub struct Field { bitfield: Option, /// If the C++ field is marked as `mutable` mutable: bool, + /// The offset of the field (in bits) + offset: Option, } impl Field { @@ -111,7 +113,8 @@ impl Field { comment: Option, annotations: Option, bitfield: Option, - mutable: bool) + mutable: bool, + offset: Option) -> Field { Field { name: name, @@ -120,6 +123,7 @@ impl Field { annotations: annotations.unwrap_or_default(), bitfield: bitfield, mutable: mutable, + offset: offset, } } @@ -152,6 +156,11 @@ impl Field { pub fn annotations(&self) -> &Annotations { &self.annotations } + + /// The offset of the field (in bits) + pub fn offset(&self) -> Option { + self.offset + } } impl CanDeriveDebug for Field { @@ -390,26 +399,73 @@ impl CompInfo { /// members. This is not ideal, but clang fails to report the size for these /// kind of unions, see test/headers/template_union.hpp pub fn layout(&self, ctx: &BindgenContext) -> Option { - use std::cmp; - // We can't do better than clang here, sorry. if self.kind == CompKind::Struct { - return None; + None + } else { + self.calc_layout(ctx) } + } + + /// Compute the layout of this type. + pub fn calc_layout(&self, ctx: &BindgenContext) -> Option { + use std::cmp; + use std::mem; - let mut max_size = 0; - let mut max_align = 0; - for field in &self.fields { - let field_layout = ctx.resolve_type(field.ty) - .layout(ctx); + if self.kind == CompKind::Struct { + let mut latest_offset_in_bits = 0; + let mut max_align = 0; - if let Some(layout) = field_layout { - max_size = cmp::max(max_size, layout.size); - max_align = cmp::max(max_align, layout.align); + if self.needs_explicit_vtable(ctx) { + latest_offset_in_bits += mem::size_of::<*mut ()>() * 8; + max_align = mem::size_of::<*mut ()>(); } - } - Some(Layout::new(max_size, max_align)) + for field in &self.fields { + if let Some(bits) = field.bitfield() { + latest_offset_in_bits += bits as usize; + } else { + let field_ty = ctx.resolve_type(field.ty); + + if let Some(field_layout) = + field_ty.as_comp() + .and_then(|comp| comp.calc_layout(ctx)) + .or_else(|| field_ty.layout(ctx)) { + + let n = (latest_offset_in_bits / 8) % + field_layout.align; + + if !self.packed && n != 0 { + latest_offset_in_bits += (field_layout.align - n) * + 8; + } + + latest_offset_in_bits += field_layout.size * 8; + max_align = cmp::max(max_align, field_layout.align); + } + } + } + + if latest_offset_in_bits == 0 && max_align == 0 { + None + } else { + Some(Layout::new((latest_offset_in_bits + 7) / 8, max_align)) + } + } else { + let mut max_size = 0; + let mut max_align = 0; + for field in &self.fields { + let field_layout = ctx.resolve_type(field.ty) + .layout(ctx); + + if let Some(layout) = field_layout { + max_size = cmp::max(max_size, layout.size); + max_align = cmp::max(max_align, layout.align); + } + } + + Some(Layout::new(max_size, max_align)) + } } /// Get this type's set of fields. @@ -529,35 +585,35 @@ impl CompInfo { let mut maybe_anonymous_struct_field = None; cursor.visit(|cur| { if cur.kind() != CXCursor_FieldDecl { - if let Some((ty, _)) = maybe_anonymous_struct_field { - let field = Field::new(None, ty, None, None, None, false); + if let Some((ty, _, offset)) = + maybe_anonymous_struct_field.take() { + let field = + Field::new(None, ty, None, None, None, false, offset); ci.fields.push(field); } - maybe_anonymous_struct_field = None; } match cur.kind() { CXCursor_FieldDecl => { - match maybe_anonymous_struct_field.take() { - Some((ty, clang_ty)) => { - let mut used = false; - cur.visit(|child| { - if child.cur_type() == clang_ty { - used = true; - } - CXChildVisit_Continue - }); - if !used { - let field = Field::new(None, - ty, - None, - None, - None, - false); - ci.fields.push(field); + if let Some((ty, clang_ty, offset)) = + maybe_anonymous_struct_field.take() { + let mut used = false; + cur.visit(|child| { + if child.cur_type() == clang_ty { + used = true; } + CXChildVisit_Continue + }); + if !used { + let field = Field::new(None, + ty, + None, + None, + None, + false, + offset); + ci.fields.push(field); } - None => {} } let bit_width = cur.bit_width(); @@ -570,6 +626,7 @@ impl CompInfo { let annotations = Annotations::new(&cur); let name = cur.spelling(); let is_mutable = cursor.is_mutable_field(); + let offset = cur.offset_of_field().ok(); // Name can be empty if there are bitfields, for example, // see tests/headers/struct_with_bitfields.h @@ -583,7 +640,8 @@ impl CompInfo { comment, annotations, bit_width, - is_mutable); + is_mutable, + offset); ci.fields.push(field); // No we look for things like attributes and stuff. @@ -615,7 +673,9 @@ impl CompInfo { if cur.spelling().is_empty() && cur.kind() != CXCursor_EnumDecl { let ty = cur.cur_type(); - maybe_anonymous_struct_field = Some((inner, ty)); + let offset = cur.offset_of_field().ok(); + maybe_anonymous_struct_field = + Some((inner, ty, offset)); } } CXCursor_PackedAttr => { @@ -748,8 +808,8 @@ impl CompInfo { CXChildVisit_Continue }); - if let Some((ty, _)) = maybe_anonymous_struct_field { - let field = Field::new(None, ty, None, None, None, false); + if let Some((ty, _, offset)) = maybe_anonymous_struct_field { + let field = Field::new(None, ty, None, None, None, false, offset); ci.fields.push(field); } diff --git a/src/ir/enum_ty.rs b/src/ir/enum_ty.rs index 8ea7a8dcbc..0a85577eea 100644 --- a/src/ir/enum_ty.rs +++ b/src/ir/enum_ty.rs @@ -5,6 +5,8 @@ use super::item::Item; use super::ty::TypeKind; use clang; use ir::annotations::Annotations; +use ir::int::IntKind; +use ir::layout::Layout; use parse::{ClangItemParser, ParseError}; /// An enum representing custom handling that can be given to a variant. @@ -49,6 +51,19 @@ impl Enum { &self.variants } + /// Compute the layout of this type. + pub fn calc_layout(&self, ctx: &BindgenContext) -> Option { + self.repr + .map(|repr| ctx.resolve_type(repr)) + .and_then(|repr| match *repr.canonical_type(ctx).kind() { + TypeKind::Int(int_kind) => Some(int_kind), + _ => None, + }) + .unwrap_or(IntKind::Int) + .known_size() + .map(|size| Layout::new(size, size)) + } + /// Construct an enumeration from the given Clang type. pub fn from_ty(ty: &clang::Type, ctx: &mut BindgenContext) diff --git a/src/ir/ty.rs b/src/ir/ty.rs index f0a8c54540..5903430c91 100644 --- a/src/ir/ty.rs +++ b/src/ir/ty.rs @@ -12,6 +12,7 @@ use super::objc::ObjCInterface; use super::type_collector::{ItemSet, TypeCollector}; use clang::{self, Cursor}; use parse::{ClangItemParser, ParseError, ParseResult}; +use std::mem; /// The base representation of a type in bindgen. /// @@ -356,6 +357,40 @@ impl Type { _ => false, } } + + /// If this type has a known size, return it (in bytes). + pub fn calc_size(&self, ctx: &BindgenContext) -> Option { + match self.kind { + TypeKind::Comp(ref ci) => { + ci.calc_layout(ctx).map(|layout| layout.size) + } + TypeKind::Enum(ref enum_ty) => { + enum_ty.calc_layout(ctx).map(|layout| layout.size) + } + TypeKind::Int(int_kind) => int_kind.known_size(), + TypeKind::Float(float_kind) => Some(float_kind.known_size()), + TypeKind::Complex(float_kind) => Some(float_kind.known_size() * 2), + TypeKind::Reference(..) | + TypeKind::NullPtr | + TypeKind::Pointer(..) | + TypeKind::BlockPointer | + TypeKind::Function(..) | + TypeKind::ObjCInterface(..) => Some(mem::size_of::<*mut ()>()), + TypeKind::ResolvedTypeRef(inner) | + TypeKind::Alias(inner) | + TypeKind::TemplateAlias(inner, _) | + TypeKind::TemplateRef(inner, _) => { + ctx.resolve_type(inner).calc_size(ctx) + } + TypeKind::Array(inner, len) => { + ctx.resolve_type(inner) + .layout(ctx) + .map(|layout| layout.size * len) + } + TypeKind::Void | TypeKind::Named => None, + TypeKind::UnresolvedTypeRef(..) => unreachable!(), + } + } } impl CanDeriveDebug for Type { @@ -425,6 +460,17 @@ pub enum FloatKind { Float128, } +impl FloatKind { + /// If this type has a known size, return it (in bytes). + pub fn known_size(&self) -> usize { + match *self { + FloatKind::Float => mem::size_of::(), + FloatKind::Double | FloatKind::LongDouble => mem::size_of::(), + FloatKind::Float128 => mem::size_of::() * 2, + } + } +} + /// The different kinds of types that we can parse. #[derive(Debug)] pub enum TypeKind { @@ -623,7 +669,9 @@ impl Type { // assume this is a Comp(..) } else if ty.is_fully_specialized_template() { debug!("Template specialization: {:?}, {:?} {:?}", - ty, location, canonical_ty); + ty, + location, + canonical_ty); let complex = CompInfo::from_ty(potential_id, ty, location, ctx) .expect("C'mon"); diff --git a/tests/expectations/tests/16-byte-alignment.rs b/tests/expectations/tests/16-byte-alignment.rs index b28c0537e6..9894a37a38 100644 --- a/tests/expectations/tests/16-byte-alignment.rs +++ b/tests/expectations/tests/16-byte-alignment.rs @@ -52,8 +52,16 @@ pub struct rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 { fn bindgen_test_layout_rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() - , 2usize); + assert_eq! (::std::mem::align_of::() + , 2usize); + assert_eq! (unsafe { + & ( + * ( 0 as * const rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) + ) . dport as * const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( + * ( 0 as * const rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) + ) . sport as * const _ as usize } , 2usize); } impl Clone for rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 { fn clone(&self) -> Self { *self } @@ -62,8 +70,11 @@ impl Clone for rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 { fn bindgen_test_layout_rte_ipv4_tuple__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , - 4usize); + assert_eq! (::std::mem::align_of::() , + 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ipv4_tuple__bindgen_ty_1 ) ) . + sctp_tag as * const _ as usize } , 0usize); } impl Clone for rte_ipv4_tuple__bindgen_ty_1 { fn clone(&self) -> Self { *self } @@ -71,7 +82,13 @@ impl Clone for rte_ipv4_tuple__bindgen_ty_1 { #[test] fn bindgen_test_layout_rte_ipv4_tuple() { assert_eq!(::std::mem::size_of::() , 12usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ipv4_tuple ) ) . src_addr as * const + _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ipv4_tuple ) ) . dst_addr as * const + _ as usize } , 4usize); } impl Clone for rte_ipv4_tuple { fn clone(&self) -> Self { *self } @@ -100,8 +117,16 @@ pub struct rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 { fn bindgen_test_layout_rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() - , 2usize); + assert_eq! (::std::mem::align_of::() + , 2usize); + assert_eq! (unsafe { + & ( + * ( 0 as * const rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) + ) . dport as * const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( + * ( 0 as * const rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) + ) . sport as * const _ as usize } , 2usize); } impl Clone for rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 { fn clone(&self) -> Self { *self } @@ -110,8 +135,11 @@ impl Clone for rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 { fn bindgen_test_layout_rte_ipv6_tuple__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , - 4usize); + assert_eq! (::std::mem::align_of::() , + 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ipv6_tuple__bindgen_ty_1 ) ) . + sctp_tag as * const _ as usize } , 0usize); } impl Clone for rte_ipv6_tuple__bindgen_ty_1 { fn clone(&self) -> Self { *self } @@ -119,7 +147,13 @@ impl Clone for rte_ipv6_tuple__bindgen_ty_1 { #[test] fn bindgen_test_layout_rte_ipv6_tuple() { assert_eq!(::std::mem::size_of::() , 36usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ipv6_tuple ) ) . src_addr as * const + _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ipv6_tuple ) ) . dst_addr as * const + _ as usize } , 16usize); } impl Clone for rte_ipv6_tuple { fn clone(&self) -> Self { *self } @@ -131,6 +165,16 @@ pub struct rte_thash_tuple { pub v6: __BindgenUnionField, pub bindgen_union_field: [u8; 48usize], } +#[test] +fn bindgen_test_layout_rte_thash_tuple() { + assert_eq!(::std::mem::size_of::() , 48usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_thash_tuple ) ) . v4 as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_thash_tuple ) ) . v6 as * const _ as + usize } , 0usize); +} impl Clone for rte_thash_tuple { fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/accessors.rs b/tests/expectations/tests/accessors.rs index b721980c4c..435b811947 100644 --- a/tests/expectations/tests/accessors.rs +++ b/tests/expectations/tests/accessors.rs @@ -18,7 +18,19 @@ pub struct SomeAccessors { #[test] fn bindgen_test_layout_SomeAccessors() { assert_eq!(::std::mem::size_of::() , 16usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const SomeAccessors ) ) . mNoAccessor as * + const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const SomeAccessors ) ) . mBothAccessors as * + const _ as usize } , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const SomeAccessors ) ) . mUnsafeAccessors as * + const _ as usize } , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const SomeAccessors ) ) . mImmutableAccessor as + * const _ as usize } , 12usize); } impl Clone for SomeAccessors { fn clone(&self) -> Self { *self } @@ -56,7 +68,13 @@ pub struct AllAccessors { #[test] fn bindgen_test_layout_AllAccessors() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const AllAccessors ) ) . mBothAccessors as * + const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const AllAccessors ) ) . mAlsoBothAccessors as + * const _ as usize } , 4usize); } impl Clone for AllAccessors { fn clone(&self) -> Self { *self } @@ -90,7 +108,13 @@ pub struct AllUnsafeAccessors { #[test] fn bindgen_test_layout_AllUnsafeAccessors() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const AllUnsafeAccessors ) ) . mBothAccessors + as * const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const AllUnsafeAccessors ) ) . + mAlsoBothAccessors as * const _ as usize } , 4usize); } impl Clone for AllUnsafeAccessors { fn clone(&self) -> Self { *self } @@ -130,7 +154,19 @@ pub struct ContradictAccessors { #[test] fn bindgen_test_layout_ContradictAccessors() { assert_eq!(::std::mem::size_of::() , 16usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const ContradictAccessors ) ) . mBothAccessors + as * const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const ContradictAccessors ) ) . mNoAccessors as + * const _ as usize } , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const ContradictAccessors ) ) . + mUnsafeAccessors as * const _ as usize } , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const ContradictAccessors ) ) . + mImmutableAccessor as * const _ as usize } , 12usize); } impl Clone for ContradictAccessors { fn clone(&self) -> Self { *self } @@ -167,7 +203,10 @@ pub struct Replaced { #[test] fn bindgen_test_layout_Replaced() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Replaced ) ) . mAccessor as * const _ as + usize } , 0usize); } impl Clone for Replaced { fn clone(&self) -> Self { *self } @@ -189,7 +228,10 @@ pub struct Wrapper { #[test] fn bindgen_test_layout_Wrapper() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Wrapper ) ) . mReplaced as * const _ as + usize } , 0usize); } impl Clone for Wrapper { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/annotation_hide.rs b/tests/expectations/tests/annotation_hide.rs index dcaf7997b6..31097b6f9d 100644 --- a/tests/expectations/tests/annotation_hide.rs +++ b/tests/expectations/tests/annotation_hide.rs @@ -15,7 +15,7 @@ pub struct D { #[test] fn bindgen_test_layout_D() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); } impl Clone for D { fn clone(&self) -> Self { *self } @@ -28,7 +28,10 @@ pub struct NotAnnotated { #[test] fn bindgen_test_layout_NotAnnotated() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const NotAnnotated ) ) . f as * const _ as + usize } , 0usize); } impl Clone for NotAnnotated { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/anon_enum.rs b/tests/expectations/tests/anon_enum.rs index 3b05eab842..7130ac0c04 100644 --- a/tests/expectations/tests/anon_enum.rs +++ b/tests/expectations/tests/anon_enum.rs @@ -17,7 +17,13 @@ pub enum Test__bindgen_ty_1 { T_NONE = 0, } #[test] fn bindgen_test_layout_Test() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Test ) ) . foo as * const _ as usize } , + 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Test ) ) . bar as * const _ as usize } , + 4usize); } impl Clone for Test { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/anon_enum_trait.rs b/tests/expectations/tests/anon_enum_trait.rs index 8198bc15ce..264b4c4674 100644 --- a/tests/expectations/tests/anon_enum_trait.rs +++ b/tests/expectations/tests/anon_enum_trait.rs @@ -40,7 +40,7 @@ pub enum Foo__bindgen_ty_1 { Bar = 0, } #[test] fn bindgen_test_layout_Foo() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } impl Clone for Foo { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/anon_union.rs b/tests/expectations/tests/anon_union.rs index f8559ca920..758150e465 100644 --- a/tests/expectations/tests/anon_union.rs +++ b/tests/expectations/tests/anon_union.rs @@ -70,7 +70,7 @@ pub struct ErrorResult { #[test] fn bindgen_test_layout_ErrorResult() { assert_eq!(::std::mem::size_of::() , 24usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); } impl Clone for ErrorResult { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/auto.rs b/tests/expectations/tests/auto.rs index 6224e8073b..d7f96e77b3 100644 --- a/tests/expectations/tests/auto.rs +++ b/tests/expectations/tests/auto.rs @@ -13,7 +13,7 @@ pub const Foo_kFoo: bool = true; #[test] fn bindgen_test_layout_Foo() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } impl Clone for Foo { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/base-to-derived.rs b/tests/expectations/tests/base-to-derived.rs index c2af2c4380..e8eb374541 100644 --- a/tests/expectations/tests/base-to-derived.rs +++ b/tests/expectations/tests/base-to-derived.rs @@ -12,7 +12,7 @@ pub struct false_type { #[test] fn bindgen_test_layout_false_type() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } impl Clone for false_type { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/bitfield-enum-basic.rs b/tests/expectations/tests/bitfield-enum-basic.rs index 7674af8bb1..45adee0fad 100644 --- a/tests/expectations/tests/bitfield-enum-basic.rs +++ b/tests/expectations/tests/bitfield-enum-basic.rs @@ -70,7 +70,7 @@ pub struct Dummy__bindgen_ty_1(pub ::std::os::raw::c_uint); #[test] fn bindgen_test_layout_Dummy() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } impl Clone for Dummy { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/bitfield_method_mangling.rs b/tests/expectations/tests/bitfield_method_mangling.rs index 5aba8abb08..b9165121c7 100644 --- a/tests/expectations/tests/bitfield_method_mangling.rs +++ b/tests/expectations/tests/bitfield_method_mangling.rs @@ -12,7 +12,7 @@ pub struct _bindgen_ty_1 { #[test] fn bindgen_test_layout__bindgen_ty_1() { assert_eq!(::std::mem::size_of::<_bindgen_ty_1>() , 4usize); - assert_eq!(::std::mem::align_of::<_bindgen_ty_1>() , 4usize); + assert_eq! (::std::mem::align_of::<_bindgen_ty_1>() , 4usize); } impl Clone for _bindgen_ty_1 { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/canonical_path_without_namespacing.rs b/tests/expectations/tests/canonical_path_without_namespacing.rs index 0b1f561c74..c175c471c6 100644 --- a/tests/expectations/tests/canonical_path_without_namespacing.rs +++ b/tests/expectations/tests/canonical_path_without_namespacing.rs @@ -12,7 +12,7 @@ pub struct Bar { #[test] fn bindgen_test_layout_Bar() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } impl Clone for Bar { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/class.rs b/tests/expectations/tests/class.rs index e55a9fe357..a1426347e7 100644 --- a/tests/expectations/tests/class.rs +++ b/tests/expectations/tests/class.rs @@ -68,7 +68,12 @@ pub struct C { #[test] fn bindgen_test_layout_C() { assert_eq!(::std::mem::size_of::() , 40usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { & ( * ( 0 as * const C ) ) . a as * const _ as usize + } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const C ) ) . big_array as * const _ as usize } + , 4usize); } #[repr(C)] pub struct C_with_zero_length_array { @@ -79,7 +84,16 @@ pub struct C_with_zero_length_array { #[test] fn bindgen_test_layout_C_with_zero_length_array() { assert_eq!(::std::mem::size_of::() , 40usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const C_with_zero_length_array ) ) . a as * + const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const C_with_zero_length_array ) ) . big_array + as * const _ as usize } , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const C_with_zero_length_array ) ) . + zero_length_array as * const _ as usize } , 37usize); } #[repr(C)] pub struct C_with_incomplete_array { @@ -90,7 +104,7 @@ pub struct C_with_incomplete_array { #[test] fn bindgen_test_layout_C_with_incomplete_array() { assert_eq!(::std::mem::size_of::() , 40usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); } #[repr(C)] pub struct C_with_zero_length_array_and_incomplete_array { @@ -103,8 +117,8 @@ pub struct C_with_zero_length_array_and_incomplete_array { fn bindgen_test_layout_C_with_zero_length_array_and_incomplete_array() { assert_eq!(::std::mem::size_of::() , 40usize); - assert_eq!(::std::mem::align_of::() - , 4usize); + assert_eq! (::std::mem::align_of::() + , 4usize); } #[repr(C)] #[derive(Debug)] @@ -114,7 +128,10 @@ pub struct WithDtor { #[test] fn bindgen_test_layout_WithDtor() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const WithDtor ) ) . b as * const _ as usize } + , 0usize); } #[repr(C)] pub struct IncompleteArrayNonCopiable { @@ -124,7 +141,8 @@ pub struct IncompleteArrayNonCopiable { #[test] fn bindgen_test_layout_IncompleteArrayNonCopiable() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , + 8usize); } #[repr(C)] #[derive(Debug, Copy)] @@ -136,7 +154,13 @@ pub struct Union { #[test] fn bindgen_test_layout_Union() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Union ) ) . d as * const _ as usize } , + 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Union ) ) . i as * const _ as usize } , + 0usize); } impl Clone for Union { fn clone(&self) -> Self { *self } @@ -149,7 +173,10 @@ pub struct WithUnion { #[test] fn bindgen_test_layout_WithUnion() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const WithUnion ) ) . data as * const _ as + usize } , 0usize); } impl Clone for WithUnion { fn clone(&self) -> Self { *self } @@ -163,8 +190,8 @@ pub struct RealAbstractionWithTonsOfMethods { fn bindgen_test_layout_RealAbstractionWithTonsOfMethods() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , - 1usize); + assert_eq! (::std::mem::align_of::() , + 1usize); } extern "C" { #[link_name = "_ZNK32RealAbstractionWithTonsOfMethods3barEv"] diff --git a/tests/expectations/tests/class_nested.rs b/tests/expectations/tests/class_nested.rs index 593e156d36..4df281988a 100644 --- a/tests/expectations/tests/class_nested.rs +++ b/tests/expectations/tests/class_nested.rs @@ -17,7 +17,10 @@ pub struct A_B { #[test] fn bindgen_test_layout_A_B() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const A_B ) ) . member_b as * const _ as usize + } , 0usize); } impl Clone for A_B { fn clone(&self) -> Self { *self } @@ -25,7 +28,10 @@ impl Clone for A_B { #[test] fn bindgen_test_layout_A() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const A ) ) . member_a as * const _ as usize } + , 0usize); } impl Clone for A { fn clone(&self) -> Self { *self } @@ -42,7 +48,10 @@ pub struct D { #[test] fn bindgen_test_layout_D() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const D ) ) . member as * const _ as usize } , + 0usize); } impl Clone for D { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/class_no_members.rs b/tests/expectations/tests/class_no_members.rs index 017f7c2266..1e3ace3b85 100644 --- a/tests/expectations/tests/class_no_members.rs +++ b/tests/expectations/tests/class_no_members.rs @@ -12,7 +12,7 @@ pub struct whatever { #[test] fn bindgen_test_layout_whatever() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } impl Clone for whatever { fn clone(&self) -> Self { *self } @@ -25,7 +25,7 @@ pub struct whatever_child { #[test] fn bindgen_test_layout_whatever_child() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } impl Clone for whatever_child { fn clone(&self) -> Self { *self } @@ -38,7 +38,11 @@ pub struct whatever_child_with_member { #[test] fn bindgen_test_layout_whatever_child_with_member() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , + 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const whatever_child_with_member ) ) . m_member + as * const _ as usize } , 0usize); } impl Clone for whatever_child_with_member { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/class_static.rs b/tests/expectations/tests/class_static.rs index 8108be2da3..7730d279c9 100644 --- a/tests/expectations/tests/class_static.rs +++ b/tests/expectations/tests/class_static.rs @@ -21,7 +21,7 @@ extern "C" { #[test] fn bindgen_test_layout_MyClass() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } impl Clone for MyClass { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/class_static_const.rs b/tests/expectations/tests/class_static_const.rs index eed6590cc8..0723325d14 100644 --- a/tests/expectations/tests/class_static_const.rs +++ b/tests/expectations/tests/class_static_const.rs @@ -15,7 +15,7 @@ pub const A_c: u32 = 255; #[test] fn bindgen_test_layout_A() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } impl Clone for A { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/class_use_as.rs b/tests/expectations/tests/class_use_as.rs index c3843b31ee..6861815542 100644 --- a/tests/expectations/tests/class_use_as.rs +++ b/tests/expectations/tests/class_use_as.rs @@ -15,7 +15,10 @@ pub struct whatever { #[test] fn bindgen_test_layout_whatever() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const whatever ) ) . replacement as * const _ + as usize } , 0usize); } impl Clone for whatever { fn clone(&self) -> Self { *self } @@ -28,7 +31,10 @@ pub struct container { #[test] fn bindgen_test_layout_container() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const container ) ) . c as * const _ as usize } + , 0usize); } impl Clone for container { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/class_with_dtor.rs b/tests/expectations/tests/class_with_dtor.rs index 8fa0951f8f..e3bed7b11e 100644 --- a/tests/expectations/tests/class_with_dtor.rs +++ b/tests/expectations/tests/class_with_dtor.rs @@ -18,7 +18,10 @@ pub struct WithoutDtor { #[test] fn bindgen_test_layout_WithoutDtor() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const WithoutDtor ) ) . shouldBeWithDtor as * + const _ as usize } , 0usize); } #[test] fn __bindgen_test_layout_template_1() { diff --git a/tests/expectations/tests/class_with_inner_struct.rs b/tests/expectations/tests/class_with_inner_struct.rs index a1bacbdb78..8c800e2912 100644 --- a/tests/expectations/tests/class_with_inner_struct.rs +++ b/tests/expectations/tests/class_with_inner_struct.rs @@ -44,7 +44,13 @@ pub struct A_Segment { #[test] fn bindgen_test_layout_A_Segment() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const A_Segment ) ) . begin as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const A_Segment ) ) . end as * const _ as usize + } , 4usize); } impl Clone for A_Segment { fn clone(&self) -> Self { *self } @@ -58,7 +64,10 @@ pub struct A__bindgen_ty_1 { #[test] fn bindgen_test_layout_A__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const A__bindgen_ty_1 ) ) . f as * const _ as + usize } , 0usize); } impl Clone for A__bindgen_ty_1 { fn clone(&self) -> Self { *self } @@ -72,7 +81,10 @@ pub struct A__bindgen_ty_2 { #[test] fn bindgen_test_layout_A__bindgen_ty_2() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const A__bindgen_ty_2 ) ) . d as * const _ as + usize } , 0usize); } impl Clone for A__bindgen_ty_2 { fn clone(&self) -> Self { *self } @@ -80,7 +92,12 @@ impl Clone for A__bindgen_ty_2 { #[test] fn bindgen_test_layout_A() { assert_eq!(::std::mem::size_of::() , 12usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { & ( * ( 0 as * const A ) ) . c as * const _ as usize + } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const A ) ) . named_union as * const _ as usize + } , 4usize); } impl Clone for A { fn clone(&self) -> Self { *self } @@ -99,7 +116,13 @@ pub struct B_Segment { #[test] fn bindgen_test_layout_B_Segment() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const B_Segment ) ) . begin as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const B_Segment ) ) . end as * const _ as usize + } , 4usize); } impl Clone for B_Segment { fn clone(&self) -> Self { *self } @@ -107,7 +130,9 @@ impl Clone for B_Segment { #[test] fn bindgen_test_layout_B() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { & ( * ( 0 as * const B ) ) . d as * const _ as usize + } , 0usize); } impl Clone for B { fn clone(&self) -> Self { *self } @@ -145,8 +170,20 @@ pub struct C__bindgen_ty_1__bindgen_ty_1 { fn bindgen_test_layout_C__bindgen_ty_1__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 16usize); - assert_eq!(::std::mem::align_of::() , - 4usize); + assert_eq! (::std::mem::align_of::() , + 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_1 ) ) . mX1 + as * const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_1 ) ) . mY1 + as * const _ as usize } , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_1 ) ) . mX2 + as * const _ as usize } , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_1 ) ) . mY2 + as * const _ as usize } , 12usize); } impl Clone for C__bindgen_ty_1__bindgen_ty_1 { fn clone(&self) -> Self { *self } @@ -161,8 +198,14 @@ pub struct C__bindgen_ty_1__bindgen_ty_2 { fn bindgen_test_layout_C__bindgen_ty_1__bindgen_ty_2() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , - 4usize); + assert_eq! (::std::mem::align_of::() , + 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_2 ) ) . + mStepSyntax as * const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_2 ) ) . + mSteps as * const _ as usize } , 4usize); } impl Clone for C__bindgen_ty_1__bindgen_ty_2 { fn clone(&self) -> Self { *self } @@ -170,7 +213,10 @@ impl Clone for C__bindgen_ty_1__bindgen_ty_2 { #[test] fn bindgen_test_layout_C__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 16usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const C__bindgen_ty_1 ) ) . mFunc as * const _ + as usize } , 0usize); } impl Clone for C__bindgen_ty_1 { fn clone(&self) -> Self { *self } @@ -184,7 +230,13 @@ pub struct C_Segment { #[test] fn bindgen_test_layout_C_Segment() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const C_Segment ) ) . begin as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const C_Segment ) ) . end as * const _ as usize + } , 4usize); } impl Clone for C_Segment { fn clone(&self) -> Self { *self } @@ -192,7 +244,9 @@ impl Clone for C_Segment { #[test] fn bindgen_test_layout_C() { assert_eq!(::std::mem::size_of::() , 20usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { & ( * ( 0 as * const C ) ) . d as * const _ as usize + } , 0usize); } impl Clone for C { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/class_with_typedef.rs b/tests/expectations/tests/class_with_typedef.rs index bc19f2bd0d..2a7da809ff 100644 --- a/tests/expectations/tests/class_with_typedef.rs +++ b/tests/expectations/tests/class_with_typedef.rs @@ -19,7 +19,20 @@ pub type C_Lookup = *const ::std::os::raw::c_char; #[test] fn bindgen_test_layout_C() { assert_eq!(::std::mem::size_of::() , 72usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { & ( * ( 0 as * const C ) ) . c as * const _ as usize + } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const C ) ) . ptr as * const _ as usize } , + 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const C ) ) . arr as * const _ as usize } , + 16usize); + assert_eq! (unsafe { & ( * ( 0 as * const C ) ) . d as * const _ as usize + } , 56usize); + assert_eq! (unsafe { + & ( * ( 0 as * const C ) ) . other_ptr as * const _ as usize } + , 64usize); } extern "C" { #[link_name = "_ZN1C6methodEi"] @@ -65,7 +78,10 @@ pub struct D { #[test] fn bindgen_test_layout_D() { assert_eq!(::std::mem::size_of::() , 80usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const D ) ) . ptr as * const _ as usize } , + 72usize); } impl Clone for D { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/complex.rs b/tests/expectations/tests/complex.rs index f2a97952bf..3f85616aed 100644 --- a/tests/expectations/tests/complex.rs +++ b/tests/expectations/tests/complex.rs @@ -18,7 +18,10 @@ pub struct TestDouble { #[test] fn bindgen_test_layout_TestDouble() { assert_eq!(::std::mem::size_of::() , 16usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const TestDouble ) ) . mMember as * const _ as + usize } , 0usize); } impl Clone for TestDouble { fn clone(&self) -> Self { *self } @@ -31,7 +34,10 @@ pub struct TestDoublePtr { #[test] fn bindgen_test_layout_TestDoublePtr() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const TestDoublePtr ) ) . mMember as * const _ + as usize } , 0usize); } impl Clone for TestDoublePtr { fn clone(&self) -> Self { *self } @@ -44,7 +50,10 @@ pub struct TestFloat { #[test] fn bindgen_test_layout_TestFloat() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const TestFloat ) ) . mMember as * const _ as + usize } , 0usize); } impl Clone for TestFloat { fn clone(&self) -> Self { *self } @@ -57,7 +66,10 @@ pub struct TestFloatPtr { #[test] fn bindgen_test_layout_TestFloatPtr() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const TestFloatPtr ) ) . mMember as * const _ + as usize } , 0usize); } impl Clone for TestFloatPtr { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/const_bool.rs b/tests/expectations/tests/const_bool.rs index 8a50a0944e..8a56811333 100644 --- a/tests/expectations/tests/const_bool.rs +++ b/tests/expectations/tests/const_bool.rs @@ -14,7 +14,7 @@ pub const A_k: bool = false; #[test] fn bindgen_test_layout_A() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } impl Clone for A { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/const_enum_unnamed.rs b/tests/expectations/tests/const_enum_unnamed.rs index 0bd3987a3b..9d586dee42 100644 --- a/tests/expectations/tests/const_enum_unnamed.rs +++ b/tests/expectations/tests/const_enum_unnamed.rs @@ -21,7 +21,7 @@ pub enum Foo__bindgen_ty_1 { FOO_BAR = 10, } #[test] fn bindgen_test_layout_Foo() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } impl Clone for Foo { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/constify-all-enums.rs b/tests/expectations/tests/constify-all-enums.rs index a676bb1019..e5b23a68af 100644 --- a/tests/expectations/tests/constify-all-enums.rs +++ b/tests/expectations/tests/constify-all-enums.rs @@ -16,7 +16,10 @@ pub struct bar { #[test] fn bindgen_test_layout_bar() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const bar ) ) . this_should_work as * const _ + as usize } , 0usize); } impl Clone for bar { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/constructor-tp.rs b/tests/expectations/tests/constructor-tp.rs index 5022048910..4e8bcf67f7 100644 --- a/tests/expectations/tests/constructor-tp.rs +++ b/tests/expectations/tests/constructor-tp.rs @@ -18,7 +18,7 @@ pub struct Bar { #[test] fn bindgen_test_layout_Bar() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } extern "C" { #[link_name = "_ZN3BarC1Ev"] diff --git a/tests/expectations/tests/constructors.rs b/tests/expectations/tests/constructors.rs index 95afb82da8..8bea85c717 100644 --- a/tests/expectations/tests/constructors.rs +++ b/tests/expectations/tests/constructors.rs @@ -12,7 +12,7 @@ pub struct TestOverload { #[test] fn bindgen_test_layout_TestOverload() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } extern "C" { #[link_name = "_ZN12TestOverloadC1Ei"] @@ -48,7 +48,7 @@ pub struct TestPublicNoArgs { #[test] fn bindgen_test_layout_TestPublicNoArgs() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } extern "C" { #[link_name = "_ZN16TestPublicNoArgsC1Ev"] diff --git a/tests/expectations/tests/convert-floats.rs b/tests/expectations/tests/convert-floats.rs index 5cd38c133c..75cbb4b242 100644 --- a/tests/expectations/tests/convert-floats.rs +++ b/tests/expectations/tests/convert-floats.rs @@ -23,7 +23,25 @@ pub struct foo { #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 48usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , + 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . baz as * const _ as usize } , + 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . bazz as * const _ as usize } , + 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . bazzz as * const _ as usize } , + 16usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . complexFloat as * const _ as + usize } , 24usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . complexDouble as * const _ as + usize } , 32usize); } impl Clone for foo { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/crtp.rs b/tests/expectations/tests/crtp.rs index cc488fd6c3..295732d01b 100644 --- a/tests/expectations/tests/crtp.rs +++ b/tests/expectations/tests/crtp.rs @@ -18,7 +18,7 @@ pub struct Derived { #[test] fn bindgen_test_layout_Derived() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } impl Clone for Derived { fn clone(&self) -> Self { *self } @@ -38,8 +38,8 @@ pub struct DerivedFromBaseWithDestructor { fn bindgen_test_layout_DerivedFromBaseWithDestructor() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , - 1usize); + assert_eq! (::std::mem::align_of::() , + 1usize); } #[test] fn __bindgen_test_layout_template_1() { diff --git a/tests/expectations/tests/duplicated-namespaces-definitions.rs b/tests/expectations/tests/duplicated-namespaces-definitions.rs index da06a2a9c3..abc4310ce1 100644 --- a/tests/expectations/tests/duplicated-namespaces-definitions.rs +++ b/tests/expectations/tests/duplicated-namespaces-definitions.rs @@ -19,7 +19,13 @@ pub mod root { #[test] fn bindgen_test_layout_Bar() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Bar ) ) . foo as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Bar ) ) . baz as * const _ as + usize } , 4usize); } impl Clone for Bar { fn clone(&self) -> Self { *self } @@ -36,7 +42,10 @@ pub mod root { #[test] fn bindgen_test_layout_Foo() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Foo ) ) . ptr as * const _ as + usize } , 0usize); } impl Clone for Foo { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/enum_and_vtable_mangling.rs b/tests/expectations/tests/enum_and_vtable_mangling.rs index a55c344e50..420246b585 100644 --- a/tests/expectations/tests/enum_and_vtable_mangling.rs +++ b/tests/expectations/tests/enum_and_vtable_mangling.rs @@ -21,7 +21,9 @@ pub struct C { #[test] fn bindgen_test_layout_C() { assert_eq!(::std::mem::size_of::() , 16usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { & ( * ( 0 as * const C ) ) . i as * const _ as usize + } , 8usize); } impl Clone for C { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/forward-declaration-autoptr.rs b/tests/expectations/tests/forward-declaration-autoptr.rs index 31013d3aef..a26d476ee7 100644 --- a/tests/expectations/tests/forward-declaration-autoptr.rs +++ b/tests/expectations/tests/forward-declaration-autoptr.rs @@ -20,7 +20,10 @@ pub struct Bar { #[test] fn bindgen_test_layout_Bar() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Bar ) ) . m_member as * const _ as usize + } , 0usize); } impl Clone for Bar { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/forward_declared_complex_types.rs b/tests/expectations/tests/forward_declared_complex_types.rs index 119ea2b535..c169ef6991 100644 --- a/tests/expectations/tests/forward_declared_complex_types.rs +++ b/tests/expectations/tests/forward_declared_complex_types.rs @@ -12,7 +12,7 @@ pub struct Foo_empty { #[test] fn bindgen_test_layout_Foo_empty() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } impl Clone for Foo_empty { fn clone(&self) -> Self { *self } @@ -28,7 +28,10 @@ pub struct Bar { #[test] fn bindgen_test_layout_Bar() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Bar ) ) . f as * const _ as usize } , + 0usize); } impl Clone for Bar { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/forward_declared_struct.rs b/tests/expectations/tests/forward_declared_struct.rs index 5c2764e106..060156b2e6 100644 --- a/tests/expectations/tests/forward_declared_struct.rs +++ b/tests/expectations/tests/forward_declared_struct.rs @@ -12,7 +12,9 @@ pub struct a { #[test] fn bindgen_test_layout_a() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { & ( * ( 0 as * const a ) ) . b as * const _ as usize + } , 0usize); } impl Clone for a { fn clone(&self) -> Self { *self } @@ -25,7 +27,9 @@ pub struct c { #[test] fn bindgen_test_layout_c() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { & ( * ( 0 as * const c ) ) . d as * const _ as usize + } , 0usize); } impl Clone for c { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/func_ptr_in_struct.rs b/tests/expectations/tests/func_ptr_in_struct.rs index dcae771b06..e1fac5e49a 100644 --- a/tests/expectations/tests/func_ptr_in_struct.rs +++ b/tests/expectations/tests/func_ptr_in_struct.rs @@ -18,7 +18,10 @@ pub struct Foo { #[test] fn bindgen_test_layout_Foo() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Foo ) ) . bar as * const _ as usize } , + 0usize); } impl Clone for Foo { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/inherit_typedef.rs b/tests/expectations/tests/inherit_typedef.rs index ca9041e202..bc8eb472ee 100644 --- a/tests/expectations/tests/inherit_typedef.rs +++ b/tests/expectations/tests/inherit_typedef.rs @@ -12,7 +12,7 @@ pub struct Foo { #[test] fn bindgen_test_layout_Foo() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } impl Clone for Foo { fn clone(&self) -> Self { *self } @@ -26,7 +26,7 @@ pub struct Bar { #[test] fn bindgen_test_layout_Bar() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } impl Clone for Bar { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/inline_namespace.rs b/tests/expectations/tests/inline_namespace.rs index 5f6776b72b..0c00724176 100644 --- a/tests/expectations/tests/inline_namespace.rs +++ b/tests/expectations/tests/inline_namespace.rs @@ -20,7 +20,10 @@ pub mod root { #[test] fn bindgen_test_layout_Bar() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Bar ) ) . baz as * const _ as usize } + , 0usize); } impl Clone for Bar { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/inline_namespace_conservative.rs b/tests/expectations/tests/inline_namespace_conservative.rs index d759a882ca..4bd06cd9a2 100644 --- a/tests/expectations/tests/inline_namespace_conservative.rs +++ b/tests/expectations/tests/inline_namespace_conservative.rs @@ -25,7 +25,10 @@ pub mod root { #[test] fn bindgen_test_layout_Bar() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Bar ) ) . baz as * const _ as usize } + , 0usize); } impl Clone for Bar { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/inner_const.rs b/tests/expectations/tests/inner_const.rs index 666b8ce2ec..bc7dd7ac99 100644 --- a/tests/expectations/tests/inner_const.rs +++ b/tests/expectations/tests/inner_const.rs @@ -20,7 +20,10 @@ extern "C" { #[test] fn bindgen_test_layout_Foo() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Foo ) ) . bar as * const _ as usize } , + 0usize); } impl Clone for Foo { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/inner_template_self.rs b/tests/expectations/tests/inner_template_self.rs index b965b92d7c..02ffea3d14 100644 --- a/tests/expectations/tests/inner_template_self.rs +++ b/tests/expectations/tests/inner_template_self.rs @@ -18,7 +18,10 @@ pub struct InstantiateIt { #[test] fn bindgen_test_layout_InstantiateIt() { assert_eq!(::std::mem::size_of::() , 16usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const InstantiateIt ) ) . m_list as * const _ + as usize } , 0usize); } impl Clone for InstantiateIt { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/issue-372.rs b/tests/expectations/tests/issue-372.rs index c6d9209e26..810be82c79 100644 --- a/tests/expectations/tests/issue-372.rs +++ b/tests/expectations/tests/issue-372.rs @@ -15,7 +15,10 @@ pub mod root { #[test] fn bindgen_test_layout_d() { assert_eq!(::std::mem::size_of::() , 24usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const d ) ) . m as * const _ as usize } , + 0usize); } impl Clone for d { fn clone(&self) -> Self { *self } @@ -30,7 +33,16 @@ pub mod root { #[test] fn bindgen_test_layout_i() { assert_eq!(::std::mem::size_of::() , 24usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const i ) ) . j as * const _ as usize } , + 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const i ) ) . k as * const _ as usize } , + 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const i ) ) . l as * const _ as usize } , + 16usize); } impl Clone for i { fn clone(&self) -> Self { *self } @@ -58,6 +70,9 @@ pub mod root { #[test] fn bindgen_test_layout_F() { assert_eq!(::std::mem::size_of::() , 264usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const F ) ) . w as * const _ as usize } , + 0usize); } } diff --git a/tests/expectations/tests/issue-410.rs b/tests/expectations/tests/issue-410.rs index 0c91e2b7de..69bf32a08e 100644 --- a/tests/expectations/tests/issue-410.rs +++ b/tests/expectations/tests/issue-410.rs @@ -18,7 +18,7 @@ pub mod root { #[test] fn bindgen_test_layout_Value() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } extern "C" { #[link_name = "_ZN2JS5Value1aE10JSWhyMagic"] diff --git a/tests/expectations/tests/issue-447.rs b/tests/expectations/tests/issue-447.rs index b49caa5477..b315e00814 100644 --- a/tests/expectations/tests/issue-447.rs +++ b/tests/expectations/tests/issue-447.rs @@ -22,8 +22,8 @@ pub mod root { fn bindgen_test_layout_GuardObjectNotifier() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , - 1usize); + assert_eq! (::std::mem::align_of::() , + 1usize); } impl Clone for GuardObjectNotifier { fn clone(&self) -> Self { *self } @@ -38,7 +38,7 @@ pub mod root { #[test] fn bindgen_test_layout_JSAutoCompartment() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } extern "C" { #[link_name = diff --git a/tests/expectations/tests/issue_311.rs b/tests/expectations/tests/issue_311.rs index f01a9d9354..62b95806f0 100644 --- a/tests/expectations/tests/issue_311.rs +++ b/tests/expectations/tests/issue_311.rs @@ -21,8 +21,8 @@ pub mod root { fn bindgen_test_layout_jsval_layout__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , - 1usize); + assert_eq! (::std::mem::align_of::() , + 1usize); } impl Clone for jsval_layout__bindgen_ty_1 { fn clone(&self) -> Self { *self } @@ -30,7 +30,7 @@ pub mod root { #[test] fn bindgen_test_layout_jsval_layout() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } impl Clone for jsval_layout { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/jsval_layout_opaque.rs b/tests/expectations/tests/jsval_layout_opaque.rs index 530fdb22c5..d77493c722 100644 --- a/tests/expectations/tests/jsval_layout_opaque.rs +++ b/tests/expectations/tests/jsval_layout_opaque.rs @@ -115,7 +115,8 @@ pub struct jsval_layout__bindgen_ty_1 { #[test] fn bindgen_test_layout_jsval_layout__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , + 8usize); } impl Clone for jsval_layout__bindgen_ty_1 { fn clone(&self) -> Self { *self } @@ -168,8 +169,20 @@ pub struct jsval_layout__bindgen_ty_2__bindgen_ty_1 { fn bindgen_test_layout_jsval_layout__bindgen_ty_2__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() - , 4usize); + assert_eq! (::std::mem::align_of::() + , 4usize); + assert_eq! (unsafe { + & ( + * ( 0 as * const jsval_layout__bindgen_ty_2__bindgen_ty_1 ) ) + . i32 as * const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( + * ( 0 as * const jsval_layout__bindgen_ty_2__bindgen_ty_1 ) ) + . u32 as * const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( + * ( 0 as * const jsval_layout__bindgen_ty_2__bindgen_ty_1 ) ) + . why as * const _ as usize } , 0usize); } impl Clone for jsval_layout__bindgen_ty_2__bindgen_ty_1 { fn clone(&self) -> Self { *self } @@ -177,11 +190,41 @@ impl Clone for jsval_layout__bindgen_ty_2__bindgen_ty_1 { #[test] fn bindgen_test_layout_jsval_layout__bindgen_ty_2() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , + 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const jsval_layout__bindgen_ty_2 ) ) . payload + as * const _ as usize } , 0usize); } 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); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const jsval_layout ) ) . asBits as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const jsval_layout ) ) . debugView as * const _ + as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const jsval_layout ) ) . s as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const jsval_layout ) ) . asDouble as * const _ + as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const jsval_layout ) ) . asPtr as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const jsval_layout ) ) . asWord as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const jsval_layout ) ) . asUIntPtr as * const _ + as usize } , 0usize); +} impl Clone for jsval_layout { fn clone(&self) -> Self { *self } } @@ -193,7 +236,10 @@ pub struct Value { #[test] fn bindgen_test_layout_Value() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Value ) ) . data as * const _ as usize } + , 0usize); } impl Clone for Value { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/layout.rs b/tests/expectations/tests/layout.rs new file mode 100644 index 0000000000..2946112fcb --- /dev/null +++ b/tests/expectations/tests/layout.rs @@ -0,0 +1,53 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[repr(C)] +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, packed)] +#[derive(Debug, Copy)] +pub struct header { + pub proto: ::std::os::raw::c_char, + pub size: ::std::os::raw::c_uint, + pub data: __IncompleteArrayField<::std::os::raw::c_uchar>, + pub __bindgen_padding_0: [u8; 11usize], +} +#[test] +fn bindgen_test_layout_header() { + assert_eq!(::std::mem::size_of::
() , 16usize); +} +impl Clone for header { + fn clone(&self) -> Self { *self } +} diff --git a/tests/expectations/tests/layout_align.rs b/tests/expectations/tests/layout_align.rs new file mode 100644 index 0000000000..8b243f5397 --- /dev/null +++ b/tests/expectations/tests/layout_align.rs @@ -0,0 +1,118 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[repr(C)] +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)] +#[derive(Debug, Copy)] +pub struct rte_kni_fifo { + /**< Next position to be written*/ + pub write: ::std::os::raw::c_uint, + /**< Next position to be read */ + pub read: ::std::os::raw::c_uint, + /**< Circular buffer length */ + pub len: ::std::os::raw::c_uint, + /**< Pointer size - for 32/64 bit OS */ + pub elem_size: ::std::os::raw::c_uint, + /**< The buffer contains mbuf pointers */ + pub buffer: __IncompleteArrayField<*mut ::std::os::raw::c_void>, + pub __bindgen_align: [u64; 0usize], +} +#[test] +fn bindgen_test_layout_rte_kni_fifo() { + assert_eq!(::std::mem::size_of::() , 16usize); + assert_eq! (::std::mem::align_of::() , 8usize); +} +impl Clone for rte_kni_fifo { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct rte_eth_link { + /**< ETH_SPEED_NUM_ */ + pub link_speed: u32, + pub _bitfield_1: u8, + pub __bindgen_align: [u64; 0usize], +} +#[test] +fn bindgen_test_layout_rte_eth_link() { + assert_eq!(::std::mem::size_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_link ) ) . link_speed as * const + _ as usize } , 0usize); +} +impl Clone for rte_eth_link { + fn clone(&self) -> Self { *self } +} +impl rte_eth_link { + #[inline] + pub fn link_duplex(&self) -> u16 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (1usize as u8)) >> + 0u32) as u16) + } + } + #[inline] + pub fn set_link_duplex(&mut self, val: u16) { + self._bitfield_1 &= !(1usize as u8); + self._bitfield_1 |= ((val as u16 as u8) << 0u32) & (1usize as u8); + } + #[inline] + pub fn link_autoneg(&self) -> u16 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (2usize as u8)) >> + 1u32) as u16) + } + } + #[inline] + pub fn set_link_autoneg(&mut self, val: u16) { + self._bitfield_1 &= !(2usize as u8); + self._bitfield_1 |= ((val as u16 as u8) << 1u32) & (2usize as u8); + } + #[inline] + pub fn link_status(&self) -> u16 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (4usize as u8)) >> + 2u32) as u16) + } + } + #[inline] + pub fn set_link_status(&mut self, val: u16) { + self._bitfield_1 &= !(4usize as u8); + self._bitfield_1 |= ((val as u16 as u8) << 2u32) & (4usize as u8); + } +} diff --git a/tests/expectations/tests/layout_arp.rs b/tests/expectations/tests/layout_arp.rs new file mode 100644 index 0000000000..f1feb92bf0 --- /dev/null +++ b/tests/expectations/tests/layout_arp.rs @@ -0,0 +1,116 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +pub const ETHER_ADDR_LEN: ::std::os::raw::c_uint = 6; +pub const ARP_HRD_ETHER: ::std::os::raw::c_uint = 1; +pub const ARP_OP_REQUEST: ::std::os::raw::c_uint = 1; +pub const ARP_OP_REPLY: ::std::os::raw::c_uint = 2; +pub const ARP_OP_REVREQUEST: ::std::os::raw::c_uint = 3; +pub const ARP_OP_REVREPLY: ::std::os::raw::c_uint = 4; +pub const ARP_OP_INVREQUEST: ::std::os::raw::c_uint = 8; +pub const ARP_OP_INVREPLY: ::std::os::raw::c_uint = 9; +/** + * Ethernet address: + * A universally administered address is uniquely assigned to a device by its + * manufacturer. The first three octets (in transmission order) contain the + * Organizationally Unique Identifier (OUI). The following three (MAC-48 and + * EUI-48) octets are assigned by that organization with the only constraint + * of uniqueness. + * A locally administered address is assigned to a device by a network + * administrator and does not contain OUIs. + * See http://standards.ieee.org/regauth/groupmac/tutorial.html + */ +#[repr(C, packed)] +#[derive(Debug, Copy)] +pub struct ether_addr { + /**< Addr bytes in tx order */ + pub addr_bytes: [u8; 6usize], +} +#[test] +fn bindgen_test_layout_ether_addr() { + assert_eq!(::std::mem::size_of::() , 6usize); + assert_eq! (::std::mem::align_of::() , 1usize); + assert_eq! (unsafe { + & ( * ( 0 as * const ether_addr ) ) . addr_bytes as * const _ + as usize } , 0usize); +} +impl Clone for ether_addr { + fn clone(&self) -> Self { *self } +} +/** + * ARP header IPv4 payload. + */ +#[repr(C, packed)] +#[derive(Debug, Copy)] +pub struct arp_ipv4 { + /**< sender hardware address */ + pub arp_sha: ether_addr, + /**< sender IP address */ + pub arp_sip: u32, + /**< target hardware address */ + pub arp_tha: ether_addr, + /**< target IP address */ + pub arp_tip: u32, +} +#[test] +fn bindgen_test_layout_arp_ipv4() { + assert_eq!(::std::mem::size_of::() , 20usize); + assert_eq! (::std::mem::align_of::() , 1usize); + assert_eq! (unsafe { + & ( * ( 0 as * const arp_ipv4 ) ) . arp_sha as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const arp_ipv4 ) ) . arp_sip as * const _ as + usize } , 6usize); + assert_eq! (unsafe { + & ( * ( 0 as * const arp_ipv4 ) ) . arp_tha as * const _ as + usize } , 10usize); + assert_eq! (unsafe { + & ( * ( 0 as * const arp_ipv4 ) ) . arp_tip as * const _ as + usize } , 16usize); +} +impl Clone for arp_ipv4 { + fn clone(&self) -> Self { *self } +} +/** + * ARP header. + */ +#[repr(C, packed)] +#[derive(Debug, Copy)] +pub struct arp_hdr { + pub arp_hrd: u16, + pub arp_pro: u16, + pub arp_hln: u8, + pub arp_pln: u8, + pub arp_op: u16, + pub arp_data: arp_ipv4, +} +#[test] +fn bindgen_test_layout_arp_hdr() { + assert_eq!(::std::mem::size_of::() , 28usize); + assert_eq! (::std::mem::align_of::() , 1usize); + assert_eq! (unsafe { + & ( * ( 0 as * const arp_hdr ) ) . arp_hrd as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const arp_hdr ) ) . arp_pro as * const _ as + usize } , 2usize); + assert_eq! (unsafe { + & ( * ( 0 as * const arp_hdr ) ) . arp_hln as * const _ as + usize } , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const arp_hdr ) ) . arp_pln as * const _ as + usize } , 5usize); + assert_eq! (unsafe { + & ( * ( 0 as * const arp_hdr ) ) . arp_op as * const _ as + usize } , 6usize); + assert_eq! (unsafe { + & ( * ( 0 as * const arp_hdr ) ) . arp_data as * const _ as + usize } , 8usize); +} +impl Clone for arp_hdr { + fn clone(&self) -> Self { *self } +} diff --git a/tests/expectations/tests/layout_array.rs b/tests/expectations/tests/layout_array.rs new file mode 100644 index 0000000000..080a0a8377 --- /dev/null +++ b/tests/expectations/tests/layout_array.rs @@ -0,0 +1,206 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +pub const RTE_CACHE_LINE_SIZE: ::std::os::raw::c_uint = 64; +pub const RTE_MEMPOOL_OPS_NAMESIZE: ::std::os::raw::c_uint = 32; +pub const RTE_MEMPOOL_MAX_OPS_IDX: ::std::os::raw::c_uint = 16; +pub const RTE_HEAP_NUM_FREELISTS: ::std::os::raw::c_uint = 13; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct rte_mempool([u8; 0]); +/** + * Prototype for implementation specific data provisioning function. + * + * The function should provide the implementation specific memory for + * for use by the other mempool ops functions in a given mempool ops struct. + * E.g. the default ops provides an instance of the rte_ring for this purpose. + * it will most likely point to a different type of data structure, and + * will be transparent to the application programmer. + * This function should set mp->pool_data. + */ +pub type rte_mempool_alloc_t = + ::std::option::Option ::std::os::raw::c_int>; +/** + * Free the opaque private data pointed to by mp->pool_data pointer. + */ +pub type rte_mempool_free_t = + ::std::option::Option; +/** + * Enqueue an object into the external pool. + */ +pub type rte_mempool_enqueue_t = + ::std::option::Option ::std::os::raw::c_int>; +/** + * Dequeue an object from the external pool. + */ +pub type rte_mempool_dequeue_t = + ::std::option::Option ::std::os::raw::c_int>; +/** + * Return the number of available objects in the external pool. + */ +pub type rte_mempool_get_count = + ::std::option::Option ::std::os::raw::c_uint>; +/** Structure defining mempool operations structure */ +#[repr(C)] +#[derive(Debug, Copy)] +pub struct rte_mempool_ops { + /**< Name of mempool ops struct. */ + pub name: [::std::os::raw::c_char; 32usize], + /**< Allocate private data. */ + pub alloc: rte_mempool_alloc_t, + /**< Free the external pool. */ + pub free: rte_mempool_free_t, + /**< Enqueue an object. */ + pub enqueue: rte_mempool_enqueue_t, + /**< Dequeue an object. */ + pub dequeue: rte_mempool_dequeue_t, + /**< Get qty of available objs. */ + pub get_count: rte_mempool_get_count, + pub __bindgen_padding_0: [u64; 7usize], +} +#[test] +fn bindgen_test_layout_rte_mempool_ops() { + assert_eq!(::std::mem::size_of::() , 128usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mempool_ops ) ) . name as * const _ + as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mempool_ops ) ) . alloc as * const _ + as usize } , 32usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mempool_ops ) ) . free as * const _ + as usize } , 40usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mempool_ops ) ) . enqueue as * const + _ as usize } , 48usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mempool_ops ) ) . dequeue as * const + _ as usize } , 56usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mempool_ops ) ) . get_count as * + const _ as usize } , 64usize); +} +impl Clone for rte_mempool_ops { + fn clone(&self) -> Self { *self } +} +/** + * The rte_spinlock_t type. + */ +#[repr(C)] +#[derive(Debug, Copy)] +pub struct _bindgen_ty_1 { + /**< lock status 0 = unlocked, 1 = locked */ + pub locked: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::<_bindgen_ty_1>() , 4usize); + assert_eq! (::std::mem::align_of::<_bindgen_ty_1>() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const _bindgen_ty_1 ) ) . locked as * const _ + as usize } , 0usize); +} +impl Clone for _bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +pub type rte_spinlock_t = _bindgen_ty_1; +/** + * Structure storing the table of registered ops structs, each of which contain + * the function pointers for the mempool ops functions. + * Each process has its own storage for this ops struct array so that + * the mempools can be shared across primary and secondary processes. + * The indices used to access the array are valid across processes, whereas + * any function pointers stored directly in the mempool struct would not be. + * This results in us simply having "ops_index" in the mempool struct. + */ +#[repr(C)] +#[derive(Debug, Copy)] +pub struct rte_mempool_ops_table { + /**< Spinlock for add/delete. */ + pub sl: rte_spinlock_t, + /**< Number of used ops structs in the table. */ + pub num_ops: u32, + pub __bindgen_padding_0: [u64; 7usize], + /** + * Storage for all possible ops structs. + */ + pub ops: [rte_mempool_ops; 16usize], +} +#[test] +fn bindgen_test_layout_rte_mempool_ops_table() { + assert_eq!(::std::mem::size_of::() , 2112usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mempool_ops_table ) ) . sl as * const + _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mempool_ops_table ) ) . num_ops as * + const _ as usize } , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mempool_ops_table ) ) . ops as * + const _ as usize } , 64usize); +} +impl Clone for rte_mempool_ops_table { + fn clone(&self) -> Self { *self } +} +/** + * Structure to hold malloc heap + */ +#[repr(C)] +#[derive(Debug, Copy)] +pub struct malloc_heap { + pub lock: rte_spinlock_t, + pub free_head: [malloc_heap__bindgen_ty_1; 13usize], + pub alloc_count: ::std::os::raw::c_uint, + pub total_size: usize, +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct malloc_heap__bindgen_ty_1 { + pub lh_first: *mut malloc_heap__bindgen_ty_1_malloc_elem, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct malloc_heap__bindgen_ty_1_malloc_elem([u8; 0]); +#[test] +fn bindgen_test_layout_malloc_heap__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const malloc_heap__bindgen_ty_1 ) ) . lh_first + as * const _ as usize } , 0usize); +} +impl Clone for malloc_heap__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_malloc_heap() { + assert_eq!(::std::mem::size_of::() , 128usize); + assert_eq! (unsafe { + & ( * ( 0 as * const malloc_heap ) ) . lock as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const malloc_heap ) ) . free_head as * const _ + as usize } , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const malloc_heap ) ) . alloc_count as * const + _ as usize } , 112usize); + assert_eq! (unsafe { + & ( * ( 0 as * const malloc_heap ) ) . total_size as * const _ + as usize } , 120usize); +} +impl Clone for malloc_heap { + fn clone(&self) -> Self { *self } +} diff --git a/tests/expectations/tests/layout_cmdline_token.rs b/tests/expectations/tests/layout_cmdline_token.rs new file mode 100644 index 0000000000..4966b307b6 --- /dev/null +++ b/tests/expectations/tests/layout_cmdline_token.rs @@ -0,0 +1,157 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +/** + * Stores a pointer to the ops struct, and the offset: the place to + * write the parsed result in the destination structure. + */ +#[repr(C)] +#[derive(Debug, Copy)] +pub struct cmdline_token_hdr { + pub ops: *mut cmdline_token_hdr_cmdline_token_ops, + pub offset: ::std::os::raw::c_uint, +} +/** + * A token is defined by this structure. + * + * parse() takes the token as first argument, then the source buffer + * starting at the token we want to parse. The 3rd arg is a pointer + * where we store the parsed data (as binary). It returns the number of + * parsed chars on success and a negative value on error. + * + * complete_get_nb() returns the number of possible values for this + * token if completion is possible. If it is NULL or if it returns 0, + * no completion is possible. + * + * complete_get_elt() copy in dstbuf (the size is specified in the + * parameter) the i-th possible completion for this token. returns 0 + * on success or and a negative value on error. + * + * get_help() fills the dstbuf with the help for the token. It returns + * -1 on error and 0 on success. + */ +#[repr(C)] +#[derive(Debug, Copy)] +pub struct cmdline_token_hdr_cmdline_token_ops { + /** parse(token ptr, buf, res pts, buf len) */ + pub parse: ::std::option::Option ::std::os::raw::c_int>, + /** return the num of possible choices for this token */ + pub complete_get_nb: ::std::option::Option ::std::os::raw::c_int>, + /** return the elt x for this token (token, idx, dstbuf, size) */ + pub complete_get_elt: ::std::option::Option ::std::os::raw::c_int>, + /** get help for this token (token, dstbuf, size) */ + pub get_help: ::std::option::Option ::std::os::raw::c_int>, +} +#[test] +fn bindgen_test_layout_cmdline_token_hdr_cmdline_token_ops() { + assert_eq!(::std::mem::size_of::() , + 32usize); + assert_eq! (::std::mem::align_of::() + , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const cmdline_token_hdr_cmdline_token_ops ) ) . + parse as * const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const cmdline_token_hdr_cmdline_token_ops ) ) . + complete_get_nb as * const _ as usize } , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const cmdline_token_hdr_cmdline_token_ops ) ) . + complete_get_elt as * const _ as usize } , 16usize); + assert_eq! (unsafe { + & ( * ( 0 as * const cmdline_token_hdr_cmdline_token_ops ) ) . + get_help as * const _ as usize } , 24usize); +} +impl Clone for cmdline_token_hdr_cmdline_token_ops { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout_cmdline_token_hdr() { + assert_eq!(::std::mem::size_of::() , 16usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const cmdline_token_hdr ) ) . ops as * const _ + as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const cmdline_token_hdr ) ) . offset as * const + _ as usize } , 8usize); +} +impl Clone for cmdline_token_hdr { + fn clone(&self) -> Self { *self } +} +pub type cmdline_parse_token_hdr_t = cmdline_token_hdr; +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum cmdline_numtype { + UINT8 = 0, + UINT16 = 1, + UINT32 = 2, + UINT64 = 3, + INT8 = 4, + INT16 = 5, + INT32 = 6, + INT64 = 7, +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct cmdline_token_num_data { + pub type_: cmdline_numtype, +} +#[test] +fn bindgen_test_layout_cmdline_token_num_data() { + assert_eq!(::std::mem::size_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const cmdline_token_num_data ) ) . type_ as * + const _ as usize } , 0usize); +} +impl Clone for cmdline_token_num_data { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct cmdline_token_num { + pub hdr: cmdline_token_hdr, + pub num_data: cmdline_token_num_data, +} +#[test] +fn bindgen_test_layout_cmdline_token_num() { + assert_eq!(::std::mem::size_of::() , 24usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const cmdline_token_num ) ) . hdr as * const _ + as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const cmdline_token_num ) ) . num_data as * + const _ as usize } , 16usize); +} +impl Clone for cmdline_token_num { + fn clone(&self) -> Self { *self } +} +pub type cmdline_parse_token_num_t = cmdline_token_num; diff --git a/tests/expectations/tests/layout_eth_conf.rs b/tests/expectations/tests/layout_eth_conf.rs new file mode 100644 index 0000000000..70d050b00d --- /dev/null +++ b/tests/expectations/tests/layout_eth_conf.rs @@ -0,0 +1,1039 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[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") + } +} +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)] +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: u16, +} +#[test] +fn bindgen_test_layout_rte_eth_rxmode() { + assert_eq!(::std::mem::size_of::() , 12usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_rxmode ) ) . mq_mode as * const _ + as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_rxmode ) ) . max_rx_pkt_len as * + const _ as usize } , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_rxmode ) ) . split_hdr_size as * + const _ as usize } , 8usize); +} +impl Clone for rte_eth_rxmode { + fn clone(&self) -> Self { *self } +} +impl rte_eth_rxmode { + #[inline] + pub fn header_split(&self) -> u16 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (1usize as u16)) >> + 0u32) as u16) + } + } + #[inline] + pub fn set_header_split(&mut self, val: u16) { + self._bitfield_1 &= !(1usize as u16); + self._bitfield_1 |= ((val as u16 as u16) << 0u32) & (1usize as u16); + } + #[inline] + pub fn hw_ip_checksum(&self) -> u16 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (2usize as u16)) >> + 1u32) as u16) + } + } + #[inline] + pub fn set_hw_ip_checksum(&mut self, val: u16) { + self._bitfield_1 &= !(2usize as u16); + self._bitfield_1 |= ((val as u16 as u16) << 1u32) & (2usize as u16); + } + #[inline] + pub fn hw_vlan_filter(&self) -> u16 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (4usize as u16)) >> + 2u32) as u16) + } + } + #[inline] + pub fn set_hw_vlan_filter(&mut self, val: u16) { + self._bitfield_1 &= !(4usize as u16); + self._bitfield_1 |= ((val as u16 as u16) << 2u32) & (4usize as u16); + } + #[inline] + pub fn hw_vlan_strip(&self) -> u16 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (8usize as u16)) >> + 3u32) as u16) + } + } + #[inline] + pub fn set_hw_vlan_strip(&mut self, val: u16) { + self._bitfield_1 &= !(8usize as u16); + self._bitfield_1 |= ((val as u16 as u16) << 3u32) & (8usize as u16); + } + #[inline] + pub fn hw_vlan_extend(&self) -> u16 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (16usize as u16)) >> + 4u32) as u16) + } + } + #[inline] + pub fn set_hw_vlan_extend(&mut self, val: u16) { + self._bitfield_1 &= !(16usize as u16); + self._bitfield_1 |= ((val as u16 as u16) << 4u32) & (16usize as u16); + } + #[inline] + pub fn jumbo_frame(&self) -> u16 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (32usize as u16)) >> + 5u32) as u16) + } + } + #[inline] + pub fn set_jumbo_frame(&mut self, val: u16) { + self._bitfield_1 &= !(32usize as u16); + self._bitfield_1 |= ((val as u16 as u16) << 5u32) & (32usize as u16); + } + #[inline] + pub fn hw_strip_crc(&self) -> u16 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (64usize as u16)) >> + 6u32) as u16) + } + } + #[inline] + pub fn set_hw_strip_crc(&mut self, val: u16) { + self._bitfield_1 &= !(64usize as u16); + self._bitfield_1 |= ((val as u16 as u16) << 6u32) & (64usize as u16); + } + #[inline] + pub fn enable_scatter(&self) -> u16 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (128usize as u16)) >> + 7u32) as u16) + } + } + #[inline] + pub fn set_enable_scatter(&mut self, val: u16) { + self._bitfield_1 &= !(128usize as u16); + self._bitfield_1 |= ((val as u16 as u16) << 7u32) & (128usize as u16); + } + #[inline] + pub fn enable_lro(&self) -> u16 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (256usize as u16)) >> + 8u32) as u16) + } + } + #[inline] + pub fn set_enable_lro(&mut self, val: u16) { + self._bitfield_1 &= !(256usize as u16); + self._bitfield_1 |= ((val as u16 as u16) << 8u32) & (256usize 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)] +pub struct rte_eth_txmode { + /**< TX multi-queues mode. */ + pub mq_mode: rte_eth_tx_mq_mode, + pub pvid: u16, + pub _bitfield_1: u8, +} +#[test] +fn bindgen_test_layout_rte_eth_txmode() { + assert_eq!(::std::mem::size_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_txmode ) ) . mq_mode as * const _ + as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_txmode ) ) . pvid as * const _ as + usize } , 4usize); +} +impl Clone for rte_eth_txmode { + fn clone(&self) -> Self { *self } +} +impl rte_eth_txmode { + #[inline] + pub fn hw_vlan_reject_tagged(&self) -> u8 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (1usize as u8)) >> + 0u32) as u8) + } + } + #[inline] + pub fn set_hw_vlan_reject_tagged(&mut self, val: u8) { + self._bitfield_1 &= !(1usize as u8); + self._bitfield_1 |= ((val as u8 as u8) << 0u32) & (1usize as u8); + } + #[inline] + pub fn hw_vlan_reject_untagged(&self) -> u8 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (2usize as u8)) >> + 1u32) as u8) + } + } + #[inline] + pub fn set_hw_vlan_reject_untagged(&mut self, val: u8) { + self._bitfield_1 &= !(2usize as u8); + self._bitfield_1 |= ((val as u8 as u8) << 1u32) & (2usize as u8); + } + #[inline] + pub fn hw_vlan_insert_pvid(&self) -> u8 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (4usize as u8)) >> + 2u32) as u8) + } + } + #[inline] + pub fn set_hw_vlan_insert_pvid(&mut self, val: u8) { + self._bitfield_1 &= !(4usize as u8); + self._bitfield_1 |= ((val as u8 as u8) << 2u32) & (4usize 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)] +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); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_rss_conf ) ) . rss_key as * const + _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_rss_conf ) ) . rss_key_len as * + const _ as usize } , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_rss_conf ) ) . rss_hf as * const + _ as usize } , 16usize); +} +impl Clone for rte_eth_rss_conf { + fn clone(&self) -> Self { *self } +} +#[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)] +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, Copy)] +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); + assert_eq! (::std::mem::align_of::() + , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_conf__bindgen_ty_1 ) ) . + vlan_id as * const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_conf__bindgen_ty_1 ) ) . + pools as * const _ as usize } , 8usize); +} +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); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_conf ) ) . + nb_queue_pools as * const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_conf ) ) . + enable_default_pool as * const _ as usize } , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_conf ) ) . default_pool + as * const _ as usize } , 5usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_conf ) ) . nb_pool_maps + as * const _ as usize } , 6usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_conf ) ) . pool_map as * + const _ as usize } , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_conf ) ) . dcb_tc as * + const _ as usize } , 1032usize); +} +#[repr(C)] +#[derive(Debug, Copy)] +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); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_dcb_rx_conf ) ) . nb_tcs as * + const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_dcb_rx_conf ) ) . dcb_tc as * + const _ as usize } , 4usize); +} +impl Clone for rte_eth_dcb_rx_conf { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Copy)] +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); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_tx_conf ) ) . + nb_queue_pools as * const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_tx_conf ) ) . dcb_tc as + * const _ as usize } , 4usize); +} +impl Clone for rte_eth_vmdq_dcb_tx_conf { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Copy)] +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); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_dcb_tx_conf ) ) . nb_tcs as * + const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_dcb_tx_conf ) ) . dcb_tc as * + const _ as usize } , 4usize); +} +impl Clone for rte_eth_dcb_tx_conf { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Copy)] +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); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_tx_conf ) ) . nb_queue_pools + as * const _ as usize } , 0usize); +} +impl Clone for rte_eth_vmdq_tx_conf { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +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, Copy)] +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); + assert_eq! (::std::mem::align_of::() , + 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_rx_conf__bindgen_ty_1 ) ) . + vlan_id as * const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_rx_conf__bindgen_ty_1 ) ) . + pools as * const _ as usize } , 8usize); +} +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); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_rx_conf ) ) . nb_queue_pools + as * const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_rx_conf ) ) . + enable_default_pool as * const _ as usize } , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_rx_conf ) ) . default_pool + as * const _ as usize } , 5usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_rx_conf ) ) . + enable_loop_back as * const _ as usize } , 6usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_rx_conf ) ) . nb_pool_maps + as * const _ as usize } , 7usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_rx_conf ) ) . rx_mode as * + const _ as usize } , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_rx_conf ) ) . pool_map as * + const _ as usize } , 16usize); +} +#[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, Copy)] +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); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv4_flow ) ) . src_ip as * const + _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv4_flow ) ) . dst_ip as * const + _ as usize } , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv4_flow ) ) . tos as * const _ + as usize } , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv4_flow ) ) . ttl as * const _ + as usize } , 9usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv4_flow ) ) . proto as * const + _ as usize } , 10usize); +} +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, Copy)] +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); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv6_flow ) ) . src_ip as * const + _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv6_flow ) ) . dst_ip as * const + _ as usize } , 16usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv6_flow ) ) . tc as * const _ + as usize } , 32usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv6_flow ) ) . proto as * const + _ as usize } , 33usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv6_flow ) ) . hop_limits as * + const _ as usize } , 34usize); +} +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, Copy)] +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); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_masks ) ) . vlan_tci_mask as + * const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_masks ) ) . ipv4_mask as * + const _ as usize } , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_masks ) ) . ipv6_mask as * + const _ as usize } , 16usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_masks ) ) . src_port_mask as + * const _ as usize } , 52usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_masks ) ) . dst_port_mask as + * const _ as usize } , 54usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_masks ) ) . + mac_addr_byte_mask as * const _ as usize } , 56usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_masks ) ) . tunnel_id_mask + as * const _ as usize } , 60usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_masks ) ) . tunnel_type_mask + as * const _ as usize } , 64usize); +} +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)] +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); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_flex_payload_cfg ) ) . type_ as * + const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_flex_payload_cfg ) ) . src_offset + as * const _ as usize } , 4usize); +} +impl Clone for rte_eth_flex_payload_cfg { + fn clone(&self) -> Self { *self } +} +/** + * A structure used to define FDIR masks for flexible payload + * for each flow type + */ +#[repr(C)] +#[derive(Debug, Copy)] +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); + assert_eq! (::std::mem::align_of::() , 2usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_flex_mask ) ) . flow_type as + * const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_flex_mask ) ) . mask as * + const _ as usize } , 2usize); +} +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)] +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); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_flex_conf ) ) . nb_payloads + as * const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_flex_conf ) ) . nb_flexmasks + as * const _ as usize } , 2usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_flex_conf ) ) . flex_set as + * const _ as usize } , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_flex_conf ) ) . flex_mask as + * const _ as usize } , 292usize); +} +impl Clone for rte_eth_fdir_flex_conf { + fn clone(&self) -> Self { *self } +} +/** + * 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)] +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); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_fdir_conf ) ) . mode as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_fdir_conf ) ) . pballoc as * const _ + as usize } , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_fdir_conf ) ) . status as * const _ + as usize } , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_fdir_conf ) ) . drop_queue as * const + _ as usize } , 12usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_fdir_conf ) ) . mask as * const _ as + usize } , 16usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_fdir_conf ) ) . flex_conf as * const + _ as usize } , 84usize); +} +impl Clone for rte_fdir_conf { + fn clone(&self) -> Self { *self } +} +/** + * A structure used to enable/disable specific device interrupts. + */ +#[repr(C)] +#[derive(Debug, Copy)] +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); + assert_eq! (::std::mem::align_of::() , 2usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_intr_conf ) ) . lsc as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_intr_conf ) ) . rxq as * const _ as + usize } , 2usize); +} +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)] +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)] +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); + assert_eq! (::std::mem::align_of::() , + 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf__bindgen_ty_1 ) ) . rss_conf + as * const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf__bindgen_ty_1 ) ) . + vmdq_dcb_conf as * const _ as usize } , 24usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf__bindgen_ty_1 ) ) . + dcb_rx_conf as * const _ as usize } , 1064usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf__bindgen_ty_1 ) ) . + vmdq_rx_conf as * const _ as usize } , 1080usize); +} +#[repr(C)] +#[derive(Debug, Copy)] +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); + assert_eq! (::std::mem::align_of::() , + 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf__bindgen_ty_2 ) ) . + vmdq_dcb_tx_conf as * const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf__bindgen_ty_2 ) ) . + dcb_tx_conf as * const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf__bindgen_ty_2 ) ) . + vmdq_tx_conf as * const _ as usize } , 0usize); +} +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); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf ) ) . link_speeds as * const + _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf ) ) . rxmode as * const _ as + usize } , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf ) ) . txmode as * const _ as + usize } , 16usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf ) ) . lpbk_mode as * const _ + as usize } , 24usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf ) ) . rx_adv_conf as * const + _ as usize } , 32usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf ) ) . tx_adv_conf as * const + _ as usize } , 2152usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf ) ) . dcb_capability_en as * + const _ as usize } , 2164usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf ) ) . fdir_conf as * const _ + as usize } , 2168usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf ) ) . intr_conf as * const _ + as usize } , 2940usize); +} diff --git a/tests/expectations/tests/layout_kni_mbuf.rs b/tests/expectations/tests/layout_kni_mbuf.rs new file mode 100644 index 0000000000..bdaf0845e9 --- /dev/null +++ b/tests/expectations/tests/layout_kni_mbuf.rs @@ -0,0 +1,82 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +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; +#[repr(C)] +#[derive(Debug, Copy)] +pub struct rte_kni_mbuf { + pub buf_addr: *mut ::std::os::raw::c_void, + pub buf_physaddr: u64, + pub pad0: [::std::os::raw::c_char; 2usize], + /**< Start address of data in segment buffer. */ + pub data_off: u16, + pub pad1: [::std::os::raw::c_char; 2usize], + /**< Number of segments. */ + pub nb_segs: u8, + pub pad4: [::std::os::raw::c_char; 1usize], + /**< Offload features. */ + pub ol_flags: u64, + pub pad2: [::std::os::raw::c_char; 4usize], + /**< Total pkt len: sum of all segment data_len. */ + pub pkt_len: u32, + /**< Amount of data in segment buffer. */ + pub data_len: u16, + pub __bindgen_padding_0: [u8; 22usize], + pub pad3: [::std::os::raw::c_char; 8usize], + pub pool: *mut ::std::os::raw::c_void, + pub next: *mut ::std::os::raw::c_void, + pub __bindgen_padding_1: [u64; 5usize], +} +#[test] +fn bindgen_test_layout_rte_kni_mbuf() { + assert_eq!(::std::mem::size_of::() , 128usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_kni_mbuf ) ) . buf_addr as * const _ + as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_kni_mbuf ) ) . buf_physaddr as * + const _ as usize } , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_kni_mbuf ) ) . pad0 as * const _ as + usize } , 16usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_kni_mbuf ) ) . data_off as * const _ + as usize } , 18usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_kni_mbuf ) ) . pad1 as * const _ as + usize } , 20usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_kni_mbuf ) ) . nb_segs as * const _ + as usize } , 22usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_kni_mbuf ) ) . pad4 as * const _ as + usize } , 23usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_kni_mbuf ) ) . ol_flags as * const _ + as usize } , 24usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_kni_mbuf ) ) . pad2 as * const _ as + usize } , 32usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_kni_mbuf ) ) . pkt_len as * const _ + as usize } , 36usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_kni_mbuf ) ) . data_len as * const _ + as usize } , 40usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_kni_mbuf ) ) . pad3 as * const _ as + usize } , 64usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_kni_mbuf ) ) . pool as * const _ as + usize } , 72usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_kni_mbuf ) ) . next as * const _ as + usize } , 80usize); +} +impl Clone for rte_kni_mbuf { + fn clone(&self) -> Self { *self } +} diff --git a/tests/expectations/tests/layout_mbuf.rs b/tests/expectations/tests/layout_mbuf.rs new file mode 100644 index 0000000000..163a62ec18 --- /dev/null +++ b/tests/expectations/tests/layout_mbuf.rs @@ -0,0 +1,602 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[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") + } +} +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, Copy)] +pub struct _bindgen_ty_1 { + /**< An internal counter value. */ + pub cnt: i16, +} +#[test] +fn bindgen_test_layout__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::<_bindgen_ty_1>() , 2usize); + assert_eq! (::std::mem::align_of::<_bindgen_ty_1>() , 2usize); + assert_eq! (unsafe { + & ( * ( 0 as * const _bindgen_ty_1 ) ) . cnt as * const _ as + usize } , 0usize); +} +impl Clone for _bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +pub type rte_atomic16_t = _bindgen_ty_1; +/** + * The generic rte_mbuf, containing a packet mbuf. + */ +#[repr(C)] +#[derive(Debug, Copy)] +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_mbuf_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, Copy)] +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); + assert_eq! (::std::mem::align_of::() , 2usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_1 ) ) . + refcnt_atomic as * const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_1 ) ) . refcnt as * + const _ as usize } , 0usize); +} +impl Clone for rte_mbuf__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Copy)] +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, Copy)] +pub struct rte_mbuf__bindgen_ty_2__bindgen_ty_1 { + pub _bitfield_1: u32, +} +#[test] +fn bindgen_test_layout_rte_mbuf__bindgen_ty_2__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , + 4usize); + assert_eq! (::std::mem::align_of::() + , 4usize); +} +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 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (15usize as u32)) >> + 0u32) as u32) + } + } + #[inline] + pub fn set_l2_type(&mut self, val: u32) { + self._bitfield_1 &= !(15usize as u32); + self._bitfield_1 |= ((val as u32 as u32) << 0u32) & (15usize as u32); + } + #[inline] + pub fn l3_type(&self) -> u32 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (240usize as u32)) >> + 4u32) as u32) + } + } + #[inline] + pub fn set_l3_type(&mut self, val: u32) { + self._bitfield_1 &= !(240usize as u32); + self._bitfield_1 |= ((val as u32 as u32) << 4u32) & (240usize as u32); + } + #[inline] + pub fn l4_type(&self) -> u32 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (3840usize as u32)) >> + 8u32) as u32) + } + } + #[inline] + pub fn set_l4_type(&mut self, val: u32) { + self._bitfield_1 &= !(3840usize as u32); + self._bitfield_1 |= + ((val as u32 as u32) << 8u32) & (3840usize as u32); + } + #[inline] + pub fn tun_type(&self) -> u32 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (61440usize as u32)) >> + 12u32) as u32) + } + } + #[inline] + pub fn set_tun_type(&mut self, val: u32) { + self._bitfield_1 &= !(61440usize as u32); + self._bitfield_1 |= + ((val as u32 as u32) << 12u32) & (61440usize as u32); + } + #[inline] + pub fn inner_l2_type(&self) -> u32 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (983040usize as u32)) + >> 16u32) as u32) + } + } + #[inline] + pub fn set_inner_l2_type(&mut self, val: u32) { + self._bitfield_1 &= !(983040usize as u32); + self._bitfield_1 |= + ((val as u32 as u32) << 16u32) & (983040usize as u32); + } + #[inline] + pub fn inner_l3_type(&self) -> u32 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (15728640usize as u32)) + >> 20u32) as u32) + } + } + #[inline] + pub fn set_inner_l3_type(&mut self, val: u32) { + self._bitfield_1 &= !(15728640usize as u32); + self._bitfield_1 |= + ((val as u32 as u32) << 20u32) & (15728640usize as u32); + } + #[inline] + pub fn inner_l4_type(&self) -> u32 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & + (251658240usize as u32)) >> 24u32) as + u32) + } + } + #[inline] + pub fn set_inner_l4_type(&mut self, val: u32) { + self._bitfield_1 &= !(251658240usize as u32); + self._bitfield_1 |= + ((val as u32 as u32) << 24u32) & (251658240usize as u32); + } +} +#[test] +fn bindgen_test_layout_rte_mbuf__bindgen_ty_2() { + assert_eq!(::std::mem::size_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_2 ) ) . packet_type + as * const _ as usize } , 0usize); +} +impl Clone for rte_mbuf__bindgen_ty_2 { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Copy)] +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, 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, Copy)] +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, Copy)] +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); + assert_eq! (::std::mem::align_of::() + , 2usize); + 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); + 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); +} +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); + assert_eq! (::std::mem::align_of::() + , 4usize); + assert_eq! (unsafe { + & ( + * ( + 0 as * const + rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 ) ) . lo as + * const _ as usize } , 0usize); +} +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); + assert_eq! (::std::mem::align_of::() + , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_3__bindgen_ty_1 ) ) + . hi as * const _ as usize } , 4usize); +} +impl Clone for rte_mbuf__bindgen_ty_3__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Copy)] +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); + assert_eq! (::std::mem::align_of::() + , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_3__bindgen_ty_2 ) ) + . lo as * const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_3__bindgen_ty_2 ) ) + . hi as * const _ as usize } , 4usize); +} +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); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_3 ) ) . rss as * + const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_3 ) ) . fdir as * + const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_3 ) ) . sched as * + const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_3 ) ) . usr as * + const _ as usize } , 0usize); +} +impl Clone for rte_mbuf__bindgen_ty_3 { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Copy)] +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); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_4 ) ) . userdata as + * const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_4 ) ) . udata64 as * + const _ as usize } , 0usize); +} +impl Clone for rte_mbuf__bindgen_ty_4 { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct rte_mbuf_rte_mempool([u8; 0]); +#[repr(C)] +#[derive(Debug, Copy)] +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, Copy)] +pub struct rte_mbuf__bindgen_ty_5__bindgen_ty_1 { + pub _bitfield_1: u64, +} +#[test] +fn bindgen_test_layout_rte_mbuf__bindgen_ty_5__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , + 8usize); + assert_eq! (::std::mem::align_of::() + , 8usize); +} +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 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (127usize as u64)) >> + 0u32) as u64) + } + } + #[inline] + pub fn set_l2_len(&mut self, val: u64) { + self._bitfield_1 &= !(127usize as u64); + self._bitfield_1 |= ((val as u64 as u64) << 0u32) & (127usize as u64); + } + #[inline] + pub fn l3_len(&self) -> u64 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (65408usize as u64)) >> + 7u32) as u64) + } + } + #[inline] + pub fn set_l3_len(&mut self, val: u64) { + self._bitfield_1 &= !(65408usize as u64); + self._bitfield_1 |= + ((val as u64 as u64) << 7u32) & (65408usize as u64); + } + #[inline] + pub fn l4_len(&self) -> u64 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & (16711680usize as u64)) + >> 16u32) as u64) + } + } + #[inline] + pub fn set_l4_len(&mut self, val: u64) { + self._bitfield_1 &= !(16711680usize as u64); + self._bitfield_1 |= + ((val as u64 as u64) << 16u32) & (16711680usize as u64); + } + #[inline] + pub fn tso_segsz(&self) -> u64 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & + (1099494850560usize as u64)) >> 24u32) + as u64) + } + } + #[inline] + pub fn set_tso_segsz(&mut self, val: u64) { + self._bitfield_1 &= !(1099494850560usize as u64); + self._bitfield_1 |= + ((val as u64 as u64) << 24u32) & (1099494850560usize as u64); + } + #[inline] + pub fn outer_l3_len(&self) -> u64 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & + (561850441793536usize as u64)) >> + 40u32) as u64) + } + } + #[inline] + pub fn set_outer_l3_len(&mut self, val: u64) { + self._bitfield_1 &= !(561850441793536usize as u64); + self._bitfield_1 |= + ((val as u64 as u64) << 40u32) & (561850441793536usize as u64); + } + #[inline] + pub fn outer_l2_len(&self) -> u64 { + unsafe { + ::std::mem::transmute(((self._bitfield_1 & + (71494644084506624usize as u64)) >> + 49u32) as u64) + } + } + #[inline] + pub fn set_outer_l2_len(&mut self, val: u64) { + self._bitfield_1 &= !(71494644084506624usize as u64); + self._bitfield_1 |= + ((val as u64 as u64) << 49u32) & (71494644084506624usize as u64); + } +} +#[test] +fn bindgen_test_layout_rte_mbuf__bindgen_ty_5() { + assert_eq!(::std::mem::size_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_5 ) ) . tx_offload + as * const _ as usize } , 0usize); +} +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); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . cacheline0 as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . buf_addr as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . buf_physaddr as * const _ + as usize } , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . buf_len as * const _ as + usize } , 16usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . rearm_data as * const _ as + usize } , 18usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . data_off as * const _ as + usize } , 18usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . nb_segs as * const _ as + usize } , 22usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . port as * const _ as usize + } , 23usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . ol_flags as * const _ as + usize } , 24usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . rx_descriptor_fields1 as * + const _ as usize } , 32usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . pkt_len as * const _ as + usize } , 36usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . data_len as * const _ as + usize } , 40usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . vlan_tci as * const _ as + usize } , 42usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . hash as * const _ as usize + } , 44usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . seqn as * const _ as usize + } , 52usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . vlan_tci_outer as * const + _ as usize } , 56usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . cacheline1 as * const _ as + usize } , 64usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . pool as * const _ as usize + } , 72usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . next as * const _ as usize + } , 80usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . priv_size as * const _ as + usize } , 96usize); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . timesync as * const _ as + usize } , 98usize); +} +impl Clone for rte_mbuf { + fn clone(&self) -> Self { *self } +} diff --git a/tests/expectations/tests/method-mangling.rs b/tests/expectations/tests/method-mangling.rs index 3b5107a8f8..99a6e9b896 100644 --- a/tests/expectations/tests/method-mangling.rs +++ b/tests/expectations/tests/method-mangling.rs @@ -12,7 +12,7 @@ pub struct Foo { #[test] fn bindgen_test_layout_Foo() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } extern "C" { #[link_name = "_ZN3Foo4typeEv"] diff --git a/tests/expectations/tests/module-whitelisted.rs b/tests/expectations/tests/module-whitelisted.rs index 6f88c54b1d..9cf4b05103 100644 --- a/tests/expectations/tests/module-whitelisted.rs +++ b/tests/expectations/tests/module-whitelisted.rs @@ -15,7 +15,7 @@ pub mod root { #[test] fn bindgen_test_layout_Test() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } impl Clone for Test { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/msvc-no-usr.rs b/tests/expectations/tests/msvc-no-usr.rs index 8cab8cdc2f..e2f9a31913 100644 --- a/tests/expectations/tests/msvc-no-usr.rs +++ b/tests/expectations/tests/msvc-no-usr.rs @@ -12,7 +12,10 @@ pub struct A { #[test] fn bindgen_test_layout_A() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const A ) ) . foo as * const _ as usize } , + 0usize); } impl Clone for A { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/multiple-inherit-empty-correct-layout.rs b/tests/expectations/tests/multiple-inherit-empty-correct-layout.rs index 5e9cf5224c..45537eefa5 100644 --- a/tests/expectations/tests/multiple-inherit-empty-correct-layout.rs +++ b/tests/expectations/tests/multiple-inherit-empty-correct-layout.rs @@ -12,7 +12,7 @@ pub struct Foo { #[test] fn bindgen_test_layout_Foo() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } impl Clone for Foo { fn clone(&self) -> Self { *self } @@ -25,7 +25,7 @@ pub struct Bar { #[test] fn bindgen_test_layout_Bar() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } impl Clone for Bar { fn clone(&self) -> Self { *self } @@ -38,7 +38,7 @@ pub struct Baz { #[test] fn bindgen_test_layout_Baz() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } impl Clone for Baz { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/mutable.rs b/tests/expectations/tests/mutable.rs index 0d0d6ea341..01ef8e8b84 100644 --- a/tests/expectations/tests/mutable.rs +++ b/tests/expectations/tests/mutable.rs @@ -13,7 +13,13 @@ pub struct C { #[test] fn bindgen_test_layout_C() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const C ) ) . m_member as * const _ as usize } + , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const C ) ) . m_other as * const _ as usize } , + 4usize); } impl Clone for C { fn clone(&self) -> Self { *self } @@ -26,7 +32,10 @@ pub struct NonCopiable { #[test] fn bindgen_test_layout_NonCopiable() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const NonCopiable ) ) . m_member as * const _ + as usize } , 0usize); } #[repr(C)] #[derive(Debug)] @@ -37,6 +46,9 @@ pub struct NonCopiableWithNonCopiableMutableMember { fn bindgen_test_layout_NonCopiableWithNonCopiableMutableMember() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() - , 4usize); + assert_eq! (::std::mem::align_of::() + , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const NonCopiableWithNonCopiableMutableMember ) + ) . m_member as * const _ as usize } , 0usize); } diff --git a/tests/expectations/tests/namespace.rs b/tests/expectations/tests/namespace.rs index ece4e3412e..4958b51996 100644 --- a/tests/expectations/tests/namespace.rs +++ b/tests/expectations/tests/namespace.rs @@ -35,7 +35,10 @@ pub mod root { #[test] fn bindgen_test_layout_A() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const A ) ) . b as * const _ as usize } + , 0usize); } extern "C" { #[link_name = "_ZN12_GLOBAL__N_11A20lets_hope_this_worksEv"] diff --git a/tests/expectations/tests/nested.rs b/tests/expectations/tests/nested.rs index fdd435aaba..5b9ce5a65e 100644 --- a/tests/expectations/tests/nested.rs +++ b/tests/expectations/tests/nested.rs @@ -12,7 +12,10 @@ pub struct Calc { #[test] fn bindgen_test_layout_Calc() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Calc ) ) . w as * const _ as usize } , + 0usize); } impl Clone for Calc { fn clone(&self) -> Self { *self } @@ -36,7 +39,7 @@ pub struct Test_Size_Dimension { #[test] fn bindgen_test_layout_Test_Size_Dimension() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); } impl Clone for Test_Size_Dimension { fn clone(&self) -> Self { *self } @@ -44,7 +47,13 @@ impl Clone for Test_Size_Dimension { #[test] fn bindgen_test_layout_Test_Size() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Test_Size ) ) . mWidth as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Test_Size ) ) . mHeight as * const _ as + usize } , 4usize); } impl Clone for Test_Size { fn clone(&self) -> Self { *self } @@ -52,7 +61,7 @@ impl Clone for Test_Size { #[test] fn bindgen_test_layout_Test() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } impl Clone for Test { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/nested_vtable.rs b/tests/expectations/tests/nested_vtable.rs index d74ad55f36..e0d81d187a 100644 --- a/tests/expectations/tests/nested_vtable.rs +++ b/tests/expectations/tests/nested_vtable.rs @@ -15,7 +15,7 @@ pub struct nsISupports { #[test] fn bindgen_test_layout_nsISupports() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); } impl Clone for nsISupports { fn clone(&self) -> Self { *self } @@ -28,7 +28,7 @@ pub struct nsIRunnable { #[test] fn bindgen_test_layout_nsIRunnable() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); } impl Clone for nsIRunnable { fn clone(&self) -> Self { *self } @@ -41,7 +41,7 @@ pub struct Runnable { #[test] fn bindgen_test_layout_Runnable() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); } impl Clone for Runnable { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/nested_within_namespace.rs b/tests/expectations/tests/nested_within_namespace.rs index 0c9c31ef74..355ab100da 100644 --- a/tests/expectations/tests/nested_within_namespace.rs +++ b/tests/expectations/tests/nested_within_namespace.rs @@ -23,7 +23,10 @@ pub mod root { #[test] fn bindgen_test_layout_Bar_Baz() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Bar_Baz ) ) . foo as * const _ as + usize } , 0usize); } impl Clone for Bar_Baz { fn clone(&self) -> Self { *self } @@ -31,7 +34,10 @@ pub mod root { #[test] fn bindgen_test_layout_Bar() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Bar ) ) . foo as * const _ as + usize } , 0usize); } impl Clone for Bar { fn clone(&self) -> Self { *self } @@ -44,7 +50,10 @@ pub mod root { #[test] fn bindgen_test_layout_Baz() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Baz ) ) . baz as * const _ as + usize } , 0usize); } impl Clone for Baz { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/no-comments.rs b/tests/expectations/tests/no-comments.rs index 8a4371e7a1..947ed5908e 100644 --- a/tests/expectations/tests/no-comments.rs +++ b/tests/expectations/tests/no-comments.rs @@ -12,7 +12,10 @@ pub struct Foo { #[test] fn bindgen_test_layout_Foo() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Foo ) ) . s as * const _ as usize } , + 0usize); } impl Clone for Foo { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/no-derive-debug.rs b/tests/expectations/tests/no-derive-debug.rs index e45b267823..9c35f78e23 100644 --- a/tests/expectations/tests/no-derive-debug.rs +++ b/tests/expectations/tests/no-derive-debug.rs @@ -19,7 +19,13 @@ pub struct bar { #[test] fn bindgen_test_layout_bar() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const bar ) ) . foo as * const _ as usize } , + 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const bar ) ) . baz as * const _ as usize } , + 4usize); } impl Clone for bar { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/no-recursive-whitelisting.rs b/tests/expectations/tests/no-recursive-whitelisting.rs index 5bc2166503..249090195b 100644 --- a/tests/expectations/tests/no-recursive-whitelisting.rs +++ b/tests/expectations/tests/no-recursive-whitelisting.rs @@ -13,7 +13,10 @@ pub struct Foo { #[test] fn bindgen_test_layout_Foo() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Foo ) ) . baz as * const _ as usize } , + 0usize); } impl Clone for Foo { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/no-std.rs b/tests/expectations/tests/no-std.rs index f50a889d4c..110255ad9a 100644 --- a/tests/expectations/tests/no-std.rs +++ b/tests/expectations/tests/no-std.rs @@ -16,7 +16,16 @@ pub struct foo { #[test] fn bindgen_test_layout_foo() { assert_eq!(::core::mem::size_of::() , 16usize); - assert_eq!(::core::mem::align_of::() , 8usize); + assert_eq! (::core::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , + 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . b as * const _ as usize } , + 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , + 8usize); } impl Clone for foo { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/objc_interface_type.rs b/tests/expectations/tests/objc_interface_type.rs index 2d68ee5078..1730f824b2 100644 --- a/tests/expectations/tests/objc_interface_type.rs +++ b/tests/expectations/tests/objc_interface_type.rs @@ -19,7 +19,10 @@ pub struct FooStruct { #[test] fn bindgen_test_layout_FooStruct() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const FooStruct ) ) . foo as * const _ as usize + } , 0usize); } impl Clone for FooStruct { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/only_bitfields.rs b/tests/expectations/tests/only_bitfields.rs index 68968826b1..97363a8725 100644 --- a/tests/expectations/tests/only_bitfields.rs +++ b/tests/expectations/tests/only_bitfields.rs @@ -12,7 +12,7 @@ pub struct C { #[test] fn bindgen_test_layout_C() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } impl Clone for C { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/opaque-tracing.rs b/tests/expectations/tests/opaque-tracing.rs index 7dcc4eefaa..86e01665f8 100644 --- a/tests/expectations/tests/opaque-tracing.rs +++ b/tests/expectations/tests/opaque-tracing.rs @@ -12,7 +12,7 @@ pub struct Container { #[test] fn bindgen_test_layout_Container() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); } impl Clone for Container { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/opaque_in_struct.rs b/tests/expectations/tests/opaque_in_struct.rs index c94caa1fc5..427692fdc4 100644 --- a/tests/expectations/tests/opaque_in_struct.rs +++ b/tests/expectations/tests/opaque_in_struct.rs @@ -13,7 +13,7 @@ pub struct opaque { #[test] fn bindgen_test_layout_opaque() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); } impl Clone for opaque { fn clone(&self) -> Self { *self } @@ -26,7 +26,10 @@ pub struct container { #[test] fn bindgen_test_layout_container() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const container ) ) . contained as * const _ as + usize } , 0usize); } impl Clone for container { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/opaque_pointer.rs b/tests/expectations/tests/opaque_pointer.rs index 118a1782b1..0dee14df25 100644 --- a/tests/expectations/tests/opaque_pointer.rs +++ b/tests/expectations/tests/opaque_pointer.rs @@ -15,7 +15,7 @@ pub struct OtherOpaque { #[test] fn bindgen_test_layout_OtherOpaque() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); } impl Clone for OtherOpaque { fn clone(&self) -> Self { *self } @@ -38,7 +38,16 @@ pub struct WithOpaquePtr { #[test] fn bindgen_test_layout_WithOpaquePtr() { assert_eq!(::std::mem::size_of::() , 16usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const WithOpaquePtr ) ) . whatever as * const _ + as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const WithOpaquePtr ) ) . other as * const _ as + usize } , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const WithOpaquePtr ) ) . t as * const _ as + usize } , 12usize); } impl Clone for WithOpaquePtr { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/private.rs b/tests/expectations/tests/private.rs index c4ac37d171..1379aa616b 100644 --- a/tests/expectations/tests/private.rs +++ b/tests/expectations/tests/private.rs @@ -14,7 +14,13 @@ pub struct HasPrivate { #[test] fn bindgen_test_layout_HasPrivate() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const HasPrivate ) ) . mNotPrivate as * const _ + as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const HasPrivate ) ) . mIsPrivate as * const _ + as usize } , 4usize); } impl Clone for HasPrivate { fn clone(&self) -> Self { *self } @@ -29,7 +35,13 @@ pub struct VeryPrivate { #[test] fn bindgen_test_layout_VeryPrivate() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const VeryPrivate ) ) . mIsPrivate as * const _ + as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const VeryPrivate ) ) . mIsAlsoPrivate as * + const _ as usize } , 4usize); } impl Clone for VeryPrivate { fn clone(&self) -> Self { *self } @@ -45,7 +57,13 @@ pub struct ContradictPrivate { #[test] fn bindgen_test_layout_ContradictPrivate() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const ContradictPrivate ) ) . mNotPrivate as * + const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const ContradictPrivate ) ) . mIsPrivate as * + const _ as usize } , 4usize); } impl Clone for ContradictPrivate { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/public-dtor.rs b/tests/expectations/tests/public-dtor.rs index 851857eeaa..ce05f173e3 100644 --- a/tests/expectations/tests/public-dtor.rs +++ b/tests/expectations/tests/public-dtor.rs @@ -12,5 +12,5 @@ pub struct cv_String { #[test] fn bindgen_test_layout_cv_String() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } diff --git a/tests/expectations/tests/ref_argument_array.rs b/tests/expectations/tests/ref_argument_array.rs index c88492d778..28c8c00dda 100644 --- a/tests/expectations/tests/ref_argument_array.rs +++ b/tests/expectations/tests/ref_argument_array.rs @@ -16,7 +16,7 @@ pub struct nsID { #[test] fn bindgen_test_layout_nsID() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); } impl Clone for nsID { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/reparented_replacement.rs b/tests/expectations/tests/reparented_replacement.rs index 74ee229c15..72fc8563e9 100644 --- a/tests/expectations/tests/reparented_replacement.rs +++ b/tests/expectations/tests/reparented_replacement.rs @@ -19,7 +19,10 @@ pub mod root { #[test] fn bindgen_test_layout_Bar() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Bar ) ) . bazz as * const _ as + usize } , 0usize); } impl Clone for Bar { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/replace_use.rs b/tests/expectations/tests/replace_use.rs index f4fee44209..201ec2fda8 100644 --- a/tests/expectations/tests/replace_use.rs +++ b/tests/expectations/tests/replace_use.rs @@ -21,7 +21,10 @@ pub struct Test { #[test] fn bindgen_test_layout_Test() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Test ) ) . a as * const _ as usize } , + 0usize); } impl Clone for Test { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/same_struct_name_in_different_namespaces.rs b/tests/expectations/tests/same_struct_name_in_different_namespaces.rs index dbf93daadb..859284d18d 100644 --- a/tests/expectations/tests/same_struct_name_in_different_namespaces.rs +++ b/tests/expectations/tests/same_struct_name_in_different_namespaces.rs @@ -16,7 +16,13 @@ pub struct JS_shadow_Zone { #[test] fn bindgen_test_layout_JS_shadow_Zone() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const JS_shadow_Zone ) ) . x as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const JS_shadow_Zone ) ) . y as * const _ as + usize } , 4usize); } impl Clone for JS_shadow_Zone { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/size_t_template.rs b/tests/expectations/tests/size_t_template.rs index 78351ecc2e..66868178dc 100644 --- a/tests/expectations/tests/size_t_template.rs +++ b/tests/expectations/tests/size_t_template.rs @@ -12,7 +12,10 @@ pub struct C { #[test] fn bindgen_test_layout_C() { assert_eq!(::std::mem::size_of::() , 12usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const C ) ) . arr as * const _ as usize } , + 0usize); } impl Clone for C { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/struct_containing_forward_declared_struct.rs b/tests/expectations/tests/struct_containing_forward_declared_struct.rs index 388cc59592..d0b139d4bb 100644 --- a/tests/expectations/tests/struct_containing_forward_declared_struct.rs +++ b/tests/expectations/tests/struct_containing_forward_declared_struct.rs @@ -17,7 +17,10 @@ pub struct a_b { #[test] fn bindgen_test_layout_a_b() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const a_b ) ) . val_b as * const _ as usize } , + 0usize); } impl Clone for a_b { fn clone(&self) -> Self { *self } @@ -25,7 +28,10 @@ impl Clone for a_b { #[test] fn bindgen_test_layout_a() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const a ) ) . val_a as * const _ as usize } , + 0usize); } impl Clone for a { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/struct_with_anon_struct.rs b/tests/expectations/tests/struct_with_anon_struct.rs index 1c49675d53..b617fb291c 100644 --- a/tests/expectations/tests/struct_with_anon_struct.rs +++ b/tests/expectations/tests/struct_with_anon_struct.rs @@ -18,7 +18,13 @@ pub struct foo__bindgen_ty_1 { #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as + usize } , 4usize); } impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } @@ -26,7 +32,10 @@ impl Clone for foo__bindgen_ty_1 { #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , + 0usize); } impl Clone for foo { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/struct_with_anon_struct_array.rs b/tests/expectations/tests/struct_with_anon_struct_array.rs index 6e1c03158f..4235c14b25 100644 --- a/tests/expectations/tests/struct_with_anon_struct_array.rs +++ b/tests/expectations/tests/struct_with_anon_struct_array.rs @@ -19,7 +19,13 @@ pub struct foo__bindgen_ty_1 { #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as + usize } , 4usize); } impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } @@ -33,7 +39,13 @@ pub struct foo__bindgen_ty_2 { #[test] fn bindgen_test_layout_foo__bindgen_ty_2() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_2 ) ) . a as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_2 ) ) . b as * const _ as + usize } , 4usize); } impl Clone for foo__bindgen_ty_2 { fn clone(&self) -> Self { *self } @@ -41,7 +53,13 @@ impl Clone for foo__bindgen_ty_2 { #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 208usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , + 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . baz as * const _ as usize } , + 16usize); } impl Clone for foo { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/struct_with_anon_struct_pointer.rs b/tests/expectations/tests/struct_with_anon_struct_pointer.rs index aa77d4b693..5ffc975587 100644 --- a/tests/expectations/tests/struct_with_anon_struct_pointer.rs +++ b/tests/expectations/tests/struct_with_anon_struct_pointer.rs @@ -18,7 +18,13 @@ pub struct foo__bindgen_ty_1 { #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as + usize } , 4usize); } impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } @@ -26,7 +32,10 @@ impl Clone for foo__bindgen_ty_1 { #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , + 0usize); } impl Clone for foo { 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 0d2e937ac3..02ccb8b1ee 100644 --- a/tests/expectations/tests/struct_with_anon_union.rs +++ b/tests/expectations/tests/struct_with_anon_union.rs @@ -43,7 +43,13 @@ pub struct foo__bindgen_ty_1 { #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as + usize } , 0usize); } impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } @@ -51,7 +57,10 @@ impl Clone for foo__bindgen_ty_1 { #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , + 0usize); } impl Clone for foo { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/struct_with_anon_unnamed_struct.rs b/tests/expectations/tests/struct_with_anon_unnamed_struct.rs index 1b77fccca4..224b711fc1 100644 --- a/tests/expectations/tests/struct_with_anon_unnamed_struct.rs +++ b/tests/expectations/tests/struct_with_anon_unnamed_struct.rs @@ -18,7 +18,13 @@ pub struct foo__bindgen_ty_1 { #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as + usize } , 4usize); } impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } @@ -26,7 +32,7 @@ impl Clone for foo__bindgen_ty_1 { #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); } 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 2914eb41ff..e8beffd7d5 100644 --- a/tests/expectations/tests/struct_with_anon_unnamed_union.rs +++ b/tests/expectations/tests/struct_with_anon_unnamed_union.rs @@ -43,7 +43,13 @@ pub struct foo__bindgen_ty_1 { #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as + usize } , 0usize); } impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } @@ -51,7 +57,7 @@ impl Clone for foo__bindgen_ty_1 { #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); } impl Clone for foo { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/struct_with_bitfields.rs b/tests/expectations/tests/struct_with_bitfields.rs index 3fb83a47ed..11fa2d682f 100644 --- a/tests/expectations/tests/struct_with_bitfields.rs +++ b/tests/expectations/tests/struct_with_bitfields.rs @@ -15,7 +15,10 @@ pub struct bitfield { #[test] fn bindgen_test_layout_bitfield() { assert_eq!(::std::mem::size_of::() , 16usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const bitfield ) ) . e as * const _ as usize } + , 4usize); } impl Clone for bitfield { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/struct_with_derive_debug.rs b/tests/expectations/tests/struct_with_derive_debug.rs index 52906a8106..f34c67f4fe 100644 --- a/tests/expectations/tests/struct_with_derive_debug.rs +++ b/tests/expectations/tests/struct_with_derive_debug.rs @@ -12,7 +12,10 @@ pub struct LittleArray { #[test] fn bindgen_test_layout_LittleArray() { assert_eq!(::std::mem::size_of::() , 128usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const LittleArray ) ) . a as * const _ as usize + } , 0usize); } impl Clone for LittleArray { fn clone(&self) -> Self { *self } @@ -24,7 +27,10 @@ pub struct BigArray { #[test] fn bindgen_test_layout_BigArray() { assert_eq!(::std::mem::size_of::() , 132usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const BigArray ) ) . a as * const _ as usize } + , 0usize); } #[repr(C)] #[derive(Debug, Copy)] @@ -34,7 +40,10 @@ pub struct WithLittleArray { #[test] fn bindgen_test_layout_WithLittleArray() { assert_eq!(::std::mem::size_of::() , 128usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const WithLittleArray ) ) . a as * const _ as + usize } , 0usize); } impl Clone for WithLittleArray { fn clone(&self) -> Self { *self } @@ -46,5 +55,8 @@ pub struct WithBigArray { #[test] fn bindgen_test_layout_WithBigArray() { assert_eq!(::std::mem::size_of::() , 132usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const WithBigArray ) ) . a as * const _ as + usize } , 0usize); } diff --git a/tests/expectations/tests/struct_with_nesting.rs b/tests/expectations/tests/struct_with_nesting.rs index b3e0a5ca88..e69268d6d7 100644 --- a/tests/expectations/tests/struct_with_nesting.rs +++ b/tests/expectations/tests/struct_with_nesting.rs @@ -52,8 +52,14 @@ pub struct foo__bindgen_ty_1__bindgen_ty_1 { fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , - 2usize); + assert_eq! (::std::mem::align_of::() , + 2usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_1 ) ) . c1 + as * const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_1 ) ) . c2 + as * const _ as usize } , 2usize); } impl Clone for foo__bindgen_ty_1__bindgen_ty_1 { fn clone(&self) -> Self { *self } @@ -70,8 +76,20 @@ pub struct foo__bindgen_ty_1__bindgen_ty_2 { fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_2() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , - 1usize); + assert_eq! (::std::mem::align_of::() , + 1usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . d1 + as * const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . d2 + as * const _ as usize } , 1usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . d3 + as * const _ as usize } , 2usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . d4 + as * const _ as usize } , 3usize); } impl Clone for foo__bindgen_ty_1__bindgen_ty_2 { fn clone(&self) -> Self { *self } @@ -79,7 +97,10 @@ impl Clone for foo__bindgen_ty_1__bindgen_ty_2 { #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as + usize } , 0usize); } impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } @@ -87,7 +108,10 @@ impl Clone for foo__bindgen_ty_1 { #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , + 0usize); } impl Clone for foo { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/struct_with_packing.rs b/tests/expectations/tests/struct_with_packing.rs index 93fc3f11b2..51ff70242a 100644 --- a/tests/expectations/tests/struct_with_packing.rs +++ b/tests/expectations/tests/struct_with_packing.rs @@ -13,7 +13,11 @@ pub struct a { #[test] fn bindgen_test_layout_a() { assert_eq!(::std::mem::size_of::() , 3usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); + assert_eq! (unsafe { & ( * ( 0 as * const a ) ) . b as * const _ as usize + } , 0usize); + assert_eq! (unsafe { & ( * ( 0 as * const a ) ) . c as * const _ as usize + } , 1usize); } impl Clone for a { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/struct_with_struct.rs b/tests/expectations/tests/struct_with_struct.rs index c8cdc927f0..cae2d677b3 100644 --- a/tests/expectations/tests/struct_with_struct.rs +++ b/tests/expectations/tests/struct_with_struct.rs @@ -18,7 +18,13 @@ pub struct foo__bindgen_ty_1 { #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . x as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . y as * const _ as + usize } , 4usize); } impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } @@ -26,7 +32,10 @@ impl Clone for foo__bindgen_ty_1 { #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , + 0usize); } impl Clone for foo { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/template.rs b/tests/expectations/tests/template.rs index 22e5a08774..800451420b 100644 --- a/tests/expectations/tests/template.rs +++ b/tests/expectations/tests/template.rs @@ -45,7 +45,10 @@ pub struct RootedContainer { #[test] fn bindgen_test_layout_RootedContainer() { assert_eq!(::std::mem::size_of::() , 24usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const RootedContainer ) ) . root as * const _ + as usize } , 0usize); } impl Clone for RootedContainer { fn clone(&self) -> Self { *self } @@ -64,7 +67,10 @@ pub struct PODButContainsDtor { #[test] fn bindgen_test_layout_PODButContainsDtor() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const PODButContainsDtor ) ) . member as * + const _ as usize } , 0usize); } /**
*/ #[repr(C)] @@ -80,7 +86,10 @@ pub struct POD { #[test] fn bindgen_test_layout_POD() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const POD ) ) . opaque_member as * const _ as + usize } , 0usize); } impl Clone for POD { fn clone(&self) -> Self { *self } @@ -119,7 +128,7 @@ pub struct Untemplated { #[test] fn bindgen_test_layout_Untemplated() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } impl Clone for Untemplated { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/type-referenced-by-whitelisted-function.rs b/tests/expectations/tests/type-referenced-by-whitelisted-function.rs index c968650115..0fd411d2ab 100644 --- a/tests/expectations/tests/type-referenced-by-whitelisted-function.rs +++ b/tests/expectations/tests/type-referenced-by-whitelisted-function.rs @@ -12,7 +12,10 @@ pub struct dl_phdr_info { #[test] fn bindgen_test_layout_dl_phdr_info() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const dl_phdr_info ) ) . x as * const _ as + usize } , 0usize); } impl Clone for dl_phdr_info { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/type_alias_template_specialized.rs b/tests/expectations/tests/type_alias_template_specialized.rs index 11813bc6a2..d898561de7 100644 --- a/tests/expectations/tests/type_alias_template_specialized.rs +++ b/tests/expectations/tests/type_alias_template_specialized.rs @@ -12,7 +12,10 @@ pub struct Rooted { #[test] fn bindgen_test_layout_Rooted() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Rooted ) ) . ptr as * const _ as usize } + , 0usize); } impl Clone for Rooted { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/typeref.rs b/tests/expectations/tests/typeref.rs index 1188393dd3..1153374fea 100644 --- a/tests/expectations/tests/typeref.rs +++ b/tests/expectations/tests/typeref.rs @@ -36,7 +36,10 @@ pub struct nsFoo { #[test] fn bindgen_test_layout_nsFoo() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const nsFoo ) ) . mBar as * const _ as usize } + , 0usize); } impl Clone for nsFoo { fn clone(&self) -> Self { *self } @@ -49,7 +52,10 @@ pub struct mozilla_FragmentOrURL { #[test] fn bindgen_test_layout_mozilla_FragmentOrURL() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); + assert_eq! (unsafe { + & ( * ( 0 as * const mozilla_FragmentOrURL ) ) . mIsLocalRef + as * const _ as usize } , 0usize); } impl Clone for mozilla_FragmentOrURL { fn clone(&self) -> Self { *self } @@ -62,7 +68,7 @@ pub struct mozilla_Position { #[test] fn bindgen_test_layout_mozilla_Position() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } impl Clone for mozilla_Position { fn clone(&self) -> Self { *self } @@ -89,7 +95,10 @@ pub struct Bar { #[test] fn bindgen_test_layout_Bar() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Bar ) ) . mFoo as * const _ as usize } , + 0usize); } impl Clone for Bar { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/union-in-ns.rs b/tests/expectations/tests/union-in-ns.rs index fa511e512f..b6cbfd8618 100644 --- a/tests/expectations/tests/union-in-ns.rs +++ b/tests/expectations/tests/union-in-ns.rs @@ -44,7 +44,10 @@ pub mod root { #[test] fn bindgen_test_layout_bar() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const bar ) ) . baz as * const _ as usize } + , 0usize); } 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 9be626ffa8..47bca484e6 100644 --- a/tests/expectations/tests/union_dtor.rs +++ b/tests/expectations/tests/union_dtor.rs @@ -38,5 +38,11 @@ pub struct UnionWithDtor { #[test] fn bindgen_test_layout_UnionWithDtor() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const UnionWithDtor ) ) . mFoo as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const UnionWithDtor ) ) . mBar as * const _ as + usize } , 0usize); } diff --git a/tests/expectations/tests/union_fields.rs b/tests/expectations/tests/union_fields.rs index 495e80f984..1dfe1ef1f5 100644 --- a/tests/expectations/tests/union_fields.rs +++ b/tests/expectations/tests/union_fields.rs @@ -39,7 +39,16 @@ pub struct _bindgen_ty_1 { #[test] fn bindgen_test_layout__bindgen_ty_1() { assert_eq!(::std::mem::size_of::<_bindgen_ty_1>() , 8usize); - assert_eq!(::std::mem::align_of::<_bindgen_ty_1>() , 8usize); + assert_eq! (::std::mem::align_of::<_bindgen_ty_1>() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const _bindgen_ty_1 ) ) . mInt as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const _bindgen_ty_1 ) ) . mFloat as * const _ + as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const _bindgen_ty_1 ) ) . mPointer as * const _ + as usize } , 0usize); } impl Clone for _bindgen_ty_1 { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/union_with_anon_struct.rs b/tests/expectations/tests/union_with_anon_struct.rs index f0a2151223..6a3469dc14 100644 --- a/tests/expectations/tests/union_with_anon_struct.rs +++ b/tests/expectations/tests/union_with_anon_struct.rs @@ -43,7 +43,13 @@ pub struct foo__bindgen_ty_1 { #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as + usize } , 4usize); } impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } @@ -51,7 +57,10 @@ impl Clone for foo__bindgen_ty_1 { #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , + 0usize); } 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 548b0dc48a..af06fea780 100644 --- a/tests/expectations/tests/union_with_anon_struct_bitfield.rs +++ b/tests/expectations/tests/union_with_anon_struct_bitfield.rs @@ -43,7 +43,7 @@ pub struct foo__bindgen_ty_1 { #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); } impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } @@ -79,7 +79,10 @@ impl foo__bindgen_ty_1 { #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , + 0usize); } 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 9527855640..f5bb4dd95e 100644 --- a/tests/expectations/tests/union_with_anon_union.rs +++ b/tests/expectations/tests/union_with_anon_union.rs @@ -44,7 +44,13 @@ pub struct foo__bindgen_ty_1 { #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as + usize } , 0usize); } impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } @@ -52,7 +58,10 @@ impl Clone for foo__bindgen_ty_1 { #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , + 0usize); } 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 2d6fab97b7..4e5fe9152d 100644 --- a/tests/expectations/tests/union_with_anon_unnamed_struct.rs +++ b/tests/expectations/tests/union_with_anon_unnamed_struct.rs @@ -46,7 +46,19 @@ pub struct pixel__bindgen_ty_1 { #[test] fn bindgen_test_layout_pixel__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); + assert_eq! (unsafe { + & ( * ( 0 as * const pixel__bindgen_ty_1 ) ) . r as * const _ + as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const pixel__bindgen_ty_1 ) ) . g as * const _ + as usize } , 1usize); + assert_eq! (unsafe { + & ( * ( 0 as * const pixel__bindgen_ty_1 ) ) . b as * const _ + as usize } , 2usize); + assert_eq! (unsafe { + & ( * ( 0 as * const pixel__bindgen_ty_1 ) ) . a as * const _ + as usize } , 3usize); } impl Clone for pixel__bindgen_ty_1 { fn clone(&self) -> Self { *self } @@ -54,7 +66,10 @@ impl Clone for pixel__bindgen_ty_1 { #[test] fn bindgen_test_layout_pixel() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const pixel ) ) . rgba as * const _ as usize } + , 0usize); } 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 eb214017fe..e9197ad7e2 100644 --- a/tests/expectations/tests/union_with_anon_unnamed_union.rs +++ b/tests/expectations/tests/union_with_anon_unnamed_union.rs @@ -45,7 +45,13 @@ pub struct foo__bindgen_ty_1 { #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 2usize); - assert_eq!(::std::mem::align_of::() , 2usize); + assert_eq! (::std::mem::align_of::() , 2usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . c as * const _ as + usize } , 0usize); } impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } @@ -53,7 +59,10 @@ impl Clone for foo__bindgen_ty_1 { #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , + 0usize); } 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 b921f33c95..f055625944 100644 --- a/tests/expectations/tests/union_with_big_member.rs +++ b/tests/expectations/tests/union_with_big_member.rs @@ -38,7 +38,13 @@ pub struct WithBigArray { #[test] fn bindgen_test_layout_WithBigArray() { assert_eq!(::std::mem::size_of::() , 132usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const WithBigArray ) ) . a as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const WithBigArray ) ) . b as * const _ as + usize } , 0usize); } impl Clone for WithBigArray { fn clone(&self) -> Self { *self } @@ -53,7 +59,13 @@ pub struct WithBigArray2 { #[test] fn bindgen_test_layout_WithBigArray2() { assert_eq!(::std::mem::size_of::() , 36usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const WithBigArray2 ) ) . a as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const WithBigArray2 ) ) . b as * const _ as + usize } , 0usize); } impl Clone for WithBigArray2 { fn clone(&self) -> Self { *self } @@ -68,7 +80,13 @@ pub struct WithBigMember { #[test] fn bindgen_test_layout_WithBigMember() { assert_eq!(::std::mem::size_of::() , 132usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const WithBigMember ) ) . a as * const _ as + usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const WithBigMember ) ) . b as * const _ as + usize } , 0usize); } impl Clone for WithBigMember { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/union_with_nesting.rs b/tests/expectations/tests/union_with_nesting.rs index af9e442d10..819dff6ead 100644 --- a/tests/expectations/tests/union_with_nesting.rs +++ b/tests/expectations/tests/union_with_nesting.rs @@ -52,8 +52,14 @@ pub struct foo__bindgen_ty_1__bindgen_ty_1 { fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 2usize); - assert_eq!(::std::mem::align_of::() , - 2usize); + assert_eq! (::std::mem::align_of::() , + 2usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_1 ) ) . b1 + as * const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_1 ) ) . b2 + as * const _ as usize } , 0usize); } impl Clone for foo__bindgen_ty_1__bindgen_ty_1 { fn clone(&self) -> Self { *self } @@ -69,8 +75,14 @@ pub struct foo__bindgen_ty_1__bindgen_ty_2 { fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_2() { assert_eq!(::std::mem::size_of::() , 2usize); - assert_eq!(::std::mem::align_of::() , - 2usize); + assert_eq! (::std::mem::align_of::() , + 2usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . c1 + as * const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . c2 + as * const _ as usize } , 0usize); } impl Clone for foo__bindgen_ty_1__bindgen_ty_2 { fn clone(&self) -> Self { *self } @@ -78,7 +90,7 @@ impl Clone for foo__bindgen_ty_1__bindgen_ty_2 { #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 2usize); + assert_eq! (::std::mem::align_of::() , 2usize); } impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } @@ -86,7 +98,10 @@ impl Clone for foo__bindgen_ty_1 { #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , + 0usize); } impl Clone for foo { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/unknown_attr.rs b/tests/expectations/tests/unknown_attr.rs index fd9cce4593..c58281e90e 100644 --- a/tests/expectations/tests/unknown_attr.rs +++ b/tests/expectations/tests/unknown_attr.rs @@ -8,7 +8,19 @@ #[derive(Debug, Copy)] pub struct _bindgen_ty_1 { pub __clang_max_align_nonce1: ::std::os::raw::c_longlong, + pub __bindgen_padding_0: u64, pub __clang_max_align_nonce2: f64, + pub __bindgen_padding_1: u64, +} +#[test] +fn bindgen_test_layout__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::<_bindgen_ty_1>() , 32usize); + assert_eq! (unsafe { + & ( * ( 0 as * const _bindgen_ty_1 ) ) . + __clang_max_align_nonce1 as * const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const _bindgen_ty_1 ) ) . + __clang_max_align_nonce2 as * const _ as usize } , 16usize); } impl Clone for _bindgen_ty_1 { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/use-core.rs b/tests/expectations/tests/use-core.rs index b0900f5fa6..023d9ee38f 100644 --- a/tests/expectations/tests/use-core.rs +++ b/tests/expectations/tests/use-core.rs @@ -15,7 +15,16 @@ pub struct foo { #[test] fn bindgen_test_layout_foo() { assert_eq!(::core::mem::size_of::() , 16usize); - assert_eq!(::core::mem::align_of::() , 8usize); + assert_eq! (::core::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , + 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . b as * const _ as usize } , + 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , + 8usize); } impl Clone for foo { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/var-tracing.rs b/tests/expectations/tests/var-tracing.rs index ef5660eb57..25d58aa48a 100644 --- a/tests/expectations/tests/var-tracing.rs +++ b/tests/expectations/tests/var-tracing.rs @@ -12,7 +12,10 @@ pub struct Bar { #[test] fn bindgen_test_layout_Bar() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Bar ) ) . m_baz as * const _ as usize } , + 0usize); } extern "C" { #[link_name = "_ZN3BarC1Ei"] @@ -41,7 +44,7 @@ extern "C" { #[test] fn bindgen_test_layout_Baz() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } impl Clone for Baz { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/variadic-method.rs b/tests/expectations/tests/variadic-method.rs index 343010694b..c4e0d3c075 100644 --- a/tests/expectations/tests/variadic-method.rs +++ b/tests/expectations/tests/variadic-method.rs @@ -16,7 +16,7 @@ pub struct Bar { #[test] fn bindgen_test_layout_Bar() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } extern "C" { #[link_name = "_ZN3Bar3fooEPKcz"] diff --git a/tests/expectations/tests/vector.rs b/tests/expectations/tests/vector.rs index b8ca573511..9b63adb141 100644 --- a/tests/expectations/tests/vector.rs +++ b/tests/expectations/tests/vector.rs @@ -12,7 +12,10 @@ pub struct foo { #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . mMember as * const _ as usize } + , 0usize); } impl Clone for foo { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/virtual_dtor.rs b/tests/expectations/tests/virtual_dtor.rs index 9571f084b9..07cc7ee7b5 100644 --- a/tests/expectations/tests/virtual_dtor.rs +++ b/tests/expectations/tests/virtual_dtor.rs @@ -15,5 +15,5 @@ pub struct nsSlots { #[test] fn bindgen_test_layout_nsSlots() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); } diff --git a/tests/expectations/tests/virtual_inheritance.rs b/tests/expectations/tests/virtual_inheritance.rs index f271223f94..e93d28640d 100644 --- a/tests/expectations/tests/virtual_inheritance.rs +++ b/tests/expectations/tests/virtual_inheritance.rs @@ -12,7 +12,10 @@ pub struct A { #[test] fn bindgen_test_layout_A() { assert_eq!(::std::mem::size_of::() , 4usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const A ) ) . foo as * const _ as usize } , + 0usize); } impl Clone for A { fn clone(&self) -> Self { *self } @@ -29,7 +32,10 @@ pub struct B { #[test] fn bindgen_test_layout_B() { assert_eq!(::std::mem::size_of::() , 16usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const B ) ) . bar as * const _ as usize } , + 8usize); } impl Clone for B { fn clone(&self) -> Self { *self } @@ -46,7 +52,10 @@ pub struct C { #[test] fn bindgen_test_layout_C() { assert_eq!(::std::mem::size_of::() , 16usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const C ) ) . baz as * const _ as usize } , + 8usize); } impl Clone for C { fn clone(&self) -> Self { *self } @@ -61,7 +70,7 @@ pub struct D { #[test] fn bindgen_test_layout_D() { assert_eq!(::std::mem::size_of::() , 40usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); } impl Clone for D { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/virtual_overloaded.rs b/tests/expectations/tests/virtual_overloaded.rs index 7833cdbfa4..b101a0a268 100644 --- a/tests/expectations/tests/virtual_overloaded.rs +++ b/tests/expectations/tests/virtual_overloaded.rs @@ -15,7 +15,7 @@ pub struct C { #[test] fn bindgen_test_layout_C() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); } impl Clone for C { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/vtable_recursive_sig.rs b/tests/expectations/tests/vtable_recursive_sig.rs index ce62eeb0fc..8d69f212c0 100644 --- a/tests/expectations/tests/vtable_recursive_sig.rs +++ b/tests/expectations/tests/vtable_recursive_sig.rs @@ -12,7 +12,7 @@ pub struct Derived { #[test] fn bindgen_test_layout_Derived() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); } impl Clone for Derived { fn clone(&self) -> Self { *self } @@ -28,7 +28,7 @@ pub struct Base { #[test] fn bindgen_test_layout_Base() { assert_eq!(::std::mem::size_of::() , 8usize); - assert_eq!(::std::mem::align_of::() , 8usize); + assert_eq! (::std::mem::align_of::() , 8usize); } impl Clone for Base { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/weird_bitfields.rs b/tests/expectations/tests/weird_bitfields.rs index 56ee76a59e..927b91f8ab 100644 --- a/tests/expectations/tests/weird_bitfields.rs +++ b/tests/expectations/tests/weird_bitfields.rs @@ -32,7 +32,43 @@ pub struct Weird { #[test] fn bindgen_test_layout_Weird() { assert_eq!(::std::mem::size_of::() , 24usize); - assert_eq!(::std::mem::align_of::() , 4usize); + assert_eq! (::std::mem::align_of::() , 4usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Weird ) ) . mStrokeDasharrayLength as * + const _ as usize } , 0usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Weird ) ) . mClipRule as * const _ as + usize } , 8usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Weird ) ) . mColorInterpolation as * + const _ as usize } , 9usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Weird ) ) . mColorInterpolationFilters as + * const _ as usize } , 10usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Weird ) ) . mFillRule as * const _ as + usize } , 11usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Weird ) ) . mImageRendering as * const _ + as usize } , 12usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Weird ) ) . mPaintOrder as * const _ as + usize } , 13usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Weird ) ) . mShapeRendering as * const _ + as usize } , 14usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Weird ) ) . mStrokeLinecap as * const _ + as usize } , 15usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Weird ) ) . mStrokeLinejoin as * const _ + as usize } , 16usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Weird ) ) . mTextAnchor as * const _ as + usize } , 17usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Weird ) ) . mTextRendering as * const _ + as usize } , 18usize); } impl Clone for Weird { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/what_is_going_on.rs b/tests/expectations/tests/what_is_going_on.rs index 6f1998d198..c4d54d05d1 100644 --- a/tests/expectations/tests/what_is_going_on.rs +++ b/tests/expectations/tests/what_is_going_on.rs @@ -12,7 +12,7 @@ pub struct UnknownUnits { #[test] fn bindgen_test_layout_UnknownUnits() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } impl Clone for UnknownUnits { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/whitelist-namespaces-basic.rs b/tests/expectations/tests/whitelist-namespaces-basic.rs index cbb12f6bbb..cfd9e5f3af 100644 --- a/tests/expectations/tests/whitelist-namespaces-basic.rs +++ b/tests/expectations/tests/whitelist-namespaces-basic.rs @@ -21,7 +21,7 @@ pub mod root { #[test] fn bindgen_test_layout_Helper() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } impl Clone for Helper { fn clone(&self) -> Self { *self } diff --git a/tests/expectations/tests/whitelist-namespaces.rs b/tests/expectations/tests/whitelist-namespaces.rs index bc257af642..858167210a 100644 --- a/tests/expectations/tests/whitelist-namespaces.rs +++ b/tests/expectations/tests/whitelist-namespaces.rs @@ -21,7 +21,7 @@ pub mod root { #[test] fn bindgen_test_layout_Helper() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); } impl Clone for Helper { fn clone(&self) -> Self { *self } @@ -35,7 +35,10 @@ pub mod root { #[test] fn bindgen_test_layout_Test() { assert_eq!(::std::mem::size_of::() , 1usize); - assert_eq!(::std::mem::align_of::() , 1usize); + assert_eq! (::std::mem::align_of::() , 1usize); + assert_eq! (unsafe { + & ( * ( 0 as * const Test ) ) . helper as * const _ as + usize } , 0usize); } impl Clone for Test { fn clone(&self) -> Self { *self } diff --git a/tests/headers/layout.h b/tests/headers/layout.h new file mode 100644 index 0000000000..d1822a04de --- /dev/null +++ b/tests/headers/layout.h @@ -0,0 +1,6 @@ +struct header +{ + char proto; + unsigned int size __attribute__ ((packed)); + unsigned char data[] __attribute__ ((aligned(8))); +} __attribute__ ((aligned, packed)); \ No newline at end of file diff --git a/tests/headers/layout_align.h b/tests/headers/layout_align.h new file mode 100644 index 0000000000..0201877e79 --- /dev/null +++ b/tests/headers/layout_align.h @@ -0,0 +1,20 @@ +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; + +struct rte_kni_fifo { + volatile unsigned write; /**< Next position to be written*/ + volatile unsigned read; /**< Next position to be read */ + unsigned len; /**< Circular buffer length */ + unsigned elem_size; /**< Pointer size - for 32/64 bit OS */ + void *volatile buffer[]; /**< The buffer contains mbuf pointers */ +}; + +__extension__ +struct rte_eth_link { + uint32_t link_speed; /**< ETH_SPEED_NUM_ */ + uint16_t link_duplex : 1; /**< ETH_LINK_[HALF/FULL]_DUPLEX */ + uint16_t link_autoneg : 1; /**< ETH_LINK_SPEED_[AUTONEG/FIXED] */ + uint16_t link_status : 1; /**< ETH_LINK_[DOWN/UP] */ +} __attribute__((aligned(8))); /**< aligned for atomic64 read/write */ \ No newline at end of file diff --git a/tests/headers/layout_arp.h b/tests/headers/layout_arp.h new file mode 100644 index 0000000000..8682cbe0ee --- /dev/null +++ b/tests/headers/layout_arp.h @@ -0,0 +1,52 @@ +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; + +#define ETHER_ADDR_LEN 6 /**< Length of Ethernet address. */ + +/** + * Ethernet address: + * A universally administered address is uniquely assigned to a device by its + * manufacturer. The first three octets (in transmission order) contain the + * Organizationally Unique Identifier (OUI). The following three (MAC-48 and + * EUI-48) octets are assigned by that organization with the only constraint + * of uniqueness. + * A locally administered address is assigned to a device by a network + * administrator and does not contain OUIs. + * See http://standards.ieee.org/regauth/groupmac/tutorial.html + */ +struct ether_addr { + uint8_t addr_bytes[ETHER_ADDR_LEN]; /**< Addr bytes in tx order */ +} __attribute__((__packed__)); + +/** + * ARP header IPv4 payload. + */ +struct arp_ipv4 { + struct ether_addr arp_sha; /**< sender hardware address */ + uint32_t arp_sip; /**< sender IP address */ + struct ether_addr arp_tha; /**< target hardware address */ + uint32_t arp_tip; /**< target IP address */ +} __attribute__((__packed__)); + +/** + * ARP header. + */ +struct arp_hdr { + uint16_t arp_hrd; /* format of hardware address */ +#define ARP_HRD_ETHER 1 /* ARP Ethernet address format */ + + uint16_t arp_pro; /* format of protocol address */ + uint8_t arp_hln; /* length of hardware address */ + uint8_t arp_pln; /* length of protocol address */ + uint16_t arp_op; /* ARP opcode (command) */ +#define ARP_OP_REQUEST 1 /* request to resolve address */ +#define ARP_OP_REPLY 2 /* response to previous request */ +#define ARP_OP_REVREQUEST 3 /* request proto addr given hardware */ +#define ARP_OP_REVREPLY 4 /* response giving protocol address */ +#define ARP_OP_INVREQUEST 8 /* request to identify peer */ +#define ARP_OP_INVREPLY 9 /* response identifying peer */ + + struct arp_ipv4 arp_data; +} __attribute__((__packed__)); \ No newline at end of file diff --git a/tests/headers/layout_array.h b/tests/headers/layout_array.h new file mode 100644 index 0000000000..4b99e0ed42 --- /dev/null +++ b/tests/headers/layout_array.h @@ -0,0 +1,109 @@ +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; + +typedef long long size_t; + +#define RTE_CACHE_LINE_SIZE 64 + +/** + * Force alignment + */ +#define __rte_aligned(a) __attribute__((__aligned__(a))) + +/** + * Force alignment to cache line. + */ +#define __rte_cache_aligned __rte_aligned(RTE_CACHE_LINE_SIZE) + +#define RTE_MEMPOOL_OPS_NAMESIZE 32 /**< Max length of ops struct name. */ + +/** + * Prototype for implementation specific data provisioning function. + * + * The function should provide the implementation specific memory for + * for use by the other mempool ops functions in a given mempool ops struct. + * E.g. the default ops provides an instance of the rte_ring for this purpose. + * it will most likely point to a different type of data structure, and + * will be transparent to the application programmer. + * This function should set mp->pool_data. + */ +typedef int (*rte_mempool_alloc_t)(struct rte_mempool *mp); + +/** + * Free the opaque private data pointed to by mp->pool_data pointer. + */ +typedef void (*rte_mempool_free_t)(struct rte_mempool *mp); + +/** + * Enqueue an object into the external pool. + */ +typedef int (*rte_mempool_enqueue_t)(struct rte_mempool *mp, + void * const *obj_table, unsigned int n); + +/** + * Dequeue an object from the external pool. + */ +typedef int (*rte_mempool_dequeue_t)(struct rte_mempool *mp, + void **obj_table, unsigned int n); + +/** + * Return the number of available objects in the external pool. + */ +typedef unsigned (*rte_mempool_get_count)(const struct rte_mempool *mp); +/** Structure defining mempool operations structure */ +struct rte_mempool_ops { + char name[RTE_MEMPOOL_OPS_NAMESIZE]; /**< Name of mempool ops struct. */ + rte_mempool_alloc_t alloc; /**< Allocate private data. */ + rte_mempool_free_t free; /**< Free the external pool. */ + rte_mempool_enqueue_t enqueue; /**< Enqueue an object. */ + rte_mempool_dequeue_t dequeue; /**< Dequeue an object. */ + rte_mempool_get_count get_count; /**< Get qty of available objs. */ +} __rte_cache_aligned; + +#define RTE_MEMPOOL_MAX_OPS_IDX 16 /**< Max registered ops structs */ + +/** + * The rte_spinlock_t type. + */ +typedef struct { + volatile int locked; /**< lock status 0 = unlocked, 1 = locked */ +} rte_spinlock_t; + +/** + * Structure storing the table of registered ops structs, each of which contain + * the function pointers for the mempool ops functions. + * Each process has its own storage for this ops struct array so that + * the mempools can be shared across primary and secondary processes. + * The indices used to access the array are valid across processes, whereas + * any function pointers stored directly in the mempool struct would not be. + * This results in us simply having "ops_index" in the mempool struct. + */ +struct rte_mempool_ops_table { + rte_spinlock_t sl; /**< Spinlock for add/delete. */ + uint32_t num_ops; /**< Number of used ops structs in the table. */ + /** + * Storage for all possible ops structs. + */ + struct rte_mempool_ops ops[RTE_MEMPOOL_MAX_OPS_IDX]; +} __rte_cache_aligned; + + +/* Number of free lists per heap, grouped by size. */ +#define RTE_HEAP_NUM_FREELISTS 13 + +#define LIST_HEAD(name, type) \ +struct name { \ + struct type *lh_first; /* first element */ \ +} + +/** + * Structure to hold malloc heap + */ +struct malloc_heap { + rte_spinlock_t lock; + LIST_HEAD(, malloc_elem) free_head[RTE_HEAP_NUM_FREELISTS]; + unsigned alloc_count; + size_t total_size; +} __rte_cache_aligned; diff --git a/tests/headers/layout_cmdline_token.h b/tests/headers/layout_cmdline_token.h new file mode 100644 index 0000000000..34ebd017de --- /dev/null +++ b/tests/headers/layout_cmdline_token.h @@ -0,0 +1,63 @@ + +/** + * Stores a pointer to the ops struct, and the offset: the place to + * write the parsed result in the destination structure. + */ +struct cmdline_token_hdr { + struct cmdline_token_ops *ops; + unsigned int offset; +}; +typedef struct cmdline_token_hdr cmdline_parse_token_hdr_t; + +/** + * A token is defined by this structure. + * + * parse() takes the token as first argument, then the source buffer + * starting at the token we want to parse. The 3rd arg is a pointer + * where we store the parsed data (as binary). It returns the number of + * parsed chars on success and a negative value on error. + * + * complete_get_nb() returns the number of possible values for this + * token if completion is possible. If it is NULL or if it returns 0, + * no completion is possible. + * + * complete_get_elt() copy in dstbuf (the size is specified in the + * parameter) the i-th possible completion for this token. returns 0 + * on success or and a negative value on error. + * + * get_help() fills the dstbuf with the help for the token. It returns + * -1 on error and 0 on success. + */ +struct cmdline_token_ops { + /** parse(token ptr, buf, res pts, buf len) */ + int (*parse)(cmdline_parse_token_hdr_t *, const char *, void *, + unsigned int); + /** return the num of possible choices for this token */ + int (*complete_get_nb)(cmdline_parse_token_hdr_t *); + /** return the elt x for this token (token, idx, dstbuf, size) */ + int (*complete_get_elt)(cmdline_parse_token_hdr_t *, int, char *, + unsigned int); + /** get help for this token (token, dstbuf, size) */ + int (*get_help)(cmdline_parse_token_hdr_t *, char *, unsigned int); +}; + +enum cmdline_numtype { + UINT8 = 0, + UINT16, + UINT32, + UINT64, + INT8, + INT16, + INT32, + INT64 +}; + +struct cmdline_token_num_data { + enum cmdline_numtype type; +}; + +struct cmdline_token_num { + struct cmdline_token_hdr hdr; + struct cmdline_token_num_data num_data; +}; +typedef struct cmdline_token_num cmdline_parse_token_num_t; \ No newline at end of file diff --git a/tests/headers/layout_eth_conf.h b/tests/headers/layout_eth_conf.h new file mode 100644 index 0000000000..a742ee5f99 --- /dev/null +++ b/tests/headers/layout_eth_conf.h @@ -0,0 +1,427 @@ +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. */ +}; \ No newline at end of file diff --git a/tests/headers/layout_kni_mbuf.h b/tests/headers/layout_kni_mbuf.h new file mode 100644 index 0000000000..ff161144a3 --- /dev/null +++ b/tests/headers/layout_kni_mbuf.h @@ -0,0 +1,32 @@ + +#define RTE_CACHE_LINE_MIN_SIZE 64 /**< Minimum Cache line size. */ + +#define RTE_CACHE_LINE_SIZE 64 + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; + +/* + * The kernel image of the rte_mbuf struct, with only the relevant fields. + * Padding is necessary to assure the offsets of these fields + */ +struct rte_kni_mbuf { + void *buf_addr __attribute__((__aligned__(RTE_CACHE_LINE_SIZE))); + uint64_t buf_physaddr; + char pad0[2]; + uint16_t data_off; /**< Start address of data in segment buffer. */ + char pad1[2]; + uint8_t nb_segs; /**< Number of segments. */ + char pad4[1]; + uint64_t ol_flags; /**< Offload features. */ + char pad2[4]; + uint32_t pkt_len; /**< Total pkt len: sum of all segment data_len. */ + uint16_t data_len; /**< Amount of data in segment buffer. */ + + /* fields on second cache line */ + char pad3[8] __attribute__((__aligned__(RTE_CACHE_LINE_MIN_SIZE))); + void *pool; + void *next; +}; diff --git a/tests/headers/layout_mbuf.h b/tests/headers/layout_mbuf.h new file mode 100644 index 0000000000..dc1c1b242b --- /dev/null +++ b/tests/headers/layout_mbuf.h @@ -0,0 +1,187 @@ + +#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; \ No newline at end of file