From aefffc6b976179a25bf1cb7aa34d2c3ffb9ae781 Mon Sep 17 00:00:00 2001 From: Dylan McKay Date: Thu, 6 Jul 2017 12:23:56 +1200 Subject: [PATCH] Intelligently convert C/C++ comments to Rust With this change, we can correctly parse C++ block comments. ``` /** * Does a thing * * More documentation. This test does something * useful. */ ``` into ``` /// Does a thing /// /// More documentation. This test does something /// useful. ``` Fixes servo/rust-bindgen#426. --- src/ir/comment.rs | 92 +++++ src/ir/comp.rs | 3 +- src/ir/enum_ty.rs | 3 +- src/ir/function.rs | 3 +- src/ir/item.rs | 6 +- src/ir/mod.rs | 1 + tests/expectations/tests/accessors.rs | 22 +- tests/expectations/tests/annotation_hide.rs | 4 +- tests/expectations/tests/class_use_as.rs | 4 +- .../tests/convert-cpp-comment-to-rust.rs | 263 +++++++++++++++ tests/expectations/tests/layout_align.rs | 12 +- tests/expectations/tests/layout_arp.rs | 38 +-- tests/expectations/tests/layout_array.rs | 82 ++--- .../tests/layout_array_too_long.rs | 38 +-- .../tests/layout_cmdline_token.rs | 50 ++- tests/expectations/tests/layout_eth_conf.rs | 316 ++++++++---------- tests/expectations/tests/layout_kni_mbuf.rs | 10 +- .../tests/layout_large_align_field.rs | 76 ++--- tests/expectations/tests/layout_mbuf.rs | 80 ++--- tests/expectations/tests/no-derive-debug.rs | 8 +- tests/expectations/tests/no-derive-default.rs | 8 +- tests/expectations/tests/no_copy.rs | 2 +- tests/expectations/tests/opaque_in_struct.rs | 2 +- tests/expectations/tests/opaque_pointer.rs | 8 +- tests/expectations/tests/opaque_typedef.rs | 2 +- tests/expectations/tests/private.rs | 8 +- tests/expectations/tests/replace_use.rs | 4 +- tests/expectations/tests/replaces_double.rs | 4 +- tests/expectations/tests/template.rs | 26 +- tests/headers/convert-cpp-comment-to-rust.hpp | 16 + 30 files changed, 733 insertions(+), 458 deletions(-) create mode 100644 src/ir/comment.rs create mode 100644 tests/expectations/tests/convert-cpp-comment-to-rust.rs create mode 100644 tests/headers/convert-cpp-comment-to-rust.hpp diff --git a/src/ir/comment.rs b/src/ir/comment.rs new file mode 100644 index 0000000000..b950fab5dd --- /dev/null +++ b/src/ir/comment.rs @@ -0,0 +1,92 @@ +/// The type of a comment. +#[derive(Debug, PartialEq, Eq)] +enum Kind { + /// A `///` comment, or something of the like. + /// All lines in a comment should start with the same symbol. + SingleLines, + /// A `/**` comment, where each other line can start with `*` and the + /// entire block ends with `*/`. + MultiLine, +} +/// Preprocesses a C/C++ comment so that it is a valid Rust comment. +pub fn preprocess(comment: String) -> String { + match self::kind(&comment) { + Some(Kind::SingleLines) => preprocess_single_lines(&comment), + Some(Kind::MultiLine) => preprocess_multi_line(&comment), + None => comment.to_owned(), + } +} + +/// Gets the kind of the doc comment, if it is one. +fn kind(comment: &str) -> Option { + if comment.starts_with("/*") { + Some(Kind::MultiLine) + } else if comment.starts_with("//") { + Some(Kind::SingleLines) + } else { + None + } +} + +/// Preprocesses mulitple single line comments. +/// +/// Handles lines starting with both `//` and `///`. +fn preprocess_single_lines(comment: &str) -> String { + assert!(comment.starts_with("//"), "comment is not single line"); + + let lines: Vec<_> = comment.lines() + .map(|l| l.trim_left_matches('/').trim()) + .map(|l| format!("/// {}", l).trim().to_owned()) + .collect(); + lines.join("\n") +} + +fn preprocess_multi_line(comment: &str) -> String { + let comment = comment.trim_left_matches('/') + .trim_left_matches("*") + .trim_left_matches("!") + .trim_right_matches('/') + .trim_right_matches('*') + .trim(); + + // Strip any potential `*` characters preceding each line. + let mut lines: Vec<_> = comment.lines() + .map(|line| line.trim().trim_left_matches('*').trim()) + .skip_while(|line| line.is_empty()) // Skip the first empty lines. + .map(|line| format!("/// {}", line).trim().to_owned()) + .collect(); + + // Remove the trailing `*/`. + let last_idx = lines.len() - 1; + if lines[last_idx].is_empty() { + lines.remove(last_idx); + } + + lines.join("\n") +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn picks_up_single_and_multi_line_doc_comments() { + assert_eq!(kind("/// hello"), Some(Kind::SingleLines)); + assert_eq!(kind("/** world */"), Some(Kind::MultiLine)); + } + + #[test] + fn processes_single_lines_correctly() { + assert_eq!(preprocess("/// hello".to_owned()), "/// hello"); + assert_eq!(preprocess("// hello".to_owned()), "/// hello"); + } + + #[test] + fn processes_multi_lines_correctly() { + assert_eq!(preprocess("/** hello \n * world \n * foo \n */".to_owned()), + "/// hello\n/// world\n/// foo"); + + assert_eq!(preprocess("/**\nhello\n*world\n*foo\n*/".to_owned()), + "/// hello\n/// world\n/// foo"); + } +} diff --git a/src/ir/comp.rs b/src/ir/comp.rs index 6dfc998028..4854949fc1 100644 --- a/src/ir/comp.rs +++ b/src/ir/comp.rs @@ -1,6 +1,7 @@ //! Compound types (unions and structs) in our intermediate representation. use super::annotations::Annotations; +use super::comment; use super::context::{BindgenContext, ItemId}; use super::derive::{CanDeriveCopy, CanDeriveDebug, CanDeriveDefault}; use super::dot::DotAttributes; @@ -1101,7 +1102,7 @@ impl CompInfo { Some(potential_id), ctx); - let comment = cur.raw_comment(); + let comment = cur.raw_comment().map(comment::preprocess); let annotations = Annotations::new(&cur); let name = cur.spelling(); let is_mutable = cursor.is_mutable_field(); diff --git a/src/ir/enum_ty.rs b/src/ir/enum_ty.rs index 38de01d9c8..731961a66e 100644 --- a/src/ir/enum_ty.rs +++ b/src/ir/enum_ty.rs @@ -1,5 +1,6 @@ //! Intermediate representation for C/C++ enumerations. +use super::comment; use super::context::{BindgenContext, ItemId}; use super::item::Item; use super::ty::TypeKind; @@ -113,7 +114,7 @@ impl Enum { }) }); - let comment = cursor.raw_comment(); + let comment = cursor.raw_comment().map(comment::preprocess); variants.push(EnumVariant::new(name, comment, val, diff --git a/src/ir/function.rs b/src/ir/function.rs index 9865997ded..299bd65c46 100644 --- a/src/ir/function.rs +++ b/src/ir/function.rs @@ -1,5 +1,6 @@ //! Intermediate representation for C/C++ functions and methods. +use super::comment; use super::context::{BindgenContext, ItemId}; use super::dot::DotAttributes; use super::item::Item; @@ -405,7 +406,7 @@ impl ClangSubItemParser for Function { mangled_name = None; } - let comment = cursor.raw_comment(); + let comment = cursor.raw_comment().map(comment::preprocess); let function = Self::new(name, mangled_name, sig, comment); Ok(ParseResult::New(function, Some(cursor))) diff --git a/src/ir/item.rs b/src/ir/item.rs index 3564c6e89a..540dd79102 100644 --- a/src/ir/item.rs +++ b/src/ir/item.rs @@ -2,6 +2,7 @@ use super::super::codegen::CONSTIFIED_ENUM_MODULE_REPR_NAME; use super::annotations::Annotations; +use super::comment; use super::context::{BindgenContext, ItemId, PartialType}; use super::derive::{CanDeriveCopy, CanDeriveDebug, CanDeriveDefault}; use super::dot::DotAttributes; @@ -1001,7 +1002,7 @@ impl ClangItemParser for Item { return Err(ParseError::Continue); } - let comment = cursor.raw_comment(); + let comment = cursor.raw_comment().map(comment::preprocess); let annotations = Annotations::new(&cursor); let current_module = ctx.current_module(); @@ -1207,7 +1208,8 @@ impl ClangItemParser for Item { }; let comment = decl.raw_comment() - .or_else(|| location.raw_comment()); + .or_else(|| location.raw_comment()) + .map(comment::preprocess); let annotations = Annotations::new(&decl) .or_else(|| Annotations::new(&location)); diff --git a/src/ir/mod.rs b/src/ir/mod.rs index d703e53dbb..ae67015c5f 100644 --- a/src/ir/mod.rs +++ b/src/ir/mod.rs @@ -5,6 +5,7 @@ pub mod annotations; pub mod comp; +pub mod comment; pub mod context; pub mod derive; pub mod dot; diff --git a/tests/expectations/tests/accessors.rs b/tests/expectations/tests/accessors.rs index ac02e71154..df1732c4c1 100644 --- a/tests/expectations/tests/accessors.rs +++ b/tests/expectations/tests/accessors.rs @@ -8,11 +8,11 @@ #[derive(Debug, Default, Copy)] pub struct SomeAccessors { pub mNoAccessor: ::std::os::raw::c_int, - /**
*/ + ///
pub mBothAccessors: ::std::os::raw::c_int, - /**
*/ + ///
pub mUnsafeAccessors: ::std::os::raw::c_int, - /**
*/ + ///
pub mImmutableAccessor: ::std::os::raw::c_int, } #[test] @@ -68,7 +68,7 @@ impl SomeAccessors { &self.mImmutableAccessor } } -/**
*/ +///
#[repr(C)] #[derive(Debug, Default, Copy)] pub struct AllAccessors { @@ -114,7 +114,7 @@ impl AllAccessors { &mut self.mAlsoBothAccessors } } -/**
*/ +///
#[repr(C)] #[derive(Debug, Default, Copy)] pub struct AllUnsafeAccessors { @@ -162,16 +162,16 @@ impl AllUnsafeAccessors { &mut self.mAlsoBothAccessors } } -/**
*/ +///
#[repr(C)] #[derive(Debug, Default, Copy)] pub struct ContradictAccessors { pub mBothAccessors: ::std::os::raw::c_int, - /**
*/ + ///
pub mNoAccessors: ::std::os::raw::c_int, - /**
*/ + ///
pub mUnsafeAccessors: ::std::os::raw::c_int, - /**
*/ + ///
pub mImmutableAccessor: ::std::os::raw::c_int, } #[test] @@ -229,7 +229,7 @@ impl ContradictAccessors { &self.mImmutableAccessor } } -/**
*/ +///
#[repr(C)] #[derive(Debug, Default, Copy)] pub struct Replaced { @@ -258,7 +258,7 @@ impl Replaced { &mut self.mAccessor } } -/**
*/ +///
#[repr(C)] #[derive(Debug, Default, Copy)] pub struct Wrapper { diff --git a/tests/expectations/tests/annotation_hide.rs b/tests/expectations/tests/annotation_hide.rs index 0b669041f2..7305091a19 100644 --- a/tests/expectations/tests/annotation_hide.rs +++ b/tests/expectations/tests/annotation_hide.rs @@ -4,9 +4,7 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -/** - *
- */ +///
#[repr(C)] #[derive(Debug, Default, Copy)] pub struct D { diff --git a/tests/expectations/tests/class_use_as.rs b/tests/expectations/tests/class_use_as.rs index 61a78e21ac..15cc61f6ba 100644 --- a/tests/expectations/tests/class_use_as.rs +++ b/tests/expectations/tests/class_use_as.rs @@ -4,9 +4,7 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -/** - *
- */ +///
#[repr(C)] #[derive(Debug, Default, Copy)] pub struct whatever { diff --git a/tests/expectations/tests/convert-cpp-comment-to-rust.rs b/tests/expectations/tests/convert-cpp-comment-to-rust.rs new file mode 100644 index 0000000000..157edfaf9d --- /dev/null +++ b/tests/expectations/tests/convert-cpp-comment-to-rust.rs @@ -0,0 +1,263 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +pub const _STDINT_H: ::std::os::raw::c_uint = 1; +pub const _FEATURES_H: ::std::os::raw::c_uint = 1; +pub const _ISOC95_SOURCE: ::std::os::raw::c_uint = 1; +pub const _ISOC99_SOURCE: ::std::os::raw::c_uint = 1; +pub const _ISOC11_SOURCE: ::std::os::raw::c_uint = 1; +pub const _POSIX_SOURCE: ::std::os::raw::c_uint = 1; +pub const _POSIX_C_SOURCE: ::std::os::raw::c_uint = 200809; +pub const _XOPEN_SOURCE: ::std::os::raw::c_uint = 700; +pub const _XOPEN_SOURCE_EXTENDED: ::std::os::raw::c_uint = 1; +pub const _LARGEFILE64_SOURCE: ::std::os::raw::c_uint = 1; +pub const _DEFAULT_SOURCE: ::std::os::raw::c_uint = 1; +pub const _ATFILE_SOURCE: ::std::os::raw::c_uint = 1; +pub const __USE_ISOC11: ::std::os::raw::c_uint = 1; +pub const __USE_ISOC99: ::std::os::raw::c_uint = 1; +pub const __USE_ISOC95: ::std::os::raw::c_uint = 1; +pub const __USE_POSIX: ::std::os::raw::c_uint = 1; +pub const __USE_POSIX2: ::std::os::raw::c_uint = 1; +pub const __USE_POSIX199309: ::std::os::raw::c_uint = 1; +pub const __USE_POSIX199506: ::std::os::raw::c_uint = 1; +pub const __USE_XOPEN2K: ::std::os::raw::c_uint = 1; +pub const __USE_XOPEN2K8: ::std::os::raw::c_uint = 1; +pub const __USE_XOPEN: ::std::os::raw::c_uint = 1; +pub const __USE_XOPEN_EXTENDED: ::std::os::raw::c_uint = 1; +pub const __USE_UNIX98: ::std::os::raw::c_uint = 1; +pub const _LARGEFILE_SOURCE: ::std::os::raw::c_uint = 1; +pub const __USE_XOPEN2K8XSI: ::std::os::raw::c_uint = 1; +pub const __USE_XOPEN2KXSI: ::std::os::raw::c_uint = 1; +pub const __USE_LARGEFILE: ::std::os::raw::c_uint = 1; +pub const __USE_LARGEFILE64: ::std::os::raw::c_uint = 1; +pub const __USE_MISC: ::std::os::raw::c_uint = 1; +pub const __USE_ATFILE: ::std::os::raw::c_uint = 1; +pub const __USE_GNU: ::std::os::raw::c_uint = 1; +pub const __USE_FORTIFY_LEVEL: ::std::os::raw::c_uint = 0; +pub const _STDC_PREDEF_H: ::std::os::raw::c_uint = 1; +pub const __STDC_IEC_559__: ::std::os::raw::c_uint = 1; +pub const __STDC_IEC_559_COMPLEX__: ::std::os::raw::c_uint = 1; +pub const __STDC_ISO_10646__: ::std::os::raw::c_uint = 201505; +pub const __STDC_NO_THREADS__: ::std::os::raw::c_uint = 1; +pub const __GNU_LIBRARY__: ::std::os::raw::c_uint = 6; +pub const __GLIBC__: ::std::os::raw::c_uint = 2; +pub const __GLIBC_MINOR__: ::std::os::raw::c_uint = 25; +pub const _SYS_CDEFS_H: ::std::os::raw::c_uint = 1; +pub const __glibc_c99_flexarr_available: ::std::os::raw::c_uint = 1; +pub const __WORDSIZE: ::std::os::raw::c_uint = 64; +pub const __WORDSIZE_TIME64_COMPAT32: ::std::os::raw::c_uint = 1; +pub const __SYSCALL_WORDSIZE: ::std::os::raw::c_uint = 64; +pub const __GLIBC_USE_LIB_EXT2: ::std::os::raw::c_uint = 1; +pub const __GLIBC_USE_IEC_60559_BFP_EXT: ::std::os::raw::c_uint = 1; +pub const __GLIBC_USE_IEC_60559_FUNCS_EXT: ::std::os::raw::c_uint = 1; +pub const _BITS_TYPES_H: ::std::os::raw::c_uint = 1; +pub const _BITS_TYPESIZES_H: ::std::os::raw::c_uint = 1; +pub const __OFF_T_MATCHES_OFF64_T: ::std::os::raw::c_uint = 1; +pub const __INO_T_MATCHES_INO64_T: ::std::os::raw::c_uint = 1; +pub const __RLIM_T_MATCHES_RLIM64_T: ::std::os::raw::c_uint = 1; +pub const __FD_SETSIZE: ::std::os::raw::c_uint = 1024; +pub const _BITS_WCHAR_H: ::std::os::raw::c_uint = 1; +pub const INT8_MIN: ::std::os::raw::c_int = -128; +pub const INT16_MIN: ::std::os::raw::c_int = -32768; +pub const INT32_MIN: ::std::os::raw::c_int = -2147483648; +pub const INT8_MAX: ::std::os::raw::c_uint = 127; +pub const INT16_MAX: ::std::os::raw::c_uint = 32767; +pub const INT32_MAX: ::std::os::raw::c_uint = 2147483647; +pub const UINT8_MAX: ::std::os::raw::c_uint = 255; +pub const UINT16_MAX: ::std::os::raw::c_uint = 65535; +pub const UINT32_MAX: ::std::os::raw::c_uint = 4294967295; +pub const INT_LEAST8_MIN: ::std::os::raw::c_int = -128; +pub const INT_LEAST16_MIN: ::std::os::raw::c_int = -32768; +pub const INT_LEAST32_MIN: ::std::os::raw::c_int = -2147483648; +pub const INT_LEAST8_MAX: ::std::os::raw::c_uint = 127; +pub const INT_LEAST16_MAX: ::std::os::raw::c_uint = 32767; +pub const INT_LEAST32_MAX: ::std::os::raw::c_uint = 2147483647; +pub const UINT_LEAST8_MAX: ::std::os::raw::c_uint = 255; +pub const UINT_LEAST16_MAX: ::std::os::raw::c_uint = 65535; +pub const UINT_LEAST32_MAX: ::std::os::raw::c_uint = 4294967295; +pub const INT_FAST8_MIN: ::std::os::raw::c_int = -128; +pub const INT_FAST16_MIN: ::std::os::raw::c_longlong = -9223372036854775808; +pub const INT_FAST32_MIN: ::std::os::raw::c_longlong = -9223372036854775808; +pub const INT_FAST8_MAX: ::std::os::raw::c_uint = 127; +pub const INT_FAST16_MAX: ::std::os::raw::c_ulonglong = 9223372036854775807; +pub const INT_FAST32_MAX: ::std::os::raw::c_ulonglong = 9223372036854775807; +pub const UINT_FAST8_MAX: ::std::os::raw::c_uint = 255; +pub const UINT_FAST16_MAX: ::std::os::raw::c_int = -1; +pub const UINT_FAST32_MAX: ::std::os::raw::c_int = -1; +pub const INTPTR_MIN: ::std::os::raw::c_longlong = -9223372036854775808; +pub const INTPTR_MAX: ::std::os::raw::c_ulonglong = 9223372036854775807; +pub const UINTPTR_MAX: ::std::os::raw::c_int = -1; +pub const PTRDIFF_MIN: ::std::os::raw::c_longlong = -9223372036854775808; +pub const PTRDIFF_MAX: ::std::os::raw::c_ulonglong = 9223372036854775807; +pub const SIG_ATOMIC_MIN: ::std::os::raw::c_int = -2147483648; +pub const SIG_ATOMIC_MAX: ::std::os::raw::c_uint = 2147483647; +pub const SIZE_MAX: ::std::os::raw::c_int = -1; +pub const WINT_MIN: ::std::os::raw::c_uint = 0; +pub const WINT_MAX: ::std::os::raw::c_uint = 4294967295; +pub const INT8_WIDTH: ::std::os::raw::c_uint = 8; +pub const UINT8_WIDTH: ::std::os::raw::c_uint = 8; +pub const INT16_WIDTH: ::std::os::raw::c_uint = 16; +pub const UINT16_WIDTH: ::std::os::raw::c_uint = 16; +pub const INT32_WIDTH: ::std::os::raw::c_uint = 32; +pub const UINT32_WIDTH: ::std::os::raw::c_uint = 32; +pub const INT64_WIDTH: ::std::os::raw::c_uint = 64; +pub const UINT64_WIDTH: ::std::os::raw::c_uint = 64; +pub const INT_LEAST8_WIDTH: ::std::os::raw::c_uint = 8; +pub const UINT_LEAST8_WIDTH: ::std::os::raw::c_uint = 8; +pub const INT_LEAST16_WIDTH: ::std::os::raw::c_uint = 16; +pub const UINT_LEAST16_WIDTH: ::std::os::raw::c_uint = 16; +pub const INT_LEAST32_WIDTH: ::std::os::raw::c_uint = 32; +pub const UINT_LEAST32_WIDTH: ::std::os::raw::c_uint = 32; +pub const INT_LEAST64_WIDTH: ::std::os::raw::c_uint = 64; +pub const UINT_LEAST64_WIDTH: ::std::os::raw::c_uint = 64; +pub const INT_FAST8_WIDTH: ::std::os::raw::c_uint = 8; +pub const UINT_FAST8_WIDTH: ::std::os::raw::c_uint = 8; +pub const INT_FAST16_WIDTH: ::std::os::raw::c_uint = 64; +pub const UINT_FAST16_WIDTH: ::std::os::raw::c_uint = 64; +pub const INT_FAST32_WIDTH: ::std::os::raw::c_uint = 64; +pub const UINT_FAST32_WIDTH: ::std::os::raw::c_uint = 64; +pub const INT_FAST64_WIDTH: ::std::os::raw::c_uint = 64; +pub const UINT_FAST64_WIDTH: ::std::os::raw::c_uint = 64; +pub const INTPTR_WIDTH: ::std::os::raw::c_uint = 64; +pub const UINTPTR_WIDTH: ::std::os::raw::c_uint = 64; +pub const INTMAX_WIDTH: ::std::os::raw::c_uint = 64; +pub const UINTMAX_WIDTH: ::std::os::raw::c_uint = 64; +pub const PTRDIFF_WIDTH: ::std::os::raw::c_uint = 64; +pub const SIG_ATOMIC_WIDTH: ::std::os::raw::c_uint = 32; +pub const SIZE_WIDTH: ::std::os::raw::c_uint = 64; +pub const WCHAR_WIDTH: ::std::os::raw::c_uint = 32; +pub const WINT_WIDTH: ::std::os::raw::c_uint = 32; +pub type __u_char = ::std::os::raw::c_uchar; +pub type __u_short = ::std::os::raw::c_ushort; +pub type __u_int = ::std::os::raw::c_uint; +pub type __u_long = ::std::os::raw::c_ulong; +pub type __int8_t = ::std::os::raw::c_schar; +pub type __uint8_t = ::std::os::raw::c_uchar; +pub type __int16_t = ::std::os::raw::c_short; +pub type __uint16_t = ::std::os::raw::c_ushort; +pub type __int32_t = ::std::os::raw::c_int; +pub type __uint32_t = ::std::os::raw::c_uint; +pub type __int64_t = ::std::os::raw::c_long; +pub type __uint64_t = ::std::os::raw::c_ulong; +pub type __quad_t = ::std::os::raw::c_long; +pub type __u_quad_t = ::std::os::raw::c_ulong; +pub type __intmax_t = ::std::os::raw::c_long; +pub type __uintmax_t = ::std::os::raw::c_ulong; +pub type __dev_t = ::std::os::raw::c_ulong; +pub type __uid_t = ::std::os::raw::c_uint; +pub type __gid_t = ::std::os::raw::c_uint; +pub type __ino_t = ::std::os::raw::c_ulong; +pub type __ino64_t = ::std::os::raw::c_ulong; +pub type __mode_t = ::std::os::raw::c_uint; +pub type __nlink_t = ::std::os::raw::c_ulong; +pub type __off_t = ::std::os::raw::c_long; +pub type __off64_t = ::std::os::raw::c_long; +pub type __pid_t = ::std::os::raw::c_int; +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct __fsid_t { + pub __val: [::std::os::raw::c_int; 2usize], +} +#[test] +fn bindgen_test_layout___fsid_t() { + assert_eq!(::std::mem::size_of::<__fsid_t>() , 8usize , concat ! ( + "Size of: " , stringify ! ( __fsid_t ) )); + assert_eq! (::std::mem::align_of::<__fsid_t>() , 4usize , concat ! ( + "Alignment of " , stringify ! ( __fsid_t ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const __fsid_t ) ) . __val as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( __fsid_t ) , "::" , + stringify ! ( __val ) )); +} +impl Clone for __fsid_t { + fn clone(&self) -> Self { *self } +} +pub type __clock_t = ::std::os::raw::c_long; +pub type __rlim_t = ::std::os::raw::c_ulong; +pub type __rlim64_t = ::std::os::raw::c_ulong; +pub type __id_t = ::std::os::raw::c_uint; +pub type __time_t = ::std::os::raw::c_long; +pub type __useconds_t = ::std::os::raw::c_uint; +pub type __suseconds_t = ::std::os::raw::c_long; +pub type __daddr_t = ::std::os::raw::c_int; +pub type __key_t = ::std::os::raw::c_int; +pub type __clockid_t = ::std::os::raw::c_int; +pub type __timer_t = *mut ::std::os::raw::c_void; +pub type __blksize_t = ::std::os::raw::c_long; +pub type __blkcnt_t = ::std::os::raw::c_long; +pub type __blkcnt64_t = ::std::os::raw::c_long; +pub type __fsblkcnt_t = ::std::os::raw::c_ulong; +pub type __fsblkcnt64_t = ::std::os::raw::c_ulong; +pub type __fsfilcnt_t = ::std::os::raw::c_ulong; +pub type __fsfilcnt64_t = ::std::os::raw::c_ulong; +pub type __fsword_t = ::std::os::raw::c_long; +pub type __ssize_t = ::std::os::raw::c_long; +pub type __syscall_slong_t = ::std::os::raw::c_long; +pub type __syscall_ulong_t = ::std::os::raw::c_ulong; +pub type __loff_t = __off64_t; +pub type __qaddr_t = *mut __quad_t; +pub type __caddr_t = *mut ::std::os::raw::c_char; +pub type __intptr_t = ::std::os::raw::c_long; +pub type __socklen_t = ::std::os::raw::c_uint; +pub type int_least8_t = ::std::os::raw::c_schar; +pub type int_least16_t = ::std::os::raw::c_short; +pub type int_least32_t = ::std::os::raw::c_int; +pub type int_least64_t = ::std::os::raw::c_long; +pub type uint_least8_t = ::std::os::raw::c_uchar; +pub type uint_least16_t = ::std::os::raw::c_ushort; +pub type uint_least32_t = ::std::os::raw::c_uint; +pub type uint_least64_t = ::std::os::raw::c_ulong; +pub type int_fast8_t = ::std::os::raw::c_schar; +pub type int_fast16_t = ::std::os::raw::c_long; +pub type int_fast32_t = ::std::os::raw::c_long; +pub type int_fast64_t = ::std::os::raw::c_long; +pub type uint_fast8_t = ::std::os::raw::c_uchar; +pub type uint_fast16_t = ::std::os::raw::c_ulong; +pub type uint_fast32_t = ::std::os::raw::c_ulong; +pub type uint_fast64_t = ::std::os::raw::c_ulong; +pub type intmax_t = __intmax_t; +pub type uintmax_t = __uintmax_t; +pub type mbedtls_mpi_uint = u32; +/// \brief MPI structure +#[repr(C)] +#[derive(Debug, Copy)] +pub struct mbedtls_mpi { + /// < integer sign + pub s: ::std::os::raw::c_int, + /// < total # of limbs + pub n: usize, + /// < pointer to limbs + pub p: *mut mbedtls_mpi_uint, +} +#[test] +fn bindgen_test_layout_mbedtls_mpi() { + assert_eq!(::std::mem::size_of::() , 24usize , concat ! ( + "Size of: " , stringify ! ( mbedtls_mpi ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( mbedtls_mpi ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const mbedtls_mpi ) ) . s as * const _ as usize + } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( mbedtls_mpi ) , "::" , + stringify ! ( s ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const mbedtls_mpi ) ) . n as * const _ as usize + } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( mbedtls_mpi ) , "::" , + stringify ! ( n ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const mbedtls_mpi ) ) . p as * const _ as usize + } , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( mbedtls_mpi ) , "::" , + stringify ! ( p ) )); +} +impl Clone for mbedtls_mpi { + fn clone(&self) -> Self { *self } +} +impl Default for mbedtls_mpi { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} diff --git a/tests/expectations/tests/layout_align.rs b/tests/expectations/tests/layout_align.rs index a8f981e8f0..c254893894 100644 --- a/tests/expectations/tests/layout_align.rs +++ b/tests/expectations/tests/layout_align.rs @@ -40,15 +40,15 @@ impl ::std::marker::Copy for __IncompleteArrayField { } #[repr(C)] #[derive(Debug, Copy)] pub struct rte_kni_fifo { - /**< Next position to be written*/ + /// < Next position to be written pub write: ::std::os::raw::c_uint, - /**< Next position to be read */ + /// < Next position to be read pub read: ::std::os::raw::c_uint, - /**< Circular buffer length */ + /// < Circular buffer length pub len: ::std::os::raw::c_uint, - /**< Pointer size - for 32/64 bit OS */ + /// < Pointer size - for 32/64 bit OS pub elem_size: ::std::os::raw::c_uint, - /**< The buffer contains mbuf pointers */ + /// < The buffer contains mbuf pointers pub buffer: __IncompleteArrayField<*mut ::std::os::raw::c_void>, pub __bindgen_align: [u64; 0usize], } @@ -68,7 +68,7 @@ impl Default for rte_kni_fifo { #[repr(C)] #[derive(Debug, Default, Copy)] pub struct rte_eth_link { - /**< ETH_SPEED_NUM_ */ + /// < ETH_SPEED_NUM_ pub link_speed: u32, pub _bitfield_1: u8, pub __bindgen_padding_0: [u8; 3usize], diff --git a/tests/expectations/tests/layout_arp.rs b/tests/expectations/tests/layout_arp.rs index 03f4b4409b..8f8530686e 100644 --- a/tests/expectations/tests/layout_arp.rs +++ b/tests/expectations/tests/layout_arp.rs @@ -12,21 +12,19 @@ pub const ARP_OP_REVREQUEST: ::std::os::raw::c_uint = 3; pub const ARP_OP_REVREPLY: ::std::os::raw::c_uint = 4; pub const ARP_OP_INVREQUEST: ::std::os::raw::c_uint = 8; pub const ARP_OP_INVREPLY: ::std::os::raw::c_uint = 9; -/** - * Ethernet address: - * A universally administered address is uniquely assigned to a device by its - * manufacturer. The first three octets (in transmission order) contain the - * Organizationally Unique Identifier (OUI). The following three (MAC-48 and - * EUI-48) octets are assigned by that organization with the only constraint - * of uniqueness. - * A locally administered address is assigned to a device by a network - * administrator and does not contain OUIs. - * See http://standards.ieee.org/regauth/groupmac/tutorial.html - */ +/// Ethernet address: +/// A universally administered address is uniquely assigned to a device by its +/// manufacturer. The first three octets (in transmission order) contain the +/// Organizationally Unique Identifier (OUI). The following three (MAC-48 and +/// EUI-48) octets are assigned by that organization with the only constraint +/// of uniqueness. +/// A locally administered address is assigned to a device by a network +/// administrator and does not contain OUIs. +/// See http://standards.ieee.org/regauth/groupmac/tutorial.html #[repr(C, packed)] #[derive(Debug, Default, Copy)] pub struct ether_addr { - /**< Addr bytes in tx order */ + /// < Addr bytes in tx order pub addr_bytes: [u8; 6usize], } #[test] @@ -44,19 +42,17 @@ fn bindgen_test_layout_ether_addr() { impl Clone for ether_addr { fn clone(&self) -> Self { *self } } -/** - * ARP header IPv4 payload. - */ +/// ARP header IPv4 payload. #[repr(C, packed)] #[derive(Debug, Default, Copy)] pub struct arp_ipv4 { - /**< sender hardware address */ + /// < sender hardware address pub arp_sha: ether_addr, - /**< sender IP address */ + /// < sender IP address pub arp_sip: u32, - /**< target hardware address */ + /// < target hardware address pub arp_tha: ether_addr, - /**< target IP address */ + /// < target IP address pub arp_tip: u32, } #[test] @@ -89,9 +85,7 @@ fn bindgen_test_layout_arp_ipv4() { impl Clone for arp_ipv4 { fn clone(&self) -> Self { *self } } -/** - * ARP header. - */ +/// ARP header. #[repr(C, packed)] #[derive(Debug, Default, Copy)] pub struct arp_hdr { diff --git a/tests/expectations/tests/layout_array.rs b/tests/expectations/tests/layout_array.rs index 3ca0ffe83b..06bc213cc7 100644 --- a/tests/expectations/tests/layout_array.rs +++ b/tests/expectations/tests/layout_array.rs @@ -13,63 +13,53 @@ pub const RTE_HEAP_NUM_FREELISTS: ::std::os::raw::c_uint = 13; pub struct rte_mempool { _unused: [u8; 0], } -/** - * Prototype for implementation specific data provisioning function. - * - * The function should provide the implementation specific memory for - * for use by the other mempool ops functions in a given mempool ops struct. - * E.g. the default ops provides an instance of the rte_ring for this purpose. - * it will most likely point to a different type of data structure, and - * will be transparent to the application programmer. - * This function should set mp->pool_data. - */ +/// Prototype for implementation specific data provisioning function. +/// +/// The function should provide the implementation specific memory for +/// for use by the other mempool ops functions in a given mempool ops struct. +/// E.g. the default ops provides an instance of the rte_ring for this purpose. +/// it will most likely point to a different type of data structure, and +/// will be transparent to the application programmer. +/// This function should set mp->pool_data. pub type rte_mempool_alloc_t = ::std::option::Option ::std::os::raw::c_int>; -/** - * Free the opaque private data pointed to by mp->pool_data pointer. - */ +/// Free the opaque private data pointed to by mp->pool_data pointer. pub type rte_mempool_free_t = ::std::option::Option; -/** - * Enqueue an object into the external pool. - */ +/// Enqueue an object into the external pool. pub type rte_mempool_enqueue_t = ::std::option::Option ::std::os::raw::c_int>; -/** - * Dequeue an object from the external pool. - */ +/// Dequeue an object from the external pool. pub type rte_mempool_dequeue_t = ::std::option::Option ::std::os::raw::c_int>; -/** - * Return the number of available objects in the external pool. - */ +/// Return the number of available objects in the external pool. pub type rte_mempool_get_count = ::std::option::Option ::std::os::raw::c_uint>; -/** Structure defining mempool operations structure */ +/// Structure defining mempool operations structure #[repr(C)] #[derive(Debug, Copy)] pub struct rte_mempool_ops { - /**< Name of mempool ops struct. */ + /// < Name of mempool ops struct. pub name: [::std::os::raw::c_char; 32usize], - /**< Allocate private data. */ + /// < Allocate private data. pub alloc: rte_mempool_alloc_t, - /**< Free the external pool. */ + /// < Free the external pool. pub free: rte_mempool_free_t, - /**< Enqueue an object. */ + /// < Enqueue an object. pub enqueue: rte_mempool_enqueue_t, - /**< Dequeue an object. */ + /// < Dequeue an object. pub dequeue: rte_mempool_dequeue_t, - /**< Get qty of available objs. */ + /// < Get qty of available objs. pub get_count: rte_mempool_get_count, pub __bindgen_padding_0: [u64; 7usize], } @@ -114,13 +104,11 @@ impl Clone for rte_mempool_ops { impl Default for rte_mempool_ops { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } -/** - * The rte_spinlock_t type. - */ +/// The rte_spinlock_t type. #[repr(C)] #[derive(Debug, Default, Copy)] pub struct rte_spinlock_t { - /**< lock status 0 = unlocked, 1 = locked */ + /// < lock status 0 = unlocked, 1 = locked pub locked: ::std::os::raw::c_int, } #[test] @@ -138,26 +126,22 @@ fn bindgen_test_layout_rte_spinlock_t() { impl Clone for rte_spinlock_t { fn clone(&self) -> Self { *self } } -/** - * Structure storing the table of registered ops structs, each of which contain - * the function pointers for the mempool ops functions. - * Each process has its own storage for this ops struct array so that - * the mempools can be shared across primary and secondary processes. - * The indices used to access the array are valid across processes, whereas - * any function pointers stored directly in the mempool struct would not be. - * This results in us simply having "ops_index" in the mempool struct. - */ +/// Structure storing the table of registered ops structs, each of which contain +/// the function pointers for the mempool ops functions. +/// Each process has its own storage for this ops struct array so that +/// the mempools can be shared across primary and secondary processes. +/// The indices used to access the array are valid across processes, whereas +/// any function pointers stored directly in the mempool struct would not be. +/// This results in us simply having "ops_index" in the mempool struct. #[repr(C)] #[derive(Debug, Copy)] pub struct rte_mempool_ops_table { - /**< Spinlock for add/delete. */ + /// < Spinlock for add/delete. pub sl: rte_spinlock_t, - /**< Number of used ops structs in the table. */ + /// < Number of used ops structs in the table. pub num_ops: u32, pub __bindgen_padding_0: [u64; 7usize], - /** - * Storage for all possible ops structs. - */ + /// Storage for all possible ops structs. pub ops: [rte_mempool_ops; 16usize], } #[test] @@ -187,9 +171,7 @@ impl Clone for rte_mempool_ops_table { impl Default for rte_mempool_ops_table { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } -/** - * Structure to hold malloc heap - */ +/// Structure to hold malloc heap #[repr(C)] #[derive(Debug, Copy)] pub struct malloc_heap { diff --git a/tests/expectations/tests/layout_array_too_long.rs b/tests/expectations/tests/layout_array_too_long.rs index 2dae536ae8..b80d0656e8 100644 --- a/tests/expectations/tests/layout_array_too_long.rs +++ b/tests/expectations/tests/layout_array_too_long.rs @@ -18,15 +18,15 @@ pub enum _bindgen_ty_1 { IP_MIN_FRAG_NUM = 2, IP_MAX_FRAG_NUM = 4, } -/** @internal fragmented mbuf */ +/// @internal fragmented mbuf #[repr(C)] #[derive(Debug, Copy)] pub struct ip_frag { - /**< offset into the packet */ + /// < offset into the packet pub ofs: u16, - /**< length of fragment */ + /// < length of fragment pub len: u16, - /**< fragment mbuf */ + /// < fragment mbuf pub mb: *mut rte_mbuf, } #[test] @@ -57,15 +57,15 @@ impl Clone for ip_frag { impl Default for ip_frag { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } -/** @internal to uniquely indetify fragmented datagram. */ +/// @internal to uniquely indetify fragmented datagram. #[repr(C)] #[derive(Debug, Default, Copy)] pub struct ip_frag_key { - /**< src address, first 8 bytes used for IPv4 */ + /// < src address, first 8 bytes used for IPv4 pub src_dst: [u64; 4usize], - /**< dst address */ + /// < dst address pub id: u32, - /**< src/dst key length */ + /// < src/dst key length pub key_len: u32, } #[test] @@ -93,26 +93,24 @@ fn bindgen_test_layout_ip_frag_key() { impl Clone for ip_frag_key { fn clone(&self) -> Self { *self } } -/** - * @internal Fragmented packet to reassemble. - * First two entries in the frags[] array are for the last and first fragments. - */ +/// @internal Fragmented packet to reassemble. +/// First two entries in the frags[] array are for the last and first fragments. #[repr(C)] #[derive(Debug, Copy)] pub struct ip_frag_pkt { - /**< LRU list */ + /// < LRU list pub lru: ip_frag_pkt__bindgen_ty_1, - /**< fragmentation key */ + /// < fragmentation key pub key: ip_frag_key, - /**< creation timestamp */ + /// < creation timestamp pub start: u64, - /**< expected reassembled size */ + /// < expected reassembled size pub total_size: u32, - /**< size of fragments received */ + /// < size of fragments received pub frag_size: u32, - /**< index of next entry to fill */ + /// < index of next entry to fill pub last_idx: u32, - /**< fragments */ + /// < fragments pub frags: [ip_frag; 4usize], pub __bindgen_padding_0: [u64; 6usize], } @@ -196,7 +194,7 @@ impl Clone for ip_frag_pkt { impl Default for ip_frag_pkt { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } -/**< fragment mbuf */ +/// < fragment mbuf #[repr(C)] #[derive(Debug, Default, Copy)] pub struct rte_mbuf { diff --git a/tests/expectations/tests/layout_cmdline_token.rs b/tests/expectations/tests/layout_cmdline_token.rs index a6113a34a4..94968579af 100644 --- a/tests/expectations/tests/layout_cmdline_token.rs +++ b/tests/expectations/tests/layout_cmdline_token.rs @@ -4,10 +4,8 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -/** - * Stores a pointer to the ops struct, and the offset: the place to - * write the parsed result in the destination structure. - */ +/// Stores a pointer to the ops struct, and the offset: the place to +/// write the parsed result in the destination structure. #[repr(C)] #[derive(Debug, Copy)] pub struct cmdline_token_hdr { @@ -38,29 +36,27 @@ impl Default for cmdline_token_hdr { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } pub type cmdline_parse_token_hdr_t = cmdline_token_hdr; -/** - * A token is defined by this structure. - * - * parse() takes the token as first argument, then the source buffer - * starting at the token we want to parse. The 3rd arg is a pointer - * where we store the parsed data (as binary). It returns the number of - * parsed chars on success and a negative value on error. - * - * complete_get_nb() returns the number of possible values for this - * token if completion is possible. If it is NULL or if it returns 0, - * no completion is possible. - * - * complete_get_elt() copy in dstbuf (the size is specified in the - * parameter) the i-th possible completion for this token. returns 0 - * on success or and a negative value on error. - * - * get_help() fills the dstbuf with the help for the token. It returns - * -1 on error and 0 on success. - */ +/// A token is defined by this structure. +/// +/// parse() takes the token as first argument, then the source buffer +/// starting at the token we want to parse. The 3rd arg is a pointer +/// where we store the parsed data (as binary). It returns the number of +/// parsed chars on success and a negative value on error. +/// +/// complete_get_nb() returns the number of possible values for this +/// token if completion is possible. If it is NULL or if it returns 0, +/// no completion is possible. +/// +/// complete_get_elt() copy in dstbuf (the size is specified in the +/// parameter) the i-th possible completion for this token. returns 0 +/// on success or and a negative value on error. +/// +/// get_help() fills the dstbuf with the help for the token. It returns +/// -1 on error and 0 on success. #[repr(C)] #[derive(Debug, Copy)] pub struct cmdline_token_ops { - /** parse(token ptr, buf, res pts, buf len) */ + /// parse(token ptr, buf, res pts, buf len) pub parse: ::std::option::Option ::std::os::raw::c_int>, - /** return the num of possible choices for this token */ + /// return the num of possible choices for this token pub complete_get_nb: ::std::option::Option ::std::os::raw::c_int>, - /** return the elt x for this token (token, idx, dstbuf, size) */ + /// return the elt x for this token (token, idx, dstbuf, size) pub complete_get_elt: ::std::option::Option ::std::os::raw::c_int>, - /** get help for this token (token, dstbuf, size) */ + /// get help for this token (token, dstbuf, size) pub get_help: ::std::option::Option Self { unsafe { ::std::mem::zeroed() } } } #[repr(u32)] -/** - * This enum indicates the possible number of traffic classes - * in DCB configratioins - */ +/// This enum indicates the possible number of traffic classes +/// in DCB configratioins #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_nb_tcs { ETH_4_TCS = 4, ETH_8_TCS = 8, } #[repr(u32)] -/** - * This enum indicates the possible number of queue pools - * in VMDQ configurations. - */ +/// This enum indicates the possible number of queue pools +/// in VMDQ configurations. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_nb_pools { ETH_8_POOLS = 8, @@ -731,37 +717,35 @@ pub enum rte_eth_nb_pools { ETH_32_POOLS = 32, ETH_64_POOLS = 64, } -/** - * A structure used to configure the VMDQ+DCB feature - * of an Ethernet port. - * - * Using this feature, packets are routed to a pool of queues, based - * on the vlan id in the vlan tag, and then to a specific queue within - * that pool, using the user priority vlan tag field. - * - * A default pool may be used, if desired, to route all traffic which - * does not match the vlan filter rules. - */ +/// A structure used to configure the VMDQ+DCB feature +/// of an Ethernet port. +/// +/// Using this feature, packets are routed to a pool of queues, based +/// on the vlan id in the vlan tag, and then to a specific queue within +/// that pool, using the user priority vlan tag field. +/// +/// A default pool may be used, if desired, to route all traffic which +/// does not match the vlan filter rules. #[repr(C)] pub struct rte_eth_vmdq_dcb_conf { - /**< With DCB, 16 or 32 pools */ + /// < With DCB, 16 or 32 pools pub nb_queue_pools: rte_eth_nb_pools, - /**< If non-zero, use a default pool */ + /// < If non-zero, use a default pool pub enable_default_pool: u8, - /**< The default pool, if applicable */ + /// < The default pool, if applicable pub default_pool: u8, - /**< We can have up to 64 filters/mappings */ + /// < We can have up to 64 filters/mappings pub nb_pool_maps: u8, - /**< VMDq vlan pool maps. */ + /// < 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)] pub struct rte_eth_vmdq_dcb_conf__bindgen_ty_1 { - /**< The vlan id of the received frame */ + /// < The vlan id of the received frame pub vlan_id: u16, - /**< Bitmask of pools for packet rx */ + /// < Bitmask of pools for packet rx pub pools: u64, } #[test] @@ -836,9 +820,9 @@ impl Default for rte_eth_vmdq_dcb_conf { #[repr(C)] #[derive(Debug, Copy)] pub struct rte_eth_dcb_rx_conf { - /**< Possible DCB TCs, 4 or 8 TCs */ + /// < Possible DCB TCs, 4 or 8 TCs pub nb_tcs: rte_eth_nb_tcs, - /** Traffic class each UP mapped to. */ + /// Traffic class each UP mapped to. pub dcb_tc: [u8; 8usize], } #[test] @@ -868,9 +852,9 @@ impl Default for rte_eth_dcb_rx_conf { #[repr(C)] #[derive(Debug, Copy)] pub struct rte_eth_vmdq_dcb_tx_conf { - /**< With DCB, 16 or 32 pools. */ + /// < With DCB, 16 or 32 pools. pub nb_queue_pools: rte_eth_nb_pools, - /** Traffic class each UP mapped to. */ + /// Traffic class each UP mapped to. pub dcb_tc: [u8; 8usize], } #[test] @@ -902,9 +886,9 @@ impl Default for rte_eth_vmdq_dcb_tx_conf { #[repr(C)] #[derive(Debug, Copy)] pub struct rte_eth_dcb_tx_conf { - /**< Possible DCB TCs, 4 or 8 TCs. */ + /// < Possible DCB TCs, 4 or 8 TCs. pub nb_tcs: rte_eth_nb_tcs, - /** Traffic class each UP mapped to. */ + /// Traffic class each UP mapped to. pub dcb_tc: [u8; 8usize], } #[test] @@ -934,7 +918,7 @@ impl Default for rte_eth_dcb_tx_conf { #[repr(C)] #[derive(Debug, Copy)] pub struct rte_eth_vmdq_tx_conf { - /**< VMDq mode, 64 pools. */ + /// < VMDq mode, 64 pools. pub nb_queue_pools: rte_eth_nb_pools, } #[test] @@ -958,27 +942,27 @@ impl Default for rte_eth_vmdq_tx_conf { } #[repr(C)] pub struct rte_eth_vmdq_rx_conf { - /**< VMDq only mode, 8 or 64 pools */ + /// < VMDq only mode, 8 or 64 pools pub nb_queue_pools: rte_eth_nb_pools, - /**< If non-zero, use a default pool */ + /// < If non-zero, use a default pool pub enable_default_pool: u8, - /**< The default pool, if applicable */ + /// < The default pool, if applicable pub default_pool: u8, - /**< Enable VT loop back */ + /// < Enable VT loop back pub enable_loop_back: u8, - /**< We can have up to 64 filters/mappings */ + /// < We can have up to 64 filters/mappings pub nb_pool_maps: u8, - /**< Flags from ETH_VMDQ_ACCEPT_* */ + /// < Flags from ETH_VMDQ_ACCEPT_* pub rx_mode: u32, - /**< VMDq vlan pool maps. */ + /// < VMDq vlan pool maps. pub pool_map: [rte_eth_vmdq_rx_conf__bindgen_ty_1; 64usize], } #[repr(C)] #[derive(Debug, Default, Copy)] pub struct rte_eth_vmdq_rx_conf__bindgen_ty_1 { - /**< The vlan id of the received frame */ + /// < The vlan id of the received frame pub vlan_id: u16, - /**< Bitmask of pools for packet rx */ + /// < Bitmask of pools for packet rx pub pools: u64, } #[test] @@ -1056,9 +1040,7 @@ impl Default for rte_eth_vmdq_rx_conf { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(u32)] -/** - * Flow Director setting modes: none, signature or perfect. - */ +/// Flow Director setting modes: none, signature or perfect. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_fdir_mode { RTE_FDIR_MODE_NONE = 0, @@ -1068,10 +1050,8 @@ pub enum rte_fdir_mode { RTE_FDIR_MODE_PERFECT_TUNNEL = 4, } #[repr(u32)] -/** - * Memory space that can be configured to store Flow Director filters - * in the board memory. - */ +/// Memory space that can be configured to store Flow Director filters +/// in the board memory. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_fdir_pballoc_type { RTE_FDIR_PBALLOC_64K = 0, @@ -1079,30 +1059,26 @@ pub enum rte_fdir_pballoc_type { RTE_FDIR_PBALLOC_256K = 2, } #[repr(u32)] -/** - * Select report mode of FDIR hash information in RX descriptors. - */ +/// Select report mode of FDIR hash information in RX descriptors. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_fdir_status_mode { RTE_FDIR_NO_REPORT_STATUS = 0, RTE_FDIR_REPORT_STATUS = 1, RTE_FDIR_REPORT_STATUS_ALWAYS = 2, } -/** - * A structure used to define the input for IPV4 flow - */ +/// A structure used to define the input for IPV4 flow #[repr(C)] #[derive(Debug, Default, Copy)] pub struct rte_eth_ipv4_flow { - /**< IPv4 source address in big endian. */ + /// < IPv4 source address in big endian. pub src_ip: u32, - /**< IPv4 destination address in big endian. */ + /// < IPv4 destination address in big endian. pub dst_ip: u32, - /**< Type of service to match. */ + /// < Type of service to match. pub tos: u8, - /**< Time to live to match. */ + /// < Time to live to match. pub ttl: u8, - /**< Protocol, next header in big endian. */ + /// < Protocol, next header in big endian. pub proto: u8, } #[test] @@ -1140,21 +1116,19 @@ fn bindgen_test_layout_rte_eth_ipv4_flow() { impl Clone for rte_eth_ipv4_flow { fn clone(&self) -> Self { *self } } -/** - * A structure used to define the input for IPV6 flow - */ +/// A structure used to define the input for IPV6 flow #[repr(C)] #[derive(Debug, Default, Copy)] pub struct rte_eth_ipv6_flow { - /**< IPv6 source address in big endian. */ + /// < IPv6 source address in big endian. pub src_ip: [u32; 4usize], - /**< IPv6 destination address in big endian. */ + /// < IPv6 destination address in big endian. pub dst_ip: [u32; 4usize], - /**< Traffic class to match. */ + /// < Traffic class to match. pub tc: u8, - /**< Protocol, next header to match. */ + /// < Protocol, next header to match. pub proto: u8, - /**< Hop limits to match. */ + /// < Hop limits to match. pub hop_limits: u8, } #[test] @@ -1192,30 +1166,28 @@ fn bindgen_test_layout_rte_eth_ipv6_flow() { 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. - */ +/// 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)] pub struct rte_eth_fdir_masks { - /**< Bit mask for vlan_tci in big endian */ + /// < Bit mask for vlan_tci in big endian pub vlan_tci_mask: u16, - /** Bit mask for ipv4 flow in big endian. */ + /// Bit mask for ipv4 flow in big endian. pub ipv4_mask: rte_eth_ipv4_flow, - /** Bit maks for ipv6 flow in big endian. */ + /// Bit maks for ipv6 flow in big endian. pub ipv6_mask: rte_eth_ipv6_flow, - /** Bit mask for L4 source port in big endian. */ + /// Bit mask for L4 source port in big endian. pub src_port_mask: u16, - /** Bit mask for L4 destination port in big endian. */ + /// 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 */ + /// 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. */ + /// Bit mask for tunnel ID in big endian. pub tunnel_id_mask: u32, - /**< 1 - Match tunnel type, - 0 - Ignore tunnel type. */ + /// < 1 - Match tunnel type, +/// 0 - Ignore tunnel type. pub tunnel_type_mask: u8, } #[test] @@ -1270,9 +1242,7 @@ impl Clone for rte_eth_fdir_masks { fn clone(&self) -> Self { *self } } #[repr(u32)] -/** - * Payload type - */ +/// Payload type #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_payload_type { RTE_ETH_PAYLOAD_UNKNOWN = 0, @@ -1282,14 +1252,12 @@ pub enum rte_eth_payload_type { 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 - */ +/// A structure used to select bytes extracted from the protocol layers to +/// flexible payload for filter #[repr(C)] #[derive(Debug, Copy)] pub struct rte_eth_flex_payload_cfg { - /**< Payload type */ + /// < Payload type pub type_: rte_eth_payload_type, pub src_offset: [u16; 16usize], } @@ -1319,10 +1287,8 @@ impl Clone for rte_eth_flex_payload_cfg { impl Default for rte_eth_flex_payload_cfg { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } -/** - * A structure used to define FDIR masks for flexible payload - * for each flow type - */ +/// A structure used to define FDIR masks for flexible payload +/// for each flow type #[repr(C)] #[derive(Debug, Default, Copy)] pub struct rte_eth_fdir_flex_mask { @@ -1351,16 +1317,14 @@ fn bindgen_test_layout_rte_eth_fdir_flex_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 - */ +/// A structure used to define all flexible payload related setting +/// include flex payload and flex mask #[repr(C)] #[derive(Debug, Copy)] pub struct rte_eth_fdir_flex_conf { - /**< The number of following payload cfg */ + /// < The number of following payload cfg pub nb_payloads: u16, - /**< The number of following mask */ + /// < 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], @@ -1400,22 +1364,20 @@ impl Clone for rte_eth_fdir_flex_conf { impl Default for rte_eth_fdir_flex_conf { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } -/** - * A structure used to configure the Flow Director (FDIR) feature - * of an Ethernet port. - * - * If mode is RTE_FDIR_DISABLE, the pballoc value is ignored. - */ +/// A structure used to configure the Flow Director (FDIR) feature +/// of an Ethernet port. +/// +/// If mode is RTE_FDIR_DISABLE, the pballoc value is ignored. #[repr(C)] #[derive(Debug, Copy)] pub struct rte_fdir_conf { - /**< Flow Director mode. */ + /// < Flow Director mode. pub mode: rte_fdir_mode, - /**< Space for FDIR filters. */ + /// < Space for FDIR filters. pub pballoc: rte_fdir_pballoc_type, - /**< How to report FDIR hash. */ + /// < How to report FDIR hash. pub status: rte_fdir_status_mode, - /** RX queue of packets matching a "drop" filter in perfect 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, @@ -1463,15 +1425,13 @@ impl Clone for rte_fdir_conf { impl Default for rte_fdir_conf { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } -/** - * A structure used to enable/disable specific device interrupts. - */ +/// A structure used to enable/disable specific device interrupts. #[repr(C)] #[derive(Debug, Default, Copy)] pub struct rte_intr_conf { - /** enable/disable lsc interrupt. 0 (default) - disable, 1 enable */ + /// enable/disable lsc interrupt. 0 (default) - disable, 1 enable pub lsc: u16, - /** enable/disable rxq interrupt. 0 (default) - disable, 1 enable */ + /// enable/disable rxq interrupt. 0 (default) - disable, 1 enable pub rxq: u16, } #[test] @@ -1494,46 +1454,44 @@ fn bindgen_test_layout_rte_intr_conf() { 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. - */ +/// A structure used to configure an Ethernet port. +/// Depending upon the RX multi-queue mode, extra advanced +/// configuration settings may be needed. #[repr(C)] pub struct rte_eth_conf { - /**< bitmap of ETH_LINK_SPEED_XXX of speeds to be - used. ETH_LINK_SPEED_FIXED disables link - autonegotiation, and a unique speed shall be - set. Otherwise, the bitmap defines the set of - speeds to be advertised. If the special value - ETH_LINK_SPEED_AUTONEG (0) is used, all speeds - supported are advertised. */ + /// < 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. */ + /// < Port RX configuration. pub rxmode: rte_eth_rxmode, - /**< Port TX configuration. */ + /// < 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. */ + /// < 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). */ + /// < Port RX filtering configuration (union). pub rx_adv_conf: rte_eth_conf__bindgen_ty_1, - /**< Port TX DCB configuration (union). */ + /// < 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. */ + /// 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. */ + /// < FDIR configuration. pub fdir_conf: rte_fdir_conf, - /**< Interrupt mode configuration. */ + /// < Interrupt mode configuration. pub intr_conf: rte_intr_conf, } #[repr(C)] pub struct rte_eth_conf__bindgen_ty_1 { - /**< Port RSS configuration */ + /// < 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, diff --git a/tests/expectations/tests/layout_kni_mbuf.rs b/tests/expectations/tests/layout_kni_mbuf.rs index 556afcc2a2..f86fee5726 100644 --- a/tests/expectations/tests/layout_kni_mbuf.rs +++ b/tests/expectations/tests/layout_kni_mbuf.rs @@ -12,18 +12,18 @@ pub struct rte_kni_mbuf { pub buf_addr: *mut ::std::os::raw::c_void, pub buf_physaddr: u64, pub pad0: [::std::os::raw::c_char; 2usize], - /**< Start address of data in segment buffer. */ + /// < Start address of data in segment buffer. pub data_off: u16, pub pad1: [::std::os::raw::c_char; 2usize], - /**< Number of segments. */ + /// < Number of segments. pub nb_segs: u8, pub pad4: [::std::os::raw::c_char; 1usize], - /**< Offload features. */ + /// < Offload features. pub ol_flags: u64, pub pad2: [::std::os::raw::c_char; 4usize], - /**< Total pkt len: sum of all segment data_len. */ + /// < Total pkt len: sum of all segment data_len. pub pkt_len: u32, - /**< Amount of data in segment buffer. */ + /// < Amount of data in segment buffer. pub data_len: u16, pub __bindgen_padding_0: [u8; 22usize], pub pad3: [::std::os::raw::c_char; 8usize], diff --git a/tests/expectations/tests/layout_large_align_field.rs b/tests/expectations/tests/layout_large_align_field.rs index 098686898d..40de09d3b0 100644 --- a/tests/expectations/tests/layout_large_align_field.rs +++ b/tests/expectations/tests/layout_large_align_field.rs @@ -51,15 +51,15 @@ pub enum _bindgen_ty_1 { IP_MIN_FRAG_NUM = 2, IP_MAX_FRAG_NUM = 4, } -/** @internal fragmented mbuf */ +/// @internal fragmented mbuf #[repr(C)] #[derive(Debug, Copy)] pub struct ip_frag { - /**< offset into the packet */ + /// < offset into the packet pub ofs: u16, - /**< length of fragment */ + /// < length of fragment pub len: u16, - /**< fragment mbuf */ + /// < fragment mbuf pub mb: *mut rte_mbuf, } #[test] @@ -90,15 +90,15 @@ impl Clone for ip_frag { impl Default for ip_frag { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } -/** @internal to uniquely indetify fragmented datagram. */ +/// @internal to uniquely indetify fragmented datagram. #[repr(C)] #[derive(Debug, Default, Copy)] pub struct ip_frag_key { - /**< src address, first 8 bytes used for IPv4 */ + /// < src address, first 8 bytes used for IPv4 pub src_dst: [u64; 4usize], - /**< dst address */ + /// < dst address pub id: u32, - /**< src/dst key length */ + /// < src/dst key length pub key_len: u32, } #[test] @@ -126,26 +126,24 @@ fn bindgen_test_layout_ip_frag_key() { impl Clone for ip_frag_key { fn clone(&self) -> Self { *self } } -/** - * @internal Fragmented packet to reassemble. - * First two entries in the frags[] array are for the last and first fragments. - */ +/// @internal Fragmented packet to reassemble. +/// First two entries in the frags[] array are for the last and first fragments. #[repr(C)] #[derive(Debug, Copy)] pub struct ip_frag_pkt { - /**< LRU list */ + /// < LRU list pub lru: ip_frag_pkt__bindgen_ty_1, - /**< fragmentation key */ + /// < fragmentation key pub key: ip_frag_key, - /**< creation timestamp */ + /// < creation timestamp pub start: u64, - /**< expected reassembled size */ + /// < expected reassembled size pub total_size: u32, - /**< size of fragments received */ + /// < size of fragments received pub frag_size: u32, - /**< index of next entry to fill */ + /// < index of next entry to fill pub last_idx: u32, - /**< fragments */ + /// < fragments pub frags: [ip_frag; 4usize], pub __bindgen_padding_0: [u64; 6usize], } @@ -258,21 +256,21 @@ impl Clone for ip_pkt_list { impl Default for ip_pkt_list { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } -/** fragmentation table statistics */ +/// fragmentation table statistics #[repr(C)] #[derive(Debug, Default, Copy)] pub struct ip_frag_tbl_stat { - /**< total # of find/insert attempts. */ + /// < total # of find/insert attempts. pub find_num: u64, - /**< # of add ops. */ + /// < # of add ops. pub add_num: u64, - /**< # of del ops. */ + /// < # of del ops. pub del_num: u64, - /**< # of reuse (del/add) ops. */ + /// < # of reuse (del/add) ops. pub reuse_num: u64, - /**< total # of add failures. */ + /// < total # of add failures. pub fail_total: u64, - /**< # of 'no space' add failures. */ + /// < # of 'no space' add failures. pub fail_nospace: u64, pub __bindgen_padding_0: [u64; 2usize], } @@ -314,32 +312,32 @@ fn bindgen_test_layout_ip_frag_tbl_stat() { impl Clone for ip_frag_tbl_stat { fn clone(&self) -> Self { *self } } -/** fragmentation table */ +/// fragmentation table #[repr(C)] #[derive(Debug, Copy)] pub struct rte_ip_frag_tbl { - /**< ttl for table entries. */ + /// < ttl for table entries. pub max_cycles: u64, - /**< hash value mask. */ + /// < hash value mask. pub entry_mask: u32, - /**< max entries allowed. */ + /// < max entries allowed. pub max_entries: u32, - /**< entries in use. */ + /// < entries in use. pub use_entries: u32, - /**< hash assocaitivity. */ + /// < hash assocaitivity. pub bucket_entries: u32, - /**< total size of the table. */ + /// < total size of the table. pub nb_entries: u32, - /**< num of associativity lines. */ + /// < num of associativity lines. pub nb_buckets: u32, - /**< last used entry. */ + /// < last used entry. pub last: *mut ip_frag_pkt, - /**< LRU list for table entries. */ + /// < LRU list for table entries. pub lru: ip_pkt_list, pub __bindgen_padding_0: u64, - /**< statistics counters. */ + /// < statistics counters. pub stat: ip_frag_tbl_stat, - /**< hash table. */ + /// < hash table. pub pkt: __IncompleteArrayField, } #[test] @@ -408,7 +406,7 @@ impl Clone for rte_ip_frag_tbl { impl Default for rte_ip_frag_tbl { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } -/**< fragment mbuf */ +/// < fragment mbuf #[repr(C)] #[derive(Debug, Default, Copy)] pub struct rte_mbuf { diff --git a/tests/expectations/tests/layout_mbuf.rs b/tests/expectations/tests/layout_mbuf.rs index d0598e628b..e527ac9252 100644 --- a/tests/expectations/tests/layout_mbuf.rs +++ b/tests/expectations/tests/layout_mbuf.rs @@ -34,13 +34,11 @@ 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. - */ +/// The atomic counter structure. #[repr(C)] #[derive(Debug, Default, Copy)] pub struct rte_atomic16_t { - /**< An internal counter value. */ + /// < An internal counter value. pub cnt: i16, } #[test] @@ -58,70 +56,66 @@ fn bindgen_test_layout_rte_atomic16_t() { impl Clone for rte_atomic16_t { fn clone(&self) -> Self { *self } } -/** - * The generic rte_mbuf, containing a packet mbuf. - */ +/// The generic rte_mbuf, containing a packet mbuf. #[repr(C)] #[derive(Debug, Copy)] pub struct rte_mbuf { pub cacheline0: MARKER, - /**< Virtual address of segment buffer. */ + /// < Virtual address of segment buffer. pub buf_addr: *mut ::std::os::raw::c_void, - /**< Physical address of segment buffer. */ + /// < Physical address of segment buffer. pub buf_physaddr: phys_addr_t, - /**< Length of segment buffer. */ + /// < 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. */ + /// < Number of segments. pub nb_segs: u8, - /**< Input port. */ + /// < Input port. pub port: u8, - /**< Offload features. */ + /// < 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. */ + /// < Total pkt len: sum of all segments. pub pkt_len: u32, - /**< Amount of data in segment buffer. */ + /// < Amount of data in segment buffer. pub data_len: u16, - /** VLAN TCI (CPU order), valid if PKT_RX_VLAN_STRIPPED is set. */ + /// VLAN TCI (CPU order), valid if PKT_RX_VLAN_STRIPPED is set. pub vlan_tci: u16, - /**< hash information */ + /// < hash information pub hash: rte_mbuf__bindgen_ty_3, - /**< Sequence number. See also rte_reorder_insert() */ + /// < Sequence number. See also rte_reorder_insert() pub seqn: u32, - /** Outer VLAN TCI (CPU order), valid if PKT_RX_QINQ_STRIPPED is set. */ + /// 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. */ + /// < Pool from which mbuf was allocated. pub pool: *mut rte_mempool, - /**< Next segment of scattered packet. */ + /// < 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. */ + /// 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. */ + /// 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. - */ +/// 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)] pub struct rte_mbuf__bindgen_ty_1 { - /**< Atomically accessed refcnt */ + /// < Atomically accessed refcnt pub refcnt_atomic: __BindgenUnionField, - /**< Non-atomically accessed refcnt */ + /// < Non-atomically accessed refcnt pub refcnt: __BindgenUnionField, pub bindgen_union_field: u16, } @@ -150,7 +144,7 @@ impl Clone for rte_mbuf__bindgen_ty_1 { #[repr(C)] #[derive(Debug, Default, Copy)] pub struct rte_mbuf__bindgen_ty_2 { - /**< L2/L3/L4 and tunnel information. */ + /// < L2/L3/L4 and tunnel information. pub packet_type: __BindgenUnionField, pub __bindgen_anon_1: __BindgenUnionField, pub bindgen_union_field: u32, @@ -481,13 +475,13 @@ impl Clone for rte_mbuf__bindgen_ty_2 { #[repr(C)] #[derive(Debug, Default, Copy)] pub struct rte_mbuf__bindgen_ty_3 { - /**< RSS hash result if RSS enabled */ + /// < RSS hash result if RSS enabled pub rss: __BindgenUnionField, - /**< Filter identifier if FDIR enabled */ + /// < Filter identifier if FDIR enabled pub fdir: __BindgenUnionField, - /**< Hierarchical scheduler */ + /// < Hierarchical scheduler pub sched: __BindgenUnionField, - /**< User defined tags. See rte_distributor_process() */ + /// < User defined tags. See rte_distributor_process() pub usr: __BindgenUnionField, pub bindgen_union_field: [u32; 2usize], } @@ -655,9 +649,9 @@ impl Clone for rte_mbuf__bindgen_ty_3 { #[repr(C)] #[derive(Debug, Default, Copy)] pub struct rte_mbuf__bindgen_ty_4 { - /**< Can be used for external metadata */ + /// < Can be used for external metadata pub userdata: __BindgenUnionField<*mut ::std::os::raw::c_void>, - /**< Allow 8-byte userdata on 32-bit */ + /// < Allow 8-byte userdata on 32-bit pub udata64: __BindgenUnionField, pub bindgen_union_field: u64, } @@ -686,7 +680,7 @@ impl Clone for rte_mbuf__bindgen_ty_4 { #[repr(C)] #[derive(Debug, Default, Copy)] pub struct rte_mbuf__bindgen_ty_5 { - /**< combined for easy fetch */ + /// < combined for easy fetch pub tx_offload: __BindgenUnionField, pub __bindgen_anon_1: __BindgenUnionField, pub bindgen_union_field: u64, @@ -1090,7 +1084,7 @@ impl Clone for rte_mbuf { impl Default for rte_mbuf { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } -/**< Pool from which mbuf was allocated. */ +/// < Pool from which mbuf was allocated. #[repr(C)] #[derive(Debug, Default, Copy)] pub struct rte_mempool { diff --git a/tests/expectations/tests/no-derive-debug.rs b/tests/expectations/tests/no-derive-debug.rs index da320e7ef9..0de55fabe0 100644 --- a/tests/expectations/tests/no-derive-debug.rs +++ b/tests/expectations/tests/no-derive-debug.rs @@ -5,11 +5,9 @@ #[repr(C)] #[derive(Copy, Clone, Default)] pub struct foo { bar: ::std::os::raw::c_int, } -/** - * bar should compile. It will normally derive debug, but our blacklist of foo - * and replacement for another type that doesn't implement it would prevent it - * from building if --no-derive-debug didn't work. - */ +/// bar should compile. It will normally derive debug, but our blacklist of foo +/// and replacement for another type that doesn't implement it would prevent it +/// from building if --no-derive-debug didn't work. #[repr(C)] #[derive(Default, Copy)] pub struct bar { diff --git a/tests/expectations/tests/no-derive-default.rs b/tests/expectations/tests/no-derive-default.rs index 544c29e350..c212f4bda1 100644 --- a/tests/expectations/tests/no-derive-default.rs +++ b/tests/expectations/tests/no-derive-default.rs @@ -5,11 +5,9 @@ #[repr(C)] #[derive(Copy, Clone, Debug)] pub struct foo { bar: ::std::os::raw::c_int, } -/** - * bar should compile. It will normally derive default, but our blacklist of foo - * and replacement for another type that doesn't implement it would prevent it - * from building if --no-derive-default didn't work. - */ +/// bar should compile. It will normally derive default, but our blacklist of foo +/// and replacement for another type that doesn't implement it would prevent it +/// from building if --no-derive-default didn't work. #[repr(C)] #[derive(Debug, Copy)] pub struct bar { diff --git a/tests/expectations/tests/no_copy.rs b/tests/expectations/tests/no_copy.rs index 0560c37ed1..ca28bdeb0a 100644 --- a/tests/expectations/tests/no_copy.rs +++ b/tests/expectations/tests/no_copy.rs @@ -4,7 +4,7 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -/**
*/ +///
#[repr(C)] #[derive(Debug, Default)] pub struct CopiableButWait { diff --git a/tests/expectations/tests/opaque_in_struct.rs b/tests/expectations/tests/opaque_in_struct.rs index 9ca0b667d3..d41cbf10a9 100644 --- a/tests/expectations/tests/opaque_in_struct.rs +++ b/tests/expectations/tests/opaque_in_struct.rs @@ -4,7 +4,7 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -/**
*/ +///
#[repr(C)] #[derive(Debug, Default, Copy)] pub struct opaque { diff --git a/tests/expectations/tests/opaque_pointer.rs b/tests/expectations/tests/opaque_pointer.rs index 1222b37491..68f8132d89 100644 --- a/tests/expectations/tests/opaque_pointer.rs +++ b/tests/expectations/tests/opaque_pointer.rs @@ -4,9 +4,7 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -/** - *
- */ +///
#[repr(C)] #[derive(Debug, Default, Copy)] pub struct OtherOpaque { @@ -22,9 +20,7 @@ fn bindgen_test_layout_OtherOpaque() { impl Clone for OtherOpaque { fn clone(&self) -> Self { *self } } -/** - *
- */ +///
#[repr(C)] #[derive(Debug, Copy, Clone)] pub struct Opaque { diff --git a/tests/expectations/tests/opaque_typedef.rs b/tests/expectations/tests/opaque_typedef.rs index 3174285496..a19a71acf3 100644 --- a/tests/expectations/tests/opaque_typedef.rs +++ b/tests/expectations/tests/opaque_typedef.rs @@ -9,6 +9,6 @@ pub struct RandomTemplate { pub _address: u8, } -/**
*/ +///
pub type ShouldBeOpaque = u8; pub type ShouldNotBeOpaque = RandomTemplate; diff --git a/tests/expectations/tests/private.rs b/tests/expectations/tests/private.rs index 301ce23097..e29ad1ba57 100644 --- a/tests/expectations/tests/private.rs +++ b/tests/expectations/tests/private.rs @@ -8,7 +8,7 @@ #[derive(Debug, Default, Copy)] pub struct HasPrivate { pub mNotPrivate: ::std::os::raw::c_int, - /**
*/ + ///
mIsPrivate: ::std::os::raw::c_int, } #[test] @@ -31,7 +31,7 @@ fn bindgen_test_layout_HasPrivate() { impl Clone for HasPrivate { fn clone(&self) -> Self { *self } } -/**
*/ +///
#[repr(C)] #[derive(Debug, Default, Copy)] pub struct VeryPrivate { @@ -58,11 +58,11 @@ fn bindgen_test_layout_VeryPrivate() { impl Clone for VeryPrivate { fn clone(&self) -> Self { *self } } -/**
*/ +///
#[repr(C)] #[derive(Debug, Default, Copy)] pub struct ContradictPrivate { - /**
*/ + ///
pub mNotPrivate: ::std::os::raw::c_int, mIsPrivate: ::std::os::raw::c_int, } diff --git a/tests/expectations/tests/replace_use.rs b/tests/expectations/tests/replace_use.rs index 4d31353049..cbbee381c2 100644 --- a/tests/expectations/tests/replace_use.rs +++ b/tests/expectations/tests/replace_use.rs @@ -4,9 +4,7 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -/** - *
- */ +///
#[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct nsTArray { diff --git a/tests/expectations/tests/replaces_double.rs b/tests/expectations/tests/replaces_double.rs index b2670893d8..7f8127fd65 100644 --- a/tests/expectations/tests/replaces_double.rs +++ b/tests/expectations/tests/replaces_double.rs @@ -20,9 +20,7 @@ pub struct Rooted { pub ptr: Rooted_MaybeWrapped, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -/** - *
- */ +///
pub type Rooted_MaybeWrapped = T; impl Default for Rooted { fn default() -> Self { unsafe { ::std::mem::zeroed() } } diff --git a/tests/expectations/tests/template.rs b/tests/expectations/tests/template.rs index e666ee3809..74dcd99cb4 100644 --- a/tests/expectations/tests/template.rs +++ b/tests/expectations/tests/template.rs @@ -102,7 +102,7 @@ fn bindgen_test_layout_PODButContainsDtor() { impl Default for PODButContainsDtor { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } -/**
*/ +///
#[repr(C)] #[derive(Debug, Copy, Clone)] pub struct Opaque { @@ -130,9 +130,7 @@ fn bindgen_test_layout_POD() { impl Clone for POD { fn clone(&self) -> Self { *self } } -/** - *
- */ +///
#[repr(C)] #[derive(Debug, Copy, Clone)] pub struct NestedReplaced { @@ -191,12 +189,10 @@ impl Clone for Untemplated { pub struct Templated { pub m_untemplated: Untemplated, } -/** - * If the replacement doesn't happen at the parse level the container would be - * copy and the replacement wouldn't, so this wouldn't compile. - * - *
- */ +/// If the replacement doesn't happen at the parse level the container would be +/// copy and the replacement wouldn't, so this wouldn't compile. +/// +///
#[repr(C)] #[derive(Debug)] pub struct ReplacedWithoutDestructor { @@ -224,12 +220,10 @@ pub struct ShouldNotBeCopiableAsWell { impl Default for ShouldNotBeCopiableAsWell { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } -/** - * If the replacement doesn't happen at the parse level the container would be - * copy and the replacement wouldn't, so this wouldn't compile. - * - *
- */ +/// If the replacement doesn't happen at the parse level the container would be +/// copy and the replacement wouldn't, so this wouldn't compile. +/// +///
#[repr(C)] #[derive(Debug)] pub struct ReplacedWithoutDestructorFwd { diff --git a/tests/headers/convert-cpp-comment-to-rust.hpp b/tests/headers/convert-cpp-comment-to-rust.hpp new file mode 100644 index 0000000000..843949b8b6 --- /dev/null +++ b/tests/headers/convert-cpp-comment-to-rust.hpp @@ -0,0 +1,16 @@ +#include +#include + +typedef uint32_t mbedtls_mpi_uint; + +/** + * \brief MPI structure + */ +typedef struct +{ + int s; /*!< integer sign */ + size_t n; /*!< total # of limbs */ + mbedtls_mpi_uint *p; /*!< pointer to limbs */ +} +mbedtls_mpi; +