From c7361b1721e16c9c5a1dae8e49cb6313521966bd Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Tue, 26 Nov 2024 19:49:04 -0500 Subject: [PATCH 1/7] Make `RustTarget` parsing more permissive --- bindgen/features.rs | 140 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 114 insertions(+), 26 deletions(-) diff --git a/bindgen/features.rs b/bindgen/features.rs index e67b00f0d3..ccc4191552 100644 --- a/bindgen/features.rs +++ b/bindgen/features.rs @@ -44,7 +44,7 @@ macro_rules! define_rust_targets { } impl RustTarget { - fn minor(self) -> Option { + const fn minor(self) -> Option { match self { $( Self::$variant => Some($minor),)* Self::Nightly => None @@ -136,7 +136,7 @@ define_rust_targets! { Stable_1_0(0) => {}, } -/// Latest stable release of Rust +/// Latest stable release of Rust that is supported by bindgen pub const LATEST_STABLE_RUST: RustTarget = { // FIXME: replace all this code by // ``` @@ -144,7 +144,7 @@ pub const LATEST_STABLE_RUST: RustTarget = { // .into_iter() // .max_by_key(|(_, m)| m) // .map(|(t, _)| t) - // .unwrap_or(RustTarget::Nightly) + // .unwrap() // ``` // once those operations can be used in constants. let targets = RustTarget::stable_releases(); @@ -170,6 +170,42 @@ pub const LATEST_STABLE_RUST: RustTarget = { } }; +/// Earliest stable release of Rust that is supported by bindgen +pub const EARLIEST_STABLE_RUST: RustTarget = { + // FIXME: replace all this code by + // ``` + // RustTarget::stable_releases() + // .into_iter() + // .min_by_key(|(_, m)| m) + // .map(|(t, _)| t) + // .unwrap_or(LATEST_STABLE_RUST) + // ``` + // once those operations can be used in constants. + let targets = RustTarget::stable_releases(); + + let mut i = 0; + let mut earliest_target = None; + let Some(mut earliest_minor) = LATEST_STABLE_RUST.minor() else { + unreachable!() + }; + + while i < targets.len() { + let (target, minor) = targets[i]; + + if earliest_minor > minor { + earliest_minor = minor; + earliest_target = Some(target); + } + + i += 1; + } + + match earliest_target { + Some(target) => target, + None => unreachable!(), + } +}; + impl Default for RustTarget { fn default() -> Self { LATEST_STABLE_RUST @@ -193,28 +229,62 @@ impl Ord for RustTarget { } } +fn invalid_input(input: &str, msg: impl std::fmt::Display) -> io::Result { + Err(io::Error::new( + io::ErrorKind::InvalidInput, + format!("\"{input}\" is not a valid Rust target, {msg}"), + )) +} + impl FromStr for RustTarget { type Err = io::Error; - fn from_str(s: &str) -> Result { - if s == "nightly" { + fn from_str(input: &str) -> Result { + if input == "nightly" { return Ok(Self::Nightly); } - if let Some(("1", str_minor)) = s.split_once('.') { - if let Ok(minor) = str_minor.parse::() { - for (target, target_minor) in Self::stable_releases() { - if minor == target_minor { - return Ok(target); - } - } - } + let Some((major_str, tail)) = input.split_once('.') else { + return invalid_input(input, "accepted values are of the form \"1.71\", \"1.71.1\" or \"nightly\"." ); + }; + + if major_str != "1" { + return invalid_input( + input, + "The largest major version of Rust released is \"1\"", + ); } - Err(io::Error::new( - io::ErrorKind::InvalidInput, - "Got an invalid Rust target. Accepted values are of the form \"1.71\" or \"nightly\"." - )) + // We ignore the patch version number as they only include backwards compatible bug fixes. + let (minor, _patch) = match tail.split_once('.') { + Some((minor_str, patch_str)) => { + let Ok(minor) = minor_str.parse::() else { + return invalid_input(input, "the minor version number must be an unsigned 64-bit integer"); + }; + let Ok(patch) = patch_str.parse::() else { + return invalid_input(input, "the patch version number must be an unsigned 64-bit integer"); + }; + (minor, patch) + } + None => { + let Ok(minor) = tail.parse::() else { + return invalid_input(input, "the minor version number must be an unsigned 64-bit integer"); + }; + (minor, 0) + } + }; + + let Some(target) = Self::stable_releases() + .iter() + .filter(|(_, target_minor)| minor >= *target_minor) + .max_by_key(|(_, target_minor)| target_minor) + .map(|(target, _)| target) + .cloned() + else { + return invalid_input(input, format!("the earliest Rust target supported by bindgen is {EARLIEST_STABLE_RUST}")); + }; + + Ok(target) } } @@ -282,19 +352,37 @@ mod test { } fn test_target(target_str: &str, target: RustTarget) { - let target_string = target.to_string(); - assert_eq!(target_str, target_string); - assert_eq!(target, RustTarget::from_str(target_str).unwrap()); + assert_eq!( + target, + target_str.parse::().unwrap(), + "{target_str}" + ); + } + + fn test_invalid_target(target_str: &str) { + assert!(target_str.parse::().is_err(), "{}", target_str); } #[test] - fn str_to_target() { - test_target("1.0", RustTarget::Stable_1_0); - test_target("1.17", RustTarget::Stable_1_17); - test_target("1.19", RustTarget::Stable_1_19); - test_target("1.21", RustTarget::Stable_1_21); - test_target("1.25", RustTarget::Stable_1_25); + fn valid_targets() { test_target("1.71", RustTarget::Stable_1_71); + test_target("1.71.0", RustTarget::Stable_1_71); + test_target("1.71.1", RustTarget::Stable_1_71); + test_target("1.72", RustTarget::Stable_1_71); + test_target("1.73", RustTarget::Stable_1_73); + test_target("1.18446744073709551615", LATEST_STABLE_RUST); test_target("nightly", RustTarget::Nightly); } + + #[test] + fn invalid_targets() { + test_invalid_target("2.0"); + test_invalid_target("1.cat"); + test_invalid_target("1.0.cat"); + test_invalid_target("1.18446744073709551616"); + test_invalid_target("1.0.18446744073709551616"); + test_invalid_target("1.-1.0"); + test_invalid_target("1.0.-1"); + test_invalid_target("beta"); + } } From 9665f635147997851fd6cd70b0d39fbd349a1257 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Tue, 26 Nov 2024 22:30:51 -0500 Subject: [PATCH 2/7] Represent Rust versions with integers --- bindgen/features.rs | 146 +++++++++++++++++++++----------------------- 1 file changed, 71 insertions(+), 75 deletions(-) diff --git a/bindgen/features.rs b/bindgen/features.rs index ccc4191552..97d85c1693 100644 --- a/bindgen/features.rs +++ b/bindgen/features.rs @@ -4,10 +4,56 @@ #![deny(clippy::missing_docs_in_private_items)] #![allow(deprecated)] -use std::cmp::Ordering; use std::io; use std::str::FromStr; +/// Represents the version of the Rust language to target. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[repr(transparent)] +pub struct RustTarget(Version); + +impl RustTarget { + const fn minor(&self) -> Option { + match self.0 { + Version::Nightly => None, + Version::Stable(minor, _) => Some(minor), + } + } + + const fn is_compatible(&self, other: &Self) -> bool { + match (self.0, other.0) { + (Version::Stable(minor, _), Version::Stable(other_minor, _)) => { + // We ignore the patch version number as they only include backwards compatible bug + // fixes. + minor >= other_minor + } + (_, Version::Nightly) => false, + (Version::Nightly, _) => true, + } + } +} + +impl Default for RustTarget { + fn default() -> Self { + LATEST_STABLE_RUST + } +} + +impl std::fmt::Display for RustTarget { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self.0 { + Version::Stable(minor, patch) => write!(f, "1.{minor}.{patch}"), + Version::Nightly => "nightly".fmt(f), + } + } +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +enum Version { + Stable(u64, u64), + Nightly, +} + /// This macro defines the [`RustTarget`] and [`RustFeatures`] types. macro_rules! define_rust_targets { ( @@ -18,38 +64,24 @@ macro_rules! define_rust_targets { )* $(,)? ) => { - /// Represents the version of the Rust language to target. - /// - /// To support a beta release, use the corresponding stable release. - /// - /// This enum will have more variants added as necessary. - #[allow(non_camel_case_types)] - #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] - pub enum RustTarget { - /// Rust Nightly + + impl RustTarget { + /// The nightly version of Rust, which introduces the following features:" $(#[doc = concat!( "- [`", stringify!($nightly_feature), "`]", "(", $("https://github.com/rust-lang/rust/pull/", stringify!($issue),)* ")", )])* - Nightly, + pub const Nightly: Self = Self(Version::Nightly); + $( - #[doc = concat!("Rust 1.", stringify!($minor))] + #[doc = concat!("Version 1.", stringify!($minor), " of Rust, which introduced the following features:")] $(#[doc = concat!( "- [`", stringify!($feature), "`]", "(", $("https://github.com/rust-lang/rust/pull/", stringify!($pull),)* ")", )])* $(#[$attrs])* - $variant, + pub const $variant: Self = Self(Version::Stable($minor, 0)); )* - } - - impl RustTarget { - const fn minor(self) -> Option { - match self { - $( Self::$variant => Some($minor),)* - Self::Nightly => None - } - } const fn stable_releases() -> [(Self, u64); [$($minor,)*].len()] { [$((Self::$variant, $minor),)*] @@ -58,7 +90,7 @@ macro_rules! define_rust_targets { #[cfg(feature = "__cli")] /// Strings of allowed `RustTarget` values - pub const RUST_TARGET_STRINGS: &[&str] = &[$(concat!("1.", stringify!($minor)),)*]; + pub(crate) const RUST_TARGET_STRINGS: &[&str] = &[$(concat!("1.", stringify!($minor)),)*]; #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] pub(crate) struct RustFeatures { @@ -80,7 +112,7 @@ macro_rules! define_rust_targets { $($nightly_feature: false,)* }; - $(if target >= RustTarget::$variant { + $(if target.is_compatible(&RustTarget::$variant) { $(features.$feature = true;)* })* @@ -206,29 +238,6 @@ pub const EARLIEST_STABLE_RUST: RustTarget = { } }; -impl Default for RustTarget { - fn default() -> Self { - LATEST_STABLE_RUST - } -} - -impl PartialOrd for RustTarget { - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.cmp(other)) - } -} - -impl Ord for RustTarget { - fn cmp(&self, other: &Self) -> Ordering { - match (self.minor(), other.minor()) { - (Some(a), Some(b)) => a.cmp(&b), - (Some(_), None) => Ordering::Less, - (None, Some(_)) => Ordering::Greater, - (None, None) => Ordering::Equal, - } - } -} - fn invalid_input(input: &str, msg: impl std::fmt::Display) -> io::Result { Err(io::Error::new( io::ErrorKind::InvalidInput, @@ -255,8 +264,7 @@ impl FromStr for RustTarget { ); } - // We ignore the patch version number as they only include backwards compatible bug fixes. - let (minor, _patch) = match tail.split_once('.') { + let (minor, patch) = match tail.split_once('.') { Some((minor_str, patch_str)) => { let Ok(minor) = minor_str.parse::() else { return invalid_input(input, "the minor version number must be an unsigned 64-bit integer"); @@ -274,26 +282,7 @@ impl FromStr for RustTarget { } }; - let Some(target) = Self::stable_releases() - .iter() - .filter(|(_, target_minor)| minor >= *target_minor) - .max_by_key(|(_, target_minor)| target_minor) - .map(|(target, _)| target) - .cloned() - else { - return invalid_input(input, format!("the earliest Rust target supported by bindgen is {EARLIEST_STABLE_RUST}")); - }; - - Ok(target) - } -} - -impl std::fmt::Display for RustTarget { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self.minor() { - Some(minor) => write!(f, "1.{}", minor), - None => "nightly".fmt(f), - } + Ok(Self(Version::Stable(minor, patch))) } } @@ -351,16 +340,23 @@ mod test { ); } - fn test_target(target_str: &str, target: RustTarget) { + fn test_target(input: &str, expected: RustTarget) { + // Two targets are equivalent if they enable the same set of features + let expected = RustFeatures::from(expected); + let found = RustFeatures::from(input.parse::().unwrap()); assert_eq!( - target, - target_str.parse::().unwrap(), - "{target_str}" + expected, + found, + "target {input} enables features:\n{found:#?}\nand should enable features:\n{expected:#?}" ); } - fn test_invalid_target(target_str: &str) { - assert!(target_str.parse::().is_err(), "{}", target_str); + fn test_invalid_target(input: &str) { + assert!( + input.parse::().is_err(), + "{} should be an invalid target", + input + ); } #[test] From f6a09142af1ede9733e3f692e3bc394b215cfb10 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Wed, 27 Nov 2024 11:58:04 -0500 Subject: [PATCH 3/7] Add constructors to `RustTarget` --- bindgen/features.rs | 60 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/bindgen/features.rs b/bindgen/features.rs index 97d85c1693..799b15a55f 100644 --- a/bindgen/features.rs +++ b/bindgen/features.rs @@ -4,8 +4,8 @@ #![deny(clippy::missing_docs_in_private_items)] #![allow(deprecated)] -use std::io; use std::str::FromStr; +use std::{fmt, io}; /// Represents the version of the Rust language to target. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] @@ -13,6 +13,17 @@ use std::str::FromStr; pub struct RustTarget(Version); impl RustTarget { + /// Create a new [`RustTarget`] for a stable release of Rust. + pub fn stable(minor: u64, patch: u64) -> Result { + let target = Self(Version::Stable(minor, patch)); + + if target < EARLIEST_STABLE_RUST { + return Err(InvalidRustTarget::TooEarly); + } + + Ok(target) + } + const fn minor(&self) -> Option { match self.0 { Version::Nightly => None, @@ -39,8 +50,8 @@ impl Default for RustTarget { } } -impl std::fmt::Display for RustTarget { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { +impl fmt::Display for RustTarget { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 { Version::Stable(minor, patch) => write!(f, "1.{minor}.{patch}"), Version::Nightly => "nightly".fmt(f), @@ -54,6 +65,18 @@ enum Version { Nightly, } +pub enum InvalidRustTarget { + TooEarly, +} + +impl fmt::Display for InvalidRustTarget { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::TooEarly => write!(f, "the earliest Rust version supported by bindgen is {EARLIEST_STABLE_RUST}"), + } + } +} + /// This macro defines the [`RustTarget`] and [`RustFeatures`] types. macro_rules! define_rust_targets { ( @@ -71,7 +94,16 @@ macro_rules! define_rust_targets { "- [`", stringify!($nightly_feature), "`]", "(", $("https://github.com/rust-lang/rust/pull/", stringify!($issue),)* ")", )])* - pub const Nightly: Self = Self(Version::Nightly); + pub const Nightly: Self = Self::nightly(); + + /// The nightly version of Rust, which introduces the following features:" + $(#[doc = concat!( + "- [`", stringify!($nightly_feature), "`]", + "(", $("https://github.com/rust-lang/rust/pull/", stringify!($issue),)* ")", + )])* + pub const fn nightly() -> Self { + Self(Version::Nightly) + } $( #[doc = concat!("Version 1.", stringify!($minor), " of Rust, which introduced the following features:")] @@ -238,11 +270,11 @@ pub const EARLIEST_STABLE_RUST: RustTarget = { } }; -fn invalid_input(input: &str, msg: impl std::fmt::Display) -> io::Result { - Err(io::Error::new( +fn invalid_input(input: &str, msg: impl fmt::Display) -> io::Error { + io::Error::new( io::ErrorKind::InvalidInput, format!("\"{input}\" is not a valid Rust target, {msg}"), - )) + ) } impl FromStr for RustTarget { @@ -254,35 +286,35 @@ impl FromStr for RustTarget { } let Some((major_str, tail)) = input.split_once('.') else { - return invalid_input(input, "accepted values are of the form \"1.71\", \"1.71.1\" or \"nightly\"." ); + return Err(invalid_input(input, "accepted values are of the form \"1.71\", \"1.71.1\" or \"nightly\"." ) ); }; if major_str != "1" { - return invalid_input( + return Err(invalid_input( input, "The largest major version of Rust released is \"1\"", - ); + )); } let (minor, patch) = match tail.split_once('.') { Some((minor_str, patch_str)) => { let Ok(minor) = minor_str.parse::() else { - return invalid_input(input, "the minor version number must be an unsigned 64-bit integer"); + return Err(invalid_input(input, "the minor version number must be an unsigned 64-bit integer")); }; let Ok(patch) = patch_str.parse::() else { - return invalid_input(input, "the patch version number must be an unsigned 64-bit integer"); + return Err(invalid_input(input, "the patch version number must be an unsigned 64-bit integer")); }; (minor, patch) } None => { let Ok(minor) = tail.parse::() else { - return invalid_input(input, "the minor version number must be an unsigned 64-bit integer"); + return Err(invalid_input(input, "the minor version number must be an unsigned 64-bit integer")); }; (minor, 0) } }; - Ok(Self(Version::Stable(minor, patch))) + Self::stable(minor, patch).map_err(|err| invalid_input(input, err)) } } From 7ce65e7ca183b28b84f36e6872a3cf53023c3210 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Wed, 27 Nov 2024 11:58:04 -0500 Subject: [PATCH 4/7] Remove deprecated targets --- .../tests/16-byte-alignment_1_0.rs | 299 --- .../tests/anon_struct_in_union_1_0.rs | 127 -- .../expectations/tests/anon_union_1_0.rs | 125 -- .../attribute_warn_unused_result_pre_1_27.rs | 25 - .../tests/bindgen-union-inside-namespace.rs | 62 +- .../tests/bitfield-enum-repr-c.rs | 2 +- .../tests/expectations/tests/class_1_0.rs | 539 ----- .../tests/class_with_inner_struct_1_0.rs | 397 ---- .../expectations/tests/derive-clone_1_0.rs | 42 - .../tests/derive-partialeq-union_1_0.rs | 96 - .../forward_declared_complex_types_1_0.rs | 89 - .../tests/expectations/tests/issue-493_1_0.rs | 136 -- .../tests/jsval_layout_opaque_1_0.rs | 459 ---- .../tests/expectations/tests/layout.rs | 53 +- .../expectations/tests/layout_eth_conf_1_0.rs | 1837 ----------------- .../expectations/tests/layout_mbuf_1_0.rs | 1047 ---------- .../expectations/tests/macro_const_1_0.rs | 8 - .../tests/expectations/tests/strings_array.rs | 6 +- .../tests/struct_with_anon_union_1_0.rs | 103 - .../struct_with_anon_unnamed_union_1_0.rs | 96 - .../tests/struct_with_nesting_1_0.rs | 184 -- .../tests/expectations/tests/transform-op.rs | 25 +- .../tests/expectations/tests/typeref_1_0.rs | 175 -- .../expectations/tests/union-in-ns_1_0.rs | 72 - .../expectations/tests/union_bitfield_1_0.rs | 285 --- .../expectations/tests/union_dtor_1_0.rs | 82 - .../expectations/tests/union_fields_1_0.rs | 83 - .../expectations/tests/union_template_1_0.rs | 72 - .../tests/union_with_anon_struct_1_0.rs | 103 - .../union_with_anon_struct_bitfield_1_0.rs | 230 --- .../tests/union_with_anon_union_1_0.rs | 104 - .../union_with_anon_unnamed_struct_1_0.rs | 116 -- .../union_with_anon_unnamed_union_1_0.rs | 105 - .../tests/union_with_big_member_1_0.rs | 165 -- .../tests/union_with_nesting_1_0.rs | 166 -- .../tests/expectations/tests/use-core_1_0.rs | 127 -- ...in32-thiscall_1_0.rs => win32-thiscall.rs} | 7 +- ...-vectorcall-1_0.rs => win32-vectorcall.rs} | 0 .../tests/wrap_unsafe_ops_anon_union.rs | 57 + .../tests/wrap_unsafe_ops_anon_union_1_0.rs | 100 - .../tests/headers/16-byte-alignment_1_0.h | 34 - .../tests/headers/anon_struct_in_union_1_0.h | 9 - .../tests/headers/anon_union_1_0.hpp | 22 - .../headers/attribute_warn_unused_result.hpp | 2 +- ...n_unused_result_no_attribute_detection.hpp | 2 +- .../attribute_warn_unused_result_pre_1_27.hpp | 8 - .../bindgen-union-inside-namespace.hpp | 2 +- .../tests/headers/bitfield-enum-repr-c.hpp | 2 +- .../bitfield-enum-repr-transparent.hpp | 2 +- bindgen-tests/tests/headers/class_1_0.hpp | 76 - .../headers/class_with_inner_struct_1_0.hpp | 44 - .../tests/headers/derive-clone_1_0.h | 7 - .../headers/derive-partialeq-union_1_0.hpp | 7 - .../forward_declared_complex_types_1_0.hpp | 18 - bindgen-tests/tests/headers/i128.h | 2 +- bindgen-tests/tests/headers/issue-1291.hpp | 2 +- bindgen-tests/tests/headers/issue-493_1_0.hpp | 49 - .../tests/headers/jsval_layout_opaque_1_0.hpp | 425 ---- bindgen-tests/tests/headers/layout.h | 2 +- .../tests/headers/layout_eth_conf_1_0.h | 429 ---- bindgen-tests/tests/headers/layout_mbuf_1_0.h | 189 -- bindgen-tests/tests/headers/long_double.h | 2 +- bindgen-tests/tests/headers/macro_const_1_0.h | 10 - bindgen-tests/tests/headers/newtype-enum.hpp | 2 +- .../tests/headers/newtype-global-enum.hpp | 2 +- bindgen-tests/tests/headers/repr-align.hpp | 2 +- bindgen-tests/tests/headers/strings_array.h | 2 +- .../headers/struct_with_anon_union_1_0.h | 8 - .../struct_with_anon_unnamed_union_1_0.h | 8 - .../tests/headers/struct_with_nesting_1_0.h | 19 - bindgen-tests/tests/headers/transform-op.hpp | 2 +- bindgen-tests/tests/headers/typeref_1_0.hpp | 30 - bindgen-tests/tests/headers/union-align.h | 2 +- .../tests/headers/union-in-ns_1_0.hpp | 5 - .../tests/headers/union_bitfield_1_0.h | 14 - .../tests/headers/union_dtor_1_0.hpp | 7 - .../tests/headers/union_fields_1_0.hpp | 7 - .../tests/headers/union_template_1_0.hpp | 21 - .../headers/union_with_anon_struct_1_0.h | 8 - .../union_with_anon_struct_bitfield_1_0.h | 9 - .../tests/headers/union_with_anon_union_1_0.h | 8 - .../union_with_anon_unnamed_struct_1_0.h | 11 - .../union_with_anon_unnamed_union_1_0.h | 9 - .../tests/headers/union_with_big_member_1_0.h | 16 - .../tests/headers/union_with_nesting_1_0.h | 16 - bindgen-tests/tests/headers/use-core_1_0.h | 13 - bindgen-tests/tests/headers/win32-dtors.hpp | 2 +- .../tests/headers/win32-thiscall.hpp | 7 + .../tests/headers/win32-thiscall_1_0.hpp | 7 - .../tests/headers/win32-vectorcall-1_0.h | 3 - .../tests/headers/win32-vectorcall.h | 3 + ...1_0.hpp => wrap_unsafe_ops_anon_union.hpp} | 2 +- bindgen/codegen/helpers.rs | 33 +- bindgen/codegen/mod.rs | 126 +- bindgen/codegen/struct_layout.rs | 6 +- bindgen/features.rs | 59 +- bindgen/ir/analysis/derive.rs | 5 +- bindgen/ir/layout.rs | 27 +- bindgen/lib.rs | 32 - 99 files changed, 251 insertions(+), 9433 deletions(-) delete mode 100644 bindgen-tests/tests/expectations/tests/16-byte-alignment_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/anon_struct_in_union_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/anon_union_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/attribute_warn_unused_result_pre_1_27.rs delete mode 100644 bindgen-tests/tests/expectations/tests/class_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/class_with_inner_struct_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/derive-clone_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/derive-partialeq-union_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/forward_declared_complex_types_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/issue-493_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/jsval_layout_opaque_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/layout_eth_conf_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/layout_mbuf_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/macro_const_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/struct_with_anon_union_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/struct_with_nesting_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/typeref_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/union-in-ns_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/union_bitfield_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/union_dtor_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/union_fields_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/union_template_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/union_with_anon_struct_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/union_with_anon_union_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/union_with_big_member_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/union_with_nesting_1_0.rs delete mode 100644 bindgen-tests/tests/expectations/tests/use-core_1_0.rs rename bindgen-tests/tests/expectations/tests/{win32-thiscall_1_0.rs => win32-thiscall.rs} (75%) rename bindgen-tests/tests/expectations/tests/{win32-vectorcall-1_0.rs => win32-vectorcall.rs} (100%) create mode 100644 bindgen-tests/tests/expectations/tests/wrap_unsafe_ops_anon_union.rs delete mode 100644 bindgen-tests/tests/expectations/tests/wrap_unsafe_ops_anon_union_1_0.rs delete mode 100644 bindgen-tests/tests/headers/16-byte-alignment_1_0.h delete mode 100644 bindgen-tests/tests/headers/anon_struct_in_union_1_0.h delete mode 100644 bindgen-tests/tests/headers/anon_union_1_0.hpp delete mode 100644 bindgen-tests/tests/headers/attribute_warn_unused_result_pre_1_27.hpp delete mode 100644 bindgen-tests/tests/headers/class_1_0.hpp delete mode 100644 bindgen-tests/tests/headers/class_with_inner_struct_1_0.hpp delete mode 100644 bindgen-tests/tests/headers/derive-clone_1_0.h delete mode 100644 bindgen-tests/tests/headers/derive-partialeq-union_1_0.hpp delete mode 100644 bindgen-tests/tests/headers/forward_declared_complex_types_1_0.hpp delete mode 100644 bindgen-tests/tests/headers/issue-493_1_0.hpp delete mode 100644 bindgen-tests/tests/headers/jsval_layout_opaque_1_0.hpp delete mode 100644 bindgen-tests/tests/headers/layout_eth_conf_1_0.h delete mode 100644 bindgen-tests/tests/headers/layout_mbuf_1_0.h delete mode 100644 bindgen-tests/tests/headers/macro_const_1_0.h delete mode 100644 bindgen-tests/tests/headers/struct_with_anon_union_1_0.h delete mode 100644 bindgen-tests/tests/headers/struct_with_anon_unnamed_union_1_0.h delete mode 100644 bindgen-tests/tests/headers/struct_with_nesting_1_0.h delete mode 100644 bindgen-tests/tests/headers/typeref_1_0.hpp delete mode 100644 bindgen-tests/tests/headers/union-in-ns_1_0.hpp delete mode 100644 bindgen-tests/tests/headers/union_bitfield_1_0.h delete mode 100644 bindgen-tests/tests/headers/union_dtor_1_0.hpp delete mode 100644 bindgen-tests/tests/headers/union_fields_1_0.hpp delete mode 100644 bindgen-tests/tests/headers/union_template_1_0.hpp delete mode 100644 bindgen-tests/tests/headers/union_with_anon_struct_1_0.h delete mode 100644 bindgen-tests/tests/headers/union_with_anon_struct_bitfield_1_0.h delete mode 100644 bindgen-tests/tests/headers/union_with_anon_union_1_0.h delete mode 100644 bindgen-tests/tests/headers/union_with_anon_unnamed_struct_1_0.h delete mode 100644 bindgen-tests/tests/headers/union_with_anon_unnamed_union_1_0.h delete mode 100644 bindgen-tests/tests/headers/union_with_big_member_1_0.h delete mode 100644 bindgen-tests/tests/headers/union_with_nesting_1_0.h delete mode 100644 bindgen-tests/tests/headers/use-core_1_0.h create mode 100644 bindgen-tests/tests/headers/win32-thiscall.hpp delete mode 100644 bindgen-tests/tests/headers/win32-thiscall_1_0.hpp delete mode 100644 bindgen-tests/tests/headers/win32-vectorcall-1_0.h create mode 100644 bindgen-tests/tests/headers/win32-vectorcall.h rename bindgen-tests/tests/headers/{wrap_unsafe_ops_anon_union_1_0.hpp => wrap_unsafe_ops_anon_union.hpp} (82%) diff --git a/bindgen-tests/tests/expectations/tests/16-byte-alignment_1_0.rs b/bindgen-tests/tests/expectations/tests/16-byte-alignment_1_0.rs deleted file mode 100644 index 06d008982c..0000000000 --- a/bindgen-tests/tests/expectations/tests/16-byte-alignment_1_0.rs +++ /dev/null @@ -1,299 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { - __BindgenUnionField(::std::marker::PhantomData) - } - #[inline] - pub unsafe fn as_ref(&self) -> &T { - ::std::mem::transmute(self) - } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { - ::std::mem::transmute(self) - } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { - Self::new() - } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { - *self - } -} -impl ::std::marker::Copy for __BindgenUnionField {} -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::std::cmp::Eq for __BindgenUnionField {} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct rte_ipv4_tuple { - pub src_addr: u32, - pub dst_addr: u32, - pub __bindgen_anon_1: rte_ipv4_tuple__bindgen_ty_1, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct rte_ipv4_tuple__bindgen_ty_1 { - pub __bindgen_anon_1: __BindgenUnionField< - rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1, - >, - pub sctp_tag: __BindgenUnionField, - pub bindgen_union_field: u32, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 { - pub dport: u16, - pub sport: u16, -} -#[test] -fn bindgen_test_layout_rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 4usize, - "Size of rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 2usize, - "Alignment of rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).dport) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1::dport", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).sport) as usize - ptr as usize }, - 2usize, - "Offset of field: rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1::sport", - ); -} -impl Clone for rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn bindgen_test_layout_rte_ipv4_tuple__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 4usize, - "Size of rte_ipv4_tuple__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of rte_ipv4_tuple__bindgen_ty_1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).sctp_tag) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_ipv4_tuple__bindgen_ty_1::sctp_tag", - ); -} -impl Clone for rte_ipv4_tuple__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn bindgen_test_layout_rte_ipv4_tuple() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 12usize, - "Size of rte_ipv4_tuple", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of rte_ipv4_tuple", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).src_addr) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_ipv4_tuple::src_addr", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).dst_addr) as usize - ptr as usize }, - 4usize, - "Offset of field: rte_ipv4_tuple::dst_addr", - ); -} -impl Clone for rte_ipv4_tuple { - fn clone(&self) -> Self { - *self - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct rte_ipv6_tuple { - pub src_addr: [u8; 16usize], - pub dst_addr: [u8; 16usize], - pub __bindgen_anon_1: rte_ipv6_tuple__bindgen_ty_1, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct rte_ipv6_tuple__bindgen_ty_1 { - pub __bindgen_anon_1: __BindgenUnionField< - rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1, - >, - pub sctp_tag: __BindgenUnionField, - pub bindgen_union_field: u32, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 { - pub dport: u16, - pub sport: u16, -} -#[test] -fn bindgen_test_layout_rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 4usize, - "Size of rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 2usize, - "Alignment of rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).dport) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1::dport", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).sport) as usize - ptr as usize }, - 2usize, - "Offset of field: rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1::sport", - ); -} -impl Clone for rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn bindgen_test_layout_rte_ipv6_tuple__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 4usize, - "Size of rte_ipv6_tuple__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of rte_ipv6_tuple__bindgen_ty_1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).sctp_tag) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_ipv6_tuple__bindgen_ty_1::sctp_tag", - ); -} -impl Clone for rte_ipv6_tuple__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn bindgen_test_layout_rte_ipv6_tuple() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 36usize, - "Size of rte_ipv6_tuple", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of rte_ipv6_tuple", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).src_addr) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_ipv6_tuple::src_addr", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).dst_addr) as usize - ptr as usize }, - 16usize, - "Offset of field: rte_ipv6_tuple::dst_addr", - ); -} -impl Clone for rte_ipv6_tuple { - fn clone(&self) -> Self { - *self - } -} -#[repr(C)] -#[derive(Copy)] -pub struct rte_thash_tuple { - pub v4: __BindgenUnionField, - pub v6: __BindgenUnionField, - pub bindgen_union_field: [u8; 48usize], -} -#[test] -fn bindgen_test_layout_rte_thash_tuple() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 48usize, - "Size of rte_thash_tuple", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).v4) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_thash_tuple::v4", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).v6) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_thash_tuple::v6", - ); -} -impl Clone for rte_thash_tuple { - fn clone(&self) -> Self { - *self - } -} -impl Default for rte_thash_tuple { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} diff --git a/bindgen-tests/tests/expectations/tests/anon_struct_in_union_1_0.rs b/bindgen-tests/tests/expectations/tests/anon_struct_in_union_1_0.rs deleted file mode 100644 index 5a6e3ca477..0000000000 --- a/bindgen-tests/tests/expectations/tests/anon_struct_in_union_1_0.rs +++ /dev/null @@ -1,127 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { - __BindgenUnionField(::std::marker::PhantomData) - } - #[inline] - pub unsafe fn as_ref(&self) -> &T { - ::std::mem::transmute(self) - } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { - ::std::mem::transmute(self) - } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { - Self::new() - } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { - *self - } -} -impl ::std::marker::Copy for __BindgenUnionField {} -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::std::cmp::Eq for __BindgenUnionField {} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct s { - pub u: s__bindgen_ty_1, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct s__bindgen_ty_1 { - pub field: __BindgenUnionField, - pub bindgen_union_field: u32, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct s__bindgen_ty_1_inner { - pub b: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_s__bindgen_ty_1_inner() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 4usize, - "Size of s__bindgen_ty_1_inner", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of s__bindgen_ty_1_inner", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).b) as usize - ptr as usize }, - 0usize, - "Offset of field: s__bindgen_ty_1_inner::b", - ); -} -impl Clone for s__bindgen_ty_1_inner { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn bindgen_test_layout_s__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 4usize, - "Size of s__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of s__bindgen_ty_1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).field) as usize - ptr as usize }, - 0usize, - "Offset of field: s__bindgen_ty_1::field", - ); -} -impl Clone for s__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn bindgen_test_layout_s() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 4usize, "Size of s"); - assert_eq!(::std::mem::align_of::(), 4usize, "Alignment of s"); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).u) as usize - ptr as usize }, - 0usize, - "Offset of field: s::u", - ); -} -impl Clone for s { - fn clone(&self) -> Self { - *self - } -} diff --git a/bindgen-tests/tests/expectations/tests/anon_union_1_0.rs b/bindgen-tests/tests/expectations/tests/anon_union_1_0.rs deleted file mode 100644 index 29b13d010d..0000000000 --- a/bindgen-tests/tests/expectations/tests/anon_union_1_0.rs +++ /dev/null @@ -1,125 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { - __BindgenUnionField(::std::marker::PhantomData) - } - #[inline] - pub unsafe fn as_ref(&self) -> &T { - ::std::mem::transmute(self) - } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { - ::std::mem::transmute(self) - } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { - Self::new() - } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { - *self - } -} -impl ::std::marker::Copy for __BindgenUnionField {} -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::std::cmp::Eq for __BindgenUnionField {} -#[repr(C)] -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub struct TErrorResult { - pub mResult: ::std::os::raw::c_int, - pub __bindgen_anon_1: TErrorResult__bindgen_ty_1, - pub mMightHaveUnreported: bool, - pub mUnionState: TErrorResult_UnionState, -} -pub const TErrorResult_UnionState_HasException: TErrorResult_UnionState = TErrorResult_UnionState::HasMessage; -#[repr(i32)] -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub enum TErrorResult_UnionState { - HasMessage = 0, -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct TErrorResult_Message { - _unused: [u8; 0], -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct TErrorResult_DOMExceptionInfo { - _unused: [u8; 0], -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] -pub struct TErrorResult__bindgen_ty_1 { - pub mMessage: __BindgenUnionField<*mut TErrorResult_Message>, - pub mDOMExceptionInfo: __BindgenUnionField<*mut TErrorResult_DOMExceptionInfo>, - pub bindgen_union_field: u64, -} -impl Default for TErrorResult { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -#[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] -pub struct ErrorResult { - pub _base: TErrorResult, -} -#[test] -fn bindgen_test_layout_ErrorResult() { - assert_eq!(::std::mem::size_of::(), 24usize, "Size of ErrorResult"); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - "Alignment of ErrorResult", - ); -} -impl Clone for ErrorResult { - fn clone(&self) -> Self { - *self - } -} -impl Default for ErrorResult { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -#[test] -fn __bindgen_test_layout_TErrorResult_open0_int_close0_instantiation() { - assert_eq!( - ::std::mem::size_of::(), - 24usize, - "Size of template specialization: TErrorResult_open0_int_close0", - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - "Align of template specialization: TErrorResult_open0_int_close0", - ); -} diff --git a/bindgen-tests/tests/expectations/tests/attribute_warn_unused_result_pre_1_27.rs b/bindgen-tests/tests/expectations/tests/attribute_warn_unused_result_pre_1_27.rs deleted file mode 100644 index f545f9e6bb..0000000000 --- a/bindgen-tests/tests/expectations/tests/attribute_warn_unused_result_pre_1_27.rs +++ /dev/null @@ -1,25 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Foo { - pub _address: u8, -} -#[allow(clippy::unnecessary_operation, clippy::identity_op)] -const _: () = { - ["Size of Foo"][::std::mem::size_of::() - 1usize]; - ["Alignment of Foo"][::std::mem::align_of::() - 1usize]; -}; -extern "C" { - #[link_name = "\u{1}_ZN3Foo3fooEi"] - pub fn Foo_foo(this: *mut Foo, arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int; -} -impl Foo { - #[inline] - pub unsafe fn foo(&mut self, arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int { - Foo_foo(self, arg1) - } -} -extern "C" { - #[link_name = "\u{1}_Z3fooi"] - pub fn foo(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int; -} diff --git a/bindgen-tests/tests/expectations/tests/bindgen-union-inside-namespace.rs b/bindgen-tests/tests/expectations/tests/bindgen-union-inside-namespace.rs index 70f9216a68..f3d7893b00 100644 --- a/bindgen-tests/tests/expectations/tests/bindgen-union-inside-namespace.rs +++ b/bindgen-tests/tests/expectations/tests/bindgen-union-inside-namespace.rs @@ -1,60 +1,16 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { - #[repr(C)] - pub struct __BindgenUnionField(::std::marker::PhantomData); - impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { - __BindgenUnionField(::std::marker::PhantomData) - } - #[inline] - pub unsafe fn as_ref(&self) -> &T { - ::std::mem::transmute(self) - } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { - ::std::mem::transmute(self) - } - } - impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { - Self::new() - } - } - impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { - *self - } - } - impl ::std::marker::Copy for __BindgenUnionField {} - impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } - } - impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} - } - impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } - } - impl ::std::cmp::Eq for __BindgenUnionField {} #[allow(unused_imports)] use self::super::root; pub mod foo { #[allow(unused_imports)] use self::super::super::root; #[repr(C)] - #[derive(Debug, Default, Copy)] - pub struct Bar { - pub foo: root::__BindgenUnionField<::std::os::raw::c_int>, - pub bar: root::__BindgenUnionField<::std::os::raw::c_int>, - pub bindgen_union_field: u32, + #[derive(Copy, Clone)] + pub union Bar { + pub foo: ::std::os::raw::c_int, + pub bar: ::std::os::raw::c_int, } #[test] fn bindgen_test_layout_Bar() { @@ -73,9 +29,13 @@ pub mod root { "Offset of field: Bar::bar", ); } - impl Clone for Bar { - fn clone(&self) -> Self { - *self + impl Default for Bar { + fn default() -> Self { + unsafe { + let mut s: Self = ::std::mem::uninitialized(); + ::std::ptr::write_bytes(&mut s, 0, 1); + s + } } } } diff --git a/bindgen-tests/tests/expectations/tests/bitfield-enum-repr-c.rs b/bindgen-tests/tests/expectations/tests/bitfield-enum-repr-c.rs index 0403e844e2..0b5202dfe3 100644 --- a/bindgen-tests/tests/expectations/tests/bitfield-enum-repr-c.rs +++ b/bindgen-tests/tests/expectations/tests/bitfield-enum-repr-c.rs @@ -37,6 +37,6 @@ impl ::std::ops::BitAndAssign for Foo { self.0 &= rhs.0; } } -#[repr(C)] +#[repr(transparent)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct Foo(pub ::std::os::raw::c_int); diff --git a/bindgen-tests/tests/expectations/tests/class_1_0.rs b/bindgen-tests/tests/expectations/tests/class_1_0.rs deleted file mode 100644 index 9db5b3a338..0000000000 --- a/bindgen-tests/tests/expectations/tests/class_1_0.rs +++ /dev/null @@ -1,539 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -#[derive(Default)] -pub struct __IncompleteArrayField(::std::marker::PhantomData, [T; 0]); -impl __IncompleteArrayField { - #[inline] - pub fn new() -> Self { - __IncompleteArrayField(::std::marker::PhantomData, []) - } - #[inline] - pub fn as_ptr(&self) -> *const T { - self as *const _ as *const T - } - #[inline] - pub fn as_mut_ptr(&mut self) -> *mut T { - self as *mut _ as *mut T - } - #[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") - } -} -#[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 - } -} -impl ::std::marker::Copy for __BindgenUnionField {} -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::std::cmp::Eq for __BindgenUnionField {} -#[repr(C)] -#[derive(Copy)] -pub struct C { - pub a: ::std::os::raw::c_int, - pub big_array: [::std::os::raw::c_char; 33usize], -} -#[test] -fn bindgen_test_layout_C() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 40usize, "Size of C"); - assert_eq!(::std::mem::align_of::(), 4usize, "Alignment of C"); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize }, - 0usize, - "Offset of field: C::a", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).big_array) as usize - ptr as usize }, - 4usize, - "Offset of field: C::big_array", - ); -} -impl Clone for C { - fn clone(&self) -> Self { - *self - } -} -impl Default for C { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -impl ::std::cmp::PartialEq for C { - fn eq(&self, other: &C) -> bool { - self.a == other.a && &self.big_array[..] == &other.big_array[..] - } -} -#[repr(C)] -pub struct C_with_zero_length_array { - pub a: ::std::os::raw::c_int, - pub big_array: [::std::os::raw::c_char; 33usize], - pub zero_length_array: __IncompleteArrayField<::std::os::raw::c_char>, -} -#[test] -fn bindgen_test_layout_C_with_zero_length_array() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 40usize, - "Size of C_with_zero_length_array", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of C_with_zero_length_array", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize }, - 0usize, - "Offset of field: C_with_zero_length_array::a", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).big_array) as usize - ptr as usize }, - 4usize, - "Offset of field: C_with_zero_length_array::big_array", - ); - assert_eq!( - unsafe { - ::std::ptr::addr_of!((*ptr).zero_length_array) as usize - ptr as usize - }, - 37usize, - "Offset of field: C_with_zero_length_array::zero_length_array", - ); -} -impl Default for C_with_zero_length_array { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -#[repr(C)] -#[derive(Debug, Default)] -pub struct C_with_zero_length_array_2 { - pub a: ::std::os::raw::c_int, - pub zero_length_array: __IncompleteArrayField<::std::os::raw::c_char>, -} -#[test] -fn bindgen_test_layout_C_with_zero_length_array_2() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 4usize, - "Size of C_with_zero_length_array_2", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of C_with_zero_length_array_2", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize }, - 0usize, - "Offset of field: C_with_zero_length_array_2::a", - ); - assert_eq!( - unsafe { - ::std::ptr::addr_of!((*ptr).zero_length_array) as usize - ptr as usize - }, - 4usize, - "Offset of field: C_with_zero_length_array_2::zero_length_array", - ); -} -#[repr(C)] -pub struct C_with_incomplete_array { - pub a: ::std::os::raw::c_int, - pub big_array: [::std::os::raw::c_char; 33usize], - pub incomplete_array: __IncompleteArrayField<::std::os::raw::c_char>, -} -#[test] -fn bindgen_test_layout_C_with_incomplete_array() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 40usize, - "Size of C_with_incomplete_array", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of C_with_incomplete_array", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize }, - 0usize, - "Offset of field: C_with_incomplete_array::a", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).big_array) as usize - ptr as usize }, - 4usize, - "Offset of field: C_with_incomplete_array::big_array", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).incomplete_array) as usize - ptr as usize }, - 37usize, - "Offset of field: C_with_incomplete_array::incomplete_array", - ); -} -impl Default for C_with_incomplete_array { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -#[repr(C)] -#[derive(Debug, Default)] -pub struct C_with_incomplete_array_2 { - pub a: ::std::os::raw::c_int, - pub incomplete_array: __IncompleteArrayField<::std::os::raw::c_char>, -} -#[test] -fn bindgen_test_layout_C_with_incomplete_array_2() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 4usize, - "Size of C_with_incomplete_array_2", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of C_with_incomplete_array_2", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize }, - 0usize, - "Offset of field: C_with_incomplete_array_2::a", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).incomplete_array) as usize - ptr as usize }, - 4usize, - "Offset of field: C_with_incomplete_array_2::incomplete_array", - ); -} -#[repr(C)] -pub struct C_with_zero_length_array_and_incomplete_array { - pub a: ::std::os::raw::c_int, - pub big_array: [::std::os::raw::c_char; 33usize], - pub zero_length_array: __IncompleteArrayField<::std::os::raw::c_char>, - pub incomplete_array: __IncompleteArrayField<::std::os::raw::c_char>, -} -#[test] -fn bindgen_test_layout_C_with_zero_length_array_and_incomplete_array() { - const UNINIT: ::std::mem::MaybeUninit< - C_with_zero_length_array_and_incomplete_array, - > = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 40usize, - "Size of C_with_zero_length_array_and_incomplete_array", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of C_with_zero_length_array_and_incomplete_array", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize }, - 0usize, - "Offset of field: C_with_zero_length_array_and_incomplete_array::a", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).big_array) as usize - ptr as usize }, - 4usize, - "Offset of field: C_with_zero_length_array_and_incomplete_array::big_array", - ); - assert_eq!( - unsafe { - ::std::ptr::addr_of!((*ptr).zero_length_array) as usize - ptr as usize - }, - 37usize, - "Offset of field: C_with_zero_length_array_and_incomplete_array::zero_length_array", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).incomplete_array) as usize - ptr as usize }, - 37usize, - "Offset of field: C_with_zero_length_array_and_incomplete_array::incomplete_array", - ); -} -impl Default for C_with_zero_length_array_and_incomplete_array { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -#[repr(C)] -#[derive(Debug, Default)] -pub struct C_with_zero_length_array_and_incomplete_array_2 { - pub a: ::std::os::raw::c_int, - pub zero_length_array: __IncompleteArrayField<::std::os::raw::c_char>, - pub incomplete_array: __IncompleteArrayField<::std::os::raw::c_char>, -} -#[test] -fn bindgen_test_layout_C_with_zero_length_array_and_incomplete_array_2() { - const UNINIT: ::std::mem::MaybeUninit< - C_with_zero_length_array_and_incomplete_array_2, - > = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 4usize, - "Size of C_with_zero_length_array_and_incomplete_array_2", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of C_with_zero_length_array_and_incomplete_array_2", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize }, - 0usize, - "Offset of field: C_with_zero_length_array_and_incomplete_array_2::a", - ); - assert_eq!( - unsafe { - ::std::ptr::addr_of!((*ptr).zero_length_array) as usize - ptr as usize - }, - 4usize, - "Offset of field: C_with_zero_length_array_and_incomplete_array_2::zero_length_array", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).incomplete_array) as usize - ptr as usize }, - 4usize, - "Offset of field: C_with_zero_length_array_and_incomplete_array_2::incomplete_array", - ); -} -#[repr(C)] -#[derive(Debug, Default, Hash, PartialEq, Eq)] -pub struct WithDtor { - pub b: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_WithDtor() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 4usize, "Size of WithDtor"); - assert_eq!(::std::mem::align_of::(), 4usize, "Alignment of WithDtor"); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).b) as usize - ptr as usize }, - 0usize, - "Offset of field: WithDtor::b", - ); -} -#[repr(C)] -pub struct IncompleteArrayNonCopiable { - pub whatever: *mut ::std::os::raw::c_void, - pub incomplete_array: __IncompleteArrayField, -} -#[test] -fn bindgen_test_layout_IncompleteArrayNonCopiable() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 8usize, - "Size of IncompleteArrayNonCopiable", - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - "Alignment of IncompleteArrayNonCopiable", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).whatever) as usize - ptr as usize }, - 0usize, - "Offset of field: IncompleteArrayNonCopiable::whatever", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).incomplete_array) as usize - ptr as usize }, - 8usize, - "Offset of field: IncompleteArrayNonCopiable::incomplete_array", - ); -} -impl Default for IncompleteArrayNonCopiable { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] -pub struct Union { - pub d: __BindgenUnionField, - pub i: __BindgenUnionField<::std::os::raw::c_int>, - pub bindgen_union_field: u32, -} -#[test] -fn bindgen_test_layout_Union() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 4usize, "Size of Union"); - assert_eq!(::std::mem::align_of::(), 4usize, "Alignment of Union"); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).d) as usize - ptr as usize }, - 0usize, - "Offset of field: Union::d", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).i) as usize - ptr as usize }, - 0usize, - "Offset of field: Union::i", - ); -} -impl Clone for Union { - fn clone(&self) -> Self { - *self - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] -pub struct WithUnion { - pub data: Union, -} -#[test] -fn bindgen_test_layout_WithUnion() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 4usize, "Size of WithUnion"); - assert_eq!(::std::mem::align_of::(), 4usize, "Alignment of WithUnion"); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, - 0usize, - "Offset of field: WithUnion::data", - ); -} -impl Clone for WithUnion { - fn clone(&self) -> Self { - *self - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct RealAbstractionWithTonsOfMethods { - pub _address: u8, -} -#[test] -fn bindgen_test_layout_RealAbstractionWithTonsOfMethods() { - assert_eq!( - ::std::mem::size_of::(), - 1usize, - "Size of RealAbstractionWithTonsOfMethods", - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - "Alignment of RealAbstractionWithTonsOfMethods", - ); -} -extern "C" { - #[link_name = "\u{1}_ZNK32RealAbstractionWithTonsOfMethods3barEv"] - pub fn RealAbstractionWithTonsOfMethods_bar( - this: *const RealAbstractionWithTonsOfMethods, - ); -} -extern "C" { - #[link_name = "\u{1}_ZN32RealAbstractionWithTonsOfMethods3barEv"] - pub fn RealAbstractionWithTonsOfMethods_bar1( - this: *mut RealAbstractionWithTonsOfMethods, - ); -} -extern "C" { - #[link_name = "\u{1}_ZN32RealAbstractionWithTonsOfMethods3barEi"] - pub fn RealAbstractionWithTonsOfMethods_bar2( - this: *mut RealAbstractionWithTonsOfMethods, - foo: ::std::os::raw::c_int, - ); -} -extern "C" { - #[link_name = "\u{1}_ZN32RealAbstractionWithTonsOfMethods3staEv"] - pub fn RealAbstractionWithTonsOfMethods_sta(); -} -impl Clone for RealAbstractionWithTonsOfMethods { - fn clone(&self) -> Self { - *self - } -} -impl RealAbstractionWithTonsOfMethods { - #[inline] - pub unsafe fn bar(&self) { - RealAbstractionWithTonsOfMethods_bar(self) - } - #[inline] - pub unsafe fn bar1(&mut self) { - RealAbstractionWithTonsOfMethods_bar1(self) - } - #[inline] - pub unsafe fn bar2(&mut self, foo: ::std::os::raw::c_int) { - RealAbstractionWithTonsOfMethods_bar2(self, foo) - } - #[inline] - pub unsafe fn sta() { - RealAbstractionWithTonsOfMethods_sta() - } -} diff --git a/bindgen-tests/tests/expectations/tests/class_with_inner_struct_1_0.rs b/bindgen-tests/tests/expectations/tests/class_with_inner_struct_1_0.rs deleted file mode 100644 index 23afad6319..0000000000 --- a/bindgen-tests/tests/expectations/tests/class_with_inner_struct_1_0.rs +++ /dev/null @@ -1,397 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { - __BindgenUnionField(::std::marker::PhantomData) - } - #[inline] - pub unsafe fn as_ref(&self) -> &T { - ::std::mem::transmute(self) - } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { - ::std::mem::transmute(self) - } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { - Self::new() - } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { - *self - } -} -impl ::std::marker::Copy for __BindgenUnionField {} -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::std::cmp::Eq for __BindgenUnionField {} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct A { - pub c: ::std::os::raw::c_uint, - pub named_union: A__bindgen_ty_1, - pub __bindgen_anon_1: A__bindgen_ty_2, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct A_Segment { - pub begin: ::std::os::raw::c_int, - pub end: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_A_Segment() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 8usize, "Size of A_Segment"); - assert_eq!(::std::mem::align_of::(), 4usize, "Alignment of A_Segment"); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).begin) as usize - ptr as usize }, - 0usize, - "Offset of field: A_Segment::begin", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).end) as usize - ptr as usize }, - 4usize, - "Offset of field: A_Segment::end", - ); -} -impl Clone for A_Segment { - fn clone(&self) -> Self { - *self - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct A__bindgen_ty_1 { - pub f: __BindgenUnionField<::std::os::raw::c_int>, - pub bindgen_union_field: u32, -} -#[test] -fn bindgen_test_layout_A__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 4usize, - "Size of A__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of A__bindgen_ty_1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).f) as usize - ptr as usize }, - 0usize, - "Offset of field: A__bindgen_ty_1::f", - ); -} -impl Clone for A__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct A__bindgen_ty_2 { - pub d: __BindgenUnionField<::std::os::raw::c_int>, - pub bindgen_union_field: u32, -} -#[test] -fn bindgen_test_layout_A__bindgen_ty_2() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 4usize, - "Size of A__bindgen_ty_2", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of A__bindgen_ty_2", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).d) as usize - ptr as usize }, - 0usize, - "Offset of field: A__bindgen_ty_2::d", - ); -} -impl Clone for A__bindgen_ty_2 { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn bindgen_test_layout_A() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 12usize, "Size of A"); - assert_eq!(::std::mem::align_of::(), 4usize, "Alignment of A"); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).c) as usize - ptr as usize }, - 0usize, - "Offset of field: A::c", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).named_union) as usize - ptr as usize }, - 4usize, - "Offset of field: A::named_union", - ); -} -impl Clone for A { - fn clone(&self) -> Self { - *self - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct B { - pub d: ::std::os::raw::c_uint, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct B_Segment { - pub begin: ::std::os::raw::c_int, - pub end: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_B_Segment() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 8usize, "Size of B_Segment"); - assert_eq!(::std::mem::align_of::(), 4usize, "Alignment of B_Segment"); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).begin) as usize - ptr as usize }, - 0usize, - "Offset of field: B_Segment::begin", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).end) as usize - ptr as usize }, - 4usize, - "Offset of field: B_Segment::end", - ); -} -impl Clone for B_Segment { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn bindgen_test_layout_B() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 4usize, "Size of B"); - assert_eq!(::std::mem::align_of::(), 4usize, "Alignment of B"); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).d) as usize - ptr as usize }, - 0usize, - "Offset of field: B::d", - ); -} -impl Clone for B { - fn clone(&self) -> Self { - *self - } -} -#[repr(i32)] -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub enum StepSyntax { - Keyword = 0, - FunctionalWithoutKeyword = 1, - FunctionalWithStartKeyword = 2, - FunctionalWithEndKeyword = 3, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] -pub struct C { - pub d: ::std::os::raw::c_uint, - pub __bindgen_anon_1: C__bindgen_ty_1, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] -pub struct C__bindgen_ty_1 { - pub mFunc: __BindgenUnionField, - pub __bindgen_anon_1: __BindgenUnionField, - pub bindgen_union_field: [u32; 4usize], -} -#[repr(C)] -#[derive(Debug, Default, Copy, PartialEq)] -pub struct C__bindgen_ty_1__bindgen_ty_1 { - pub mX1: f32, - pub mY1: f32, - pub mX2: f32, - pub mY2: f32, -} -#[test] -fn bindgen_test_layout_C__bindgen_ty_1__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 16usize, - "Size of C__bindgen_ty_1__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of C__bindgen_ty_1__bindgen_ty_1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).mX1) as usize - ptr as usize }, - 0usize, - "Offset of field: C__bindgen_ty_1__bindgen_ty_1::mX1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).mY1) as usize - ptr as usize }, - 4usize, - "Offset of field: C__bindgen_ty_1__bindgen_ty_1::mY1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).mX2) as usize - ptr as usize }, - 8usize, - "Offset of field: C__bindgen_ty_1__bindgen_ty_1::mX2", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).mY2) as usize - ptr as usize }, - 12usize, - "Offset of field: C__bindgen_ty_1__bindgen_ty_1::mY2", - ); -} -impl Clone for C__bindgen_ty_1__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -#[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] -pub struct C__bindgen_ty_1__bindgen_ty_2 { - pub mStepSyntax: StepSyntax, - pub mSteps: ::std::os::raw::c_uint, -} -#[test] -fn bindgen_test_layout_C__bindgen_ty_1__bindgen_ty_2() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 8usize, - "Size of C__bindgen_ty_1__bindgen_ty_2", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of C__bindgen_ty_1__bindgen_ty_2", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).mStepSyntax) as usize - ptr as usize }, - 0usize, - "Offset of field: C__bindgen_ty_1__bindgen_ty_2::mStepSyntax", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).mSteps) as usize - ptr as usize }, - 4usize, - "Offset of field: C__bindgen_ty_1__bindgen_ty_2::mSteps", - ); -} -impl Clone for C__bindgen_ty_1__bindgen_ty_2 { - fn clone(&self) -> Self { - *self - } -} -impl Default for C__bindgen_ty_1__bindgen_ty_2 { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -#[test] -fn bindgen_test_layout_C__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 16usize, - "Size of C__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of C__bindgen_ty_1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).mFunc) as usize - ptr as usize }, - 0usize, - "Offset of field: C__bindgen_ty_1::mFunc", - ); -} -impl Clone for C__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct C_Segment { - pub begin: ::std::os::raw::c_int, - pub end: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_C_Segment() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 8usize, "Size of C_Segment"); - assert_eq!(::std::mem::align_of::(), 4usize, "Alignment of C_Segment"); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).begin) as usize - ptr as usize }, - 0usize, - "Offset of field: C_Segment::begin", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).end) as usize - ptr as usize }, - 4usize, - "Offset of field: C_Segment::end", - ); -} -impl Clone for C_Segment { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn bindgen_test_layout_C() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 20usize, "Size of C"); - assert_eq!(::std::mem::align_of::(), 4usize, "Alignment of C"); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).d) as usize - ptr as usize }, - 0usize, - "Offset of field: C::d", - ); -} -impl Clone for C { - fn clone(&self) -> Self { - *self - } -} diff --git a/bindgen-tests/tests/expectations/tests/derive-clone_1_0.rs b/bindgen-tests/tests/expectations/tests/derive-clone_1_0.rs deleted file mode 100644 index 7b3a00738c..0000000000 --- a/bindgen-tests/tests/expectations/tests/derive-clone_1_0.rs +++ /dev/null @@ -1,42 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -/** Since builtin `Clone` impls were introduced in Rust 1.21 this struct - should impl `Clone` "manually".*/ -#[repr(C)] -#[derive(Copy)] -pub struct ShouldImplClone { - pub large: [::std::os::raw::c_int; 33usize], -} -#[test] -fn bindgen_test_layout_ShouldImplClone() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 132usize, - "Size of ShouldImplClone", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of ShouldImplClone", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).large) as usize - ptr as usize }, - 0usize, - "Offset of field: ShouldImplClone::large", - ); -} -impl Clone for ShouldImplClone { - fn clone(&self) -> Self { - *self - } -} -impl Default for ShouldImplClone { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} diff --git a/bindgen-tests/tests/expectations/tests/derive-partialeq-union_1_0.rs b/bindgen-tests/tests/expectations/tests/derive-partialeq-union_1_0.rs deleted file mode 100644 index f120f4fc12..0000000000 --- a/bindgen-tests/tests/expectations/tests/derive-partialeq-union_1_0.rs +++ /dev/null @@ -1,96 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { - __BindgenUnionField(::std::marker::PhantomData) - } - #[inline] - pub unsafe fn as_ref(&self) -> &T { - ::std::mem::transmute(self) - } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { - ::std::mem::transmute(self) - } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { - Self::new() - } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { - *self - } -} -impl ::std::marker::Copy for __BindgenUnionField {} -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::std::cmp::Eq for __BindgenUnionField {} -/// This should manually derive PartialEq. -#[repr(C)] -#[derive(Copy)] -pub struct ShouldDerivePartialEq { - pub a: __BindgenUnionField<[::std::os::raw::c_char; 150usize]>, - pub b: __BindgenUnionField<::std::os::raw::c_int>, - pub bindgen_union_field: [u32; 38usize], -} -#[test] -fn bindgen_test_layout_ShouldDerivePartialEq() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 152usize, - "Size of ShouldDerivePartialEq", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of ShouldDerivePartialEq", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize }, - 0usize, - "Offset of field: ShouldDerivePartialEq::a", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).b) as usize - ptr as usize }, - 0usize, - "Offset of field: ShouldDerivePartialEq::b", - ); -} -impl Clone for ShouldDerivePartialEq { - fn clone(&self) -> Self { - *self - } -} -impl Default for ShouldDerivePartialEq { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -impl ::std::cmp::PartialEq for ShouldDerivePartialEq { - fn eq(&self, other: &ShouldDerivePartialEq) -> bool { - &self.bindgen_union_field[..] == &other.bindgen_union_field[..] - } -} diff --git a/bindgen-tests/tests/expectations/tests/forward_declared_complex_types_1_0.rs b/bindgen-tests/tests/expectations/tests/forward_declared_complex_types_1_0.rs deleted file mode 100644 index e891a6b01b..0000000000 --- a/bindgen-tests/tests/expectations/tests/forward_declared_complex_types_1_0.rs +++ /dev/null @@ -1,89 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct Foo_empty { - pub _address: u8, -} -#[test] -fn bindgen_test_layout_Foo_empty() { - assert_eq!(::std::mem::size_of::(), 1usize, "Size of Foo_empty"); - assert_eq!(::std::mem::align_of::(), 1usize, "Alignment of Foo_empty"); -} -impl Clone for Foo_empty { - fn clone(&self) -> Self { - *self - } -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct Foo { - _unused: [u8; 0], -} -impl Clone for Foo { - fn clone(&self) -> Self { - *self - } -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct Bar { - pub f: *mut Foo, -} -#[test] -fn bindgen_test_layout_Bar() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 8usize, "Size of Bar"); - assert_eq!(::std::mem::align_of::(), 8usize, "Alignment of Bar"); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).f) as usize - ptr as usize }, - 0usize, - "Offset of field: Bar::f", - ); -} -impl Clone for Bar { - fn clone(&self) -> Self { - *self - } -} -impl Default for Bar { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -extern "C" { - #[link_name = "\u{1}_Z10baz_structP3Foo"] - pub fn baz_struct(f: *mut Foo); -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct Union { - _unused: [u8; 0], -} -impl Clone for Union { - fn clone(&self) -> Self { - *self - } -} -extern "C" { - #[link_name = "\u{1}_Z9baz_unionP5Union"] - pub fn baz_union(u: *mut Union); -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct Quux { - _unused: [u8; 0], -} -impl Clone for Quux { - fn clone(&self) -> Self { - *self - } -} -extern "C" { - #[link_name = "\u{1}_Z9baz_classP4Quux"] - pub fn baz_class(q: *mut Quux); -} diff --git a/bindgen-tests/tests/expectations/tests/issue-493_1_0.rs b/bindgen-tests/tests/expectations/tests/issue-493_1_0.rs deleted file mode 100644 index ff0c93428b..0000000000 --- a/bindgen-tests/tests/expectations/tests/issue-493_1_0.rs +++ /dev/null @@ -1,136 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { - __BindgenUnionField(::std::marker::PhantomData) - } - #[inline] - pub unsafe fn as_ref(&self) -> &T { - ::std::mem::transmute(self) - } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { - ::std::mem::transmute(self) - } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { - Self::new() - } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { - *self - } -} -impl ::std::marker::Copy for __BindgenUnionField {} -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::std::cmp::Eq for __BindgenUnionField {} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] -pub struct basic_string { - pub _address: u8, -} -pub type basic_string_size_type = ::std::os::raw::c_ulonglong; -pub type basic_string_value_type = ::std::os::raw::c_char; -pub type basic_string_pointer = *mut basic_string_value_type; -#[repr(C)] -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub struct basic_string___long { - pub __cap_: basic_string_size_type, - pub __size_: basic_string_size_type, - pub __data_: basic_string_pointer, -} -impl Default for basic_string___long { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -pub const basic_string___min_cap: basic_string__bindgen_ty_1 = basic_string__bindgen_ty_1::__min_cap; -#[repr(i32)] -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub enum basic_string__bindgen_ty_1 { - __min_cap = 0, -} -#[repr(C)] -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub struct basic_string___short { - pub __bindgen_anon_1: basic_string___short__bindgen_ty_1, - pub __data_: *mut basic_string_value_type, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] -pub struct basic_string___short__bindgen_ty_1 { - pub __size_: __BindgenUnionField<::std::os::raw::c_uchar>, - pub __lx: __BindgenUnionField, - pub bindgen_union_field: u8, -} -impl Default for basic_string___short { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] -pub struct basic_string___ulx { - pub __lx: __BindgenUnionField, - pub __lxx: __BindgenUnionField, - pub bindgen_union_field: [u8; 0usize], -} -pub const basic_string___n_words: basic_string__bindgen_ty_2 = basic_string__bindgen_ty_2::__n_words; -#[repr(i32)] -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub enum basic_string__bindgen_ty_2 { - __n_words = 0, -} -#[repr(C)] -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub struct basic_string___raw { - pub __words: *mut basic_string_size_type, -} -impl Default for basic_string___raw { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] -pub struct basic_string___rep { - pub __bindgen_anon_1: basic_string___rep__bindgen_ty_1, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] -pub struct basic_string___rep__bindgen_ty_1 { - pub __l: __BindgenUnionField, - pub __s: __BindgenUnionField, - pub __r: __BindgenUnionField, - pub bindgen_union_field: [u8; 0usize], -} diff --git a/bindgen-tests/tests/expectations/tests/jsval_layout_opaque_1_0.rs b/bindgen-tests/tests/expectations/tests/jsval_layout_opaque_1_0.rs deleted file mode 100644 index 422782d66d..0000000000 --- a/bindgen-tests/tests/expectations/tests/jsval_layout_opaque_1_0.rs +++ /dev/null @@ -1,459 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] -pub struct __BindgenBitfieldUnit { - storage: Storage, -} -impl __BindgenBitfieldUnit { - #[inline] - pub fn new(storage: Storage) -> Self { - Self { storage } - } -} -impl __BindgenBitfieldUnit -where - Storage: AsRef<[u8]> + AsMut<[u8]>, -{ - #[inline] - fn extract_bit(byte: u8, index: usize) -> bool { - let bit_index = if cfg!(target_endian = "big") { - 7 - (index % 8) - } else { - index % 8 - }; - let mask = 1 << bit_index; - byte & mask == mask - } - #[inline] - pub fn get_bit(&self, index: usize) -> bool { - debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; - let byte = self.storage.as_ref()[byte_index]; - Self::extract_bit(byte, index) - } - #[inline] - fn change_bit(byte: u8, index: usize, val: bool) -> u8 { - let bit_index = if cfg!(target_endian = "big") { - 7 - (index % 8) - } else { - index % 8 - }; - let mask = 1 << bit_index; - if val { byte | mask } else { byte & !mask } - } - #[inline] - pub fn set_bit(&mut self, index: usize, val: bool) { - debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; - let byte = &mut self.storage.as_mut()[byte_index]; - *byte = Self::change_bit(*byte, index, val); - } - #[inline] - pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { - debug_assert!(bit_width <= 64); - debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); - debug_assert!( - (bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len(), - ); - let mut val = 0; - for i in 0..(bit_width as usize) { - if self.get_bit(i + bit_offset) { - let index = if cfg!(target_endian = "big") { - bit_width as usize - 1 - i - } else { - i - }; - val |= 1 << index; - } - } - val - } - #[inline] - pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { - debug_assert!(bit_width <= 64); - debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); - debug_assert!( - (bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len(), - ); - for i in 0..(bit_width as usize) { - let mask = 1 << i; - let val_bit_is_set = val & mask == mask; - let index = if cfg!(target_endian = "big") { - bit_width as usize - 1 - i - } else { - i - }; - self.set_bit(index + bit_offset, val_bit_is_set); - } - } -} -#[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 - } -} -impl ::std::marker::Copy for __BindgenUnionField {} -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::std::cmp::Eq for __BindgenUnionField {} -pub const JSVAL_TAG_SHIFT: u32 = 47; -pub const JSVAL_PAYLOAD_MASK: u64 = 140737488355327; -pub const JSVAL_TAG_MASK: i64 = -140737488355328; -#[repr(u8)] -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub enum JSValueType { - JSVAL_TYPE_DOUBLE = 0, - JSVAL_TYPE_INT32 = 1, - JSVAL_TYPE_UNDEFINED = 2, - JSVAL_TYPE_BOOLEAN = 3, - JSVAL_TYPE_MAGIC = 4, - JSVAL_TYPE_STRING = 5, - JSVAL_TYPE_SYMBOL = 6, - JSVAL_TYPE_NULL = 7, - JSVAL_TYPE_OBJECT = 8, - JSVAL_TYPE_UNKNOWN = 32, - JSVAL_TYPE_MISSING = 33, -} -#[repr(u32)] -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub enum JSValueTag { - JSVAL_TAG_MAX_DOUBLE = 131056, - JSVAL_TAG_INT32 = 131057, - JSVAL_TAG_UNDEFINED = 131058, - JSVAL_TAG_STRING = 131061, - JSVAL_TAG_SYMBOL = 131062, - JSVAL_TAG_BOOLEAN = 131059, - JSVAL_TAG_MAGIC = 131060, - JSVAL_TAG_NULL = 131063, - JSVAL_TAG_OBJECT = 131064, -} -#[repr(u64)] -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub enum JSValueShiftedTag { - JSVAL_SHIFTED_TAG_MAX_DOUBLE = 18444492278190833663, - JSVAL_SHIFTED_TAG_INT32 = 18444633011384221696, - JSVAL_SHIFTED_TAG_UNDEFINED = 18444773748872577024, - JSVAL_SHIFTED_TAG_STRING = 18445195961337643008, - JSVAL_SHIFTED_TAG_SYMBOL = 18445336698825998336, - JSVAL_SHIFTED_TAG_BOOLEAN = 18444914486360932352, - JSVAL_SHIFTED_TAG_MAGIC = 18445055223849287680, - JSVAL_SHIFTED_TAG_NULL = 18445477436314353664, - JSVAL_SHIFTED_TAG_OBJECT = 18445618173802708992, -} -#[repr(u32)] -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub enum JSWhyMagic { - /// a hole in a native object's elements - JS_ELEMENTS_HOLE = 0, - /// there is not a pending iterator value - JS_NO_ITER_VALUE = 1, - /// exception value thrown when closing a generator - JS_GENERATOR_CLOSING = 2, - /// compiler sentinel value - JS_NO_CONSTANT = 3, - /// used in debug builds to catch tracing errors - JS_THIS_POISON = 4, - /// used in debug builds to catch tracing errors - JS_ARG_POISON = 5, - /// an empty subnode in the AST serializer - JS_SERIALIZE_NO_NODE = 6, - /// lazy arguments value on the stack - JS_LAZY_ARGUMENTS = 7, - /// optimized-away 'arguments' value - JS_OPTIMIZED_ARGUMENTS = 8, - /// magic value passed to natives to indicate construction - JS_IS_CONSTRUCTING = 9, - /// arguments.callee has been overwritten - JS_OVERWRITTEN_CALLEE = 10, - /// value of static block object slot - JS_BLOCK_NEEDS_CLONE = 11, - /// see class js::HashableValue - JS_HASH_KEY_EMPTY = 12, - /// error while running Ion code - JS_ION_ERROR = 13, - /// missing recover instruction result - JS_ION_BAILOUT = 14, - /// optimized out slot - JS_OPTIMIZED_OUT = 15, - /// uninitialized lexical bindings that produce ReferenceError on touch. - JS_UNINITIALIZED_LEXICAL = 16, - /// for local use - JS_GENERIC_MAGIC = 17, - /// for local use - JS_WHY_MAGIC_COUNT = 18, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] -pub struct jsval_layout { - pub asBits: __BindgenUnionField, - pub debugView: __BindgenUnionField, - pub s: __BindgenUnionField, - pub asDouble: __BindgenUnionField, - pub asPtr: __BindgenUnionField<*mut ::std::os::raw::c_void>, - pub asWord: __BindgenUnionField, - pub asUIntPtr: __BindgenUnionField, - pub bindgen_union_field: u64, -} -#[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] -pub struct jsval_layout__bindgen_ty_1 { - pub _bitfield_align_1: [u64; 0], - pub _bitfield_1: __BindgenBitfieldUnit<[u8; 8usize]>, -} -#[test] -fn bindgen_test_layout_jsval_layout__bindgen_ty_1() { - assert_eq!( - ::std::mem::size_of::(), - 8usize, - "Size of jsval_layout__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - "Alignment of jsval_layout__bindgen_ty_1", - ); -} -impl Clone for jsval_layout__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -impl Default for jsval_layout__bindgen_ty_1 { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -impl jsval_layout__bindgen_ty_1 { - #[inline] - pub fn payload47(&self) -> u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 47u8) as u64) } - } - #[inline] - pub fn set_payload47(&mut self, val: u64) { - unsafe { - let val: u64 = ::std::mem::transmute(val); - self._bitfield_1.set(0usize, 47u8, val as u64) - } - } - #[inline] - pub fn tag(&self) -> JSValueTag { - unsafe { ::std::mem::transmute(self._bitfield_1.get(47usize, 17u8) as u32) } - } - #[inline] - pub fn set_tag(&mut self, val: JSValueTag) { - unsafe { - let val: u32 = ::std::mem::transmute(val); - self._bitfield_1.set(47usize, 17u8, val as u64) - } - } - #[inline] - pub fn new_bitfield_1( - payload47: u64, - tag: JSValueTag, - ) -> __BindgenBitfieldUnit<[u8; 8usize]> { - let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 8usize]> = Default::default(); - __bindgen_bitfield_unit - .set( - 0usize, - 47u8, - { - let payload47: u64 = unsafe { ::std::mem::transmute(payload47) }; - payload47 as u64 - }, - ); - __bindgen_bitfield_unit - .set( - 47usize, - 17u8, - { - let tag: u32 = unsafe { ::std::mem::transmute(tag) }; - tag as u64 - }, - ); - __bindgen_bitfield_unit - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct jsval_layout__bindgen_ty_2 { - pub payload: jsval_layout__bindgen_ty_2__bindgen_ty_1, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct jsval_layout__bindgen_ty_2__bindgen_ty_1 { - pub i32_: __BindgenUnionField, - pub u32_: __BindgenUnionField, - pub why: __BindgenUnionField, - pub bindgen_union_field: u32, -} -#[test] -fn bindgen_test_layout_jsval_layout__bindgen_ty_2__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 4usize, - "Size of jsval_layout__bindgen_ty_2__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of jsval_layout__bindgen_ty_2__bindgen_ty_1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).i32_) as usize - ptr as usize }, - 0usize, - "Offset of field: jsval_layout__bindgen_ty_2__bindgen_ty_1::i32_", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).u32_) as usize - ptr as usize }, - 0usize, - "Offset of field: jsval_layout__bindgen_ty_2__bindgen_ty_1::u32_", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).why) as usize - ptr as usize }, - 0usize, - "Offset of field: jsval_layout__bindgen_ty_2__bindgen_ty_1::why", - ); -} -impl Clone for jsval_layout__bindgen_ty_2__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn bindgen_test_layout_jsval_layout__bindgen_ty_2() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 4usize, - "Size of jsval_layout__bindgen_ty_2", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of jsval_layout__bindgen_ty_2", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).payload) as usize - ptr as usize }, - 0usize, - "Offset of field: jsval_layout__bindgen_ty_2::payload", - ); -} -impl Clone for jsval_layout__bindgen_ty_2 { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn bindgen_test_layout_jsval_layout() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 8usize, "Size of jsval_layout"); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - "Alignment of jsval_layout", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).asBits) as usize - ptr as usize }, - 0usize, - "Offset of field: jsval_layout::asBits", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).debugView) as usize - ptr as usize }, - 0usize, - "Offset of field: jsval_layout::debugView", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).s) as usize - ptr as usize }, - 0usize, - "Offset of field: jsval_layout::s", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).asDouble) as usize - ptr as usize }, - 0usize, - "Offset of field: jsval_layout::asDouble", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).asPtr) as usize - ptr as usize }, - 0usize, - "Offset of field: jsval_layout::asPtr", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).asWord) as usize - ptr as usize }, - 0usize, - "Offset of field: jsval_layout::asWord", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).asUIntPtr) as usize - ptr as usize }, - 0usize, - "Offset of field: jsval_layout::asUIntPtr", - ); -} -impl Clone for jsval_layout { - fn clone(&self) -> Self { - *self - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] -pub struct Value { - pub data: jsval_layout, -} -#[test] -fn bindgen_test_layout_Value() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 8usize, "Size of Value"); - assert_eq!(::std::mem::align_of::(), 8usize, "Alignment of Value"); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, - 0usize, - "Offset of field: Value::data", - ); -} -impl Clone for Value { - fn clone(&self) -> Self { - *self - } -} diff --git a/bindgen-tests/tests/expectations/tests/layout.rs b/bindgen-tests/tests/expectations/tests/layout.rs index 8c4819f543..073f184f11 100644 --- a/bindgen-tests/tests/expectations/tests/layout.rs +++ b/bindgen-tests/tests/expectations/tests/layout.rs @@ -1,11 +1,62 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] #[repr(C)] +#[derive(Default)] +pub struct __IncompleteArrayField(::std::marker::PhantomData, [T; 0]); +impl __IncompleteArrayField { + #[inline] + pub const fn new() -> Self { + __IncompleteArrayField(::std::marker::PhantomData, []) + } + #[inline] + pub fn as_ptr(&self) -> *const T { + self as *const _ as *const T + } + #[inline] + pub fn as_mut_ptr(&mut self) -> *mut T { + self as *mut _ as *mut T + } + #[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") + } +} +#[repr(C, packed(16))] +#[repr(align(16))] pub struct header { - pub _bindgen_opaque_blob: [u8; 16usize], + pub proto: ::std::os::raw::c_char, + pub size: ::std::os::raw::c_uint, + pub data: __IncompleteArrayField<::std::os::raw::c_uchar>, } #[test] fn bindgen_test_layout_header() { + const UNINIT: ::std::mem::MaybeUninit
= ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!(::std::mem::size_of::
(), 16usize, "Size of header"); + assert_eq!(::std::mem::align_of::
(), 16usize, "Alignment of header"); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).proto) as usize - ptr as usize }, + 0usize, + "Offset of field: header::proto", + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, + 1usize, + "Offset of field: header::size", + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 8usize, + "Offset of field: header::data", + ); } impl Default for header { fn default() -> Self { diff --git a/bindgen-tests/tests/expectations/tests/layout_eth_conf_1_0.rs b/bindgen-tests/tests/expectations/tests/layout_eth_conf_1_0.rs deleted file mode 100644 index 6cbeb042aa..0000000000 --- a/bindgen-tests/tests/expectations/tests/layout_eth_conf_1_0.rs +++ /dev/null @@ -1,1837 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] -pub struct __BindgenBitfieldUnit { - storage: Storage, -} -impl __BindgenBitfieldUnit { - #[inline] - pub fn new(storage: Storage) -> Self { - Self { storage } - } -} -impl __BindgenBitfieldUnit -where - Storage: AsRef<[u8]> + AsMut<[u8]>, -{ - #[inline] - fn extract_bit(byte: u8, index: usize) -> bool { - let bit_index = if cfg!(target_endian = "big") { - 7 - (index % 8) - } else { - index % 8 - }; - let mask = 1 << bit_index; - byte & mask == mask - } - #[inline] - pub fn get_bit(&self, index: usize) -> bool { - debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; - let byte = self.storage.as_ref()[byte_index]; - Self::extract_bit(byte, index) - } - #[inline] - fn change_bit(byte: u8, index: usize, val: bool) -> u8 { - let bit_index = if cfg!(target_endian = "big") { - 7 - (index % 8) - } else { - index % 8 - }; - let mask = 1 << bit_index; - if val { byte | mask } else { byte & !mask } - } - #[inline] - pub fn set_bit(&mut self, index: usize, val: bool) { - debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; - let byte = &mut self.storage.as_mut()[byte_index]; - *byte = Self::change_bit(*byte, index, val); - } - #[inline] - pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { - debug_assert!(bit_width <= 64); - debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); - debug_assert!( - (bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len(), - ); - let mut val = 0; - for i in 0..(bit_width as usize) { - if self.get_bit(i + bit_offset) { - let index = if cfg!(target_endian = "big") { - bit_width as usize - 1 - i - } else { - i - }; - val |= 1 << index; - } - } - val - } - #[inline] - pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { - debug_assert!(bit_width <= 64); - debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); - debug_assert!( - (bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len(), - ); - for i in 0..(bit_width as usize) { - let mask = 1 << i; - let val_bit_is_set = val & mask == mask; - let index = if cfg!(target_endian = "big") { - bit_width as usize - 1 - i - } else { - i - }; - self.set_bit(index + bit_offset, val_bit_is_set); - } - } -} -#[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 - } -} -impl ::std::marker::Copy for __BindgenUnionField {} -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::std::cmp::Eq for __BindgenUnionField {} -pub const ETH_MQ_RX_RSS_FLAG: u32 = 1; -pub const ETH_MQ_RX_DCB_FLAG: u32 = 2; -pub const ETH_MQ_RX_VMDQ_FLAG: u32 = 4; -pub const ETH_VMDQ_MAX_VLAN_FILTERS: u32 = 64; -pub const ETH_DCB_NUM_USER_PRIORITIES: u32 = 8; -pub const ETH_VMDQ_DCB_NUM_QUEUES: u32 = 128; -pub const ETH_DCB_NUM_QUEUES: u32 = 128; -pub const RTE_ETH_FDIR_MAX_FLEXLEN: u32 = 16; -pub const RTE_ETH_INSET_SIZE_MAX: u32 = 128; -pub const RTE_ETH_FLOW_UNKNOWN: u32 = 0; -pub const RTE_ETH_FLOW_RAW: u32 = 1; -pub const RTE_ETH_FLOW_IPV4: u32 = 2; -pub const RTE_ETH_FLOW_FRAG_IPV4: u32 = 3; -pub const RTE_ETH_FLOW_NONFRAG_IPV4_TCP: u32 = 4; -pub const RTE_ETH_FLOW_NONFRAG_IPV4_UDP: u32 = 5; -pub const RTE_ETH_FLOW_NONFRAG_IPV4_SCTP: u32 = 6; -pub const RTE_ETH_FLOW_NONFRAG_IPV4_OTHER: u32 = 7; -pub const RTE_ETH_FLOW_IPV6: u32 = 8; -pub const RTE_ETH_FLOW_FRAG_IPV6: u32 = 9; -pub const RTE_ETH_FLOW_NONFRAG_IPV6_TCP: u32 = 10; -pub const RTE_ETH_FLOW_NONFRAG_IPV6_UDP: u32 = 11; -pub const RTE_ETH_FLOW_NONFRAG_IPV6_SCTP: u32 = 12; -pub const RTE_ETH_FLOW_NONFRAG_IPV6_OTHER: u32 = 13; -pub const RTE_ETH_FLOW_L2_PAYLOAD: u32 = 14; -pub const RTE_ETH_FLOW_IPV6_EX: u32 = 15; -pub const RTE_ETH_FLOW_IPV6_TCP_EX: u32 = 16; -pub const RTE_ETH_FLOW_IPV6_UDP_EX: u32 = 17; -pub const RTE_ETH_FLOW_PORT: u32 = 18; -pub const RTE_ETH_FLOW_VXLAN: u32 = 19; -pub const RTE_ETH_FLOW_GENEVE: u32 = 20; -pub const RTE_ETH_FLOW_NVGRE: u32 = 21; -pub const RTE_ETH_FLOW_MAX: u32 = 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, Hash, PartialEq, Eq)] -pub 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 = 1, - /// For RX side,only DCB is on. - ETH_MQ_RX_DCB = 2, - /// Both DCB and RSS enable - ETH_MQ_RX_DCB_RSS = 3, - /// Only VMDQ, no RSS nor DCB - ETH_MQ_RX_VMDQ_ONLY = 4, - /// RSS mode with VMDQ - ETH_MQ_RX_VMDQ_RSS = 5, - /// Use VMDQ+DCB to route traffic to queues - ETH_MQ_RX_VMDQ_DCB = 6, - /// Enable both VMDQ and DCB in VMDq - ETH_MQ_RX_VMDQ_DCB_RSS = 7, -} -/// A structure used to configure the RX features of an Ethernet port. -#[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] -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_align_1: [u8; 0], - pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, -} -#[test] -fn bindgen_test_layout_rte_eth_rxmode() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 12usize, - "Size of rte_eth_rxmode", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of rte_eth_rxmode", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).mq_mode) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_eth_rxmode::mq_mode", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).max_rx_pkt_len) as usize - ptr as usize }, - 4usize, - "Offset of field: rte_eth_rxmode::max_rx_pkt_len", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).split_hdr_size) as usize - ptr as usize }, - 8usize, - "Offset of field: rte_eth_rxmode::split_hdr_size", - ); -} -impl Clone for rte_eth_rxmode { - fn clone(&self) -> Self { - *self - } -} -impl Default for rte_eth_rxmode { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -impl rte_eth_rxmode { - #[inline] - pub fn header_split(&self) -> u16 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } - } - #[inline] - pub fn set_header_split(&mut self, val: u16) { - unsafe { - let val: u16 = ::std::mem::transmute(val); - self._bitfield_1.set(0usize, 1u8, val as u64) - } - } - #[inline] - pub fn hw_ip_checksum(&self) -> u16 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u16) } - } - #[inline] - pub fn set_hw_ip_checksum(&mut self, val: u16) { - unsafe { - let val: u16 = ::std::mem::transmute(val); - self._bitfield_1.set(1usize, 1u8, val as u64) - } - } - #[inline] - pub fn hw_vlan_filter(&self) -> u16 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u16) } - } - #[inline] - pub fn set_hw_vlan_filter(&mut self, val: u16) { - unsafe { - let val: u16 = ::std::mem::transmute(val); - self._bitfield_1.set(2usize, 1u8, val as u64) - } - } - #[inline] - pub fn hw_vlan_strip(&self) -> u16 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u16) } - } - #[inline] - pub fn set_hw_vlan_strip(&mut self, val: u16) { - unsafe { - let val: u16 = ::std::mem::transmute(val); - self._bitfield_1.set(3usize, 1u8, val as u64) - } - } - #[inline] - pub fn hw_vlan_extend(&self) -> u16 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u16) } - } - #[inline] - pub fn set_hw_vlan_extend(&mut self, val: u16) { - unsafe { - let val: u16 = ::std::mem::transmute(val); - self._bitfield_1.set(4usize, 1u8, val as u64) - } - } - #[inline] - pub fn jumbo_frame(&self) -> u16 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u16) } - } - #[inline] - pub fn set_jumbo_frame(&mut self, val: u16) { - unsafe { - let val: u16 = ::std::mem::transmute(val); - self._bitfield_1.set(5usize, 1u8, val as u64) - } - } - #[inline] - pub fn hw_strip_crc(&self) -> u16 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u16) } - } - #[inline] - pub fn set_hw_strip_crc(&mut self, val: u16) { - unsafe { - let val: u16 = ::std::mem::transmute(val); - self._bitfield_1.set(6usize, 1u8, val as u64) - } - } - #[inline] - pub fn enable_scatter(&self) -> u16 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u16) } - } - #[inline] - pub fn set_enable_scatter(&mut self, val: u16) { - unsafe { - let val: u16 = ::std::mem::transmute(val); - self._bitfield_1.set(7usize, 1u8, val as u64) - } - } - #[inline] - pub fn enable_lro(&self) -> u16 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(8usize, 1u8) as u16) } - } - #[inline] - pub fn set_enable_lro(&mut self, val: u16) { - unsafe { - let val: u16 = ::std::mem::transmute(val); - self._bitfield_1.set(8usize, 1u8, val as u64) - } - } - #[inline] - pub fn new_bitfield_1( - header_split: u16, - hw_ip_checksum: u16, - hw_vlan_filter: u16, - hw_vlan_strip: u16, - hw_vlan_extend: u16, - jumbo_frame: u16, - hw_strip_crc: u16, - enable_scatter: u16, - enable_lro: u16, - ) -> __BindgenBitfieldUnit<[u8; 2usize]> { - let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); - __bindgen_bitfield_unit - .set( - 0usize, - 1u8, - { - let header_split: u16 = unsafe { - ::std::mem::transmute(header_split) - }; - header_split as u64 - }, - ); - __bindgen_bitfield_unit - .set( - 1usize, - 1u8, - { - let hw_ip_checksum: u16 = unsafe { - ::std::mem::transmute(hw_ip_checksum) - }; - hw_ip_checksum as u64 - }, - ); - __bindgen_bitfield_unit - .set( - 2usize, - 1u8, - { - let hw_vlan_filter: u16 = unsafe { - ::std::mem::transmute(hw_vlan_filter) - }; - hw_vlan_filter as u64 - }, - ); - __bindgen_bitfield_unit - .set( - 3usize, - 1u8, - { - let hw_vlan_strip: u16 = unsafe { - ::std::mem::transmute(hw_vlan_strip) - }; - hw_vlan_strip as u64 - }, - ); - __bindgen_bitfield_unit - .set( - 4usize, - 1u8, - { - let hw_vlan_extend: u16 = unsafe { - ::std::mem::transmute(hw_vlan_extend) - }; - hw_vlan_extend as u64 - }, - ); - __bindgen_bitfield_unit - .set( - 5usize, - 1u8, - { - let jumbo_frame: u16 = unsafe { ::std::mem::transmute(jumbo_frame) }; - jumbo_frame as u64 - }, - ); - __bindgen_bitfield_unit - .set( - 6usize, - 1u8, - { - let hw_strip_crc: u16 = unsafe { - ::std::mem::transmute(hw_strip_crc) - }; - hw_strip_crc as u64 - }, - ); - __bindgen_bitfield_unit - .set( - 7usize, - 1u8, - { - let enable_scatter: u16 = unsafe { - ::std::mem::transmute(enable_scatter) - }; - enable_scatter as u64 - }, - ); - __bindgen_bitfield_unit - .set( - 8usize, - 1u8, - { - let enable_lro: u16 = unsafe { ::std::mem::transmute(enable_lro) }; - enable_lro as u64 - }, - ); - __bindgen_bitfield_unit - } -} -#[repr(u32)] -/** A set of values to identify what method is to be used to transmit - packets using multi-TCs.*/ -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub enum rte_eth_tx_mq_mode { - ///< It is in neither DCB nor VT mode. - ETH_MQ_TX_NONE = 0, - ///< For TX side,only DCB is on. - ETH_MQ_TX_DCB = 1, - ///< For TX side,both DCB and VT is on. - ETH_MQ_TX_VMDQ_DCB = 2, - ///< Only VT on, no DCB - ETH_MQ_TX_VMDQ_ONLY = 3, -} -/// A structure used to configure the TX features of an Ethernet port. -#[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] -pub struct rte_eth_txmode { - ///< TX multi-queues mode. - pub mq_mode: rte_eth_tx_mq_mode, - pub pvid: u16, - pub _bitfield_align_1: [u8; 0], - pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, - pub __bindgen_padding_0: u8, -} -#[test] -fn bindgen_test_layout_rte_eth_txmode() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 8usize, - "Size of rte_eth_txmode", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of rte_eth_txmode", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).mq_mode) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_eth_txmode::mq_mode", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).pvid) as usize - ptr as usize }, - 4usize, - "Offset of field: rte_eth_txmode::pvid", - ); -} -impl Clone for rte_eth_txmode { - fn clone(&self) -> Self { - *self - } -} -impl Default for rte_eth_txmode { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -impl rte_eth_txmode { - #[inline] - pub fn hw_vlan_reject_tagged(&self) -> u8 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } - } - #[inline] - pub fn set_hw_vlan_reject_tagged(&mut self, val: u8) { - unsafe { - let val: u8 = ::std::mem::transmute(val); - self._bitfield_1.set(0usize, 1u8, val as u64) - } - } - #[inline] - pub fn hw_vlan_reject_untagged(&self) -> u8 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } - } - #[inline] - pub fn set_hw_vlan_reject_untagged(&mut self, val: u8) { - unsafe { - let val: u8 = ::std::mem::transmute(val); - self._bitfield_1.set(1usize, 1u8, val as u64) - } - } - #[inline] - pub fn hw_vlan_insert_pvid(&self) -> u8 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } - } - #[inline] - pub fn set_hw_vlan_insert_pvid(&mut self, val: u8) { - unsafe { - let val: u8 = ::std::mem::transmute(val); - self._bitfield_1.set(2usize, 1u8, val as u64) - } - } - #[inline] - pub fn new_bitfield_1( - hw_vlan_reject_tagged: u8, - hw_vlan_reject_untagged: u8, - hw_vlan_insert_pvid: u8, - ) -> __BindgenBitfieldUnit<[u8; 1usize]> { - let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); - __bindgen_bitfield_unit - .set( - 0usize, - 1u8, - { - let hw_vlan_reject_tagged: u8 = unsafe { - ::std::mem::transmute(hw_vlan_reject_tagged) - }; - hw_vlan_reject_tagged as u64 - }, - ); - __bindgen_bitfield_unit - .set( - 1usize, - 1u8, - { - let hw_vlan_reject_untagged: u8 = unsafe { - ::std::mem::transmute(hw_vlan_reject_untagged) - }; - hw_vlan_reject_untagged as u64 - }, - ); - __bindgen_bitfield_unit - .set( - 2usize, - 1u8, - { - let hw_vlan_insert_pvid: u8 = unsafe { - ::std::mem::transmute(hw_vlan_insert_pvid) - }; - hw_vlan_insert_pvid as u64 - }, - ); - __bindgen_bitfield_unit - } -} -/** A structure used to configure the Receive Side Scaling (RSS) feature - of an Ethernet port. - If not NULL, the *rss_key* pointer of the *rss_conf* structure points - to an array holding the RSS key to use for hashing specific header - fields of received packets. The length of this array should be indicated - by *rss_key_len* below. Otherwise, a default random hash key is used by - the device driver. - - The *rss_key_len* field of the *rss_conf* structure indicates the length - in bytes of the array pointed by *rss_key*. To be compatible, this length - will be checked in i40e only. Others assume 40 bytes to be used as before. - - The *rss_hf* field of the *rss_conf* structure indicates the different - types of IPv4/IPv6 packets to which the RSS hashing must be applied. - Supplying an *rss_hf* equal to zero disables the RSS feature.*/ -#[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] -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() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 24usize, - "Size of rte_eth_rss_conf", - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - "Alignment of rte_eth_rss_conf", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).rss_key) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_eth_rss_conf::rss_key", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).rss_key_len) as usize - ptr as usize }, - 8usize, - "Offset of field: rte_eth_rss_conf::rss_key_len", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).rss_hf) as usize - ptr as usize }, - 16usize, - "Offset of field: rte_eth_rss_conf::rss_hf", - ); -} -impl Clone for rte_eth_rss_conf { - fn clone(&self) -> Self { - *self - } -} -impl Default for rte_eth_rss_conf { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -#[repr(u32)] -/** This enum indicates the possible number of traffic classes - in DCB configratioins*/ -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub enum rte_eth_nb_tcs { - ///< 4 TCs with DCB. - ETH_4_TCS = 4, - ///< 8 TCs with DCB. - ETH_8_TCS = 8, -} -#[repr(u32)] -/** This enum indicates the possible number of queue pools - in VMDQ configurations.*/ -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub enum rte_eth_nb_pools { - ///< 8 VMDq pools. - ETH_8_POOLS = 8, - ///< 16 VMDq pools. - ETH_16_POOLS = 16, - ///< 32 VMDq pools. - ETH_32_POOLS = 32, - ///< 64 VMDq pools. - ETH_64_POOLS = 64, -} -/** A structure used to configure the VMDQ+DCB feature - of an Ethernet port. - - Using this feature, packets are routed to a pool of queues, based - on the vlan ID in the vlan tag, and then to a specific queue within - that pool, using the user priority vlan tag field. - - A default pool may be used, if desired, to route all traffic which - does not match the vlan filter rules.*/ -#[repr(C)] -#[derive(Copy)] -pub struct rte_eth_vmdq_dcb_conf { - ///< With DCB, 16 or 32 pools - pub nb_queue_pools: rte_eth_nb_pools, - ///< If non-zero, use a default pool - pub enable_default_pool: u8, - ///< The default pool, if applicable - pub default_pool: u8, - ///< We can have up to 64 filters/mappings - pub nb_pool_maps: u8, - ///< VMDq vlan pool maps. - pub pool_map: [rte_eth_vmdq_dcb_conf__bindgen_ty_1; 64usize], - pub dcb_tc: [u8; 8usize], -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -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() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 16usize, - "Size of rte_eth_vmdq_dcb_conf__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - "Alignment of rte_eth_vmdq_dcb_conf__bindgen_ty_1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).vlan_id) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_eth_vmdq_dcb_conf__bindgen_ty_1::vlan_id", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).pools) as usize - ptr as usize }, - 8usize, - "Offset of field: rte_eth_vmdq_dcb_conf__bindgen_ty_1::pools", - ); -} -impl Clone for rte_eth_vmdq_dcb_conf__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn bindgen_test_layout_rte_eth_vmdq_dcb_conf() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 1040usize, - "Size of rte_eth_vmdq_dcb_conf", - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - "Alignment of rte_eth_vmdq_dcb_conf", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).nb_queue_pools) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_eth_vmdq_dcb_conf::nb_queue_pools", - ); - assert_eq!( - unsafe { - ::std::ptr::addr_of!((*ptr).enable_default_pool) as usize - ptr as usize - }, - 4usize, - "Offset of field: rte_eth_vmdq_dcb_conf::enable_default_pool", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).default_pool) as usize - ptr as usize }, - 5usize, - "Offset of field: rte_eth_vmdq_dcb_conf::default_pool", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).nb_pool_maps) as usize - ptr as usize }, - 6usize, - "Offset of field: rte_eth_vmdq_dcb_conf::nb_pool_maps", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).pool_map) as usize - ptr as usize }, - 8usize, - "Offset of field: rte_eth_vmdq_dcb_conf::pool_map", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).dcb_tc) as usize - ptr as usize }, - 1032usize, - "Offset of field: rte_eth_vmdq_dcb_conf::dcb_tc", - ); -} -impl Clone for rte_eth_vmdq_dcb_conf { - fn clone(&self) -> Self { - *self - } -} -impl Default for rte_eth_vmdq_dcb_conf { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -#[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] -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() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 12usize, - "Size of rte_eth_dcb_rx_conf", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of rte_eth_dcb_rx_conf", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).nb_tcs) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_eth_dcb_rx_conf::nb_tcs", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).dcb_tc) as usize - ptr as usize }, - 4usize, - "Offset of field: rte_eth_dcb_rx_conf::dcb_tc", - ); -} -impl Clone for rte_eth_dcb_rx_conf { - fn clone(&self) -> Self { - *self - } -} -impl Default for rte_eth_dcb_rx_conf { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -#[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] -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() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 12usize, - "Size of rte_eth_vmdq_dcb_tx_conf", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of rte_eth_vmdq_dcb_tx_conf", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).nb_queue_pools) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_eth_vmdq_dcb_tx_conf::nb_queue_pools", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).dcb_tc) as usize - ptr as usize }, - 4usize, - "Offset of field: rte_eth_vmdq_dcb_tx_conf::dcb_tc", - ); -} -impl Clone for rte_eth_vmdq_dcb_tx_conf { - fn clone(&self) -> Self { - *self - } -} -impl Default for rte_eth_vmdq_dcb_tx_conf { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -#[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] -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() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 12usize, - "Size of rte_eth_dcb_tx_conf", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of rte_eth_dcb_tx_conf", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).nb_tcs) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_eth_dcb_tx_conf::nb_tcs", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).dcb_tc) as usize - ptr as usize }, - 4usize, - "Offset of field: rte_eth_dcb_tx_conf::dcb_tc", - ); -} -impl Clone for rte_eth_dcb_tx_conf { - fn clone(&self) -> Self { - *self - } -} -impl Default for rte_eth_dcb_tx_conf { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -#[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] -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() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 4usize, - "Size of rte_eth_vmdq_tx_conf", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of rte_eth_vmdq_tx_conf", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).nb_queue_pools) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_eth_vmdq_tx_conf::nb_queue_pools", - ); -} -impl Clone for rte_eth_vmdq_tx_conf { - fn clone(&self) -> Self { - *self - } -} -impl Default for rte_eth_vmdq_tx_conf { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -#[repr(C)] -#[derive(Copy)] -pub struct rte_eth_vmdq_rx_conf { - ///< VMDq only mode, 8 or 64 pools - pub nb_queue_pools: rte_eth_nb_pools, - ///< If non-zero, use a default pool - pub enable_default_pool: u8, - ///< The default pool, if applicable - pub default_pool: u8, - ///< Enable VT loop back - pub enable_loop_back: u8, - ///< We can have up to 64 filters/mappings - pub nb_pool_maps: u8, - ///< Flags from ETH_VMDQ_ACCEPT_* - pub rx_mode: u32, - ///< VMDq vlan pool maps. - pub pool_map: [rte_eth_vmdq_rx_conf__bindgen_ty_1; 64usize], -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -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() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 16usize, - "Size of rte_eth_vmdq_rx_conf__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - "Alignment of rte_eth_vmdq_rx_conf__bindgen_ty_1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).vlan_id) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_eth_vmdq_rx_conf__bindgen_ty_1::vlan_id", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).pools) as usize - ptr as usize }, - 8usize, - "Offset of field: rte_eth_vmdq_rx_conf__bindgen_ty_1::pools", - ); -} -impl Clone for rte_eth_vmdq_rx_conf__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn bindgen_test_layout_rte_eth_vmdq_rx_conf() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 1040usize, - "Size of rte_eth_vmdq_rx_conf", - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - "Alignment of rte_eth_vmdq_rx_conf", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).nb_queue_pools) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_eth_vmdq_rx_conf::nb_queue_pools", - ); - assert_eq!( - unsafe { - ::std::ptr::addr_of!((*ptr).enable_default_pool) as usize - ptr as usize - }, - 4usize, - "Offset of field: rte_eth_vmdq_rx_conf::enable_default_pool", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).default_pool) as usize - ptr as usize }, - 5usize, - "Offset of field: rte_eth_vmdq_rx_conf::default_pool", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).enable_loop_back) as usize - ptr as usize }, - 6usize, - "Offset of field: rte_eth_vmdq_rx_conf::enable_loop_back", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).nb_pool_maps) as usize - ptr as usize }, - 7usize, - "Offset of field: rte_eth_vmdq_rx_conf::nb_pool_maps", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).rx_mode) as usize - ptr as usize }, - 8usize, - "Offset of field: rte_eth_vmdq_rx_conf::rx_mode", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).pool_map) as usize - ptr as usize }, - 16usize, - "Offset of field: rte_eth_vmdq_rx_conf::pool_map", - ); -} -impl Clone for rte_eth_vmdq_rx_conf { - fn clone(&self) -> Self { - *self - } -} -impl Default for rte_eth_vmdq_rx_conf { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -#[repr(u32)] -/// Flow Director setting modes: none, signature or perfect. -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub enum rte_fdir_mode { - ///< Disable FDIR support. - RTE_FDIR_MODE_NONE = 0, - ///< Enable FDIR signature filter mode. - RTE_FDIR_MODE_SIGNATURE = 1, - ///< Enable FDIR perfect filter mode. - RTE_FDIR_MODE_PERFECT = 2, - ///< Enable FDIR filter mode - MAC VLAN. - RTE_FDIR_MODE_PERFECT_MAC_VLAN = 3, - ///< Enable FDIR filter mode - tunnel. - 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, Hash, PartialEq, Eq)] -pub enum rte_fdir_pballoc_type { - ///< 64k. - RTE_FDIR_PBALLOC_64K = 0, - ///< 128k. - RTE_FDIR_PBALLOC_128K = 1, - ///< 256k. - RTE_FDIR_PBALLOC_256K = 2, -} -#[repr(u32)] -/// Select report mode of FDIR hash information in RX descriptors. -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub enum rte_fdir_status_mode { - ///< Never report FDIR hash. - RTE_FDIR_NO_REPORT_STATUS = 0, - ///< Only report FDIR hash for matching pkts. - RTE_FDIR_REPORT_STATUS = 1, - ///< Always report FDIR hash. - RTE_FDIR_REPORT_STATUS_ALWAYS = 2, -} -/// A structure used to define the input for IPV4 flow -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -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() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 12usize, - "Size of rte_eth_ipv4_flow", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of rte_eth_ipv4_flow", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).src_ip) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_eth_ipv4_flow::src_ip", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).dst_ip) as usize - ptr as usize }, - 4usize, - "Offset of field: rte_eth_ipv4_flow::dst_ip", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).tos) as usize - ptr as usize }, - 8usize, - "Offset of field: rte_eth_ipv4_flow::tos", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).ttl) as usize - ptr as usize }, - 9usize, - "Offset of field: rte_eth_ipv4_flow::ttl", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).proto) as usize - ptr as usize }, - 10usize, - "Offset of field: rte_eth_ipv4_flow::proto", - ); -} -impl Clone for rte_eth_ipv4_flow { - fn clone(&self) -> Self { - *self - } -} -/// A structure used to define the input for IPV6 flow -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -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() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 36usize, - "Size of rte_eth_ipv6_flow", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of rte_eth_ipv6_flow", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).src_ip) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_eth_ipv6_flow::src_ip", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).dst_ip) as usize - ptr as usize }, - 16usize, - "Offset of field: rte_eth_ipv6_flow::dst_ip", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).tc) as usize - ptr as usize }, - 32usize, - "Offset of field: rte_eth_ipv6_flow::tc", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).proto) as usize - ptr as usize }, - 33usize, - "Offset of field: rte_eth_ipv6_flow::proto", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).hop_limits) as usize - ptr as usize }, - 34usize, - "Offset of field: rte_eth_ipv6_flow::hop_limits", - ); -} -impl Clone for rte_eth_ipv6_flow { - fn clone(&self) -> Self { - *self - } -} -/** A structure used to configure FDIR masks that are used by the device - to match the various fields of RX packet headers.*/ -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -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() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 68usize, - "Size of rte_eth_fdir_masks", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of rte_eth_fdir_masks", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).vlan_tci_mask) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_eth_fdir_masks::vlan_tci_mask", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).ipv4_mask) as usize - ptr as usize }, - 4usize, - "Offset of field: rte_eth_fdir_masks::ipv4_mask", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).ipv6_mask) as usize - ptr as usize }, - 16usize, - "Offset of field: rte_eth_fdir_masks::ipv6_mask", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).src_port_mask) as usize - ptr as usize }, - 52usize, - "Offset of field: rte_eth_fdir_masks::src_port_mask", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).dst_port_mask) as usize - ptr as usize }, - 54usize, - "Offset of field: rte_eth_fdir_masks::dst_port_mask", - ); - assert_eq!( - unsafe { - ::std::ptr::addr_of!((*ptr).mac_addr_byte_mask) as usize - ptr as usize - }, - 56usize, - "Offset of field: rte_eth_fdir_masks::mac_addr_byte_mask", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).tunnel_id_mask) as usize - ptr as usize }, - 60usize, - "Offset of field: rte_eth_fdir_masks::tunnel_id_mask", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).tunnel_type_mask) as usize - ptr as usize }, - 64usize, - "Offset of field: rte_eth_fdir_masks::tunnel_type_mask", - ); -} -impl Clone for rte_eth_fdir_masks { - fn clone(&self) -> Self { - *self - } -} -#[repr(u32)] -/// Payload type -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub enum rte_eth_payload_type { - RTE_ETH_PAYLOAD_UNKNOWN = 0, - RTE_ETH_RAW_PAYLOAD = 1, - RTE_ETH_L2_PAYLOAD = 2, - RTE_ETH_L3_PAYLOAD = 3, - RTE_ETH_L4_PAYLOAD = 4, - RTE_ETH_PAYLOAD_MAX = 8, -} -/** A structure used to select bytes extracted from the protocol layers to - flexible payload for filter*/ -#[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] -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() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 36usize, - "Size of rte_eth_flex_payload_cfg", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of rte_eth_flex_payload_cfg", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_eth_flex_payload_cfg::type_", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).src_offset) as usize - ptr as usize }, - 4usize, - "Offset of field: rte_eth_flex_payload_cfg::src_offset", - ); -} -impl Clone for rte_eth_flex_payload_cfg { - fn clone(&self) -> Self { - *self - } -} -impl Default for rte_eth_flex_payload_cfg { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -/** A structure used to define FDIR masks for flexible payload - for each flow type*/ -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -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() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 18usize, - "Size of rte_eth_fdir_flex_mask", - ); - assert_eq!( - ::std::mem::align_of::(), - 2usize, - "Alignment of rte_eth_fdir_flex_mask", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).flow_type) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_eth_fdir_flex_mask::flow_type", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).mask) as usize - ptr as usize }, - 2usize, - "Offset of field: rte_eth_fdir_flex_mask::mask", - ); -} -impl Clone for rte_eth_fdir_flex_mask { - fn clone(&self) -> Self { - *self - } -} -/** A structure used to define all flexible payload related setting - include flex payload and flex mask*/ -#[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] -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() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 688usize, - "Size of rte_eth_fdir_flex_conf", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of rte_eth_fdir_flex_conf", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).nb_payloads) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_eth_fdir_flex_conf::nb_payloads", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).nb_flexmasks) as usize - ptr as usize }, - 2usize, - "Offset of field: rte_eth_fdir_flex_conf::nb_flexmasks", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).flex_set) as usize - ptr as usize }, - 4usize, - "Offset of field: rte_eth_fdir_flex_conf::flex_set", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).flex_mask) as usize - ptr as usize }, - 292usize, - "Offset of field: rte_eth_fdir_flex_conf::flex_mask", - ); -} -impl Clone for rte_eth_fdir_flex_conf { - fn clone(&self) -> Self { - *self - } -} -impl Default for rte_eth_fdir_flex_conf { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -/** A structure used to configure the Flow Director (FDIR) feature - of an Ethernet port. - - If mode is RTE_FDIR_DISABLE, the pballoc value is ignored.*/ -#[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] -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() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 772usize, - "Size of rte_fdir_conf", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of rte_fdir_conf", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).mode) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_fdir_conf::mode", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).pballoc) as usize - ptr as usize }, - 4usize, - "Offset of field: rte_fdir_conf::pballoc", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).status) as usize - ptr as usize }, - 8usize, - "Offset of field: rte_fdir_conf::status", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).drop_queue) as usize - ptr as usize }, - 12usize, - "Offset of field: rte_fdir_conf::drop_queue", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).mask) as usize - ptr as usize }, - 16usize, - "Offset of field: rte_fdir_conf::mask", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).flex_conf) as usize - ptr as usize }, - 84usize, - "Offset of field: rte_fdir_conf::flex_conf", - ); -} -impl Clone for rte_fdir_conf { - fn clone(&self) -> Self { - *self - } -} -impl Default for rte_fdir_conf { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -/// A structure used to enable/disable specific device interrupts. -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -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() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 4usize, "Size of rte_intr_conf"); - assert_eq!( - ::std::mem::align_of::(), - 2usize, - "Alignment of rte_intr_conf", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).lsc) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_intr_conf::lsc", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).rxq) as usize - ptr as usize }, - 2usize, - "Offset of field: rte_intr_conf::rxq", - ); -} -impl Clone for rte_intr_conf { - fn clone(&self) -> Self { - *self - } -} -/** A structure used to configure an Ethernet port. - Depending upon the RX multi-queue mode, extra advanced - configuration settings may be needed.*/ -#[repr(C)] -#[derive(Copy)] -pub struct rte_eth_conf { - /**< bitmap of ETH_LINK_SPEED_XXX of speeds to be -used. ETH_LINK_SPEED_FIXED disables link -autonegotiation, and a unique speed shall be -set. Otherwise, the bitmap defines the set of -speeds to be advertised. If the special value -ETH_LINK_SPEED_AUTONEG (0) is used, all speeds -supported are advertised.*/ - pub link_speeds: u32, - ///< Port RX configuration. - pub rxmode: rte_eth_rxmode, - ///< Port TX configuration. - pub txmode: rte_eth_txmode, - /**< Loopback operation mode. By default the value -is 0, meaning the loopback mode is disabled. -Read the datasheet of given ethernet controller -for details. The possible values of this field -are defined in implementation of each driver.*/ - pub lpbk_mode: u32, - ///< Port RX filtering configuration (union). - pub rx_adv_conf: rte_eth_conf__bindgen_ty_1, - ///< Port TX DCB configuration (union). - pub tx_adv_conf: rte_eth_conf__bindgen_ty_2, - /** Currently,Priority Flow Control(PFC) are supported,if DCB with PFC -is needed,and the variable must be set ETH_DCB_PFC_SUPPORT.*/ - pub dcb_capability_en: u32, - ///< FDIR configuration. - pub fdir_conf: rte_fdir_conf, - ///< Interrupt mode configuration. - pub intr_conf: rte_intr_conf, -} -#[repr(C)] -#[derive(Copy)] -pub struct rte_eth_conf__bindgen_ty_1 { - ///< Port RSS configuration - pub rss_conf: rte_eth_rss_conf, - pub vmdq_dcb_conf: rte_eth_vmdq_dcb_conf, - pub dcb_rx_conf: rte_eth_dcb_rx_conf, - pub vmdq_rx_conf: rte_eth_vmdq_rx_conf, -} -#[test] -fn bindgen_test_layout_rte_eth_conf__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 2120usize, - "Size of rte_eth_conf__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - "Alignment of rte_eth_conf__bindgen_ty_1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).rss_conf) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_eth_conf__bindgen_ty_1::rss_conf", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).vmdq_dcb_conf) as usize - ptr as usize }, - 24usize, - "Offset of field: rte_eth_conf__bindgen_ty_1::vmdq_dcb_conf", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).dcb_rx_conf) as usize - ptr as usize }, - 1064usize, - "Offset of field: rte_eth_conf__bindgen_ty_1::dcb_rx_conf", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).vmdq_rx_conf) as usize - ptr as usize }, - 1080usize, - "Offset of field: rte_eth_conf__bindgen_ty_1::vmdq_rx_conf", - ); -} -impl Clone for rte_eth_conf__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -impl Default for rte_eth_conf__bindgen_ty_1 { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -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() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 12usize, - "Size of rte_eth_conf__bindgen_ty_2", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of rte_eth_conf__bindgen_ty_2", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).vmdq_dcb_tx_conf) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_eth_conf__bindgen_ty_2::vmdq_dcb_tx_conf", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).dcb_tx_conf) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_eth_conf__bindgen_ty_2::dcb_tx_conf", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).vmdq_tx_conf) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_eth_conf__bindgen_ty_2::vmdq_tx_conf", - ); -} -impl Clone for rte_eth_conf__bindgen_ty_2 { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn bindgen_test_layout_rte_eth_conf() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 2944usize, "Size of rte_eth_conf"); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - "Alignment of rte_eth_conf", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).link_speeds) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_eth_conf::link_speeds", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).rxmode) as usize - ptr as usize }, - 4usize, - "Offset of field: rte_eth_conf::rxmode", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).txmode) as usize - ptr as usize }, - 16usize, - "Offset of field: rte_eth_conf::txmode", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).lpbk_mode) as usize - ptr as usize }, - 24usize, - "Offset of field: rte_eth_conf::lpbk_mode", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).rx_adv_conf) as usize - ptr as usize }, - 32usize, - "Offset of field: rte_eth_conf::rx_adv_conf", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).tx_adv_conf) as usize - ptr as usize }, - 2152usize, - "Offset of field: rte_eth_conf::tx_adv_conf", - ); - assert_eq!( - unsafe { - ::std::ptr::addr_of!((*ptr).dcb_capability_en) as usize - ptr as usize - }, - 2164usize, - "Offset of field: rte_eth_conf::dcb_capability_en", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).fdir_conf) as usize - ptr as usize }, - 2168usize, - "Offset of field: rte_eth_conf::fdir_conf", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).intr_conf) as usize - ptr as usize }, - 2940usize, - "Offset of field: rte_eth_conf::intr_conf", - ); -} -impl Clone for rte_eth_conf { - fn clone(&self) -> Self { - *self - } -} -impl Default for rte_eth_conf { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} diff --git a/bindgen-tests/tests/expectations/tests/layout_mbuf_1_0.rs b/bindgen-tests/tests/expectations/tests/layout_mbuf_1_0.rs deleted file mode 100644 index 38e221f3ca..0000000000 --- a/bindgen-tests/tests/expectations/tests/layout_mbuf_1_0.rs +++ /dev/null @@ -1,1047 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] -pub struct __BindgenBitfieldUnit { - storage: Storage, -} -impl __BindgenBitfieldUnit { - #[inline] - pub fn new(storage: Storage) -> Self { - Self { storage } - } -} -impl __BindgenBitfieldUnit -where - Storage: AsRef<[u8]> + AsMut<[u8]>, -{ - #[inline] - fn extract_bit(byte: u8, index: usize) -> bool { - let bit_index = if cfg!(target_endian = "big") { - 7 - (index % 8) - } else { - index % 8 - }; - let mask = 1 << bit_index; - byte & mask == mask - } - #[inline] - pub fn get_bit(&self, index: usize) -> bool { - debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; - let byte = self.storage.as_ref()[byte_index]; - Self::extract_bit(byte, index) - } - #[inline] - fn change_bit(byte: u8, index: usize, val: bool) -> u8 { - let bit_index = if cfg!(target_endian = "big") { - 7 - (index % 8) - } else { - index % 8 - }; - let mask = 1 << bit_index; - if val { byte | mask } else { byte & !mask } - } - #[inline] - pub fn set_bit(&mut self, index: usize, val: bool) { - debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; - let byte = &mut self.storage.as_mut()[byte_index]; - *byte = Self::change_bit(*byte, index, val); - } - #[inline] - pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { - debug_assert!(bit_width <= 64); - debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); - debug_assert!( - (bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len(), - ); - let mut val = 0; - for i in 0..(bit_width as usize) { - if self.get_bit(i + bit_offset) { - let index = if cfg!(target_endian = "big") { - bit_width as usize - 1 - i - } else { - i - }; - val |= 1 << index; - } - } - val - } - #[inline] - pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { - debug_assert!(bit_width <= 64); - debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); - debug_assert!( - (bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len(), - ); - for i in 0..(bit_width as usize) { - let mask = 1 << i; - let val_bit_is_set = val & mask == mask; - let index = if cfg!(target_endian = "big") { - bit_width as usize - 1 - i - } else { - i - }; - self.set_bit(index + bit_offset, val_bit_is_set); - } - } -} -#[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 - } -} -impl ::std::marker::Copy for __BindgenUnionField {} -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::std::cmp::Eq for __BindgenUnionField {} -pub const RTE_CACHE_LINE_MIN_SIZE: u32 = 64; -pub const RTE_CACHE_LINE_SIZE: u32 = 64; -pub type phys_addr_t = u64; -pub type MARKER = [*mut ::std::os::raw::c_void; 0usize]; -pub type MARKER8 = [u8; 0usize]; -pub type MARKER64 = [u64; 0usize]; -/// The atomic counter structure. -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct rte_atomic16_t { - ///< An internal counter value. - pub cnt: i16, -} -#[test] -fn bindgen_test_layout_rte_atomic16_t() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 2usize, - "Size of rte_atomic16_t", - ); - assert_eq!( - ::std::mem::align_of::(), - 2usize, - "Alignment of rte_atomic16_t", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).cnt) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_atomic16_t::cnt", - ); -} -impl Clone for rte_atomic16_t { - fn clone(&self) -> Self { - *self - } -} -/// The generic rte_mbuf, containing a packet mbuf. -#[repr(C)] -pub struct rte_mbuf { - pub cacheline0: MARKER, - ///< Virtual address of segment buffer. - pub buf_addr: *mut ::std::os::raw::c_void, - ///< Physical address of segment buffer. - pub buf_physaddr: phys_addr_t, - ///< Length of segment buffer. - pub buf_len: u16, - pub rearm_data: MARKER8, - pub data_off: u16, - pub __bindgen_anon_1: rte_mbuf__bindgen_ty_1, - ///< Number of segments. - pub nb_segs: u8, - ///< Input port. - pub port: u8, - ///< Offload features. - pub ol_flags: u64, - pub rx_descriptor_fields1: MARKER, - pub __bindgen_anon_2: rte_mbuf__bindgen_ty_2, - ///< Total pkt len: sum of all segments. - pub pkt_len: u32, - ///< Amount of data in segment buffer. - pub data_len: u16, - /// VLAN TCI (CPU order), valid if PKT_RX_VLAN_STRIPPED is set. - pub vlan_tci: u16, - ///< hash information - pub hash: rte_mbuf__bindgen_ty_3, - ///< Sequence number. See also rte_reorder_insert() - pub seqn: u32, - /// Outer VLAN TCI (CPU order), valid if PKT_RX_QINQ_STRIPPED is set. - pub vlan_tci_outer: u16, - pub cacheline1: MARKER, - pub __bindgen_anon_3: rte_mbuf__bindgen_ty_4, - ///< Pool from which mbuf was allocated. - pub pool: *mut rte_mempool, - ///< Next segment of scattered packet. - pub next: *mut rte_mbuf, - pub __bindgen_anon_4: rte_mbuf__bindgen_ty_5, - /** Size of the application private data. In case of an indirect - mbuf, it stores the direct mbuf private data size.*/ - pub priv_size: u16, - /// Timesync flags for use with IEEE1588. - pub timesync: u16, - pub __bindgen_padding_0: [u32; 7usize], -} -/** 16-bit Reference counter. - It should only be accessed using the following functions: - rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and - rte_mbuf_refcnt_set(). The functionality of these functions (atomic, - or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC - config option.*/ -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -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() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 2usize, - "Size of rte_mbuf__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 2usize, - "Alignment of rte_mbuf__bindgen_ty_1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).refcnt_atomic) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_mbuf__bindgen_ty_1::refcnt_atomic", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).refcnt) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_mbuf__bindgen_ty_1::refcnt", - ); -} -impl Clone for rte_mbuf__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct rte_mbuf__bindgen_ty_2 { - ///< L2/L3/L4 and tunnel information. - pub packet_type: __BindgenUnionField, - pub __bindgen_anon_1: __BindgenUnionField, - pub bindgen_union_field: u32, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct rte_mbuf__bindgen_ty_2__bindgen_ty_1 { - pub _bitfield_align_1: [u8; 0], - pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>, - pub __bindgen_align: [u32; 0usize], -} -#[test] -fn bindgen_test_layout_rte_mbuf__bindgen_ty_2__bindgen_ty_1() { - assert_eq!( - ::std::mem::size_of::(), - 4usize, - "Size of rte_mbuf__bindgen_ty_2__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of rte_mbuf__bindgen_ty_2__bindgen_ty_1", - ); -} -impl Clone for rte_mbuf__bindgen_ty_2__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 { - #[inline] - pub fn l2_type(&self) -> u32 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 4u8) as u32) } - } - #[inline] - pub fn set_l2_type(&mut self, val: u32) { - unsafe { - let val: u32 = ::std::mem::transmute(val); - self._bitfield_1.set(0usize, 4u8, val as u64) - } - } - #[inline] - pub fn l3_type(&self) -> u32 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 4u8) as u32) } - } - #[inline] - pub fn set_l3_type(&mut self, val: u32) { - unsafe { - let val: u32 = ::std::mem::transmute(val); - self._bitfield_1.set(4usize, 4u8, val as u64) - } - } - #[inline] - pub fn l4_type(&self) -> u32 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(8usize, 4u8) as u32) } - } - #[inline] - pub fn set_l4_type(&mut self, val: u32) { - unsafe { - let val: u32 = ::std::mem::transmute(val); - self._bitfield_1.set(8usize, 4u8, val as u64) - } - } - #[inline] - pub fn tun_type(&self) -> u32 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(12usize, 4u8) as u32) } - } - #[inline] - pub fn set_tun_type(&mut self, val: u32) { - unsafe { - let val: u32 = ::std::mem::transmute(val); - self._bitfield_1.set(12usize, 4u8, val as u64) - } - } - #[inline] - pub fn inner_l2_type(&self) -> u32 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(16usize, 4u8) as u32) } - } - #[inline] - pub fn set_inner_l2_type(&mut self, val: u32) { - unsafe { - let val: u32 = ::std::mem::transmute(val); - self._bitfield_1.set(16usize, 4u8, val as u64) - } - } - #[inline] - pub fn inner_l3_type(&self) -> u32 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(20usize, 4u8) as u32) } - } - #[inline] - pub fn set_inner_l3_type(&mut self, val: u32) { - unsafe { - let val: u32 = ::std::mem::transmute(val); - self._bitfield_1.set(20usize, 4u8, val as u64) - } - } - #[inline] - pub fn inner_l4_type(&self) -> u32 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(24usize, 4u8) as u32) } - } - #[inline] - pub fn set_inner_l4_type(&mut self, val: u32) { - unsafe { - let val: u32 = ::std::mem::transmute(val); - self._bitfield_1.set(24usize, 4u8, val as u64) - } - } - #[inline] - pub fn new_bitfield_1( - l2_type: u32, - l3_type: u32, - l4_type: u32, - tun_type: u32, - inner_l2_type: u32, - inner_l3_type: u32, - inner_l4_type: u32, - ) -> __BindgenBitfieldUnit<[u8; 4usize]> { - let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default(); - __bindgen_bitfield_unit - .set( - 0usize, - 4u8, - { - let l2_type: u32 = unsafe { ::std::mem::transmute(l2_type) }; - l2_type as u64 - }, - ); - __bindgen_bitfield_unit - .set( - 4usize, - 4u8, - { - let l3_type: u32 = unsafe { ::std::mem::transmute(l3_type) }; - l3_type as u64 - }, - ); - __bindgen_bitfield_unit - .set( - 8usize, - 4u8, - { - let l4_type: u32 = unsafe { ::std::mem::transmute(l4_type) }; - l4_type as u64 - }, - ); - __bindgen_bitfield_unit - .set( - 12usize, - 4u8, - { - let tun_type: u32 = unsafe { ::std::mem::transmute(tun_type) }; - tun_type as u64 - }, - ); - __bindgen_bitfield_unit - .set( - 16usize, - 4u8, - { - let inner_l2_type: u32 = unsafe { - ::std::mem::transmute(inner_l2_type) - }; - inner_l2_type as u64 - }, - ); - __bindgen_bitfield_unit - .set( - 20usize, - 4u8, - { - let inner_l3_type: u32 = unsafe { - ::std::mem::transmute(inner_l3_type) - }; - inner_l3_type as u64 - }, - ); - __bindgen_bitfield_unit - .set( - 24usize, - 4u8, - { - let inner_l4_type: u32 = unsafe { - ::std::mem::transmute(inner_l4_type) - }; - inner_l4_type as u64 - }, - ); - __bindgen_bitfield_unit - } -} -#[test] -fn bindgen_test_layout_rte_mbuf__bindgen_ty_2() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 4usize, - "Size of rte_mbuf__bindgen_ty_2", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of rte_mbuf__bindgen_ty_2", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).packet_type) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_mbuf__bindgen_ty_2::packet_type", - ); -} -impl Clone for rte_mbuf__bindgen_ty_2 { - fn clone(&self) -> Self { - *self - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct rte_mbuf__bindgen_ty_3 { - ///< RSS hash result if RSS enabled - pub rss: __BindgenUnionField, - ///< Filter identifier if FDIR enabled - pub fdir: __BindgenUnionField, - ///< Hierarchical scheduler - pub sched: __BindgenUnionField, - ///< User defined tags. See rte_distributor_process() - pub usr: __BindgenUnionField, - pub bindgen_union_field: [u32; 2usize], -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_1 { - pub __bindgen_anon_1: rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1, - pub hi: u32, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 { - pub __bindgen_anon_1: __BindgenUnionField< - rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1, - >, - pub lo: __BindgenUnionField, - pub bindgen_union_field: u32, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -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() { - const UNINIT: ::std::mem::MaybeUninit< - rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1, - > = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::< - rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1, - >(), - 4usize, - "Size of rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::< - rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1, - >(), - 2usize, - "Alignment of rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).hash) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1::hash", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize }, - 2usize, - "Offset of field: rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1::id", - ); -} -impl Clone for rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit< - rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1, - > = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 4usize, - "Size of rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).lo) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1::lo", - ); -} -impl Clone for rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 8usize, - "Size of rte_mbuf__bindgen_ty_3__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of rte_mbuf__bindgen_ty_3__bindgen_ty_1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).hi) as usize - ptr as usize }, - 4usize, - "Offset of field: rte_mbuf__bindgen_ty_3__bindgen_ty_1::hi", - ); -} -impl Clone for rte_mbuf__bindgen_ty_3__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -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() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 8usize, - "Size of rte_mbuf__bindgen_ty_3__bindgen_ty_2", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of rte_mbuf__bindgen_ty_3__bindgen_ty_2", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).lo) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_mbuf__bindgen_ty_3__bindgen_ty_2::lo", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).hi) as usize - ptr as usize }, - 4usize, - "Offset of field: rte_mbuf__bindgen_ty_3__bindgen_ty_2::hi", - ); -} -impl Clone for rte_mbuf__bindgen_ty_3__bindgen_ty_2 { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn bindgen_test_layout_rte_mbuf__bindgen_ty_3() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 8usize, - "Size of rte_mbuf__bindgen_ty_3", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of rte_mbuf__bindgen_ty_3", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).rss) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_mbuf__bindgen_ty_3::rss", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).fdir) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_mbuf__bindgen_ty_3::fdir", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).sched) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_mbuf__bindgen_ty_3::sched", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).usr) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_mbuf__bindgen_ty_3::usr", - ); -} -impl Clone for rte_mbuf__bindgen_ty_3 { - fn clone(&self) -> Self { - *self - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -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() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 8usize, - "Size of rte_mbuf__bindgen_ty_4", - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - "Alignment of rte_mbuf__bindgen_ty_4", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).userdata) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_mbuf__bindgen_ty_4::userdata", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).udata64) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_mbuf__bindgen_ty_4::udata64", - ); -} -impl Clone for rte_mbuf__bindgen_ty_4 { - fn clone(&self) -> Self { - *self - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct rte_mbuf__bindgen_ty_5 { - ///< combined for easy fetch - pub tx_offload: __BindgenUnionField, - pub __bindgen_anon_1: __BindgenUnionField, - pub bindgen_union_field: u64, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct rte_mbuf__bindgen_ty_5__bindgen_ty_1 { - pub _bitfield_align_1: [u16; 0], - pub _bitfield_1: __BindgenBitfieldUnit<[u8; 7usize]>, - pub __bindgen_align: [u64; 0usize], -} -#[test] -fn bindgen_test_layout_rte_mbuf__bindgen_ty_5__bindgen_ty_1() { - assert_eq!( - ::std::mem::size_of::(), - 8usize, - "Size of rte_mbuf__bindgen_ty_5__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - "Alignment of rte_mbuf__bindgen_ty_5__bindgen_ty_1", - ); -} -impl Clone for rte_mbuf__bindgen_ty_5__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -impl rte_mbuf__bindgen_ty_5__bindgen_ty_1 { - #[inline] - pub fn l2_len(&self) -> u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 7u8) as u64) } - } - #[inline] - pub fn set_l2_len(&mut self, val: u64) { - unsafe { - let val: u64 = ::std::mem::transmute(val); - self._bitfield_1.set(0usize, 7u8, val as u64) - } - } - #[inline] - pub fn l3_len(&self) -> u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(7usize, 9u8) as u64) } - } - #[inline] - pub fn set_l3_len(&mut self, val: u64) { - unsafe { - let val: u64 = ::std::mem::transmute(val); - self._bitfield_1.set(7usize, 9u8, val as u64) - } - } - #[inline] - pub fn l4_len(&self) -> u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(16usize, 8u8) as u64) } - } - #[inline] - pub fn set_l4_len(&mut self, val: u64) { - unsafe { - let val: u64 = ::std::mem::transmute(val); - self._bitfield_1.set(16usize, 8u8, val as u64) - } - } - #[inline] - pub fn tso_segsz(&self) -> u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(24usize, 16u8) as u64) } - } - #[inline] - pub fn set_tso_segsz(&mut self, val: u64) { - unsafe { - let val: u64 = ::std::mem::transmute(val); - self._bitfield_1.set(24usize, 16u8, val as u64) - } - } - #[inline] - pub fn outer_l3_len(&self) -> u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(40usize, 9u8) as u64) } - } - #[inline] - pub fn set_outer_l3_len(&mut self, val: u64) { - unsafe { - let val: u64 = ::std::mem::transmute(val); - self._bitfield_1.set(40usize, 9u8, val as u64) - } - } - #[inline] - pub fn outer_l2_len(&self) -> u64 { - unsafe { ::std::mem::transmute(self._bitfield_1.get(49usize, 7u8) as u64) } - } - #[inline] - pub fn set_outer_l2_len(&mut self, val: u64) { - unsafe { - let val: u64 = ::std::mem::transmute(val); - self._bitfield_1.set(49usize, 7u8, val as u64) - } - } - #[inline] - pub fn new_bitfield_1( - l2_len: u64, - l3_len: u64, - l4_len: u64, - tso_segsz: u64, - outer_l3_len: u64, - outer_l2_len: u64, - ) -> __BindgenBitfieldUnit<[u8; 7usize]> { - let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 7usize]> = Default::default(); - __bindgen_bitfield_unit - .set( - 0usize, - 7u8, - { - let l2_len: u64 = unsafe { ::std::mem::transmute(l2_len) }; - l2_len as u64 - }, - ); - __bindgen_bitfield_unit - .set( - 7usize, - 9u8, - { - let l3_len: u64 = unsafe { ::std::mem::transmute(l3_len) }; - l3_len as u64 - }, - ); - __bindgen_bitfield_unit - .set( - 16usize, - 8u8, - { - let l4_len: u64 = unsafe { ::std::mem::transmute(l4_len) }; - l4_len as u64 - }, - ); - __bindgen_bitfield_unit - .set( - 24usize, - 16u8, - { - let tso_segsz: u64 = unsafe { ::std::mem::transmute(tso_segsz) }; - tso_segsz as u64 - }, - ); - __bindgen_bitfield_unit - .set( - 40usize, - 9u8, - { - let outer_l3_len: u64 = unsafe { - ::std::mem::transmute(outer_l3_len) - }; - outer_l3_len as u64 - }, - ); - __bindgen_bitfield_unit - .set( - 49usize, - 7u8, - { - let outer_l2_len: u64 = unsafe { - ::std::mem::transmute(outer_l2_len) - }; - outer_l2_len as u64 - }, - ); - __bindgen_bitfield_unit - } -} -#[test] -fn bindgen_test_layout_rte_mbuf__bindgen_ty_5() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 8usize, - "Size of rte_mbuf__bindgen_ty_5", - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - "Alignment of rte_mbuf__bindgen_ty_5", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).tx_offload) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_mbuf__bindgen_ty_5::tx_offload", - ); -} -impl Clone for rte_mbuf__bindgen_ty_5 { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn bindgen_test_layout_rte_mbuf() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 128usize, "Size of rte_mbuf"); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).cacheline0) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_mbuf::cacheline0", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).buf_addr) as usize - ptr as usize }, - 0usize, - "Offset of field: rte_mbuf::buf_addr", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).buf_physaddr) as usize - ptr as usize }, - 8usize, - "Offset of field: rte_mbuf::buf_physaddr", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).buf_len) as usize - ptr as usize }, - 16usize, - "Offset of field: rte_mbuf::buf_len", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).rearm_data) as usize - ptr as usize }, - 18usize, - "Offset of field: rte_mbuf::rearm_data", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).data_off) as usize - ptr as usize }, - 18usize, - "Offset of field: rte_mbuf::data_off", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).nb_segs) as usize - ptr as usize }, - 22usize, - "Offset of field: rte_mbuf::nb_segs", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).port) as usize - ptr as usize }, - 23usize, - "Offset of field: rte_mbuf::port", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).ol_flags) as usize - ptr as usize }, - 24usize, - "Offset of field: rte_mbuf::ol_flags", - ); - assert_eq!( - unsafe { - ::std::ptr::addr_of!((*ptr).rx_descriptor_fields1) as usize - ptr as usize - }, - 32usize, - "Offset of field: rte_mbuf::rx_descriptor_fields1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).pkt_len) as usize - ptr as usize }, - 36usize, - "Offset of field: rte_mbuf::pkt_len", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).data_len) as usize - ptr as usize }, - 40usize, - "Offset of field: rte_mbuf::data_len", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).vlan_tci) as usize - ptr as usize }, - 42usize, - "Offset of field: rte_mbuf::vlan_tci", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).hash) as usize - ptr as usize }, - 44usize, - "Offset of field: rte_mbuf::hash", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).seqn) as usize - ptr as usize }, - 52usize, - "Offset of field: rte_mbuf::seqn", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).vlan_tci_outer) as usize - ptr as usize }, - 56usize, - "Offset of field: rte_mbuf::vlan_tci_outer", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).cacheline1) as usize - ptr as usize }, - 64usize, - "Offset of field: rte_mbuf::cacheline1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).pool) as usize - ptr as usize }, - 72usize, - "Offset of field: rte_mbuf::pool", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).next) as usize - ptr as usize }, - 80usize, - "Offset of field: rte_mbuf::next", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).priv_size) as usize - ptr as usize }, - 96usize, - "Offset of field: rte_mbuf::priv_size", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).timesync) as usize - ptr as usize }, - 98usize, - "Offset of field: rte_mbuf::timesync", - ); -} -impl Default for rte_mbuf { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -///< Pool from which mbuf was allocated. -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct rte_mempool { - pub _address: u8, -} -impl Clone for rte_mempool { - fn clone(&self) -> Self { - *self - } -} diff --git a/bindgen-tests/tests/expectations/tests/macro_const_1_0.rs b/bindgen-tests/tests/expectations/tests/macro_const_1_0.rs deleted file mode 100644 index 2f3e228d80..0000000000 --- a/bindgen-tests/tests/expectations/tests/macro_const_1_0.rs +++ /dev/null @@ -1,8 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -pub const foo: &'static [u8; 4] = b"bar\0"; -pub const CHAR: u8 = 98u8; -pub const CHARR: u8 = 0u8; -pub const FLOAT: f64 = 5.09; -pub const FLOAT_EXPR: f64 = 0.005; -pub const LONG: u32 = 3; -pub const INVALID_UTF8: &'static [u8; 5] = b"\xF0(\x8C(\0"; diff --git a/bindgen-tests/tests/expectations/tests/strings_array.rs b/bindgen-tests/tests/expectations/tests/strings_array.rs index 6f352b32ca..12543e59a8 100644 --- a/bindgen-tests/tests/expectations/tests/strings_array.rs +++ b/bindgen-tests/tests/expectations/tests/strings_array.rs @@ -1,4 +1,4 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -pub const MY_STRING_UTF8: &'static [u8; 14] = b"Hello, world!\0"; -pub const MY_STRING_INTERIOR_NULL: &'static [u8; 7] = b"Hello,\0"; -pub const MY_STRING_NON_UTF8: &'static [u8; 7] = b"ABCDE\xFF\0"; +pub const MY_STRING_UTF8: &[u8; 14] = b"Hello, world!\0"; +pub const MY_STRING_INTERIOR_NULL: &[u8; 7] = b"Hello,\0"; +pub const MY_STRING_NON_UTF8: &[u8; 7] = b"ABCDE\xFF\0"; diff --git a/bindgen-tests/tests/expectations/tests/struct_with_anon_union_1_0.rs b/bindgen-tests/tests/expectations/tests/struct_with_anon_union_1_0.rs deleted file mode 100644 index dda2d06eb8..0000000000 --- a/bindgen-tests/tests/expectations/tests/struct_with_anon_union_1_0.rs +++ /dev/null @@ -1,103 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { - __BindgenUnionField(::std::marker::PhantomData) - } - #[inline] - pub unsafe fn as_ref(&self) -> &T { - ::std::mem::transmute(self) - } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { - ::std::mem::transmute(self) - } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { - Self::new() - } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { - *self - } -} -impl ::std::marker::Copy for __BindgenUnionField {} -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::std::cmp::Eq for __BindgenUnionField {} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct foo { - pub bar: foo__bindgen_ty_1, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct foo__bindgen_ty_1 { - pub a: __BindgenUnionField<::std::os::raw::c_uint>, - pub b: __BindgenUnionField<::std::os::raw::c_ushort>, - pub bindgen_union_field: u32, -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 4usize, - "Size of foo__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of foo__bindgen_ty_1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize }, - 0usize, - "Offset of field: foo__bindgen_ty_1::a", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).b) as usize - ptr as usize }, - 0usize, - "Offset of field: foo__bindgen_ty_1::b", - ); -} -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn bindgen_test_layout_foo() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 4usize, "Size of foo"); - assert_eq!(::std::mem::align_of::(), 4usize, "Alignment of foo"); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).bar) as usize - ptr as usize }, - 0usize, - "Offset of field: foo::bar", - ); -} -impl Clone for foo { - fn clone(&self) -> Self { - *self - } -} diff --git a/bindgen-tests/tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs b/bindgen-tests/tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs deleted file mode 100644 index b9977c688b..0000000000 --- a/bindgen-tests/tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs +++ /dev/null @@ -1,96 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { - __BindgenUnionField(::std::marker::PhantomData) - } - #[inline] - pub unsafe fn as_ref(&self) -> &T { - ::std::mem::transmute(self) - } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { - ::std::mem::transmute(self) - } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { - Self::new() - } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { - *self - } -} -impl ::std::marker::Copy for __BindgenUnionField {} -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::std::cmp::Eq for __BindgenUnionField {} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct foo { - pub __bindgen_anon_1: foo__bindgen_ty_1, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct foo__bindgen_ty_1 { - pub a: __BindgenUnionField<::std::os::raw::c_uint>, - pub b: __BindgenUnionField<::std::os::raw::c_ushort>, - pub bindgen_union_field: u32, -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 4usize, - "Size of foo__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of foo__bindgen_ty_1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize }, - 0usize, - "Offset of field: foo__bindgen_ty_1::a", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).b) as usize - ptr as usize }, - 0usize, - "Offset of field: foo__bindgen_ty_1::b", - ); -} -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::(), 4usize, "Size of foo"); - assert_eq!(::std::mem::align_of::(), 4usize, "Alignment of foo"); -} -impl Clone for foo { - fn clone(&self) -> Self { - *self - } -} diff --git a/bindgen-tests/tests/expectations/tests/struct_with_nesting_1_0.rs b/bindgen-tests/tests/expectations/tests/struct_with_nesting_1_0.rs deleted file mode 100644 index 0753326174..0000000000 --- a/bindgen-tests/tests/expectations/tests/struct_with_nesting_1_0.rs +++ /dev/null @@ -1,184 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { - __BindgenUnionField(::std::marker::PhantomData) - } - #[inline] - pub unsafe fn as_ref(&self) -> &T { - ::std::mem::transmute(self) - } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { - ::std::mem::transmute(self) - } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { - Self::new() - } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { - *self - } -} -impl ::std::marker::Copy for __BindgenUnionField {} -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::std::cmp::Eq for __BindgenUnionField {} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct foo { - pub a: ::std::os::raw::c_uint, - pub __bindgen_anon_1: foo__bindgen_ty_1, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct foo__bindgen_ty_1 { - pub b: __BindgenUnionField<::std::os::raw::c_uint>, - pub __bindgen_anon_1: __BindgenUnionField, - pub __bindgen_anon_2: __BindgenUnionField, - pub bindgen_union_field: u32, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct foo__bindgen_ty_1__bindgen_ty_1 { - pub c1: ::std::os::raw::c_ushort, - pub c2: ::std::os::raw::c_ushort, -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 4usize, - "Size of foo__bindgen_ty_1__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 2usize, - "Alignment of foo__bindgen_ty_1__bindgen_ty_1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).c1) as usize - ptr as usize }, - 0usize, - "Offset of field: foo__bindgen_ty_1__bindgen_ty_1::c1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).c2) as usize - ptr as usize }, - 2usize, - "Offset of field: foo__bindgen_ty_1__bindgen_ty_1::c2", - ); -} -impl Clone for foo__bindgen_ty_1__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct foo__bindgen_ty_1__bindgen_ty_2 { - pub d1: ::std::os::raw::c_uchar, - pub d2: ::std::os::raw::c_uchar, - pub d3: ::std::os::raw::c_uchar, - pub d4: ::std::os::raw::c_uchar, -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_2() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 4usize, - "Size of foo__bindgen_ty_1__bindgen_ty_2", - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - "Alignment of foo__bindgen_ty_1__bindgen_ty_2", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).d1) as usize - ptr as usize }, - 0usize, - "Offset of field: foo__bindgen_ty_1__bindgen_ty_2::d1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).d2) as usize - ptr as usize }, - 1usize, - "Offset of field: foo__bindgen_ty_1__bindgen_ty_2::d2", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).d3) as usize - ptr as usize }, - 2usize, - "Offset of field: foo__bindgen_ty_1__bindgen_ty_2::d3", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).d4) as usize - ptr as usize }, - 3usize, - "Offset of field: foo__bindgen_ty_1__bindgen_ty_2::d4", - ); -} -impl Clone for foo__bindgen_ty_1__bindgen_ty_2 { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 4usize, - "Size of foo__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of foo__bindgen_ty_1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).b) as usize - ptr as usize }, - 0usize, - "Offset of field: foo__bindgen_ty_1::b", - ); -} -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn bindgen_test_layout_foo() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 8usize, "Size of foo"); - assert_eq!(::std::mem::align_of::(), 4usize, "Alignment of foo"); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize }, - 0usize, - "Offset of field: foo::a", - ); -} -impl Clone for foo { - fn clone(&self) -> Self { - *self - } -} diff --git a/bindgen-tests/tests/expectations/tests/transform-op.rs b/bindgen-tests/tests/expectations/tests/transform-op.rs index b53cea166a..c626049b46 100644 --- a/bindgen-tests/tests/expectations/tests/transform-op.rs +++ b/bindgen-tests/tests/expectations/tests/transform-op.rs @@ -3,7 +3,7 @@ pub struct __BindgenUnionField(::std::marker::PhantomData); impl __BindgenUnionField { #[inline] - pub fn new() -> Self { + pub const fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } #[inline] @@ -59,7 +59,7 @@ impl Default for StylePoint { } } #[repr(C)] -#[derive(Debug, Default, Copy, Clone)] +#[repr(align(1))] pub struct StyleFoo { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub __bindgen_anon_1: __BindgenUnionField, @@ -137,8 +137,16 @@ impl Default for StyleFoo__bindgen_ty_1 { } } } +impl Default for StyleFoo { + fn default() -> Self { + unsafe { + let mut s: Self = ::std::mem::uninitialized(); + ::std::ptr::write_bytes(&mut s, 0, 1); + s + } + } +} #[repr(C)] -#[derive(Debug, Copy, Clone)] pub struct StyleBar { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub tag: StyleBar_Tag, @@ -197,7 +205,7 @@ impl Default for StyleBar_StyleBar3_Body { } } #[repr(C)] -#[derive(Debug, Default, Copy, Clone)] +#[repr(align(1))] pub struct StyleBar__bindgen_ty_1 { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub bar1: __BindgenUnionField>, @@ -205,6 +213,15 @@ pub struct StyleBar__bindgen_ty_1 { pub bar3: __BindgenUnionField>, pub bindgen_union_field: [u8; 0usize], } +impl Default for StyleBar__bindgen_ty_1 { + fn default() -> Self { + unsafe { + let mut s: Self = ::std::mem::uninitialized(); + ::std::ptr::write_bytes(&mut s, 0, 1); + s + } + } +} impl Default for StyleBar { fn default() -> Self { unsafe { diff --git a/bindgen-tests/tests/expectations/tests/typeref_1_0.rs b/bindgen-tests/tests/expectations/tests/typeref_1_0.rs deleted file mode 100644 index 2cf1633a61..0000000000 --- a/bindgen-tests/tests/expectations/tests/typeref_1_0.rs +++ /dev/null @@ -1,175 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { - __BindgenUnionField(::std::marker::PhantomData) - } - #[inline] - pub unsafe fn as_ref(&self) -> &T { - ::std::mem::transmute(self) - } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { - ::std::mem::transmute(self) - } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { - Self::new() - } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { - *self - } -} -impl ::std::marker::Copy for __BindgenUnionField {} -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::std::cmp::Eq for __BindgenUnionField {} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct mozilla_FragmentOrURL { - pub mIsLocalRef: bool, -} -#[test] -fn bindgen_test_layout_mozilla_FragmentOrURL() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 1usize, - "Size of mozilla_FragmentOrURL", - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - "Alignment of mozilla_FragmentOrURL", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).mIsLocalRef) as usize - ptr as usize }, - 0usize, - "Offset of field: mozilla_FragmentOrURL::mIsLocalRef", - ); -} -impl Clone for mozilla_FragmentOrURL { - fn clone(&self) -> Self { - *self - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct mozilla_Position { - pub _address: u8, -} -#[test] -fn bindgen_test_layout_mozilla_Position() { - assert_eq!( - ::std::mem::size_of::(), - 1usize, - "Size of mozilla_Position", - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - "Alignment of mozilla_Position", - ); -} -impl Clone for mozilla_Position { - fn clone(&self) -> Self { - *self - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] -pub struct mozilla_StyleShapeSource { - pub __bindgen_anon_1: mozilla_StyleShapeSource__bindgen_ty_1, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] -pub struct mozilla_StyleShapeSource__bindgen_ty_1 { - pub mPosition: __BindgenUnionField<*mut mozilla_Position>, - pub mFragmentOrURL: __BindgenUnionField<*mut mozilla_FragmentOrURL>, - pub bindgen_union_field: u64, -} -#[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] -pub struct Bar { - pub mFoo: *mut nsFoo, -} -#[test] -fn bindgen_test_layout_Bar() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 8usize, "Size of Bar"); - assert_eq!(::std::mem::align_of::(), 8usize, "Alignment of Bar"); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).mFoo) as usize - ptr as usize }, - 0usize, - "Offset of field: Bar::mFoo", - ); -} -impl Clone for Bar { - fn clone(&self) -> Self { - *self - } -} -impl Default for Bar { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct nsFoo { - pub mBar: mozilla_StyleShapeSource, -} -#[test] -fn bindgen_test_layout_nsFoo() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 8usize, "Size of nsFoo"); - assert_eq!(::std::mem::align_of::(), 8usize, "Alignment of nsFoo"); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).mBar) as usize - ptr as usize }, - 0usize, - "Offset of field: nsFoo::mBar", - ); -} -impl Clone for nsFoo { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn __bindgen_test_layout_mozilla_StyleShapeSource_open0_int_close0_instantiation() { - assert_eq!( - ::std::mem::size_of::(), - 8usize, - "Size of template specialization: mozilla_StyleShapeSource_open0_int_close0", - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - "Align of template specialization: mozilla_StyleShapeSource_open0_int_close0", - ); -} diff --git a/bindgen-tests/tests/expectations/tests/union-in-ns_1_0.rs b/bindgen-tests/tests/expectations/tests/union-in-ns_1_0.rs deleted file mode 100644 index eac1df1a13..0000000000 --- a/bindgen-tests/tests/expectations/tests/union-in-ns_1_0.rs +++ /dev/null @@ -1,72 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] -pub mod root { - #[repr(C)] - pub struct __BindgenUnionField(::std::marker::PhantomData); - impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { - __BindgenUnionField(::std::marker::PhantomData) - } - #[inline] - pub unsafe fn as_ref(&self) -> &T { - ::std::mem::transmute(self) - } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { - ::std::mem::transmute(self) - } - } - impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { - Self::new() - } - } - impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { - *self - } - } - impl ::std::marker::Copy for __BindgenUnionField {} - impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } - } - impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} - } - impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } - } - impl ::std::cmp::Eq for __BindgenUnionField {} - #[allow(unused_imports)] - use self::super::root; - #[repr(C)] - #[derive(Debug, Default, Copy)] - pub struct bar { - pub baz: root::__BindgenUnionField<::std::os::raw::c_int>, - pub bindgen_union_field: u32, - } - #[test] - fn bindgen_test_layout_bar() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 4usize, "Size of bar"); - assert_eq!(::std::mem::align_of::(), 4usize, "Alignment of bar"); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).baz) as usize - ptr as usize }, - 0usize, - "Offset of field: bar::baz", - ); - } - impl Clone for bar { - fn clone(&self) -> Self { - *self - } - } -} diff --git a/bindgen-tests/tests/expectations/tests/union_bitfield_1_0.rs b/bindgen-tests/tests/expectations/tests/union_bitfield_1_0.rs deleted file mode 100644 index bd4a772cb7..0000000000 --- a/bindgen-tests/tests/expectations/tests/union_bitfield_1_0.rs +++ /dev/null @@ -1,285 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] -pub struct __BindgenBitfieldUnit { - storage: Storage, -} -impl __BindgenBitfieldUnit { - #[inline] - pub fn new(storage: Storage) -> Self { - Self { storage } - } -} -impl __BindgenBitfieldUnit -where - Storage: AsRef<[u8]> + AsMut<[u8]>, -{ - #[inline] - fn extract_bit(byte: u8, index: usize) -> bool { - let bit_index = if cfg!(target_endian = "big") { - 7 - (index % 8) - } else { - index % 8 - }; - let mask = 1 << bit_index; - byte & mask == mask - } - #[inline] - pub fn get_bit(&self, index: usize) -> bool { - debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; - let byte = self.storage.as_ref()[byte_index]; - Self::extract_bit(byte, index) - } - #[inline] - fn change_bit(byte: u8, index: usize, val: bool) -> u8 { - let bit_index = if cfg!(target_endian = "big") { - 7 - (index % 8) - } else { - index % 8 - }; - let mask = 1 << bit_index; - if val { byte | mask } else { byte & !mask } - } - #[inline] - pub fn set_bit(&mut self, index: usize, val: bool) { - debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; - let byte = &mut self.storage.as_mut()[byte_index]; - *byte = Self::change_bit(*byte, index, val); - } - #[inline] - pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { - debug_assert!(bit_width <= 64); - debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); - debug_assert!( - (bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len(), - ); - let mut val = 0; - for i in 0..(bit_width as usize) { - if self.get_bit(i + bit_offset) { - let index = if cfg!(target_endian = "big") { - bit_width as usize - 1 - i - } else { - i - }; - val |= 1 << index; - } - } - val - } - #[inline] - pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { - debug_assert!(bit_width <= 64); - debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); - debug_assert!( - (bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len(), - ); - for i in 0..(bit_width as usize) { - let mask = 1 << i; - let val_bit_is_set = val & mask == mask; - let index = if cfg!(target_endian = "big") { - bit_width as usize - 1 - i - } else { - i - }; - self.set_bit(index + bit_offset, val_bit_is_set); - } - } -} -#[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 - } -} -impl ::std::marker::Copy for __BindgenUnionField {} -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::std::cmp::Eq for __BindgenUnionField {} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct U4 { - pub _bitfield_align_1: [u8; 0], - pub _bitfield_1: __BindgenUnionField<__BindgenBitfieldUnit<[u8; 1usize]>>, - pub bindgen_union_field: u32, -} -#[test] -fn bindgen_test_layout_U4() { - assert_eq!(::std::mem::size_of::(), 4usize, "Size of U4"); - assert_eq!(::std::mem::align_of::(), 4usize, "Alignment of U4"); -} -impl Clone for U4 { - fn clone(&self) -> Self { - *self - } -} -impl U4 { - #[inline] - pub fn derp(&self) -> ::std::os::raw::c_uint { - unsafe { - ::std::mem::transmute(self._bitfield_1.as_ref().get(0usize, 1u8) as u32) - } - } - #[inline] - pub fn set_derp(&mut self, val: ::std::os::raw::c_uint) { - unsafe { - let val: u32 = ::std::mem::transmute(val); - self._bitfield_1.as_mut().set(0usize, 1u8, val as u64) - } - } - #[inline] - pub fn new_bitfield_1( - derp: ::std::os::raw::c_uint, - ) -> __BindgenBitfieldUnit<[u8; 1usize]> { - let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); - __bindgen_bitfield_unit - .set( - 0usize, - 1u8, - { - let derp: u32 = unsafe { ::std::mem::transmute(derp) }; - derp as u64 - }, - ); - __bindgen_bitfield_unit - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct B { - pub _bitfield_align_1: [u32; 0], - pub _bitfield_1: __BindgenUnionField<__BindgenBitfieldUnit<[u8; 4usize]>>, - pub bindgen_union_field: u32, -} -#[test] -fn bindgen_test_layout_B() { - assert_eq!(::std::mem::size_of::(), 4usize, "Size of B"); - assert_eq!(::std::mem::align_of::(), 4usize, "Alignment of B"); -} -impl Clone for B { - fn clone(&self) -> Self { - *self - } -} -impl B { - #[inline] - pub fn foo(&self) -> ::std::os::raw::c_uint { - unsafe { - ::std::mem::transmute(self._bitfield_1.as_ref().get(0usize, 31u8) as u32) - } - } - #[inline] - pub fn set_foo(&mut self, val: ::std::os::raw::c_uint) { - unsafe { - let val: u32 = ::std::mem::transmute(val); - self._bitfield_1.as_mut().set(0usize, 31u8, val as u64) - } - } - #[inline] - pub fn bar(&self) -> ::std::os::raw::c_uchar { - unsafe { - ::std::mem::transmute(self._bitfield_1.as_ref().get(31usize, 1u8) as u8) - } - } - #[inline] - pub fn set_bar(&mut self, val: ::std::os::raw::c_uchar) { - unsafe { - let val: u8 = ::std::mem::transmute(val); - self._bitfield_1.as_mut().set(31usize, 1u8, val as u64) - } - } - #[inline] - pub fn new_bitfield_1( - foo: ::std::os::raw::c_uint, - bar: ::std::os::raw::c_uchar, - ) -> __BindgenBitfieldUnit<[u8; 4usize]> { - let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default(); - __bindgen_bitfield_unit - .set( - 0usize, - 31u8, - { - let foo: u32 = unsafe { ::std::mem::transmute(foo) }; - foo as u64 - }, - ); - __bindgen_bitfield_unit - .set( - 31usize, - 1u8, - { - let bar: u8 = unsafe { ::std::mem::transmute(bar) }; - bar as u64 - }, - ); - __bindgen_bitfield_unit - } -} -#[repr(C)] -#[derive(Copy)] -pub struct HasBigBitfield { - pub _bitfield_align_1: [u64; 0], - pub _bitfield_1: __BindgenUnionField<__BindgenBitfieldUnit<[u8; 16usize]>>, - pub bindgen_union_field: [u8; 16usize], -} -#[test] -fn bindgen_test_layout_HasBigBitfield() { - assert_eq!( - ::std::mem::size_of::(), - 16usize, - "Size of HasBigBitfield", - ); -} -impl Clone for HasBigBitfield { - fn clone(&self) -> Self { - *self - } -} -impl Default for HasBigBitfield { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -impl ::std::cmp::PartialEq for HasBigBitfield { - fn eq(&self, other: &HasBigBitfield) -> bool { - &self.bindgen_union_field[..] == &other.bindgen_union_field[..] - } -} diff --git a/bindgen-tests/tests/expectations/tests/union_dtor_1_0.rs b/bindgen-tests/tests/expectations/tests/union_dtor_1_0.rs deleted file mode 100644 index e9c777df94..0000000000 --- a/bindgen-tests/tests/expectations/tests/union_dtor_1_0.rs +++ /dev/null @@ -1,82 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { - __BindgenUnionField(::std::marker::PhantomData) - } - #[inline] - pub unsafe fn as_ref(&self) -> &T { - ::std::mem::transmute(self) - } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { - ::std::mem::transmute(self) - } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { - Self::new() - } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { - *self - } -} -impl ::std::marker::Copy for __BindgenUnionField {} -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::std::cmp::Eq for __BindgenUnionField {} -#[repr(C)] -#[derive(Debug, Default)] -pub struct UnionWithDtor { - pub mFoo: __BindgenUnionField<::std::os::raw::c_int>, - pub mBar: __BindgenUnionField<*mut ::std::os::raw::c_void>, - pub bindgen_union_field: u64, -} -#[test] -fn bindgen_test_layout_UnionWithDtor() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 8usize, "Size of UnionWithDtor"); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - "Alignment of UnionWithDtor", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).mFoo) as usize - ptr as usize }, - 0usize, - "Offset of field: UnionWithDtor::mFoo", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).mBar) as usize - ptr as usize }, - 0usize, - "Offset of field: UnionWithDtor::mBar", - ); -} -extern "C" { - #[link_name = "\u{1}_ZN13UnionWithDtorD1Ev"] - pub fn UnionWithDtor_UnionWithDtor_destructor(this: *mut UnionWithDtor); -} -impl UnionWithDtor { - #[inline] - pub unsafe fn destruct(&mut self) { - UnionWithDtor_UnionWithDtor_destructor(self) - } -} diff --git a/bindgen-tests/tests/expectations/tests/union_fields_1_0.rs b/bindgen-tests/tests/expectations/tests/union_fields_1_0.rs deleted file mode 100644 index 9cf2f09832..0000000000 --- a/bindgen-tests/tests/expectations/tests/union_fields_1_0.rs +++ /dev/null @@ -1,83 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { - __BindgenUnionField(::std::marker::PhantomData) - } - #[inline] - pub unsafe fn as_ref(&self) -> &T { - ::std::mem::transmute(self) - } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { - ::std::mem::transmute(self) - } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { - Self::new() - } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { - *self - } -} -impl ::std::marker::Copy for __BindgenUnionField {} -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::std::cmp::Eq for __BindgenUnionField {} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq)] -pub struct nsStyleUnion { - pub mInt: __BindgenUnionField<::std::os::raw::c_int>, - pub mFloat: __BindgenUnionField, - pub mPointer: __BindgenUnionField<*mut ::std::os::raw::c_void>, - pub bindgen_union_field: u64, -} -#[test] -fn bindgen_test_layout_nsStyleUnion() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 8usize, "Size of nsStyleUnion"); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - "Alignment of nsStyleUnion", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).mInt) as usize - ptr as usize }, - 0usize, - "Offset of field: nsStyleUnion::mInt", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).mFloat) as usize - ptr as usize }, - 0usize, - "Offset of field: nsStyleUnion::mFloat", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).mPointer) as usize - ptr as usize }, - 0usize, - "Offset of field: nsStyleUnion::mPointer", - ); -} -impl Clone for nsStyleUnion { - fn clone(&self) -> Self { - *self - } -} diff --git a/bindgen-tests/tests/expectations/tests/union_template_1_0.rs b/bindgen-tests/tests/expectations/tests/union_template_1_0.rs deleted file mode 100644 index 4ebad2a2e2..0000000000 --- a/bindgen-tests/tests/expectations/tests/union_template_1_0.rs +++ /dev/null @@ -1,72 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { - __BindgenUnionField(::std::marker::PhantomData) - } - #[inline] - pub unsafe fn as_ref(&self) -> &T { - ::std::mem::transmute(self) - } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { - ::std::mem::transmute(self) - } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { - Self::new() - } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { - *self - } -} -impl ::std::marker::Copy for __BindgenUnionField {} -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::std::cmp::Eq for __BindgenUnionField {} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] -pub struct NastyStruct { - pub mIsSome: bool, - pub mStorage: NastyStruct__bindgen_ty_1, - pub __bindgen_anon_1: NastyStruct__bindgen_ty_2, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] -pub struct NastyStruct__bindgen_ty_1 { - pub mFoo: __BindgenUnionField<*mut ::std::os::raw::c_void>, - pub mDummy: __BindgenUnionField<::std::os::raw::c_ulong>, - pub bindgen_union_field: u64, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] -pub struct NastyStruct__bindgen_ty_2 { - pub wat: __BindgenUnionField<::std::os::raw::c_short>, - pub wut: __BindgenUnionField<*mut ::std::os::raw::c_int>, - pub bindgen_union_field: u64, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] -pub struct Whatever { - pub mTPtr: __BindgenUnionField<*mut ::std::os::raw::c_void>, - pub mInt: __BindgenUnionField<::std::os::raw::c_int>, - pub bindgen_union_field: u64, -} diff --git a/bindgen-tests/tests/expectations/tests/union_with_anon_struct_1_0.rs b/bindgen-tests/tests/expectations/tests/union_with_anon_struct_1_0.rs deleted file mode 100644 index 7ea38b8bae..0000000000 --- a/bindgen-tests/tests/expectations/tests/union_with_anon_struct_1_0.rs +++ /dev/null @@ -1,103 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { - __BindgenUnionField(::std::marker::PhantomData) - } - #[inline] - pub unsafe fn as_ref(&self) -> &T { - ::std::mem::transmute(self) - } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { - ::std::mem::transmute(self) - } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { - Self::new() - } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { - *self - } -} -impl ::std::marker::Copy for __BindgenUnionField {} -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::std::cmp::Eq for __BindgenUnionField {} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct foo { - pub bar: __BindgenUnionField, - pub bindgen_union_field: [u32; 2usize], -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct foo__bindgen_ty_1 { - pub a: ::std::os::raw::c_uint, - pub b: ::std::os::raw::c_uint, -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 8usize, - "Size of foo__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of foo__bindgen_ty_1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize }, - 0usize, - "Offset of field: foo__bindgen_ty_1::a", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).b) as usize - ptr as usize }, - 4usize, - "Offset of field: foo__bindgen_ty_1::b", - ); -} -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn bindgen_test_layout_foo() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 8usize, "Size of foo"); - assert_eq!(::std::mem::align_of::(), 4usize, "Alignment of foo"); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).bar) as usize - ptr as usize }, - 0usize, - "Offset of field: foo::bar", - ); -} -impl Clone for foo { - fn clone(&self) -> Self { - *self - } -} diff --git a/bindgen-tests/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs b/bindgen-tests/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs deleted file mode 100644 index ff19f398ad..0000000000 --- a/bindgen-tests/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs +++ /dev/null @@ -1,230 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] -pub struct __BindgenBitfieldUnit { - storage: Storage, -} -impl __BindgenBitfieldUnit { - #[inline] - pub fn new(storage: Storage) -> Self { - Self { storage } - } -} -impl __BindgenBitfieldUnit -where - Storage: AsRef<[u8]> + AsMut<[u8]>, -{ - #[inline] - fn extract_bit(byte: u8, index: usize) -> bool { - let bit_index = if cfg!(target_endian = "big") { - 7 - (index % 8) - } else { - index % 8 - }; - let mask = 1 << bit_index; - byte & mask == mask - } - #[inline] - pub fn get_bit(&self, index: usize) -> bool { - debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; - let byte = self.storage.as_ref()[byte_index]; - Self::extract_bit(byte, index) - } - #[inline] - fn change_bit(byte: u8, index: usize, val: bool) -> u8 { - let bit_index = if cfg!(target_endian = "big") { - 7 - (index % 8) - } else { - index % 8 - }; - let mask = 1 << bit_index; - if val { byte | mask } else { byte & !mask } - } - #[inline] - pub fn set_bit(&mut self, index: usize, val: bool) { - debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; - let byte = &mut self.storage.as_mut()[byte_index]; - *byte = Self::change_bit(*byte, index, val); - } - #[inline] - pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { - debug_assert!(bit_width <= 64); - debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); - debug_assert!( - (bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len(), - ); - let mut val = 0; - for i in 0..(bit_width as usize) { - if self.get_bit(i + bit_offset) { - let index = if cfg!(target_endian = "big") { - bit_width as usize - 1 - i - } else { - i - }; - val |= 1 << index; - } - } - val - } - #[inline] - pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { - debug_assert!(bit_width <= 64); - debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); - debug_assert!( - (bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len(), - ); - for i in 0..(bit_width as usize) { - let mask = 1 << i; - let val_bit_is_set = val & mask == mask; - let index = if cfg!(target_endian = "big") { - bit_width as usize - 1 - i - } else { - i - }; - self.set_bit(index + bit_offset, val_bit_is_set); - } - } -} -#[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 - } -} -impl ::std::marker::Copy for __BindgenUnionField {} -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::std::cmp::Eq for __BindgenUnionField {} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct foo { - pub a: __BindgenUnionField<::std::os::raw::c_int>, - pub __bindgen_anon_1: __BindgenUnionField, - pub bindgen_union_field: u32, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct foo__bindgen_ty_1 { - pub _bitfield_align_1: [u32; 0], - pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>, -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!( - ::std::mem::size_of::(), - 4usize, - "Size of foo__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of foo__bindgen_ty_1", - ); -} -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -impl foo__bindgen_ty_1 { - #[inline] - pub fn b(&self) -> ::std::os::raw::c_int { - unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 7u8) as u32) } - } - #[inline] - pub fn set_b(&mut self, val: ::std::os::raw::c_int) { - unsafe { - let val: u32 = ::std::mem::transmute(val); - self._bitfield_1.set(0usize, 7u8, val as u64) - } - } - #[inline] - pub fn c(&self) -> ::std::os::raw::c_int { - unsafe { ::std::mem::transmute(self._bitfield_1.get(7usize, 25u8) as u32) } - } - #[inline] - pub fn set_c(&mut self, val: ::std::os::raw::c_int) { - unsafe { - let val: u32 = ::std::mem::transmute(val); - self._bitfield_1.set(7usize, 25u8, val as u64) - } - } - #[inline] - pub fn new_bitfield_1( - b: ::std::os::raw::c_int, - c: ::std::os::raw::c_int, - ) -> __BindgenBitfieldUnit<[u8; 4usize]> { - let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default(); - __bindgen_bitfield_unit - .set( - 0usize, - 7u8, - { - let b: u32 = unsafe { ::std::mem::transmute(b) }; - b as u64 - }, - ); - __bindgen_bitfield_unit - .set( - 7usize, - 25u8, - { - let c: u32 = unsafe { ::std::mem::transmute(c) }; - c as u64 - }, - ); - __bindgen_bitfield_unit - } -} -#[test] -fn bindgen_test_layout_foo() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 4usize, "Size of foo"); - assert_eq!(::std::mem::align_of::(), 4usize, "Alignment of foo"); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize }, - 0usize, - "Offset of field: foo::a", - ); -} -impl Clone for foo { - fn clone(&self) -> Self { - *self - } -} diff --git a/bindgen-tests/tests/expectations/tests/union_with_anon_union_1_0.rs b/bindgen-tests/tests/expectations/tests/union_with_anon_union_1_0.rs deleted file mode 100644 index ad6d9c7e16..0000000000 --- a/bindgen-tests/tests/expectations/tests/union_with_anon_union_1_0.rs +++ /dev/null @@ -1,104 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { - __BindgenUnionField(::std::marker::PhantomData) - } - #[inline] - pub unsafe fn as_ref(&self) -> &T { - ::std::mem::transmute(self) - } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { - ::std::mem::transmute(self) - } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { - Self::new() - } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { - *self - } -} -impl ::std::marker::Copy for __BindgenUnionField {} -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::std::cmp::Eq for __BindgenUnionField {} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct foo { - pub bar: __BindgenUnionField, - pub bindgen_union_field: u32, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct foo__bindgen_ty_1 { - pub a: __BindgenUnionField<::std::os::raw::c_uint>, - pub b: __BindgenUnionField<::std::os::raw::c_ushort>, - pub bindgen_union_field: u32, -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 4usize, - "Size of foo__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of foo__bindgen_ty_1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize }, - 0usize, - "Offset of field: foo__bindgen_ty_1::a", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).b) as usize - ptr as usize }, - 0usize, - "Offset of field: foo__bindgen_ty_1::b", - ); -} -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn bindgen_test_layout_foo() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 4usize, "Size of foo"); - assert_eq!(::std::mem::align_of::(), 4usize, "Alignment of foo"); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).bar) as usize - ptr as usize }, - 0usize, - "Offset of field: foo::bar", - ); -} -impl Clone for foo { - fn clone(&self) -> Self { - *self - } -} diff --git a/bindgen-tests/tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs b/bindgen-tests/tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs deleted file mode 100644 index 20ceaee90c..0000000000 --- a/bindgen-tests/tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs +++ /dev/null @@ -1,116 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { - __BindgenUnionField(::std::marker::PhantomData) - } - #[inline] - pub unsafe fn as_ref(&self) -> &T { - ::std::mem::transmute(self) - } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { - ::std::mem::transmute(self) - } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { - Self::new() - } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { - *self - } -} -impl ::std::marker::Copy for __BindgenUnionField {} -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::std::cmp::Eq for __BindgenUnionField {} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct pixel { - pub rgba: __BindgenUnionField<::std::os::raw::c_uint>, - pub __bindgen_anon_1: __BindgenUnionField, - pub bindgen_union_field: u32, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct pixel__bindgen_ty_1 { - pub r: ::std::os::raw::c_uchar, - pub g: ::std::os::raw::c_uchar, - pub b: ::std::os::raw::c_uchar, - pub a: ::std::os::raw::c_uchar, -} -#[test] -fn bindgen_test_layout_pixel__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 4usize, - "Size of pixel__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - "Alignment of pixel__bindgen_ty_1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).r) as usize - ptr as usize }, - 0usize, - "Offset of field: pixel__bindgen_ty_1::r", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).g) as usize - ptr as usize }, - 1usize, - "Offset of field: pixel__bindgen_ty_1::g", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).b) as usize - ptr as usize }, - 2usize, - "Offset of field: pixel__bindgen_ty_1::b", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize }, - 3usize, - "Offset of field: pixel__bindgen_ty_1::a", - ); -} -impl Clone for pixel__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn bindgen_test_layout_pixel() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 4usize, "Size of pixel"); - assert_eq!(::std::mem::align_of::(), 4usize, "Alignment of pixel"); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).rgba) as usize - ptr as usize }, - 0usize, - "Offset of field: pixel::rgba", - ); -} -impl Clone for pixel { - fn clone(&self) -> Self { - *self - } -} diff --git a/bindgen-tests/tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs b/bindgen-tests/tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs deleted file mode 100644 index 561c7f8071..0000000000 --- a/bindgen-tests/tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs +++ /dev/null @@ -1,105 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { - __BindgenUnionField(::std::marker::PhantomData) - } - #[inline] - pub unsafe fn as_ref(&self) -> &T { - ::std::mem::transmute(self) - } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { - ::std::mem::transmute(self) - } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { - Self::new() - } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { - *self - } -} -impl ::std::marker::Copy for __BindgenUnionField {} -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::std::cmp::Eq for __BindgenUnionField {} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct foo { - pub a: __BindgenUnionField<::std::os::raw::c_uint>, - pub __bindgen_anon_1: __BindgenUnionField, - pub bindgen_union_field: u32, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct foo__bindgen_ty_1 { - pub b: __BindgenUnionField<::std::os::raw::c_ushort>, - pub c: __BindgenUnionField<::std::os::raw::c_uchar>, - pub bindgen_union_field: u16, -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 2usize, - "Size of foo__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 2usize, - "Alignment of foo__bindgen_ty_1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).b) as usize - ptr as usize }, - 0usize, - "Offset of field: foo__bindgen_ty_1::b", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).c) as usize - ptr as usize }, - 0usize, - "Offset of field: foo__bindgen_ty_1::c", - ); -} -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn bindgen_test_layout_foo() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 4usize, "Size of foo"); - assert_eq!(::std::mem::align_of::(), 4usize, "Alignment of foo"); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize }, - 0usize, - "Offset of field: foo::a", - ); -} -impl Clone for foo { - fn clone(&self) -> Self { - *self - } -} diff --git a/bindgen-tests/tests/expectations/tests/union_with_big_member_1_0.rs b/bindgen-tests/tests/expectations/tests/union_with_big_member_1_0.rs deleted file mode 100644 index 14a68fc0bf..0000000000 --- a/bindgen-tests/tests/expectations/tests/union_with_big_member_1_0.rs +++ /dev/null @@ -1,165 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { - __BindgenUnionField(::std::marker::PhantomData) - } - #[inline] - pub unsafe fn as_ref(&self) -> &T { - ::std::mem::transmute(self) - } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { - ::std::mem::transmute(self) - } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { - Self::new() - } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { - *self - } -} -impl ::std::marker::Copy for __BindgenUnionField {} -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::std::cmp::Eq for __BindgenUnionField {} -#[repr(C)] -#[derive(Copy)] -pub struct WithBigArray { - pub a: __BindgenUnionField<::std::os::raw::c_int>, - pub b: __BindgenUnionField<[::std::os::raw::c_int; 33usize]>, - pub bindgen_union_field: [u32; 33usize], -} -#[test] -fn bindgen_test_layout_WithBigArray() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 132usize, "Size of WithBigArray"); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of WithBigArray", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize }, - 0usize, - "Offset of field: WithBigArray::a", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).b) as usize - ptr as usize }, - 0usize, - "Offset of field: WithBigArray::b", - ); -} -impl Clone for WithBigArray { - fn clone(&self) -> Self { - *self - } -} -impl Default for WithBigArray { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct WithBigArray2 { - pub a: __BindgenUnionField<::std::os::raw::c_int>, - pub b: __BindgenUnionField<[::std::os::raw::c_char; 33usize]>, - pub bindgen_union_field: [u32; 9usize], -} -#[test] -fn bindgen_test_layout_WithBigArray2() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 36usize, "Size of WithBigArray2"); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of WithBigArray2", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize }, - 0usize, - "Offset of field: WithBigArray2::a", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).b) as usize - ptr as usize }, - 0usize, - "Offset of field: WithBigArray2::b", - ); -} -impl Clone for WithBigArray2 { - fn clone(&self) -> Self { - *self - } -} -#[repr(C)] -#[derive(Copy)] -pub struct WithBigMember { - pub a: __BindgenUnionField<::std::os::raw::c_int>, - pub b: __BindgenUnionField, - pub bindgen_union_field: [u32; 33usize], -} -#[test] -fn bindgen_test_layout_WithBigMember() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 132usize, - "Size of WithBigMember", - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - "Alignment of WithBigMember", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize }, - 0usize, - "Offset of field: WithBigMember::a", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).b) as usize - ptr as usize }, - 0usize, - "Offset of field: WithBigMember::b", - ); -} -impl Clone for WithBigMember { - fn clone(&self) -> Self { - *self - } -} -impl Default for WithBigMember { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} diff --git a/bindgen-tests/tests/expectations/tests/union_with_nesting_1_0.rs b/bindgen-tests/tests/expectations/tests/union_with_nesting_1_0.rs deleted file mode 100644 index 22b902d82c..0000000000 --- a/bindgen-tests/tests/expectations/tests/union_with_nesting_1_0.rs +++ /dev/null @@ -1,166 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { - __BindgenUnionField(::std::marker::PhantomData) - } - #[inline] - pub unsafe fn as_ref(&self) -> &T { - ::std::mem::transmute(self) - } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { - ::std::mem::transmute(self) - } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { - Self::new() - } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { - *self - } -} -impl ::std::marker::Copy for __BindgenUnionField {} -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::std::cmp::Eq for __BindgenUnionField {} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct foo { - pub a: __BindgenUnionField<::std::os::raw::c_uint>, - pub __bindgen_anon_1: __BindgenUnionField, - pub bindgen_union_field: u32, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct foo__bindgen_ty_1 { - pub __bindgen_anon_1: foo__bindgen_ty_1__bindgen_ty_1, - pub __bindgen_anon_2: foo__bindgen_ty_1__bindgen_ty_2, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct foo__bindgen_ty_1__bindgen_ty_1 { - pub b1: __BindgenUnionField<::std::os::raw::c_ushort>, - pub b2: __BindgenUnionField<::std::os::raw::c_ushort>, - pub bindgen_union_field: u16, -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 2usize, - "Size of foo__bindgen_ty_1__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 2usize, - "Alignment of foo__bindgen_ty_1__bindgen_ty_1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).b1) as usize - ptr as usize }, - 0usize, - "Offset of field: foo__bindgen_ty_1__bindgen_ty_1::b1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).b2) as usize - ptr as usize }, - 0usize, - "Offset of field: foo__bindgen_ty_1__bindgen_ty_1::b2", - ); -} -impl Clone for foo__bindgen_ty_1__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct foo__bindgen_ty_1__bindgen_ty_2 { - pub c1: __BindgenUnionField<::std::os::raw::c_ushort>, - pub c2: __BindgenUnionField<::std::os::raw::c_ushort>, - pub bindgen_union_field: u16, -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_2() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 2usize, - "Size of foo__bindgen_ty_1__bindgen_ty_2", - ); - assert_eq!( - ::std::mem::align_of::(), - 2usize, - "Alignment of foo__bindgen_ty_1__bindgen_ty_2", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).c1) as usize - ptr as usize }, - 0usize, - "Offset of field: foo__bindgen_ty_1__bindgen_ty_2::c1", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).c2) as usize - ptr as usize }, - 0usize, - "Offset of field: foo__bindgen_ty_1__bindgen_ty_2::c2", - ); -} -impl Clone for foo__bindgen_ty_1__bindgen_ty_2 { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!( - ::std::mem::size_of::(), - 4usize, - "Size of foo__bindgen_ty_1", - ); - assert_eq!( - ::std::mem::align_of::(), - 2usize, - "Alignment of foo__bindgen_ty_1", - ); -} -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -#[test] -fn bindgen_test_layout_foo() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 4usize, "Size of foo"); - assert_eq!(::std::mem::align_of::(), 4usize, "Alignment of foo"); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize }, - 0usize, - "Offset of field: foo::a", - ); -} -impl Clone for foo { - fn clone(&self) -> Self { - *self - } -} diff --git a/bindgen-tests/tests/expectations/tests/use-core_1_0.rs b/bindgen-tests/tests/expectations/tests/use-core_1_0.rs deleted file mode 100644 index 707ca3d962..0000000000 --- a/bindgen-tests/tests/expectations/tests/use-core_1_0.rs +++ /dev/null @@ -1,127 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -extern crate core; -#[repr(C)] -pub struct __BindgenUnionField(::core::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { - __BindgenUnionField(::core::marker::PhantomData) - } - #[inline] - pub unsafe fn as_ref(&self) -> &T { - ::core::mem::transmute(self) - } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { - ::core::mem::transmute(self) - } -} -impl ::core::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { - Self::new() - } -} -impl ::core::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { - *self - } -} -impl ::core::marker::Copy for __BindgenUnionField {} -impl ::core::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::core::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::core::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::core::cmp::Eq for __BindgenUnionField {} -#[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] -pub struct foo { - pub a: ::std::os::raw::c_int, - pub b: ::std::os::raw::c_int, - pub bar: *mut ::std::os::raw::c_void, -} -#[test] -fn bindgen_test_layout_foo() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::core::mem::size_of::(), 16usize, "Size of foo"); - assert_eq!(::core::mem::align_of::(), 8usize, "Alignment of foo"); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).a) as usize - ptr as usize }, - 0usize, - "Offset of field: foo::a", - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).b) as usize - ptr as usize }, - 4usize, - "Offset of field: foo::b", - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).bar) as usize - ptr as usize }, - 8usize, - "Offset of field: foo::bar", - ); -} -impl Clone for foo { - fn clone(&self) -> Self { - *self - } -} -impl Default for foo { - fn default() -> Self { - unsafe { - let mut s: Self = ::core::mem::uninitialized(); - ::core::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] -pub struct _bindgen_ty_1 { - pub bar: __BindgenUnionField<::std::os::raw::c_int>, - pub baz: __BindgenUnionField<::std::os::raw::c_long>, - pub bindgen_union_field: u64, -} -#[test] -fn bindgen_test_layout__bindgen_ty_1() { - const UNINIT: ::core::mem::MaybeUninit<_bindgen_ty_1> = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::core::mem::size_of::<_bindgen_ty_1>(), 8usize, "Size of _bindgen_ty_1"); - assert_eq!( - ::core::mem::align_of::<_bindgen_ty_1>(), - 8usize, - "Alignment of _bindgen_ty_1", - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).bar) as usize - ptr as usize }, - 0usize, - "Offset of field: _bindgen_ty_1::bar", - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).baz) as usize - ptr as usize }, - 0usize, - "Offset of field: _bindgen_ty_1::baz", - ); -} -impl Clone for _bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} -extern "C" { - pub static mut bazz: _bindgen_ty_1; -} -pub type fooFunction = ::core::option::Option< - unsafe extern "C" fn(bar: ::std::os::raw::c_int), ->; diff --git a/bindgen-tests/tests/expectations/tests/win32-thiscall_1_0.rs b/bindgen-tests/tests/expectations/tests/win32-thiscall.rs similarity index 75% rename from bindgen-tests/tests/expectations/tests/win32-thiscall_1_0.rs rename to bindgen-tests/tests/expectations/tests/win32-thiscall.rs index 185b935808..d50348e799 100644 --- a/bindgen-tests/tests/expectations/tests/win32-thiscall_1_0.rs +++ b/bindgen-tests/tests/expectations/tests/win32-thiscall.rs @@ -1,6 +1,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct Foo { pub _address: u8, } @@ -9,8 +9,3 @@ fn bindgen_test_layout_Foo() { assert_eq!(::std::mem::size_of::(), 1usize, "Size of Foo"); assert_eq!(::std::mem::align_of::(), 1usize, "Alignment of Foo"); } -impl Clone for Foo { - fn clone(&self) -> Self { - *self - } -} diff --git a/bindgen-tests/tests/expectations/tests/win32-vectorcall-1_0.rs b/bindgen-tests/tests/expectations/tests/win32-vectorcall.rs similarity index 100% rename from bindgen-tests/tests/expectations/tests/win32-vectorcall-1_0.rs rename to bindgen-tests/tests/expectations/tests/win32-vectorcall.rs diff --git a/bindgen-tests/tests/expectations/tests/wrap_unsafe_ops_anon_union.rs b/bindgen-tests/tests/expectations/tests/wrap_unsafe_ops_anon_union.rs new file mode 100644 index 0000000000..50cefed043 --- /dev/null +++ b/bindgen-tests/tests/expectations/tests/wrap_unsafe_ops_anon_union.rs @@ -0,0 +1,57 @@ +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#[repr(C)] +pub struct TErrorResult { + pub mResult: ::std::os::raw::c_int, + pub __bindgen_anon_1: TErrorResult__bindgen_ty_1, + pub mMightHaveUnreported: bool, + pub mUnionState: TErrorResult_UnionState, +} +pub const TErrorResult_UnionState_HasMessage: TErrorResult_UnionState = 0; +pub const TErrorResult_UnionState_HasException: TErrorResult_UnionState = 0; +pub type TErrorResult_UnionState = i32; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct TErrorResult_Message { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct TErrorResult_DOMExceptionInfo { + _unused: [u8; 0], +} +#[repr(C)] +pub union TErrorResult__bindgen_ty_1 { + pub mMessage: *mut TErrorResult_Message, + pub mDOMExceptionInfo: *mut TErrorResult_DOMExceptionInfo, +} +impl Default for TErrorResult__bindgen_ty_1 { + fn default() -> Self { + unsafe { + let mut s: Self = ::std::mem::uninitialized(); + ::std::ptr::write_bytes(&mut s, 0, 1); + s + } + } +} +impl Default for TErrorResult { + fn default() -> Self { + unsafe { + let mut s: Self = ::std::mem::uninitialized(); + ::std::ptr::write_bytes(&mut s, 0, 1); + s + } + } +} +#[repr(C)] +pub struct ErrorResult { + pub _base: TErrorResult, +} +impl Default for ErrorResult { + fn default() -> Self { + unsafe { + let mut s: Self = ::std::mem::uninitialized(); + ::std::ptr::write_bytes(&mut s, 0, 1); + s + } + } +} diff --git a/bindgen-tests/tests/expectations/tests/wrap_unsafe_ops_anon_union_1_0.rs b/bindgen-tests/tests/expectations/tests/wrap_unsafe_ops_anon_union_1_0.rs deleted file mode 100644 index dfe2213ed4..0000000000 --- a/bindgen-tests/tests/expectations/tests/wrap_unsafe_ops_anon_union_1_0.rs +++ /dev/null @@ -1,100 +0,0 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { - __BindgenUnionField(::std::marker::PhantomData) - } - #[inline] - pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } - } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::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 - } -} -impl ::std::marker::Copy for __BindgenUnionField {} -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::std::cmp::Eq for __BindgenUnionField {} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct TErrorResult { - pub mResult: ::std::os::raw::c_int, - pub __bindgen_anon_1: TErrorResult__bindgen_ty_1, - pub mMightHaveUnreported: bool, - pub mUnionState: TErrorResult_UnionState, -} -pub const TErrorResult_UnionState_HasMessage: TErrorResult_UnionState = 0; -pub const TErrorResult_UnionState_HasException: TErrorResult_UnionState = 0; -pub type TErrorResult_UnionState = i32; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct TErrorResult_Message { - _unused: [u8; 0], -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct TErrorResult_DOMExceptionInfo { - _unused: [u8; 0], -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct TErrorResult__bindgen_ty_1 { - pub mMessage: __BindgenUnionField<*mut TErrorResult_Message>, - pub mDOMExceptionInfo: __BindgenUnionField<*mut TErrorResult_DOMExceptionInfo>, - pub bindgen_union_field: u64, -} -impl Default for TErrorResult { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct ErrorResult { - pub _base: TErrorResult, -} -impl Clone for ErrorResult { - fn clone(&self) -> Self { - *self - } -} -impl Default for ErrorResult { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} diff --git a/bindgen-tests/tests/headers/16-byte-alignment_1_0.h b/bindgen-tests/tests/headers/16-byte-alignment_1_0.h deleted file mode 100644 index 8a9fd4910e..0000000000 --- a/bindgen-tests/tests/headers/16-byte-alignment_1_0.h +++ /dev/null @@ -1,34 +0,0 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq - -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned int uint32_t; - -struct rte_ipv4_tuple { - uint32_t src_addr; - uint32_t dst_addr; - union { - struct { - uint16_t dport; - uint16_t sport; - }; - uint32_t sctp_tag; - }; -}; - -struct rte_ipv6_tuple { - uint8_t src_addr[16]; - uint8_t dst_addr[16]; - union { - struct { - uint16_t dport; - uint16_t sport; - }; - uint32_t sctp_tag; - }; -}; - -union rte_thash_tuple { - struct rte_ipv4_tuple v4; - struct rte_ipv6_tuple v6; -} __attribute__((aligned(16))); diff --git a/bindgen-tests/tests/headers/anon_struct_in_union_1_0.h b/bindgen-tests/tests/headers/anon_struct_in_union_1_0.h deleted file mode 100644 index 6b59723a3c..0000000000 --- a/bindgen-tests/tests/headers/anon_struct_in_union_1_0.h +++ /dev/null @@ -1,9 +0,0 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq - -struct s { - union { - struct inner { - int b; - } field; - } u; -}; diff --git a/bindgen-tests/tests/headers/anon_union_1_0.hpp b/bindgen-tests/tests/headers/anon_union_1_0.hpp deleted file mode 100644 index 3d9ae3dde9..0000000000 --- a/bindgen-tests/tests/headers/anon_union_1_0.hpp +++ /dev/null @@ -1,22 +0,0 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum ".*" - -template -struct TErrorResult { - enum UnionState { - HasMessage, - HasException, - }; - int mResult; - struct Message; - struct DOMExceptionInfo; - union { - Message* mMessage; - DOMExceptionInfo* mDOMExceptionInfo; - }; - - bool mMightHaveUnreported; - UnionState mUnionState; -}; - -struct ErrorResult : public TErrorResult { -}; diff --git a/bindgen-tests/tests/headers/attribute_warn_unused_result.hpp b/bindgen-tests/tests/headers/attribute_warn_unused_result.hpp index 26fda0910c..258b6396de 100644 --- a/bindgen-tests/tests/headers/attribute_warn_unused_result.hpp +++ b/bindgen-tests/tests/headers/attribute_warn_unused_result.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.27 --enable-function-attribute-detection +// bindgen-flags: \-\-rust-target=1.33 --enable-function-attribute-detection class Foo { public: diff --git a/bindgen-tests/tests/headers/attribute_warn_unused_result_no_attribute_detection.hpp b/bindgen-tests/tests/headers/attribute_warn_unused_result_no_attribute_detection.hpp index 2155030711..a102cbf100 100644 --- a/bindgen-tests/tests/headers/attribute_warn_unused_result_no_attribute_detection.hpp +++ b/bindgen-tests/tests/headers/attribute_warn_unused_result_no_attribute_detection.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.27 +// bindgen-flags: \-\-rust-target=1.33 class Foo { public: diff --git a/bindgen-tests/tests/headers/attribute_warn_unused_result_pre_1_27.hpp b/bindgen-tests/tests/headers/attribute_warn_unused_result_pre_1_27.hpp deleted file mode 100644 index 25127d9cd0..0000000000 --- a/bindgen-tests/tests/headers/attribute_warn_unused_result_pre_1_27.hpp +++ /dev/null @@ -1,8 +0,0 @@ -class Foo { -public: - __attribute__((warn_unused_result)) - int foo(int); -}; - -__attribute__((warn_unused_result)) -int foo(int); diff --git a/bindgen-tests/tests/headers/bindgen-union-inside-namespace.hpp b/bindgen-tests/tests/headers/bindgen-union-inside-namespace.hpp index 6a7d3a300c..78b05b4f92 100644 --- a/bindgen-tests/tests/headers/bindgen-union-inside-namespace.hpp +++ b/bindgen-tests/tests/headers/bindgen-union-inside-namespace.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.0 --enable-cxx-namespaces +// bindgen-flags: \-\-rust-target=1.33 --enable-cxx-namespaces namespace foo { union Bar { diff --git a/bindgen-tests/tests/headers/bitfield-enum-repr-c.hpp b/bindgen-tests/tests/headers/bitfield-enum-repr-c.hpp index 20a3f9dbbe..b80f5d99a5 100644 --- a/bindgen-tests/tests/headers/bitfield-enum-repr-c.hpp +++ b/bindgen-tests/tests/headers/bitfield-enum-repr-c.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --bitfield-enum "Foo" --rust-target 1.27 -- -std=c++11 +// bindgen-flags: --bitfield-enum "Foo" \-\-rust-target=1.33 -- -std=c++11 enum Foo { Bar = 1 << 1, diff --git a/bindgen-tests/tests/headers/bitfield-enum-repr-transparent.hpp b/bindgen-tests/tests/headers/bitfield-enum-repr-transparent.hpp index e53bb0753c..b80f5d99a5 100644 --- a/bindgen-tests/tests/headers/bitfield-enum-repr-transparent.hpp +++ b/bindgen-tests/tests/headers/bitfield-enum-repr-transparent.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --bitfield-enum "Foo" --rust-target 1.28 -- -std=c++11 +// bindgen-flags: --bitfield-enum "Foo" \-\-rust-target=1.33 -- -std=c++11 enum Foo { Bar = 1 << 1, diff --git a/bindgen-tests/tests/headers/class_1_0.hpp b/bindgen-tests/tests/headers/class_1_0.hpp deleted file mode 100644 index e3735eb68d..0000000000 --- a/bindgen-tests/tests/headers/class_1_0.hpp +++ /dev/null @@ -1,76 +0,0 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --impl-partialeq --with-derive-eq - -class C { - int a; - // More than rust limits (32) - char big_array[33]; -}; - -class C_with_zero_length_array { - int a; - // More than rust limits (32) - char big_array[33]; - char zero_length_array[0]; -}; - -class C_with_zero_length_array_2 { - int a; - char zero_length_array[0]; -}; - -class C_with_incomplete_array { - int a; - // More than rust limits (32) - char big_array[33]; - char incomplete_array[]; -}; - -class C_with_incomplete_array_2 { - int a; - char incomplete_array[]; -}; - - -class C_with_zero_length_array_and_incomplete_array { - int a; - // More than rust limits (32) - char big_array[33]; - char zero_length_array[0]; - char incomplete_array[]; -}; - -class C_with_zero_length_array_and_incomplete_array_2 { - int a; - char zero_length_array[0]; - char incomplete_array[]; -}; - - -class WithDtor { - int b; - - ~WithDtor() {} -}; - -class IncompleteArrayNonCopiable { - void* whatever; - C incomplete_array[]; -}; - -union Union { - float d; - int i; -}; - -class WithUnion { - Union data; -}; - -class RealAbstractionWithTonsOfMethods { - void foo(); -public: - void bar() const; - void bar(); - void bar(int foo); - static void sta(); -}; diff --git a/bindgen-tests/tests/headers/class_with_inner_struct_1_0.hpp b/bindgen-tests/tests/headers/class_with_inner_struct_1_0.hpp deleted file mode 100644 index 34ed96e722..0000000000 --- a/bindgen-tests/tests/headers/class_with_inner_struct_1_0.hpp +++ /dev/null @@ -1,44 +0,0 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum ".*" -// bindgen-flags: -- -std=c++11 - -class A { - unsigned c; - struct Segment { int begin, end; }; - union { - int f; - } named_union; - union { - int d; - }; -}; - -class B { - unsigned d; - struct Segment { int begin, end; }; -}; - - -enum class StepSyntax { - Keyword, // step-start and step-end - FunctionalWithoutKeyword, // steps(...) - FunctionalWithStartKeyword, // steps(..., start) - FunctionalWithEndKeyword, // steps(..., end) -}; - -class C { - unsigned d; - union { - struct { - float mX1; - float mY1; - float mX2; - float mY2; - } mFunc; - struct { - StepSyntax mStepSyntax; - unsigned int mSteps; - }; - }; - // To ensure it doesn't collide - struct Segment { int begin, end; }; -}; diff --git a/bindgen-tests/tests/headers/derive-clone_1_0.h b/bindgen-tests/tests/headers/derive-clone_1_0.h deleted file mode 100644 index 34ef40ae97..0000000000 --- a/bindgen-tests/tests/headers/derive-clone_1_0.h +++ /dev/null @@ -1,7 +0,0 @@ -// bindgen-flags: --rust-target 1.0 - -/// Since builtin `Clone` impls were introduced in Rust 1.21 this struct -/// should impl `Clone` "manually". -struct ShouldImplClone { - int large[33]; -}; diff --git a/bindgen-tests/tests/headers/derive-partialeq-union_1_0.hpp b/bindgen-tests/tests/headers/derive-partialeq-union_1_0.hpp deleted file mode 100644 index d546d77b10..0000000000 --- a/bindgen-tests/tests/headers/derive-partialeq-union_1_0.hpp +++ /dev/null @@ -1,7 +0,0 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-partialeq --impl-partialeq - -/// This should manually derive PartialEq. -union ShouldDerivePartialEq { - char a[150]; - int b; -}; diff --git a/bindgen-tests/tests/headers/forward_declared_complex_types_1_0.hpp b/bindgen-tests/tests/headers/forward_declared_complex_types_1_0.hpp deleted file mode 100644 index ff6076fc43..0000000000 --- a/bindgen-tests/tests/headers/forward_declared_complex_types_1_0.hpp +++ /dev/null @@ -1,18 +0,0 @@ -// bindgen-flags: --rust-target 1.0 - -struct Foo_empty {}; -struct Foo; - -struct Bar { - Foo *f; -}; - -void baz_struct(Foo* f); - -union Union; - -void baz_union(Union* u); - -class Quux; - -void baz_class(Quux* q); diff --git a/bindgen-tests/tests/headers/i128.h b/bindgen-tests/tests/headers/i128.h index 6ec399c726..609d546190 100644 --- a/bindgen-tests/tests/headers/i128.h +++ b/bindgen-tests/tests/headers/i128.h @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.26 +// bindgen-flags: \-\-rust-target=1.33 struct foo { __int128 my_signed; diff --git a/bindgen-tests/tests/headers/issue-1291.hpp b/bindgen-tests/tests/headers/issue-1291.hpp index 4ec524f12f..313f7f7103 100644 --- a/bindgen-tests/tests/headers/issue-1291.hpp +++ b/bindgen-tests/tests/headers/issue-1291.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.25 +// bindgen-flags: \-\-rust-target=1.33 // bindgen-unstable struct __attribute__((aligned(16))) RTCRay diff --git a/bindgen-tests/tests/headers/issue-493_1_0.hpp b/bindgen-tests/tests/headers/issue-493_1_0.hpp deleted file mode 100644 index af6fd47c41..0000000000 --- a/bindgen-tests/tests/headers/issue-493_1_0.hpp +++ /dev/null @@ -1,49 +0,0 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum ".*" - -template -class basic_string -{ -public: - typedef unsigned long long size_type; - typedef char value_type; - typedef value_type * pointer; - - struct __long - { - size_type __cap_; - size_type __size_; - pointer __data_; - }; - - enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ? - (sizeof(__long) - 1)/sizeof(value_type) : 2}; - - struct __short - { - union - { - unsigned char __size_; - value_type __lx; - }; - value_type __data_[__min_cap]; - }; - - union __ulx{__long __lx; __short __lxx;}; - - enum {__n_words = sizeof(__ulx) / sizeof(size_type)}; - - struct __raw - { - size_type __words[__n_words]; - }; - - struct __rep - { - union - { - __long __l; - __short __s; - __raw __r; - }; - }; -}; diff --git a/bindgen-tests/tests/headers/jsval_layout_opaque_1_0.hpp b/bindgen-tests/tests/headers/jsval_layout_opaque_1_0.hpp deleted file mode 100644 index c8e665516b..0000000000 --- a/bindgen-tests/tests/headers/jsval_layout_opaque_1_0.hpp +++ /dev/null @@ -1,425 +0,0 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum ".*" -// bindgen-flags: -- -std=c++11 - -/** - * These typedefs are hacky, but keep our tests consistent across 64-bit - * platforms, otherwise the id's change and our CI is unhappy. - */ -typedef unsigned char uint8_t; -typedef int int32_t; -typedef unsigned int uint32_t; -typedef unsigned long long uint64_t; -typedef unsigned long long size_t; -typedef unsigned long long uintptr_t; - - -#define JS_PUNBOX64 -#define IS_LITTLE_ENDIAN - -/* - * Try to get jsvals 64-bit aligned. We could almost assert that all values are - * aligned, but MSVC and GCC occasionally break alignment. - */ -#if defined(__GNUC__) || defined(__xlc__) || defined(__xlC__) -# define JSVAL_ALIGNMENT __attribute__((aligned (8))) -#elif defined(_MSC_VER) - /* - * Structs can be aligned with MSVC, but not if they are used as parameters, - * so we just don't try to align. - */ -# define JSVAL_ALIGNMENT -#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) -# define JSVAL_ALIGNMENT -#elif defined(__HP_cc) || defined(__HP_aCC) -# define JSVAL_ALIGNMENT -#endif - -#if defined(JS_PUNBOX64) -# define JSVAL_TAG_SHIFT 47 -#endif - -/* - * We try to use enums so that printing a jsval_layout in the debugger shows - * nice symbolic type tags, however we can only do this when we can force the - * underlying type of the enum to be the desired size. - */ -#if !defined(__SUNPRO_CC) && !defined(__xlC__) - -#if defined(_MSC_VER) -# define JS_ENUM_HEADER(id, type) enum id : type -# define JS_ENUM_FOOTER(id) -#else -# define JS_ENUM_HEADER(id, type) enum id -# define JS_ENUM_FOOTER(id) __attribute__((packed)) -#endif - -/* Remember to propagate changes to the C defines below. */ -JS_ENUM_HEADER(JSValueType, uint8_t) -{ - JSVAL_TYPE_DOUBLE = 0x00, - JSVAL_TYPE_INT32 = 0x01, - JSVAL_TYPE_UNDEFINED = 0x02, - JSVAL_TYPE_BOOLEAN = 0x03, - JSVAL_TYPE_MAGIC = 0x04, - JSVAL_TYPE_STRING = 0x05, - JSVAL_TYPE_SYMBOL = 0x06, - JSVAL_TYPE_NULL = 0x07, - JSVAL_TYPE_OBJECT = 0x08, - - /* These never appear in a jsval; they are only provided as an out-of-band value. */ - JSVAL_TYPE_UNKNOWN = 0x20, - JSVAL_TYPE_MISSING = 0x21 -} JS_ENUM_FOOTER(JSValueType); - -static_assert(sizeof(JSValueType) == 1, - "compiler typed enum support is apparently buggy"); - -#if defined(JS_NUNBOX32) - -/* Remember to propagate changes to the C defines below. */ -JS_ENUM_HEADER(JSValueTag, uint32_t) -{ - JSVAL_TAG_CLEAR = 0xFFFFFF80, - JSVAL_TAG_INT32 = JSVAL_TAG_CLEAR | JSVAL_TYPE_INT32, - JSVAL_TAG_UNDEFINED = JSVAL_TAG_CLEAR | JSVAL_TYPE_UNDEFINED, - JSVAL_TAG_STRING = JSVAL_TAG_CLEAR | JSVAL_TYPE_STRING, - JSVAL_TAG_SYMBOL = JSVAL_TAG_CLEAR | JSVAL_TYPE_SYMBOL, - JSVAL_TAG_BOOLEAN = JSVAL_TAG_CLEAR | JSVAL_TYPE_BOOLEAN, - JSVAL_TAG_MAGIC = JSVAL_TAG_CLEAR | JSVAL_TYPE_MAGIC, - JSVAL_TAG_NULL = JSVAL_TAG_CLEAR | JSVAL_TYPE_NULL, - JSVAL_TAG_OBJECT = JSVAL_TAG_CLEAR | JSVAL_TYPE_OBJECT -} JS_ENUM_FOOTER(JSValueTag); - -static_assert(sizeof(JSValueTag) == sizeof(uint32_t), - "compiler typed enum support is apparently buggy"); - -#elif defined(JS_PUNBOX64) - -/* Remember to propagate changes to the C defines below. */ -JS_ENUM_HEADER(JSValueTag, uint32_t) -{ - JSVAL_TAG_MAX_DOUBLE = 0x1FFF0, - JSVAL_TAG_INT32 = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_INT32, - JSVAL_TAG_UNDEFINED = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_UNDEFINED, - JSVAL_TAG_STRING = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_STRING, - JSVAL_TAG_SYMBOL = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_SYMBOL, - JSVAL_TAG_BOOLEAN = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_BOOLEAN, - JSVAL_TAG_MAGIC = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_MAGIC, - JSVAL_TAG_NULL = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_NULL, - JSVAL_TAG_OBJECT = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_OBJECT -} JS_ENUM_FOOTER(JSValueTag); - -static_assert(sizeof(JSValueTag) == sizeof(uint32_t), - "compiler typed enum support is apparently buggy"); - -JS_ENUM_HEADER(JSValueShiftedTag, uint64_t) -{ - JSVAL_SHIFTED_TAG_MAX_DOUBLE = ((((uint64_t)JSVAL_TAG_MAX_DOUBLE) << JSVAL_TAG_SHIFT) | 0xFFFFFFFF), - JSVAL_SHIFTED_TAG_INT32 = (((uint64_t)JSVAL_TAG_INT32) << JSVAL_TAG_SHIFT), - JSVAL_SHIFTED_TAG_UNDEFINED = (((uint64_t)JSVAL_TAG_UNDEFINED) << JSVAL_TAG_SHIFT), - JSVAL_SHIFTED_TAG_STRING = (((uint64_t)JSVAL_TAG_STRING) << JSVAL_TAG_SHIFT), - JSVAL_SHIFTED_TAG_SYMBOL = (((uint64_t)JSVAL_TAG_SYMBOL) << JSVAL_TAG_SHIFT), - JSVAL_SHIFTED_TAG_BOOLEAN = (((uint64_t)JSVAL_TAG_BOOLEAN) << JSVAL_TAG_SHIFT), - JSVAL_SHIFTED_TAG_MAGIC = (((uint64_t)JSVAL_TAG_MAGIC) << JSVAL_TAG_SHIFT), - JSVAL_SHIFTED_TAG_NULL = (((uint64_t)JSVAL_TAG_NULL) << JSVAL_TAG_SHIFT), - JSVAL_SHIFTED_TAG_OBJECT = (((uint64_t)JSVAL_TAG_OBJECT) << JSVAL_TAG_SHIFT) -} JS_ENUM_FOOTER(JSValueShiftedTag); - -static_assert(sizeof(JSValueShiftedTag) == sizeof(uint64_t), - "compiler typed enum support is apparently buggy"); - -#endif - -/* - * All our supported compilers implement C++11 |enum Foo : T| syntax, so don't - * expose these macros. (This macro exists *only* because gcc bug 51242 - * makes bit-fields of - * typed enums trigger a warning that can't be turned off. Don't expose it - * beyond this file!) - */ -#undef JS_ENUM_HEADER -#undef JS_ENUM_FOOTER - -#else /* !defined(__SUNPRO_CC) && !defined(__xlC__) */ - -typedef uint8_t JSValueType; -#define JSVAL_TYPE_DOUBLE ((uint8_t)0x00) -#define JSVAL_TYPE_INT32 ((uint8_t)0x01) -#define JSVAL_TYPE_UNDEFINED ((uint8_t)0x02) -#define JSVAL_TYPE_BOOLEAN ((uint8_t)0x03) -#define JSVAL_TYPE_MAGIC ((uint8_t)0x04) -#define JSVAL_TYPE_STRING ((uint8_t)0x05) -#define JSVAL_TYPE_SYMBOL ((uint8_t)0x06) -#define JSVAL_TYPE_NULL ((uint8_t)0x07) -#define JSVAL_TYPE_OBJECT ((uint8_t)0x08) -#define JSVAL_TYPE_UNKNOWN ((uint8_t)0x20) - -#if defined(JS_NUNBOX32) - -typedef uint32_t JSValueTag; -#define JSVAL_TAG_CLEAR ((uint32_t)(0xFFFFFF80)) -#define JSVAL_TAG_INT32 ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_INT32)) -#define JSVAL_TAG_UNDEFINED ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_UNDEFINED)) -#define JSVAL_TAG_STRING ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_STRING)) -#define JSVAL_TAG_SYMBOL ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_SYMBOL)) -#define JSVAL_TAG_BOOLEAN ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_BOOLEAN)) -#define JSVAL_TAG_MAGIC ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_MAGIC)) -#define JSVAL_TAG_NULL ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_NULL)) -#define JSVAL_TAG_OBJECT ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_OBJECT)) - -#elif defined(JS_PUNBOX64) - -typedef uint32_t JSValueTag; -#define JSVAL_TAG_MAX_DOUBLE ((uint32_t)(0x1FFF0)) -#define JSVAL_TAG_INT32 (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_INT32) -#define JSVAL_TAG_UNDEFINED (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_UNDEFINED) -#define JSVAL_TAG_STRING (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_STRING) -#define JSVAL_TAG_SYMBOL (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_SYMBOL) -#define JSVAL_TAG_BOOLEAN (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_BOOLEAN) -#define JSVAL_TAG_MAGIC (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_MAGIC) -#define JSVAL_TAG_NULL (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_NULL) -#define JSVAL_TAG_OBJECT (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_OBJECT) - -typedef uint64_t JSValueShiftedTag; -#define JSVAL_SHIFTED_TAG_MAX_DOUBLE ((((uint64_t)JSVAL_TAG_MAX_DOUBLE) << JSVAL_TAG_SHIFT) | 0xFFFFFFFF) -#define JSVAL_SHIFTED_TAG_INT32 (((uint64_t)JSVAL_TAG_INT32) << JSVAL_TAG_SHIFT) -#define JSVAL_SHIFTED_TAG_UNDEFINED (((uint64_t)JSVAL_TAG_UNDEFINED) << JSVAL_TAG_SHIFT) -#define JSVAL_SHIFTED_TAG_STRING (((uint64_t)JSVAL_TAG_STRING) << JSVAL_TAG_SHIFT) -#define JSVAL_SHIFTED_TAG_SYMBOL (((uint64_t)JSVAL_TAG_SYMBOL) << JSVAL_TAG_SHIFT) -#define JSVAL_SHIFTED_TAG_BOOLEAN (((uint64_t)JSVAL_TAG_BOOLEAN) << JSVAL_TAG_SHIFT) -#define JSVAL_SHIFTED_TAG_MAGIC (((uint64_t)JSVAL_TAG_MAGIC) << JSVAL_TAG_SHIFT) -#define JSVAL_SHIFTED_TAG_NULL (((uint64_t)JSVAL_TAG_NULL) << JSVAL_TAG_SHIFT) -#define JSVAL_SHIFTED_TAG_OBJECT (((uint64_t)JSVAL_TAG_OBJECT) << JSVAL_TAG_SHIFT) - -#endif /* JS_PUNBOX64 */ -#endif /* !defined(__SUNPRO_CC) && !defined(__xlC__) */ - -#if defined(JS_NUNBOX32) - -#define JSVAL_TYPE_TO_TAG(type) ((JSValueTag)(JSVAL_TAG_CLEAR | (type))) - -#define JSVAL_LOWER_INCL_TAG_OF_OBJ_OR_NULL_SET JSVAL_TAG_NULL -#define JSVAL_UPPER_EXCL_TAG_OF_PRIMITIVE_SET JSVAL_TAG_OBJECT -#define JSVAL_UPPER_INCL_TAG_OF_NUMBER_SET JSVAL_TAG_INT32 -#define JSVAL_LOWER_INCL_TAG_OF_GCTHING_SET JSVAL_TAG_STRING - -#elif defined(JS_PUNBOX64) - -#define JSVAL_PAYLOAD_MASK 0x00007FFFFFFFFFFFLL -#define JSVAL_TAG_MASK 0xFFFF800000000000LL -#define JSVAL_TYPE_TO_TAG(type) ((JSValueTag)(JSVAL_TAG_MAX_DOUBLE | (type))) -#define JSVAL_TYPE_TO_SHIFTED_TAG(type) (((uint64_t)JSVAL_TYPE_TO_TAG(type)) << JSVAL_TAG_SHIFT) - -#define JSVAL_LOWER_INCL_TAG_OF_OBJ_OR_NULL_SET JSVAL_TAG_NULL -#define JSVAL_UPPER_EXCL_TAG_OF_PRIMITIVE_SET JSVAL_TAG_OBJECT -#define JSVAL_UPPER_INCL_TAG_OF_NUMBER_SET JSVAL_TAG_INT32 -#define JSVAL_LOWER_INCL_TAG_OF_GCTHING_SET JSVAL_TAG_STRING - -#define JSVAL_LOWER_INCL_SHIFTED_TAG_OF_OBJ_OR_NULL_SET JSVAL_SHIFTED_TAG_NULL -#define JSVAL_UPPER_EXCL_SHIFTED_TAG_OF_PRIMITIVE_SET JSVAL_SHIFTED_TAG_OBJECT -#define JSVAL_UPPER_EXCL_SHIFTED_TAG_OF_NUMBER_SET JSVAL_SHIFTED_TAG_UNDEFINED -#define JSVAL_LOWER_INCL_SHIFTED_TAG_OF_GCTHING_SET JSVAL_SHIFTED_TAG_STRING - -#endif /* JS_PUNBOX64 */ - -typedef enum JSWhyMagic -{ - /** a hole in a native object's elements */ - JS_ELEMENTS_HOLE, - - /** there is not a pending iterator value */ - JS_NO_ITER_VALUE, - - /** exception value thrown when closing a generator */ - JS_GENERATOR_CLOSING, - - /** compiler sentinel value */ - JS_NO_CONSTANT, - - /** used in debug builds to catch tracing errors */ - JS_THIS_POISON, - - /** used in debug builds to catch tracing errors */ - JS_ARG_POISON, - - /** an empty subnode in the AST serializer */ - JS_SERIALIZE_NO_NODE, - - /** lazy arguments value on the stack */ - JS_LAZY_ARGUMENTS, - - /** optimized-away 'arguments' value */ - JS_OPTIMIZED_ARGUMENTS, - - /** magic value passed to natives to indicate construction */ - JS_IS_CONSTRUCTING, - - /** arguments.callee has been overwritten */ - JS_OVERWRITTEN_CALLEE, - - /** value of static block object slot */ - JS_BLOCK_NEEDS_CLONE, - - /** see class js::HashableValue */ - JS_HASH_KEY_EMPTY, - - /** error while running Ion code */ - JS_ION_ERROR, - - /** missing recover instruction result */ - JS_ION_BAILOUT, - - /** optimized out slot */ - JS_OPTIMIZED_OUT, - - /** uninitialized lexical bindings that produce ReferenceError on touch. */ - JS_UNINITIALIZED_LEXICAL, - - /** for local use */ - JS_GENERIC_MAGIC, - - JS_WHY_MAGIC_COUNT -} JSWhyMagic; - -#if defined(IS_LITTLE_ENDIAN) -# if defined(JS_NUNBOX32) -typedef union jsval_layout -{ - uint64_t asBits; - struct { - union { - int32_t i32; - uint32_t u32; - uint32_t boo; // Don't use |bool| -- it must be four bytes. - JSString* str; - JS::Symbol* sym; - JSObject* obj; - js::gc::Cell* cell; - void* ptr; - JSWhyMagic why; - size_t word; - uintptr_t uintptr; - } payload; - JSValueTag tag; - } s; - double asDouble; - void* asPtr; -} JSVAL_ALIGNMENT jsval_layout; -# elif defined(JS_PUNBOX64) -typedef union jsval_layout -{ - uint64_t asBits; -#if !defined(_WIN64) - /* MSVC does not pack these correctly :-( */ - struct { - uint64_t payload47 : 47; - JSValueTag tag : 17; - } debugView; -#endif - struct { - union { - int32_t i32; - uint32_t u32; - JSWhyMagic why; - } payload; - } s; - double asDouble; - void* asPtr; - size_t asWord; - uintptr_t asUIntPtr; -} JSVAL_ALIGNMENT jsval_layout; -# endif /* JS_PUNBOX64 */ -#else /* defined(IS_LITTLE_ENDIAN) */ -# if defined(JS_NUNBOX32) -typedef union jsval_layout -{ - uint64_t asBits; - struct { - JSValueTag tag; - union { - int32_t i32; - uint32_t u32; - uint32_t boo; // Don't use |bool| -- it must be four bytes. - JSString* str; - JS::Symbol* sym; - JSObject* obj; - js::gc::Cell* cell; - void* ptr; - JSWhyMagic why; - size_t word; - uintptr_t uintptr; - } payload; - } s; - double asDouble; - void* asPtr; -} JSVAL_ALIGNMENT jsval_layout; -# elif defined(JS_PUNBOX64) -typedef union jsval_layout -{ - uint64_t asBits; - struct { - JSValueTag tag : 17; - uint64_t payload47 : 47; - } debugView; - struct { - uint32_t padding; - union { - int32_t i32; - uint32_t u32; - JSWhyMagic why; - } payload; - } s; - double asDouble; - void* asPtr; - size_t asWord; - uintptr_t asUIntPtr; -} JSVAL_ALIGNMENT jsval_layout; -# endif /* JS_PUNBOX64 */ -#endif /* defined(IS_LITTLE_ENDIAN) */ - -/* - * For codesize purposes on some platforms, it's important that the - * compiler know that JS::Values constructed from constant values can be - * folded to constant bit patterns at compile time, rather than - * constructed at runtime. Doing this requires a fair amount of C++11 - * features, which are not supported on all of our compilers. Set up - * some defines and helper macros in an attempt to confine the ugliness - * here, rather than scattering it all about the file. The important - * features are: - * - * - constexpr; - * - defaulted functions; - * - C99-style designated initializers. - */ -#if defined(__clang__) -# if __has_feature(cxx_constexpr) && __has_feature(cxx_defaulted_functions) -# define JS_VALUE_IS_CONSTEXPR -# endif -#elif defined(__GNUC__) -/* - * We need 4.5 for defaulted functions, 4.6 for constexpr, 4.7 because 4.6 - * doesn't understand |(X) { .field = ... }| syntax, and 4.7.3 because - * versions prior to that have bugs in the C++ front-end that cause crashes. - */ -# if MOZ_GCC_VERSION_AT_LEAST(4, 7, 3) -# define JS_VALUE_IS_CONSTEXPR -# endif -#endif - -#if defined(JS_VALUE_IS_CONSTEXPR) -# define JS_RETURN_LAYOUT_FROM_BITS(BITS) \ - return (jsval_layout) { .asBits = (BITS) } -# define JS_VALUE_CONSTEXPR MOZ_CONSTEXPR -# define JS_VALUE_CONSTEXPR_VAR MOZ_CONSTEXPR_VAR -#else -# define JS_RETURN_LAYOUT_FROM_BITS(BITS) \ - jsval_layout l; \ - l.asBits = (BITS); \ - return l; -# define JS_VALUE_CONSTEXPR -# define JS_VALUE_CONSTEXPR_VAR const -#endif - -struct Value { - jsval_layout data; -}; diff --git a/bindgen-tests/tests/headers/layout.h b/bindgen-tests/tests/headers/layout.h index b290ee856b..6a3df9b3f5 100644 --- a/bindgen-tests/tests/headers/layout.h +++ b/bindgen-tests/tests/headers/layout.h @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.21 +// bindgen-flags: \-\-rust-target=1.33 // // FIXME: https://github.com/rust-lang/rust-bindgen/issues/1498 diff --git a/bindgen-tests/tests/headers/layout_eth_conf_1_0.h b/bindgen-tests/tests/headers/layout_eth_conf_1_0.h deleted file mode 100644 index 7da582ba19..0000000000 --- a/bindgen-tests/tests/headers/layout_eth_conf_1_0.h +++ /dev/null @@ -1,429 +0,0 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum ".*" - -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned int uint32_t; -typedef unsigned long long uint64_t; - -/** - * Simple flags are used for rte_eth_conf.rxmode.mq_mode. - */ -#define ETH_MQ_RX_RSS_FLAG 0x1 -#define ETH_MQ_RX_DCB_FLAG 0x2 -#define ETH_MQ_RX_VMDQ_FLAG 0x4 - -/* Definitions used for VMDQ and DCB functionality */ -#define ETH_VMDQ_MAX_VLAN_FILTERS 64 /**< Maximum nb. of VMDQ vlan filters. */ -#define ETH_DCB_NUM_USER_PRIORITIES 8 /**< Maximum nb. of DCB priorities. */ -#define ETH_VMDQ_DCB_NUM_QUEUES 128 /**< Maximum nb. of VMDQ DCB queues. */ -#define ETH_DCB_NUM_QUEUES 128 /**< Maximum nb. of DCB queues. */ - -/** - * A set of values to identify what method is to be used to route - * packets to multiple queues. - */ -enum rte_eth_rx_mq_mode { - /** None of DCB,RSS or VMDQ mode */ - ETH_MQ_RX_NONE = 0, - - /** For RX side, only RSS is on */ - ETH_MQ_RX_RSS = ETH_MQ_RX_RSS_FLAG, - /** For RX side,only DCB is on. */ - ETH_MQ_RX_DCB = ETH_MQ_RX_DCB_FLAG, - /** Both DCB and RSS enable */ - ETH_MQ_RX_DCB_RSS = ETH_MQ_RX_RSS_FLAG | ETH_MQ_RX_DCB_FLAG, - - /** Only VMDQ, no RSS nor DCB */ - ETH_MQ_RX_VMDQ_ONLY = ETH_MQ_RX_VMDQ_FLAG, - /** RSS mode with VMDQ */ - ETH_MQ_RX_VMDQ_RSS = ETH_MQ_RX_RSS_FLAG | ETH_MQ_RX_VMDQ_FLAG, - /** Use VMDQ+DCB to route traffic to queues */ - ETH_MQ_RX_VMDQ_DCB = ETH_MQ_RX_VMDQ_FLAG | ETH_MQ_RX_DCB_FLAG, - /** Enable both VMDQ and DCB in VMDq */ - ETH_MQ_RX_VMDQ_DCB_RSS = ETH_MQ_RX_RSS_FLAG | ETH_MQ_RX_DCB_FLAG | - ETH_MQ_RX_VMDQ_FLAG, -}; - -/** - * A structure used to configure the RX features of an Ethernet port. - */ -struct rte_eth_rxmode { - /** The multi-queue packet distribution mode to be used, e.g. RSS. */ - enum rte_eth_rx_mq_mode mq_mode; - uint32_t max_rx_pkt_len; /**< Only used if jumbo_frame enabled. */ - uint16_t split_hdr_size; /**< hdr buf size (header_split enabled).*/ - __extension__ - uint16_t header_split : 1, /**< Header Split enable. */ - hw_ip_checksum : 1, /**< IP/UDP/TCP checksum offload enable. */ - hw_vlan_filter : 1, /**< VLAN filter enable. */ - hw_vlan_strip : 1, /**< VLAN strip enable. */ - hw_vlan_extend : 1, /**< Extended VLAN enable. */ - jumbo_frame : 1, /**< Jumbo Frame Receipt enable. */ - hw_strip_crc : 1, /**< Enable CRC stripping by hardware. */ - enable_scatter : 1, /**< Enable scatter packets rx handler */ - enable_lro : 1; /**< Enable LRO */ -}; - -/** - * A set of values to identify what method is to be used to transmit - * packets using multi-TCs. - */ -enum rte_eth_tx_mq_mode { - ETH_MQ_TX_NONE = 0, /**< It is in neither DCB nor VT mode. */ - ETH_MQ_TX_DCB, /**< For TX side,only DCB is on. */ - ETH_MQ_TX_VMDQ_DCB, /**< For TX side,both DCB and VT is on. */ - ETH_MQ_TX_VMDQ_ONLY, /**< Only VT on, no DCB */ -}; - -/** - * A structure used to configure the TX features of an Ethernet port. - */ -struct rte_eth_txmode { - enum rte_eth_tx_mq_mode mq_mode; /**< TX multi-queues mode. */ - - /* For i40e specifically */ - uint16_t pvid; - __extension__ - uint8_t hw_vlan_reject_tagged : 1, - /**< If set, reject sending out tagged pkts */ - hw_vlan_reject_untagged : 1, - /**< If set, reject sending out untagged pkts */ - hw_vlan_insert_pvid : 1; - /**< If set, enable port based VLAN insertion */ -}; - -/** - * A structure used to configure the Receive Side Scaling (RSS) feature - * of an Ethernet port. - * If not NULL, the *rss_key* pointer of the *rss_conf* structure points - * to an array holding the RSS key to use for hashing specific header - * fields of received packets. The length of this array should be indicated - * by *rss_key_len* below. Otherwise, a default random hash key is used by - * the device driver. - * - * The *rss_key_len* field of the *rss_conf* structure indicates the length - * in bytes of the array pointed by *rss_key*. To be compatible, this length - * will be checked in i40e only. Others assume 40 bytes to be used as before. - * - * The *rss_hf* field of the *rss_conf* structure indicates the different - * types of IPv4/IPv6 packets to which the RSS hashing must be applied. - * Supplying an *rss_hf* equal to zero disables the RSS feature. - */ -struct rte_eth_rss_conf { - uint8_t *rss_key; /**< If not NULL, 40-byte hash key. */ - uint8_t rss_key_len; /**< hash key length in bytes. */ - uint64_t rss_hf; /**< Hash functions to apply - see below. */ -}; - -/** - * This enum indicates the possible number of traffic classes - * in DCB configratioins - */ -enum rte_eth_nb_tcs { - ETH_4_TCS = 4, /**< 4 TCs with DCB. */ - ETH_8_TCS = 8 /**< 8 TCs with DCB. */ -}; - -/** - * This enum indicates the possible number of queue pools - * in VMDQ configurations. - */ -enum rte_eth_nb_pools { - ETH_8_POOLS = 8, /**< 8 VMDq pools. */ - ETH_16_POOLS = 16, /**< 16 VMDq pools. */ - ETH_32_POOLS = 32, /**< 32 VMDq pools. */ - ETH_64_POOLS = 64 /**< 64 VMDq pools. */ -}; - -/** - * A structure used to configure the VMDQ+DCB feature - * of an Ethernet port. - * - * Using this feature, packets are routed to a pool of queues, based - * on the vlan ID in the vlan tag, and then to a specific queue within - * that pool, using the user priority vlan tag field. - * - * A default pool may be used, if desired, to route all traffic which - * does not match the vlan filter rules. - */ -struct rte_eth_vmdq_dcb_conf { - enum rte_eth_nb_pools nb_queue_pools; /**< With DCB, 16 or 32 pools */ - uint8_t enable_default_pool; /**< If non-zero, use a default pool */ - uint8_t default_pool; /**< The default pool, if applicable */ - uint8_t nb_pool_maps; /**< We can have up to 64 filters/mappings */ - struct { - uint16_t vlan_id; /**< The vlan ID of the received frame */ - uint64_t pools; /**< Bitmask of pools for packet rx */ - } pool_map[ETH_VMDQ_MAX_VLAN_FILTERS]; /**< VMDq vlan pool maps. */ - uint8_t dcb_tc[ETH_DCB_NUM_USER_PRIORITIES]; - /**< Selects a queue in a pool */ -}; - -/* This structure may be extended in future. */ -struct rte_eth_dcb_rx_conf { - enum rte_eth_nb_tcs nb_tcs; /**< Possible DCB TCs, 4 or 8 TCs */ - /** Traffic class each UP mapped to. */ - uint8_t dcb_tc[ETH_DCB_NUM_USER_PRIORITIES]; -}; - -struct rte_eth_vmdq_dcb_tx_conf { - enum rte_eth_nb_pools nb_queue_pools; /**< With DCB, 16 or 32 pools. */ - /** Traffic class each UP mapped to. */ - uint8_t dcb_tc[ETH_DCB_NUM_USER_PRIORITIES]; -}; - -struct rte_eth_dcb_tx_conf { - enum rte_eth_nb_tcs nb_tcs; /**< Possible DCB TCs, 4 or 8 TCs. */ - /** Traffic class each UP mapped to. */ - uint8_t dcb_tc[ETH_DCB_NUM_USER_PRIORITIES]; -}; - -struct rte_eth_vmdq_tx_conf { - enum rte_eth_nb_pools nb_queue_pools; /**< VMDq mode, 64 pools. */ -}; - -struct rte_eth_vmdq_rx_conf { - enum rte_eth_nb_pools nb_queue_pools; /**< VMDq only mode, 8 or 64 pools */ - uint8_t enable_default_pool; /**< If non-zero, use a default pool */ - uint8_t default_pool; /**< The default pool, if applicable */ - uint8_t enable_loop_back; /**< Enable VT loop back */ - uint8_t nb_pool_maps; /**< We can have up to 64 filters/mappings */ - uint32_t rx_mode; /**< Flags from ETH_VMDQ_ACCEPT_* */ - struct { - uint16_t vlan_id; /**< The vlan ID of the received frame */ - uint64_t pools; /**< Bitmask of pools for packet rx */ - } pool_map[ETH_VMDQ_MAX_VLAN_FILTERS]; /**< VMDq vlan pool maps. */ -}; - -/** - * Flow Director setting modes: none, signature or perfect. - */ -enum rte_fdir_mode { - RTE_FDIR_MODE_NONE = 0, /**< Disable FDIR support. */ - RTE_FDIR_MODE_SIGNATURE, /**< Enable FDIR signature filter mode. */ - RTE_FDIR_MODE_PERFECT, /**< Enable FDIR perfect filter mode. */ - RTE_FDIR_MODE_PERFECT_MAC_VLAN, /**< Enable FDIR filter mode - MAC VLAN. */ - RTE_FDIR_MODE_PERFECT_TUNNEL, /**< Enable FDIR filter mode - tunnel. */ -}; - -/** - * Memory space that can be configured to store Flow Director filters - * in the board memory. - */ -enum rte_fdir_pballoc_type { - RTE_FDIR_PBALLOC_64K = 0, /**< 64k. */ - RTE_FDIR_PBALLOC_128K, /**< 128k. */ - RTE_FDIR_PBALLOC_256K, /**< 256k. */ -}; - -/** - * Select report mode of FDIR hash information in RX descriptors. - */ -enum rte_fdir_status_mode { - RTE_FDIR_NO_REPORT_STATUS = 0, /**< Never report FDIR hash. */ - RTE_FDIR_REPORT_STATUS, /**< Only report FDIR hash for matching pkts. */ - RTE_FDIR_REPORT_STATUS_ALWAYS, /**< Always report FDIR hash. */ -}; - -/** - * A structure used to define the input for IPV4 flow - */ -struct rte_eth_ipv4_flow { - uint32_t src_ip; /**< IPv4 source address in big endian. */ - uint32_t dst_ip; /**< IPv4 destination address in big endian. */ - uint8_t tos; /**< Type of service to match. */ - uint8_t ttl; /**< Time to live to match. */ - uint8_t proto; /**< Protocol, next header in big endian. */ -}; - -/** - * A structure used to define the input for IPV6 flow - */ -struct rte_eth_ipv6_flow { - uint32_t src_ip[4]; /**< IPv6 source address in big endian. */ - uint32_t dst_ip[4]; /**< IPv6 destination address in big endian. */ - uint8_t tc; /**< Traffic class to match. */ - uint8_t proto; /**< Protocol, next header to match. */ - uint8_t hop_limits; /**< Hop limits to match. */ -}; - -/** - * A structure used to configure FDIR masks that are used by the device - * to match the various fields of RX packet headers. - */ -struct rte_eth_fdir_masks { - uint16_t vlan_tci_mask; /**< Bit mask for vlan_tci in big endian */ - /** Bit mask for ipv4 flow in big endian. */ - struct rte_eth_ipv4_flow ipv4_mask; - /** Bit maks for ipv6 flow in big endian. */ - struct rte_eth_ipv6_flow ipv6_mask; - /** Bit mask for L4 source port in big endian. */ - uint16_t src_port_mask; - /** Bit mask for L4 destination port in big endian. */ - uint16_t dst_port_mask; - /** 6 bit mask for proper 6 bytes of Mac address, bit 0 matches the - first byte on the wire */ - uint8_t mac_addr_byte_mask; - /** Bit mask for tunnel ID in big endian. */ - uint32_t tunnel_id_mask; - uint8_t tunnel_type_mask; /**< 1 - Match tunnel type, - 0 - Ignore tunnel type. */ -}; - -/** - * Payload type - */ -enum rte_eth_payload_type { - RTE_ETH_PAYLOAD_UNKNOWN = 0, - RTE_ETH_RAW_PAYLOAD, - RTE_ETH_L2_PAYLOAD, - RTE_ETH_L3_PAYLOAD, - RTE_ETH_L4_PAYLOAD, - RTE_ETH_PAYLOAD_MAX = 8, -}; - -#define RTE_ETH_FDIR_MAX_FLEXLEN 16 /**< Max length of flexbytes. */ -#define RTE_ETH_INSET_SIZE_MAX 128 /**< Max length of input set. */ - -/** - * A structure used to select bytes extracted from the protocol layers to - * flexible payload for filter - */ -struct rte_eth_flex_payload_cfg { - enum rte_eth_payload_type type; /**< Payload type */ - uint16_t src_offset[RTE_ETH_FDIR_MAX_FLEXLEN]; - /**< Offset in bytes from the beginning of packet's payload - src_offset[i] indicates the flexbyte i's offset in original - packet payload. This value should be less than - flex_payload_limit in struct rte_eth_fdir_info.*/ -}; - -/** - * A structure used to define FDIR masks for flexible payload - * for each flow type - */ -struct rte_eth_fdir_flex_mask { - uint16_t flow_type; - uint8_t mask[RTE_ETH_FDIR_MAX_FLEXLEN]; - /**< Mask for the whole flexible payload */ -}; - - -/* - * A packet can be identified by hardware as different flow types. Different - * NIC hardwares may support different flow types. - * Basically, the NIC hardware identifies the flow type as deep protocol as - * possible, and exclusively. For example, if a packet is identified as - * 'RTE_ETH_FLOW_NONFRAG_IPV4_TCP', it will not be any of other flow types, - * though it is an actual IPV4 packet. - * Note that the flow types are used to define RSS offload types in - * rte_ethdev.h. - */ -#define RTE_ETH_FLOW_UNKNOWN 0 -#define RTE_ETH_FLOW_RAW 1 -#define RTE_ETH_FLOW_IPV4 2 -#define RTE_ETH_FLOW_FRAG_IPV4 3 -#define RTE_ETH_FLOW_NONFRAG_IPV4_TCP 4 -#define RTE_ETH_FLOW_NONFRAG_IPV4_UDP 5 -#define RTE_ETH_FLOW_NONFRAG_IPV4_SCTP 6 -#define RTE_ETH_FLOW_NONFRAG_IPV4_OTHER 7 -#define RTE_ETH_FLOW_IPV6 8 -#define RTE_ETH_FLOW_FRAG_IPV6 9 -#define RTE_ETH_FLOW_NONFRAG_IPV6_TCP 10 -#define RTE_ETH_FLOW_NONFRAG_IPV6_UDP 11 -#define RTE_ETH_FLOW_NONFRAG_IPV6_SCTP 12 -#define RTE_ETH_FLOW_NONFRAG_IPV6_OTHER 13 -#define RTE_ETH_FLOW_L2_PAYLOAD 14 -#define RTE_ETH_FLOW_IPV6_EX 15 -#define RTE_ETH_FLOW_IPV6_TCP_EX 16 -#define RTE_ETH_FLOW_IPV6_UDP_EX 17 -#define RTE_ETH_FLOW_PORT 18 - /**< Consider device port number as a flow differentiator */ -#define RTE_ETH_FLOW_VXLAN 19 /**< VXLAN protocol based flow */ -#define RTE_ETH_FLOW_GENEVE 20 /**< GENEVE protocol based flow */ -#define RTE_ETH_FLOW_NVGRE 21 /**< NVGRE protocol based flow */ -#define RTE_ETH_FLOW_MAX 22 - -/** - * A structure used to define all flexible payload related setting - * include flex payload and flex mask - */ -struct rte_eth_fdir_flex_conf { - uint16_t nb_payloads; /**< The number of following payload cfg */ - uint16_t nb_flexmasks; /**< The number of following mask */ - struct rte_eth_flex_payload_cfg flex_set[RTE_ETH_PAYLOAD_MAX]; - /**< Flex payload configuration for each payload type */ - struct rte_eth_fdir_flex_mask flex_mask[RTE_ETH_FLOW_MAX]; - /**< Flex mask configuration for each flow type */ -}; - -/** - * A structure used to configure the Flow Director (FDIR) feature - * of an Ethernet port. - * - * If mode is RTE_FDIR_DISABLE, the pballoc value is ignored. - */ -struct rte_fdir_conf { - enum rte_fdir_mode mode; /**< Flow Director mode. */ - enum rte_fdir_pballoc_type pballoc; /**< Space for FDIR filters. */ - enum rte_fdir_status_mode status; /**< How to report FDIR hash. */ - /** RX queue of packets matching a "drop" filter in perfect mode. */ - uint8_t drop_queue; - struct rte_eth_fdir_masks mask; - struct rte_eth_fdir_flex_conf flex_conf; - /**< Flex payload configuration. */ -}; - -/** - * A structure used to enable/disable specific device interrupts. - */ -struct rte_intr_conf { - /** enable/disable lsc interrupt. 0 (default) - disable, 1 enable */ - uint16_t lsc; - /** enable/disable rxq interrupt. 0 (default) - disable, 1 enable */ - uint16_t rxq; -}; - -/** - * A structure used to configure an Ethernet port. - * Depending upon the RX multi-queue mode, extra advanced - * configuration settings may be needed. - */ -struct rte_eth_conf { - uint32_t link_speeds; /**< bitmap of ETH_LINK_SPEED_XXX of speeds to be - used. ETH_LINK_SPEED_FIXED disables link - autonegotiation, and a unique speed shall be - set. Otherwise, the bitmap defines the set of - speeds to be advertised. If the special value - ETH_LINK_SPEED_AUTONEG (0) is used, all speeds - supported are advertised. */ - struct rte_eth_rxmode rxmode; /**< Port RX configuration. */ - struct rte_eth_txmode txmode; /**< Port TX configuration. */ - uint32_t lpbk_mode; /**< Loopback operation mode. By default the value - is 0, meaning the loopback mode is disabled. - Read the datasheet of given ethernet controller - for details. The possible values of this field - are defined in implementation of each driver. */ - struct { - struct rte_eth_rss_conf rss_conf; /**< Port RSS configuration */ - struct rte_eth_vmdq_dcb_conf vmdq_dcb_conf; - /**< Port vmdq+dcb configuration. */ - struct rte_eth_dcb_rx_conf dcb_rx_conf; - /**< Port dcb RX configuration. */ - struct rte_eth_vmdq_rx_conf vmdq_rx_conf; - /**< Port vmdq RX configuration. */ - } rx_adv_conf; /**< Port RX filtering configuration (union). */ - union { - struct rte_eth_vmdq_dcb_tx_conf vmdq_dcb_tx_conf; - /**< Port vmdq+dcb TX configuration. */ - struct rte_eth_dcb_tx_conf dcb_tx_conf; - /**< Port dcb TX configuration. */ - struct rte_eth_vmdq_tx_conf vmdq_tx_conf; - /**< Port vmdq TX configuration. */ - } tx_adv_conf; /**< Port TX DCB configuration (union). */ - /** Currently,Priority Flow Control(PFC) are supported,if DCB with PFC - is needed,and the variable must be set ETH_DCB_PFC_SUPPORT. */ - uint32_t dcb_capability_en; - struct rte_fdir_conf fdir_conf; /**< FDIR configuration. */ - struct rte_intr_conf intr_conf; /**< Interrupt mode configuration. */ -}; diff --git a/bindgen-tests/tests/headers/layout_mbuf_1_0.h b/bindgen-tests/tests/headers/layout_mbuf_1_0.h deleted file mode 100644 index 2854de5038..0000000000 --- a/bindgen-tests/tests/headers/layout_mbuf_1_0.h +++ /dev/null @@ -1,189 +0,0 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq - - -#define RTE_CACHE_LINE_MIN_SIZE 64 /**< Minimum Cache line size. */ - -#define RTE_CACHE_LINE_SIZE 64 - -typedef char int8_t; -typedef short int16_t; -typedef int int32_t; -typedef long long int64_t; - -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned int uint32_t; -typedef unsigned long long uint64_t; - -typedef uint64_t phys_addr_t; - -/** - * Force alignment - */ -#define __rte_aligned(a) __attribute__((__aligned__(a))) - -/** - * Force alignment to cache line. - */ -#define __rte_cache_aligned __rte_aligned(RTE_CACHE_LINE_SIZE) - -/** - * Force minimum cache line alignment. - */ -#define __rte_cache_min_aligned __rte_aligned(RTE_CACHE_LINE_MIN_SIZE) - -/* define a set of marker types that can be used to refer to set points in the - * mbuf */ -__extension__ -typedef void *MARKER[0]; /**< generic marker for a point in a structure */ -__extension__ -typedef uint8_t MARKER8[0]; /**< generic marker with 1B alignment */ -__extension__ -typedef uint64_t MARKER64[0]; /**< marker that allows us to overwrite 8 bytes - * with a single assignment */ - -/** C extension macro for environments lacking C11 features. */ -#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L -#define RTE_STD_C11 __extension__ -#else -#define RTE_STD_C11 -#endif - -/** - * The atomic counter structure. - */ -typedef struct { - volatile int16_t cnt; /**< An internal counter value. */ -} rte_atomic16_t; - -/** - * The generic rte_mbuf, containing a packet mbuf. - */ -struct rte_mbuf { - MARKER cacheline0; - - void *buf_addr; /**< Virtual address of segment buffer. */ - phys_addr_t buf_physaddr; /**< Physical address of segment buffer. */ - - uint16_t buf_len; /**< Length of segment buffer. */ - - /* next 6 bytes are initialised on RX descriptor rearm */ - MARKER8 rearm_data; - uint16_t data_off; - - /** - * 16-bit Reference counter. - * It should only be accessed using the following functions: - * rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and - * rte_mbuf_refcnt_set(). The functionality of these functions (atomic, - * or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC - * config option. - */ - RTE_STD_C11 - union { - rte_atomic16_t refcnt_atomic; /**< Atomically accessed refcnt */ - uint16_t refcnt; /**< Non-atomically accessed refcnt */ - }; - uint8_t nb_segs; /**< Number of segments. */ - uint8_t port; /**< Input port. */ - - uint64_t ol_flags; /**< Offload features. */ - - /* remaining bytes are set on RX when pulling packet from descriptor */ - MARKER rx_descriptor_fields1; - - /* - * The packet type, which is the combination of outer/inner L2, L3, L4 - * and tunnel types. The packet_type is about data really present in the - * mbuf. Example: if vlan stripping is enabled, a received vlan packet - * would have RTE_PTYPE_L2_ETHER and not RTE_PTYPE_L2_VLAN because the - * vlan is stripped from the data. - */ - RTE_STD_C11 - union { - uint32_t packet_type; /**< L2/L3/L4 and tunnel information. */ - struct { - uint32_t l2_type:4; /**< (Outer) L2 type. */ - uint32_t l3_type:4; /**< (Outer) L3 type. */ - uint32_t l4_type:4; /**< (Outer) L4 type. */ - uint32_t tun_type:4; /**< Tunnel type. */ - uint32_t inner_l2_type:4; /**< Inner L2 type. */ - uint32_t inner_l3_type:4; /**< Inner L3 type. */ - uint32_t inner_l4_type:4; /**< Inner L4 type. */ - }; - }; - - uint32_t pkt_len; /**< Total pkt len: sum of all segments. */ - uint16_t data_len; /**< Amount of data in segment buffer. */ - /** VLAN TCI (CPU order), valid if PKT_RX_VLAN_STRIPPED is set. */ - uint16_t vlan_tci; - - union { - uint32_t rss; /**< RSS hash result if RSS enabled */ - struct { - RTE_STD_C11 - union { - struct { - uint16_t hash; - uint16_t id; - }; - uint32_t lo; - /**< Second 4 flexible bytes */ - }; - uint32_t hi; - /**< First 4 flexible bytes or FD ID, dependent on - PKT_RX_FDIR_* flag in ol_flags. */ - } fdir; /**< Filter identifier if FDIR enabled */ - struct { - uint32_t lo; - uint32_t hi; - } sched; /**< Hierarchical scheduler */ - uint32_t usr; /**< User defined tags. See rte_distributor_process() */ - } hash; /**< hash information */ - - uint32_t seqn; /**< Sequence number. See also rte_reorder_insert() */ - - /** Outer VLAN TCI (CPU order), valid if PKT_RX_QINQ_STRIPPED is set. */ - uint16_t vlan_tci_outer; - - /* second cache line - fields only used in slow path or on TX */ - MARKER cacheline1 __rte_cache_min_aligned; - - RTE_STD_C11 - union { - void *userdata; /**< Can be used for external metadata */ - uint64_t udata64; /**< Allow 8-byte userdata on 32-bit */ - }; - - struct rte_mempool *pool; /**< Pool from which mbuf was allocated. */ - struct rte_mbuf *next; /**< Next segment of scattered packet. */ - - /* fields to support TX offloads */ - RTE_STD_C11 - union { - uint64_t tx_offload; /**< combined for easy fetch */ - __extension__ - struct { - uint64_t l2_len:7; - /**< L2 (MAC) Header Length for non-tunneling pkt. - * Outer_L4_len + ... + Inner_L2_len for tunneling pkt. - */ - uint64_t l3_len:9; /**< L3 (IP) Header Length. */ - uint64_t l4_len:8; /**< L4 (TCP/UDP) Header Length. */ - uint64_t tso_segsz:16; /**< TCP TSO segment size */ - - /* fields for TX offloading of tunnels */ - uint64_t outer_l3_len:9; /**< Outer L3 (IP) Hdr Length. */ - uint64_t outer_l2_len:7; /**< Outer L2 (MAC) Hdr Length. */ - - /* uint64_t unused:8; */ - }; - }; - - /** Size of the application private data. In case of an indirect - * mbuf, it stores the direct mbuf private data size. */ - uint16_t priv_size; - - /** Timesync flags for use with IEEE1588. */ - uint16_t timesync; -} __rte_cache_aligned; diff --git a/bindgen-tests/tests/headers/long_double.h b/bindgen-tests/tests/headers/long_double.h index 91c4ed6ce9..c8872d6ebf 100644 --- a/bindgen-tests/tests/headers/long_double.h +++ b/bindgen-tests/tests/headers/long_double.h @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.26 +// bindgen-flags: \-\-rust-target=1.33 struct foo { long double bar; diff --git a/bindgen-tests/tests/headers/macro_const_1_0.h b/bindgen-tests/tests/headers/macro_const_1_0.h deleted file mode 100644 index 3be86b4fd2..0000000000 --- a/bindgen-tests/tests/headers/macro_const_1_0.h +++ /dev/null @@ -1,10 +0,0 @@ -// bindgen-flags: --rust-target 1.0 - -#define foo "bar" -#define CHAR 'b' -#define CHARR '\0' -#define FLOAT 5.09f -#define FLOAT_EXPR (5 / 1000.0f) -#define LONG 3L - -#define INVALID_UTF8 "\xf0\x28\x8c\x28" diff --git a/bindgen-tests/tests/headers/newtype-enum.hpp b/bindgen-tests/tests/headers/newtype-enum.hpp index 890683ae85..45f3303c8c 100644 --- a/bindgen-tests/tests/headers/newtype-enum.hpp +++ b/bindgen-tests/tests/headers/newtype-enum.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --newtype-enum "Foo" --rust-target 1.28 -- -std=c++11 +// bindgen-flags: --newtype-enum "Foo" \-\-rust-target=1.33 -- -std=c++11 enum Foo { Bar = 1 << 1, diff --git a/bindgen-tests/tests/headers/newtype-global-enum.hpp b/bindgen-tests/tests/headers/newtype-global-enum.hpp index 8021a3cc72..e52b19b84a 100644 --- a/bindgen-tests/tests/headers/newtype-global-enum.hpp +++ b/bindgen-tests/tests/headers/newtype-global-enum.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --newtype-global-enum "Foo" --rust-target 1.28 -- -std=c++11 +// bindgen-flags: --newtype-global-enum "Foo" \-\-rust-target=1.33 -- -std=c++11 enum Foo { Bar = 1 << 1, diff --git a/bindgen-tests/tests/headers/repr-align.hpp b/bindgen-tests/tests/headers/repr-align.hpp index 3347594b5c..b3231d39bc 100644 --- a/bindgen-tests/tests/headers/repr-align.hpp +++ b/bindgen-tests/tests/headers/repr-align.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --raw-line '#![cfg(feature = "nightly")]' --rust-target 1.25 -- -std=c++11 +// bindgen-flags: --raw-line '#![cfg(feature = "nightly")]' \-\-rust-target=1.33 -- -std=c++11 struct alignas(8) a { int b; diff --git a/bindgen-tests/tests/headers/strings_array.h b/bindgen-tests/tests/headers/strings_array.h index 6a61d71049..212b0903a7 100644 --- a/bindgen-tests/tests/headers/strings_array.h +++ b/bindgen-tests/tests/headers/strings_array.h @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target=1.0 +// bindgen-flags: \-\-rust-target=1.33 const char* MY_STRING_UTF8 = "Hello, world!"; const char* MY_STRING_INTERIOR_NULL = "Hello,\0World!"; diff --git a/bindgen-tests/tests/headers/struct_with_anon_union_1_0.h b/bindgen-tests/tests/headers/struct_with_anon_union_1_0.h deleted file mode 100644 index 847c354b59..0000000000 --- a/bindgen-tests/tests/headers/struct_with_anon_union_1_0.h +++ /dev/null @@ -1,8 +0,0 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq - -struct foo { - union { - unsigned int a; - unsigned short b; - } bar; -}; diff --git a/bindgen-tests/tests/headers/struct_with_anon_unnamed_union_1_0.h b/bindgen-tests/tests/headers/struct_with_anon_unnamed_union_1_0.h deleted file mode 100644 index 791a1593af..0000000000 --- a/bindgen-tests/tests/headers/struct_with_anon_unnamed_union_1_0.h +++ /dev/null @@ -1,8 +0,0 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq - -struct foo { - union { - unsigned int a; - unsigned short b; - }; -}; diff --git a/bindgen-tests/tests/headers/struct_with_nesting_1_0.h b/bindgen-tests/tests/headers/struct_with_nesting_1_0.h deleted file mode 100644 index a24ae1db58..0000000000 --- a/bindgen-tests/tests/headers/struct_with_nesting_1_0.h +++ /dev/null @@ -1,19 +0,0 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq - -struct foo { - unsigned int a; - union { - unsigned int b; - struct { - unsigned short c1; - unsigned short c2; - }; - - struct { - unsigned char d1; - unsigned char d2; - unsigned char d3; - unsigned char d4; - }; - }; -}; diff --git a/bindgen-tests/tests/headers/transform-op.hpp b/bindgen-tests/tests/headers/transform-op.hpp index aa6118eb67..907a5a4657 100644 --- a/bindgen-tests/tests/headers/transform-op.hpp +++ b/bindgen-tests/tests/headers/transform-op.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.0 -- -std=c++11 +// bindgen-flags: \-\-rust-target=1.33 -- -std=c++11 typedef unsigned char uint8_t; typedef int int32_t; diff --git a/bindgen-tests/tests/headers/typeref_1_0.hpp b/bindgen-tests/tests/headers/typeref_1_0.hpp deleted file mode 100644 index 70dfc11fb1..0000000000 --- a/bindgen-tests/tests/headers/typeref_1_0.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq - -struct nsFoo; - -namespace mozilla { - -struct FragmentOrURL { bool mIsLocalRef; }; -struct Position { }; - -} // namespace mozilla - -class Bar { - nsFoo* mFoo; -}; - -namespace mozilla { - -template -struct StyleShapeSource { - union { - Position* mPosition; - FragmentOrURL* mFragmentOrURL; - }; -}; - -} // namespace mozilla - -struct nsFoo { - mozilla::StyleShapeSource mBar; -}; diff --git a/bindgen-tests/tests/headers/union-align.h b/bindgen-tests/tests/headers/union-align.h index 9557b2798a..bfb5b5a199 100644 --- a/bindgen-tests/tests/headers/union-align.h +++ b/bindgen-tests/tests/headers/union-align.h @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.26 +// bindgen-flags: \-\-rust-target=1.33 union Bar { unsigned char foo; diff --git a/bindgen-tests/tests/headers/union-in-ns_1_0.hpp b/bindgen-tests/tests/headers/union-in-ns_1_0.hpp deleted file mode 100644 index f3ae221057..0000000000 --- a/bindgen-tests/tests/headers/union-in-ns_1_0.hpp +++ /dev/null @@ -1,5 +0,0 @@ -// bindgen-flags: --rust-target 1.0 --enable-cxx-namespaces - -union bar { - int baz; -}; diff --git a/bindgen-tests/tests/headers/union_bitfield_1_0.h b/bindgen-tests/tests/headers/union_bitfield_1_0.h deleted file mode 100644 index 06b61ad771..0000000000 --- a/bindgen-tests/tests/headers/union_bitfield_1_0.h +++ /dev/null @@ -1,14 +0,0 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq --impl-partialeq - -union U4 { - unsigned derp : 1; -}; - -union B { - unsigned foo : 31; - unsigned char bar : 1; -}; - -union HasBigBitfield { - __int128 x : 128; -}; diff --git a/bindgen-tests/tests/headers/union_dtor_1_0.hpp b/bindgen-tests/tests/headers/union_dtor_1_0.hpp deleted file mode 100644 index 01f7636671..0000000000 --- a/bindgen-tests/tests/headers/union_dtor_1_0.hpp +++ /dev/null @@ -1,7 +0,0 @@ -// bindgen-flags: --rust-target 1.0 - -union UnionWithDtor { - ~UnionWithDtor(); - int mFoo; - void* mBar; -}; diff --git a/bindgen-tests/tests/headers/union_fields_1_0.hpp b/bindgen-tests/tests/headers/union_fields_1_0.hpp deleted file mode 100644 index bbb67fbc6e..0000000000 --- a/bindgen-tests/tests/headers/union_fields_1_0.hpp +++ /dev/null @@ -1,7 +0,0 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq - -typedef union { - int mInt; - float mFloat; - void* mPointer; -} nsStyleUnion; diff --git a/bindgen-tests/tests/headers/union_template_1_0.hpp b/bindgen-tests/tests/headers/union_template_1_0.hpp deleted file mode 100644 index 18e3d74a37..0000000000 --- a/bindgen-tests/tests/headers/union_template_1_0.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq - -template -struct NastyStruct { - bool mIsSome; - union { - void* mFoo; - unsigned long mDummy; - } mStorage; - - union { - short wat; - int* wut; - }; -}; - -template -union Whatever { - void* mTPtr; - int mInt; -}; diff --git a/bindgen-tests/tests/headers/union_with_anon_struct_1_0.h b/bindgen-tests/tests/headers/union_with_anon_struct_1_0.h deleted file mode 100644 index 9313299eb0..0000000000 --- a/bindgen-tests/tests/headers/union_with_anon_struct_1_0.h +++ /dev/null @@ -1,8 +0,0 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq - -union foo { - struct { - unsigned int a; - unsigned int b; - } bar; -}; diff --git a/bindgen-tests/tests/headers/union_with_anon_struct_bitfield_1_0.h b/bindgen-tests/tests/headers/union_with_anon_struct_bitfield_1_0.h deleted file mode 100644 index 0b0e3d7371..0000000000 --- a/bindgen-tests/tests/headers/union_with_anon_struct_bitfield_1_0.h +++ /dev/null @@ -1,9 +0,0 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq - -union foo { - int a; - struct { - int b : 7; - int c : 25; - }; -}; diff --git a/bindgen-tests/tests/headers/union_with_anon_union_1_0.h b/bindgen-tests/tests/headers/union_with_anon_union_1_0.h deleted file mode 100644 index 28a7231dbf..0000000000 --- a/bindgen-tests/tests/headers/union_with_anon_union_1_0.h +++ /dev/null @@ -1,8 +0,0 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq - -union foo { - union { - unsigned int a; - unsigned short b; - } bar; -}; diff --git a/bindgen-tests/tests/headers/union_with_anon_unnamed_struct_1_0.h b/bindgen-tests/tests/headers/union_with_anon_unnamed_struct_1_0.h deleted file mode 100644 index 506a41f661..0000000000 --- a/bindgen-tests/tests/headers/union_with_anon_unnamed_struct_1_0.h +++ /dev/null @@ -1,11 +0,0 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq - -union pixel { - unsigned int rgba; - struct { - unsigned char r; - unsigned char g; - unsigned char b; - unsigned char a; - }; -}; diff --git a/bindgen-tests/tests/headers/union_with_anon_unnamed_union_1_0.h b/bindgen-tests/tests/headers/union_with_anon_unnamed_union_1_0.h deleted file mode 100644 index c556a61311..0000000000 --- a/bindgen-tests/tests/headers/union_with_anon_unnamed_union_1_0.h +++ /dev/null @@ -1,9 +0,0 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq - -union foo { - unsigned int a; - union { - unsigned short b; - unsigned char c; - }; -}; diff --git a/bindgen-tests/tests/headers/union_with_big_member_1_0.h b/bindgen-tests/tests/headers/union_with_big_member_1_0.h deleted file mode 100644 index 0429435478..0000000000 --- a/bindgen-tests/tests/headers/union_with_big_member_1_0.h +++ /dev/null @@ -1,16 +0,0 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq - -union WithBigArray { - int a; - int b[33]; -}; - -union WithBigArray2 { - int a; - char b[33]; -}; - -union WithBigMember { - int a; - union WithBigArray b; -}; diff --git a/bindgen-tests/tests/headers/union_with_nesting_1_0.h b/bindgen-tests/tests/headers/union_with_nesting_1_0.h deleted file mode 100644 index 3cdb7238bc..0000000000 --- a/bindgen-tests/tests/headers/union_with_nesting_1_0.h +++ /dev/null @@ -1,16 +0,0 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq - -union foo { - unsigned int a; - struct { - union { - unsigned short b1; - unsigned short b2; - }; - - union { - unsigned short c1; - unsigned short c2; - }; - }; -}; diff --git a/bindgen-tests/tests/headers/use-core_1_0.h b/bindgen-tests/tests/headers/use-core_1_0.h deleted file mode 100644 index 40de9d158d..0000000000 --- a/bindgen-tests/tests/headers/use-core_1_0.h +++ /dev/null @@ -1,13 +0,0 @@ -// bindgen-flags: --rust-target 1.0 --use-core --raw-line "extern crate core;" --with-derive-hash --with-derive-partialeq --with-derive-eq - -struct foo { - int a, b; - void* bar; -}; - -union { - int bar; - long baz; -} bazz; - -typedef void (*fooFunction)(int bar); diff --git a/bindgen-tests/tests/headers/win32-dtors.hpp b/bindgen-tests/tests/headers/win32-dtors.hpp index dc9b0fdc6e..7faa5e9562 100644 --- a/bindgen-tests/tests/headers/win32-dtors.hpp +++ b/bindgen-tests/tests/headers/win32-dtors.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.0 -- --target=x86_64-pc-windows-msvc +// bindgen-flags: \-\-rust-target=1.33 -- --target=x86_64-pc-windows-msvc struct CppObj { int x; diff --git a/bindgen-tests/tests/headers/win32-thiscall.hpp b/bindgen-tests/tests/headers/win32-thiscall.hpp new file mode 100644 index 0000000000..d4e3976303 --- /dev/null +++ b/bindgen-tests/tests/headers/win32-thiscall.hpp @@ -0,0 +1,7 @@ +// bindgen-flags: \-\-rust-target=1.33 -- --target=i686-pc-windows-msvc + +class Foo { + public: + void test(); + int test2(int var); +}; diff --git a/bindgen-tests/tests/headers/win32-thiscall_1_0.hpp b/bindgen-tests/tests/headers/win32-thiscall_1_0.hpp deleted file mode 100644 index 5907c76eaf..0000000000 --- a/bindgen-tests/tests/headers/win32-thiscall_1_0.hpp +++ /dev/null @@ -1,7 +0,0 @@ -// bindgen-flags: --rust-target 1.0 -- --target=i686-pc-windows-msvc - -class Foo { - public: - void test(); - int test2(int var); -}; diff --git a/bindgen-tests/tests/headers/win32-vectorcall-1_0.h b/bindgen-tests/tests/headers/win32-vectorcall-1_0.h deleted file mode 100644 index a1f852b52f..0000000000 --- a/bindgen-tests/tests/headers/win32-vectorcall-1_0.h +++ /dev/null @@ -1,3 +0,0 @@ -// bindgen-flags: --rust-target 1.0 -- --target=x86_64-pc-windows-msvc - -int __vectorcall test_vectorcall(int a, int b); diff --git a/bindgen-tests/tests/headers/win32-vectorcall.h b/bindgen-tests/tests/headers/win32-vectorcall.h new file mode 100644 index 0000000000..245d97b340 --- /dev/null +++ b/bindgen-tests/tests/headers/win32-vectorcall.h @@ -0,0 +1,3 @@ +// bindgen-flags: \-\-rust-target=1.33 -- --target=x86_64-pc-windows-msvc + +int __vectorcall test_vectorcall(int a, int b); diff --git a/bindgen-tests/tests/headers/wrap_unsafe_ops_anon_union_1_0.hpp b/bindgen-tests/tests/headers/wrap_unsafe_ops_anon_union.hpp similarity index 82% rename from bindgen-tests/tests/headers/wrap_unsafe_ops_anon_union_1_0.hpp rename to bindgen-tests/tests/headers/wrap_unsafe_ops_anon_union.hpp index 3b595f2ea7..e44b43285a 100644 --- a/bindgen-tests/tests/headers/wrap_unsafe_ops_anon_union_1_0.hpp +++ b/bindgen-tests/tests/headers/wrap_unsafe_ops_anon_union.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.0 --wrap-unsafe-ops --no-layout-tests +// bindgen-flags: \-\-rust-target=1.33 --wrap-unsafe-ops --no-layout-tests template struct TErrorResult { diff --git a/bindgen/codegen/helpers.rs b/bindgen/codegen/helpers.rs index 4038340100..4bd08011f9 100644 --- a/bindgen/codegen/helpers.rs +++ b/bindgen/codegen/helpers.rs @@ -79,14 +79,14 @@ pub(crate) mod attributes { /// Generates a proper type for a field or type with a given `Layout`, that is, /// a type with the correct size and alignment restrictions. -pub(crate) fn blob(ctx: &BindgenContext, layout: Layout) -> syn::Type { +pub(crate) fn blob(layout: Layout) -> syn::Type { let opaque = layout.opaque(); // FIXME(emilio, #412): We fall back to byte alignment, but there are // some things that legitimately are more than 8-byte aligned. // // Eventually we should be able to `unwrap` here, but... - let ty = match opaque.known_rust_type_for_array(ctx) { + let ty = match opaque.known_rust_type_for_array() { Some(ty) => ty, None => { warn!("Found unknown alignment on code generation!"); @@ -94,7 +94,7 @@ pub(crate) fn blob(ctx: &BindgenContext, layout: Layout) -> syn::Type { } }; - let data_len = opaque.array_size(ctx).unwrap_or(layout.size); + let data_len = opaque.array_size().unwrap_or(layout.size); if data_len == 1 { ty @@ -104,11 +104,8 @@ pub(crate) fn blob(ctx: &BindgenContext, layout: Layout) -> syn::Type { } /// Integer type of the same size as the given `Layout`. -pub(crate) fn integer_type( - ctx: &BindgenContext, - layout: Layout, -) -> Option { - Layout::known_type_for_size(ctx, layout.size) +pub(crate) fn integer_type(layout: Layout) -> Option { + Layout::known_type_for_size(layout.size) } pub(crate) const BITFIELD_UNIT: &str = "__BindgenBitfieldUnit"; @@ -143,9 +140,7 @@ pub(crate) mod ast_ty { syn::parse_quote! { #prefix::c_void } } None => { - if ctx.options().use_core && - ctx.options().rust_features.core_ffi_c_void - { + if ctx.options().use_core { syn::parse_quote! { ::core::ffi::c_void } } else { syn::parse_quote! { ::std::os::raw::c_void } @@ -194,7 +189,7 @@ pub(crate) mod ast_ty { IntKind::WChar => { let layout = layout.expect("Couldn't compute wchar_t's layout?"); - Layout::known_type_for_size(ctx, layout.size) + Layout::known_type_for_size(layout.size) .expect("Non-representable wchar_t?") } @@ -210,7 +205,7 @@ pub(crate) mod ast_ty { syn::parse_str(name).expect("Invalid integer type.") } IntKind::U128 => { - if ctx.options().rust_features.i128_and_u128 { + if true { syn::parse_quote! { u128 } } else { // Best effort thing, but wrong alignment @@ -219,7 +214,7 @@ pub(crate) mod ast_ty { } } IntKind::I128 => { - if ctx.options().rust_features.i128_and_u128 { + if true { syn::parse_quote! { i128 } } else { syn::parse_quote! { [u64; 2] } @@ -259,7 +254,7 @@ pub(crate) mod ast_ty { 8 => syn::parse_quote! { f64 }, // TODO(emilio): If rust ever gains f128 we should // use it here and below. - _ => super::integer_type(ctx, layout) + _ => super::integer_type(layout) .unwrap_or(syn::parse_quote! { f64 }), } } @@ -273,7 +268,7 @@ pub(crate) mod ast_ty { } } (FloatKind::Float128, _) => { - if ctx.options().rust_features.i128_and_u128 { + if true { syn::parse_quote! { u128 } } else { syn::parse_quote! { [u64; 2] } @@ -316,6 +311,8 @@ pub(crate) mod ast_ty { let rust_target = ctx.options().rust_target; if f.is_nan() { + // FIXME: This should be done behind a `RustFeature` instead + #[allow(deprecated)] let tokens = if rust_target >= RustTarget::Stable_1_43 { quote! { f64::NAN @@ -330,6 +327,8 @@ pub(crate) mod ast_ty { if f.is_infinite() { let tokens = if f.is_sign_positive() { + // FIXME: This should be done behind a `RustFeature` instead + #[allow(deprecated)] if rust_target >= RustTarget::Stable_1_43 { quote! { f64::INFINITY @@ -340,6 +339,8 @@ pub(crate) mod ast_ty { } } } else { + // FIXME: This should be done behind a `RustFeature` instead + #[allow(deprecated)] // Negative infinity if rust_target >= RustTarget::Stable_1_43 { quote! { diff --git a/bindgen/codegen/mod.rs b/bindgen/codegen/mod.rs index ccc5758a14..943d8c7513 100644 --- a/bindgen/codegen/mod.rs +++ b/bindgen/codegen/mod.rs @@ -151,22 +151,16 @@ fn derives_of_item( ) -> DerivableTraits { let mut derivable_traits = DerivableTraits::empty(); - let all_template_params = item.all_template_params(ctx); - if item.can_derive_copy(ctx) && !item.annotations().disallow_copy() { derivable_traits |= DerivableTraits::COPY; - if ctx.options().rust_features().builtin_clone_impls || - !all_template_params.is_empty() - { - // FIXME: This requires extra logic if you have a big array in a - // templated struct. The reason for this is that the magic: - // fn clone(&self) -> Self { *self } - // doesn't work for templates. - // - // It's not hard to fix though. - derivable_traits |= DerivableTraits::CLONE; - } + // FIXME: This requires extra logic if you have a big array in a + // templated struct. The reason for this is that the magic: + // fn clone(&self) -> Self { *self } + // doesn't work for templates. + // + // It's not hard to fix though. + derivable_traits |= DerivableTraits::CLONE; } else if packed { // If the struct or union is packed, deriving from Copy is required for // deriving from any other trait. @@ -743,13 +737,9 @@ impl CodeGenerator for Var { }; }); } else { - let lifetime = if rust_features.static_lifetime_elision - { - None - } else { - Some(quote! { 'static }) - } - .into_iter(); + let lifetime = + if true { None } else { Some(quote! { 'static }) } + .into_iter(); result.push(quote! { #(#attrs)* @@ -1024,12 +1014,6 @@ impl CodeGenerator for Type { pub type #rust_name }, AliasVariation::NewType | AliasVariation::NewTypeDeref => { - assert!( - ctx.options().rust_features().repr_transparent, - "repr_transparent feature is required to use {:?}", - alias_style - ); - let mut attributes = vec![attributes::repr("transparent")]; let packed = false; // Types can't be packed in Rust. @@ -1644,11 +1628,10 @@ impl Bitfield { let bitfield_ty_layout = bitfield_ty .layout(ctx) .expect("Bitfield without layout? Gah!"); - let bitfield_int_ty = helpers::integer_type(ctx, bitfield_ty_layout) - .expect( - "Should already have verified that the bitfield is \ + let bitfield_int_ty = helpers::integer_type(bitfield_ty_layout).expect( + "Should already have verified that the bitfield is \ representable as an int", - ); + ); let offset = self.offset_into_unit(); let width = self.width() as u8; @@ -1950,17 +1933,16 @@ impl<'a> FieldCodegen<'a> for Bitfield { let bitfield_ty_layout = bitfield_ty .layout(ctx) .expect("Bitfield without layout? Gah!"); - let bitfield_int_ty = - match helpers::integer_type(ctx, bitfield_ty_layout) { - Some(int_ty) => { - *bitfield_representable_as_int = true; - int_ty - } - None => { - *bitfield_representable_as_int = false; - return; - } - }; + let bitfield_int_ty = match helpers::integer_type(bitfield_ty_layout) { + Some(int_ty) => { + *bitfield_representable_as_int = true; + int_ty + } + None => { + *bitfield_representable_as_int = false; + return; + } + }; let bitfield_ty = bitfield_ty.to_rust_ty_or_opaque(ctx, bitfield_ty_item); @@ -2275,7 +2257,7 @@ impl CodeGenerator for CompInfo { if has_address { let layout = Layout::new(1, 1); - let ty = helpers::blob(ctx, Layout::new(1, 1)); + let ty = helpers::blob(Layout::new(1, 1)); struct_layout.saw_field_with_layout( "_address", layout, @@ -2292,7 +2274,7 @@ impl CodeGenerator for CompInfo { Some(l) => { explicit_align = Some(l.align); - let ty = helpers::blob(ctx, l); + let ty = helpers::blob(l); fields.push(quote! { pub _bindgen_opaque_blob: #ty , }); @@ -2314,15 +2296,6 @@ impl CodeGenerator for CompInfo { packed = true; } else { explicit_align = Some(layout.align); - if !ctx.options().rust_features.repr_align { - let ty = helpers::blob( - ctx, - Layout::new(0, layout.align), - ); - fields.push(quote! { - pub __bindgen_align: #ty , - }); - } } } } @@ -2335,7 +2308,7 @@ impl CodeGenerator for CompInfo { } if !struct_layout.is_rust_union() { - let ty = helpers::blob(ctx, layout); + let ty = helpers::blob(layout); fields.push(quote! { pub bindgen_union_field: #ty , }) @@ -2425,7 +2398,7 @@ impl CodeGenerator for CompInfo { attributes.push(attributes::repr("C")); } - if ctx.options().rust_features().repr_align { + if true { if let Some(explicit) = explicit_align { // Ensure that the struct has the correct alignment even in // presence of alignas. @@ -2582,19 +2555,14 @@ impl CodeGenerator for CompInfo { let align_of_err = format!("Alignment of {canonical_ident}"); - let check_struct_align = if align > - ctx.target_pointer_size() && - !ctx.options().rust_features().repr_align - { - None - } else if compile_time { - Some(quote! { + let check_struct_align = if compile_time { + quote! { [#align_of_err][#align_of_expr - #align]; - }) + } } else { - Some(quote! { + quote! { assert_eq!(#align_of_expr, #align, #align_of_err); - }) + } }; let should_skip_field_offset_checks = is_opaque; @@ -3126,9 +3094,7 @@ impl Method { let mut attrs = vec![attributes::inline()]; - if signature.must_use() && - ctx.options().rust_features().must_use_function - { + if signature.must_use() { attrs.push(attributes::must_use()); } @@ -3396,10 +3362,7 @@ impl<'a> EnumBuilder<'a> { is_global, .. } => { - if ctx.options().rust_features().associated_const && - is_ty_named && - !is_global - { + if is_ty_named && !is_global { let enum_ident = ctx.rust_ident(canonical_name); let variant_ident = ctx.rust_ident(variant_name); @@ -3654,7 +3617,7 @@ impl CodeGenerator for Enum { } } EnumVariation::NewType { .. } => { - if ctx.options().rust_features.repr_transparent { + if true { attrs.push(attributes::repr("transparent")); } else { attrs.push(attributes::repr("C")); @@ -3816,9 +3779,7 @@ impl CodeGenerator for Enum { let existing_variant_name = entry.get(); // Use associated constants for named enums. - if enum_ty.name().is_some() && - ctx.options().rust_features().associated_const - { + if enum_ty.name().is_some() { let enum_canonical_name = &ident; let variant_name = ctx.rust_ident_raw(&*mangled_name); @@ -4052,8 +4013,7 @@ pub(crate) trait TryToOpaque { ctx: &BindgenContext, extra: &Self::Extra, ) -> error::Result { - self.try_get_layout(ctx, extra) - .map(|layout| helpers::blob(ctx, layout)) + self.try_get_layout(ctx, extra).map(helpers::blob) } } @@ -4079,7 +4039,7 @@ pub(crate) trait ToOpaque: TryToOpaque { extra: &Self::Extra, ) -> syn::Type { let layout = self.get_layout(ctx, extra); - helpers::blob(ctx, layout) + helpers::blob(layout) } } @@ -4130,7 +4090,7 @@ where ) -> error::Result { self.try_to_rust_ty(ctx, extra).or_else(|_| { if let Ok(layout) = self.try_get_layout(ctx, extra) { - Ok(helpers::blob(ctx, layout)) + Ok(helpers::blob(layout)) } else { Err(error::Error::NoLayoutForOpaqueBlob) } @@ -4583,7 +4543,7 @@ impl CodeGenerator for Function { let mut attributes = vec![]; - if ctx.options().rust_features().must_use_function { + if true { let must_use = signature.must_use() || { let ret_ty = signature .return_type() @@ -5316,7 +5276,7 @@ pub(crate) mod utils { } else { include_str!("./bitfield_unit.rs") }; - let bitfield_unit_src = if ctx.options().rust_features().min_const_fn { + let bitfield_unit_src = if true { Cow::Borrowed(bitfield_unit_src) } else { Cow::Owned(bitfield_unit_src.replace("const fn ", "fn ")) @@ -5382,7 +5342,7 @@ pub(crate) mod utils { // If the target supports `const fn`, declare eligible functions // as `const fn` else just `fn`. - let const_fn = if ctx.options().rust_features().min_const_fn { + let const_fn = if true { quote! { const fn } } else { quote! { fn } @@ -5494,7 +5454,7 @@ pub(crate) mod utils { // If the target supports `const fn`, declare eligible functions // as `const fn` else just `fn`. - let const_fn = if ctx.options().rust_features().min_const_fn { + let const_fn = if true { quote! { const fn } } else { quote! { fn } diff --git a/bindgen/codegen/struct_layout.rs b/bindgen/codegen/struct_layout.rs index 507c8d40e2..b78c65e55b 100644 --- a/bindgen/codegen/struct_layout.rs +++ b/bindgen/codegen/struct_layout.rs @@ -344,7 +344,7 @@ impl<'a> StructLayoutTracker<'a> { return None; } - let repr_align = self.ctx.options().rust_features().repr_align; + let repr_align = true; // We always pad to get to the correct size if the struct is one of // those we can't align properly. @@ -377,7 +377,7 @@ impl<'a> StructLayoutTracker<'a> { } pub(crate) fn requires_explicit_align(&self, layout: Layout) -> bool { - let repr_align = self.ctx.options().rust_features().repr_align; + let repr_align = true; // Always force explicit repr(align) for stuff more than 16-byte aligned // to work-around https://github.com/rust-lang/rust/issues/54341. @@ -401,7 +401,7 @@ impl<'a> StructLayoutTracker<'a> { } fn padding_field(&mut self, layout: Layout) -> proc_macro2::TokenStream { - let ty = helpers::blob(self.ctx, layout); + let ty = helpers::blob(layout); let padding_count = self.padding_count; self.padding_count += 1; diff --git a/bindgen/features.rs b/bindgen/features.rs index 799b15a55f..915e8ebef0 100644 --- a/bindgen/features.rs +++ b/bindgen/features.rs @@ -82,7 +82,6 @@ macro_rules! define_rust_targets { ( Nightly => {$($nightly_feature:ident $(: #$issue:literal)?),* $(,)?} $(,)? $( - $(#[$attrs:meta])* $variant:ident($minor:literal) => {$($feature:ident $(: #$pull:literal)?),* $(,)?}, )* $(,)? @@ -94,6 +93,7 @@ macro_rules! define_rust_targets { "- [`", stringify!($nightly_feature), "`]", "(", $("https://github.com/rust-lang/rust/pull/", stringify!($issue),)* ")", )])* + #[deprecated = "The use of this constant is deprecated, please use `RustTarget::nightly` instead."] pub const Nightly: Self = Self::nightly(); /// The nightly version of Rust, which introduces the following features:" @@ -111,7 +111,7 @@ macro_rules! define_rust_targets { "- [`", stringify!($feature), "`]", "(", $("https://github.com/rust-lang/rust/pull/", stringify!($pull),)* ")", )])* - $(#[$attrs])* + #[deprecated = "The use of this constant is deprecated, please use `RustTarget::stable` instead."] pub const $variant: Self = Self(Version::Stable($minor, 0)); )* @@ -175,29 +175,6 @@ define_rust_targets! { Stable_1_40(40) => { non_exhaustive: #44109 }, Stable_1_36(36) => { maybe_uninit: #60445 }, Stable_1_33(33) => { repr_packed_n: #57049 }, - #[deprecated] - Stable_1_30(30) => { - core_ffi_c_void: #53910, - min_const_fn: #54835, - }, - #[deprecated] - Stable_1_28(28) => { repr_transparent: #51562 }, - #[deprecated] - Stable_1_27(27) => { must_use_function: #48925 }, - #[deprecated] - Stable_1_26(26) => { i128_and_u128: #49101 }, - #[deprecated] - Stable_1_25(25) => { repr_align: #47006 }, - #[deprecated] - Stable_1_21(21) => { builtin_clone_impls: #43690 }, - #[deprecated] - Stable_1_20(20) => { associated_const: #42809 }, - #[deprecated] - Stable_1_19(19) => { untagged_union: #42068 }, - #[deprecated] - Stable_1_17(17) => { static_lifetime_elision: #39265 }, - #[deprecated] - Stable_1_0(0) => {}, } /// Latest stable release of Rust that is supported by bindgen @@ -330,28 +307,6 @@ mod test { #[test] fn target_features() { - let f_1_0 = RustFeatures::from(RustTarget::Stable_1_0); - assert!( - !f_1_0.static_lifetime_elision && - !f_1_0.core_ffi_c_void && - !f_1_0.untagged_union && - !f_1_0.associated_const && - !f_1_0.builtin_clone_impls && - !f_1_0.repr_align && - !f_1_0.thiscall_abi && - !f_1_0.vectorcall_abi - ); - let f_1_21 = RustFeatures::from(RustTarget::Stable_1_21); - assert!( - f_1_21.static_lifetime_elision && - !f_1_21.core_ffi_c_void && - f_1_21.untagged_union && - f_1_21.associated_const && - f_1_21.builtin_clone_impls && - !f_1_21.repr_align && - !f_1_21.thiscall_abi && - !f_1_21.vectorcall_abi - ); let features = RustFeatures::from(RustTarget::Stable_1_71); assert!( features.c_unwind_abi && @@ -360,13 +315,7 @@ mod test { ); let f_nightly = RustFeatures::from(RustTarget::Nightly); assert!( - f_nightly.static_lifetime_elision && - f_nightly.core_ffi_c_void && - f_nightly.untagged_union && - f_nightly.associated_const && - f_nightly.builtin_clone_impls && - f_nightly.maybe_uninit && - f_nightly.repr_align && + f_nightly.maybe_uninit && f_nightly.thiscall_abi && f_nightly.vectorcall_abi ); @@ -412,5 +361,7 @@ mod test { test_invalid_target("1.-1.0"); test_invalid_target("1.0.-1"); test_invalid_target("beta"); + test_invalid_target("1.0.0"); + test_invalid_target("1.32.0"); } } diff --git a/bindgen/ir/analysis/derive.rs b/bindgen/ir/analysis/derive.rs index d8d29ed9a8..f3c64307c4 100644 --- a/bindgen/ir/analysis/derive.rs +++ b/bindgen/ir/analysis/derive.rs @@ -183,7 +183,7 @@ impl<'ctx> CannotDerive<'ctx> { let layout_can_derive = ty.layout(self.ctx).map_or(CanDerive::Yes, |l| { - l.opaque().array_size_within_derive_limit(self.ctx) + l.opaque().array_size_within_derive_limit() }); match layout_can_derive { @@ -344,8 +344,7 @@ impl<'ctx> CannotDerive<'ctx> { let layout_can_derive = ty.layout(self.ctx).map_or(CanDerive::Yes, |l| { - l.opaque() - .array_size_within_derive_limit(self.ctx) + l.opaque().array_size_within_derive_limit() }); match layout_can_derive { CanDerive::Yes => { diff --git a/bindgen/ir/layout.rs b/bindgen/ir/layout.rs index 85a553da31..9aee857948 100644 --- a/bindgen/ir/layout.rs +++ b/bindgen/ir/layout.rs @@ -34,14 +34,9 @@ fn test_layout_for_size() { impl Layout { /// Gets the integer type name for a given known size. - pub(crate) fn known_type_for_size( - ctx: &BindgenContext, - size: usize, - ) -> Option { + pub(crate) fn known_type_for_size(size: usize) -> Option { Some(match size { - 16 if ctx.options().rust_features.i128_and_u128 => { - syn::parse_quote! { u128 } - } + 16 => syn::parse_quote! { u128 }, 8 => syn::parse_quote! { u64 }, 4 => syn::parse_quote! { u32 }, 2 => syn::parse_quote! { u16 }, @@ -102,17 +97,14 @@ impl Opaque { /// Return the known rust type we should use to create a correctly-aligned /// field with this layout. - pub(crate) fn known_rust_type_for_array( - &self, - ctx: &BindgenContext, - ) -> Option { - Layout::known_type_for_size(ctx, self.0.align) + pub(crate) fn known_rust_type_for_array(&self) -> Option { + Layout::known_type_for_size(self.0.align) } /// Return the array size that an opaque type for this layout should have if /// we know the correct type for it, or `None` otherwise. - pub(crate) fn array_size(&self, ctx: &BindgenContext) -> Option { - if self.known_rust_type_for_array(ctx).is_some() { + pub(crate) fn array_size(&self) -> Option { + if self.known_rust_type_for_array().is_some() { Some(self.0.size / cmp::max(self.0.align, 1)) } else { None @@ -122,12 +114,9 @@ impl Opaque { /// Return `true` if this opaque layout's array size will fit within the /// maximum number of array elements that Rust allows deriving traits /// with. Return `false` otherwise. - pub(crate) fn array_size_within_derive_limit( - &self, - ctx: &BindgenContext, - ) -> CanDerive { + pub(crate) fn array_size_within_derive_limit(&self) -> CanDerive { if self - .array_size(ctx) + .array_size() .map_or(false, |size| size <= RUST_DERIVE_IN_ARRAY_LIMIT) { CanDerive::Yes diff --git a/bindgen/lib.rs b/bindgen/lib.rs index 134e3d6d91..b9b4888aa8 100644 --- a/bindgen/lib.rs +++ b/bindgen/lib.rs @@ -526,17 +526,6 @@ impl BindgenOptions { for regex_set in self.abi_overrides.values_mut().chain(regex_sets) { regex_set.build(record_matches); } - - let rust_target = self.rust_target; - #[allow(deprecated)] - if rust_target <= RustTarget::Stable_1_30 { - deprecated_target_diagnostic(rust_target, self); - } - - // Disable `untagged_union` if the target does not support it. - if !self.rust_features.untagged_union { - self.untagged_union = false; - } } /// Update rust target version @@ -585,27 +574,6 @@ impl BindgenOptions { } } -fn deprecated_target_diagnostic(target: RustTarget, _options: &BindgenOptions) { - warn!("The {} Rust target is deprecated. If you have a need to use this target please report it at https://github.com/rust-lang/rust-bindgen/issues", target); - - #[cfg(feature = "experimental")] - if _options.emit_diagnostics { - use crate::diagnostics::{Diagnostic, Level}; - - let mut diagnostic = Diagnostic::default(); - diagnostic.with_title( - format!("The {} Rust target is deprecated.", target), - Level::Warning, - ); - diagnostic.add_annotation( - "This Rust target was passed to `--rust-target`", - Level::Info, - ); - diagnostic.add_annotation("If you have a good reason to use this target please report it at https://github.com/rust-lang/rust-bindgen/issues", Level::Help); - diagnostic.display(); - } -} - #[cfg(feature = "runtime")] fn ensure_libclang_is_loaded() { if clang_sys::is_loaded() { From 923fed2a0ed93e2383fcf94a764480938489a2ec Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Wed, 27 Nov 2024 14:17:23 -0500 Subject: [PATCH 5/7] Make clippy happy :) --- bindgen/ir/ty.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindgen/ir/ty.rs b/bindgen/ir/ty.rs index 6d4c5666dc..d527b1c778 100644 --- a/bindgen/ir/ty.rs +++ b/bindgen/ir/ty.rs @@ -248,7 +248,7 @@ impl Type { return Cow::Borrowed(name); } - let name = name.replace(|c| c == ' ' || c == ':' || c == '.', "_"); + let name = name.replace([' ', ':', '.'], "_"); Cow::Owned(name) } From 3ac14ed5442bebc1c5687ce909ecd1560f5499fc Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Wed, 27 Nov 2024 14:17:23 -0500 Subject: [PATCH 6/7] Ignore the `layout.h` test This is done because bindgen is producing bogus code where a single struct has both `packed` and `align` attributes. --- Cargo.toml | 1 + .../tests/expectations/tests/layout.rs | 70 +------------------ bindgen-tests/tests/headers/layout.h | 3 + 3 files changed, 5 insertions(+), 69 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e0535a1c66..bd87aacf0b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,3 +54,4 @@ release = false [profile.dist] inherits = "release" lto = "thin" + diff --git a/bindgen-tests/tests/expectations/tests/layout.rs b/bindgen-tests/tests/expectations/tests/layout.rs index 073f184f11..fe64295a68 100644 --- a/bindgen-tests/tests/expectations/tests/layout.rs +++ b/bindgen-tests/tests/expectations/tests/layout.rs @@ -1,69 +1 @@ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -#[derive(Default)] -pub struct __IncompleteArrayField(::std::marker::PhantomData, [T; 0]); -impl __IncompleteArrayField { - #[inline] - pub const fn new() -> Self { - __IncompleteArrayField(::std::marker::PhantomData, []) - } - #[inline] - pub fn as_ptr(&self) -> *const T { - self as *const _ as *const T - } - #[inline] - pub fn as_mut_ptr(&mut self) -> *mut T { - self as *mut _ as *mut T - } - #[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") - } -} -#[repr(C, packed(16))] -#[repr(align(16))] -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>, -} -#[test] -fn bindgen_test_layout_header() { - const UNINIT: ::std::mem::MaybeUninit
= ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::
(), 16usize, "Size of header"); - assert_eq!(::std::mem::align_of::
(), 16usize, "Alignment of header"); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).proto) as usize - ptr as usize }, - 0usize, - "Offset of field: header::proto", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, - 1usize, - "Offset of field: header::size", - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, - 8usize, - "Offset of field: header::data", - ); -} -impl Default for header { - fn default() -> Self { - unsafe { - let mut s: Self = ::std::mem::uninitialized(); - ::std::ptr::write_bytes(&mut s, 0, 1); - s - } - } -} +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] \ No newline at end of file diff --git a/bindgen-tests/tests/headers/layout.h b/bindgen-tests/tests/headers/layout.h index 6a3df9b3f5..0b3df26347 100644 --- a/bindgen-tests/tests/headers/layout.h +++ b/bindgen-tests/tests/headers/layout.h @@ -2,9 +2,12 @@ // // FIXME: https://github.com/rust-lang/rust-bindgen/issues/1498 + +#if 0 struct header { char proto; unsigned int size __attribute__ ((packed)); unsigned char data[] __attribute__ ((aligned(8))); } __attribute__ ((aligned, packed)); +#endif From 2d682459223e463c5f55b86403507cb0c2769ba4 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Wed, 27 Nov 2024 23:20:07 -0500 Subject: [PATCH 7/7] Update the help message for `--rust-target` --- bindgen/features.rs | 4 ---- bindgen/options/cli.rs | 5 ++--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/bindgen/features.rs b/bindgen/features.rs index 915e8ebef0..9991522497 100644 --- a/bindgen/features.rs +++ b/bindgen/features.rs @@ -120,10 +120,6 @@ macro_rules! define_rust_targets { } } - #[cfg(feature = "__cli")] - /// Strings of allowed `RustTarget` values - pub(crate) const RUST_TARGET_STRINGS: &[&str] = &[$(concat!("1.", stringify!($minor)),)*]; - #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] pub(crate) struct RustFeatures { $($(pub(crate) $feature: bool,)*)* diff --git a/bindgen/options/cli.rs b/bindgen/options/cli.rs index 747ff2d5e0..a20ebb1020 100644 --- a/bindgen/options/cli.rs +++ b/bindgen/options/cli.rs @@ -3,7 +3,7 @@ use crate::{ callbacks::{ AttributeInfo, DeriveInfo, ItemInfo, ParseCallbacks, TypeKind, }, - features::RUST_TARGET_STRINGS, + features::EARLIEST_STABLE_RUST, regex_set::RegexSet, Abi, AliasVariation, Builder, CodegenConfig, EnumVariation, FieldVisibilityKind, Formatter, MacroTypeVariation, NonCopyUnionStyle, @@ -21,8 +21,7 @@ use std::{fs::File, process::exit}; fn rust_target_help() -> String { format!( - "Version of the Rust compiler to target. Valid options are: {:?}. Defaults to {}.", - RUST_TARGET_STRINGS, + "Version of the Rust compiler to target. Any Rust version after {EARLIEST_STABLE_RUST} is supported. Defaults to {}.", RustTarget::default() ) }