From beb33cb9a51cb8130b50260fe9bdac2338dffc2a Mon Sep 17 00:00:00 2001 From: drunkirishcoder Date: Mon, 29 Mar 2021 18:37:25 -0400 Subject: [PATCH] general cleanup --- bench/Cargo.toml | 7 +- bench/combinators.rs | 229 - bench/mbuf.rs | 2 +- bench/packets.rs | 6 +- core/Cargo.toml | 24 +- core/src/batch/emit.rs | 56 - core/src/batch/filter.rs | 69 - core/src/batch/filter_map.rs | 82 - core/src/batch/for_each.rs | 63 - core/src/batch/group_by.rs | 207 - core/src/batch/inspect.rs | 61 - core/src/batch/map.rs | 67 - core/src/batch/mod.rs | 736 - core/src/batch/poll.rs | 71 - core/src/batch/replace.rs | 89 - core/src/batch/rxtx.rs | 89 - core/src/batch/send.rs | 151 - core/src/config.rs | 513 - core/src/dpdk/kni.rs | 411 - core/src/dpdk/mempool.rs | 180 - core/src/dpdk/mod.rs | 244 - core/src/dpdk/port.rs | 651 - core/src/dpdk/stats.rs | 130 - core/src/ffi/dpdk.rs | 35 +- core/src/ffi/mod.rs | 4 - core/src/ffi/pcap.rs | 41 +- core/src/lib.rs | 21 +- core/src/metrics.rs | 140 - core/src/net/cidr/v4.rs | 2 +- core/src/net/cidr/v6.rs | 2 +- core/src/packets/arp.rs | 19 +- core/src/packets/ethernet.rs | 11 +- core/src/packets/icmp/v4/echo_reply.rs | 7 +- core/src/packets/icmp/v4/echo_request.rs | 7 +- core/src/packets/icmp/v4/mod.rs | 8 +- core/src/packets/icmp/v4/redirect.rs | 7 +- core/src/packets/icmp/v4/time_exceeded.rs | 7 +- core/src/packets/icmp/v6/echo_reply.rs | 7 +- core/src/packets/icmp/v6/echo_request.rs | 7 +- core/src/packets/icmp/v6/mod.rs | 12 +- core/src/packets/icmp/v6/ndp/mod.rs | 21 +- .../packets/icmp/v6/ndp/neighbor_advert.rs | 7 +- .../packets/icmp/v6/ndp/neighbor_solicit.rs | 7 +- .../icmp/v6/ndp/options/link_layer_addr.rs | 7 +- core/src/packets/icmp/v6/ndp/options/mtu.rs | 7 +- .../icmp/v6/ndp/options/prefix_info.rs | 7 +- .../packets/icmp/v6/ndp/options/redirected.rs | 7 +- core/src/packets/icmp/v6/ndp/redirect.rs | 7 +- core/src/packets/icmp/v6/ndp/router_advert.rs | 7 +- .../src/packets/icmp/v6/ndp/router_solicit.rs | 7 +- core/src/packets/icmp/v6/time_exceeded.rs | 7 +- core/src/packets/icmp/v6/too_big.rs | 7 +- ...tination_unreachable.rs => unreachable.rs} | 7 +- core/src/packets/ip/v4.rs | 23 +- core/src/packets/ip/v6/fragment.rs | 8 +- core/src/packets/ip/v6/mod.rs | 7 +- core/src/packets/ip/v6/srh.rs | 9 +- core/src/{dpdk => packets}/mbuf.rs | 79 +- core/src/packets/mod.rs | 17 +- core/src/packets/size_of.rs | 85 + core/src/packets/tcp.rs | 10 +- core/src/packets/udp.rs | 10 +- core/src/pcap.rs | 340 - core/src/rt2/mod.rs | 234 - core/src/{rt2 => runtime}/config.rs | 12 +- core/src/runtime/core_map.rs | 386 - core/src/{rt2 => runtime}/lcore.rs | 2 +- core/src/{rt2 => runtime}/mempool.rs | 0 core/src/runtime/mod.rs | 718 +- core/src/{rt2 => runtime}/pcap_dump.rs | 7 +- core/src/{rt2 => runtime}/port.rs | 38 +- core/src/testils/criterion.rs | 55 - core/src/testils/mod.rs | 4 +- core/src/testils/packet.rs | 5 +- core/src/testils/proptest/arbitrary.rs | 2 +- core/src/testils/proptest/strategy.rs | 8 +- examples/kni/Cargo.toml | 4 +- examples/kni/README.md | 18 +- examples/kni/main.rs | 8 +- examples/nat64/Cargo.toml | 4 +- examples/nat64/README.md | 34 +- examples/nat64/main.rs | 12 +- examples/ping4d/Cargo.toml | 4 +- examples/ping4d/README.md | 22 +- examples/ping4d/main.rs | 7 +- examples/pktdump/Cargo.toml | 5 +- examples/pktdump/README.md | 2 +- examples/pktdump/main.rs | 19 +- examples/skeleton/Cargo.toml | 4 +- examples/skeleton/main.rs | 4 +- examples/syn-flood/Cargo.toml | 4 +- examples/syn-flood/README.md | 14 +- examples/syn-flood/main.rs | 12 +- ffi/Cargo.toml | 4 +- ffi/build.rs | 6 +- ffi/src/bindings_rustdoc.rs | 32826 ++++++++++------ macros/Cargo.toml | 2 +- macros/src/derive_packet.rs | 2 + macros/src/lib.rs | 2 +- 99 files changed, 21035 insertions(+), 18623 deletions(-) delete mode 100644 bench/combinators.rs delete mode 100644 core/src/batch/emit.rs delete mode 100644 core/src/batch/filter.rs delete mode 100644 core/src/batch/filter_map.rs delete mode 100644 core/src/batch/for_each.rs delete mode 100644 core/src/batch/group_by.rs delete mode 100644 core/src/batch/inspect.rs delete mode 100644 core/src/batch/map.rs delete mode 100644 core/src/batch/mod.rs delete mode 100644 core/src/batch/poll.rs delete mode 100644 core/src/batch/replace.rs delete mode 100644 core/src/batch/rxtx.rs delete mode 100644 core/src/batch/send.rs delete mode 100644 core/src/config.rs delete mode 100644 core/src/dpdk/kni.rs delete mode 100644 core/src/dpdk/mempool.rs delete mode 100644 core/src/dpdk/mod.rs delete mode 100644 core/src/dpdk/port.rs delete mode 100644 core/src/dpdk/stats.rs delete mode 100644 core/src/metrics.rs rename core/src/packets/icmp/v6/{destination_unreachable.rs => unreachable.rs} (98%) rename core/src/{dpdk => packets}/mbuf.rs (91%) create mode 100644 core/src/packets/size_of.rs delete mode 100644 core/src/pcap.rs delete mode 100644 core/src/rt2/mod.rs rename core/src/{rt2 => runtime}/config.rs (98%) delete mode 100644 core/src/runtime/core_map.rs rename core/src/{rt2 => runtime}/lcore.rs (98%) rename core/src/{rt2 => runtime}/mempool.rs (100%) rename core/src/{rt2 => runtime}/pcap_dump.rs (96%) rename core/src/{rt2 => runtime}/port.rs (96%) diff --git a/bench/Cargo.toml b/bench/Cargo.toml index e9d23606..2a4de6b8 100644 --- a/bench/Cargo.toml +++ b/bench/Cargo.toml @@ -11,7 +11,7 @@ Benchmarks for Capsule. [dev-dependencies] anyhow = "1.0" -capsule = { version = "0.1", path = "../core", features = ["testils"] } +capsule = { version = "0.2", path = "../core", features = ["testils"] } criterion = "0.3" proptest = "1.0" @@ -20,11 +20,6 @@ name = "packets" path = "packets.rs" harness = false -[[bench]] -name = "combinators" -path = "combinators.rs" -harness = false - [[bench]] name = "mbuf" path = "mbuf.rs" diff --git a/bench/combinators.rs b/bench/combinators.rs deleted file mode 100644 index 2866bc53..00000000 --- a/bench/combinators.rs +++ /dev/null @@ -1,229 +0,0 @@ -/* -* Copyright 2019 Comcast Cable Communications Management, LLC -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* SPDX-License-Identifier: Apache-2.0 -*/ - -use anyhow::Result; -use capsule::batch::{Batch, Either}; -use capsule::packets::ip::v4::Ipv4; -use capsule::packets::{Ethernet, Packet}; -use capsule::testils::criterion::BencherExt; -use capsule::testils::proptest::*; -use capsule::{compose, Mbuf}; -use criterion::{criterion_group, criterion_main, Criterion}; -use proptest::prelude::*; -use proptest::strategy; - -const BATCH_SIZE: usize = 500; - -fn filter_true(batch: impl Batch) -> impl Batch { - batch.filter(|_p| true) -} - -fn filter_false(batch: impl Batch) -> impl Batch { - batch.filter(|_p| false) -} - -#[capsule::bench(mempool_capacity = 511)] -fn filters_batch(c: &mut Criterion) { - let mut group = c.benchmark_group("combinators::filter"); - - group.bench_function("combinators::filter_true", |b| { - let s = any::(); - b.iter_proptest_combinators(s, filter_true, BATCH_SIZE) - }); - - group.bench_function("combinators::filter_false", |b| { - let s = any::(); - b.iter_proptest_combinators(s, filter_false, BATCH_SIZE) - }); - - group.finish() -} - -fn filter_map(batch: impl Batch) -> impl Batch { - batch.filter_map(|p| { - let ethernet = p.parse::()?; - Ok(Either::Keep(ethernet)) - }) -} - -fn map_then_filter(batch: impl Batch) -> impl Batch { - batch.map(|p| p.parse::()).filter(|_p| true) -} - -#[capsule::bench(mempool_capacity = 511)] -fn filter_map_vs_map_then_filter_batch(c: &mut Criterion) { - let mut group = c.benchmark_group("combinators::filter_map_vs_map_then_filter"); - - group.bench_function("combinators::filter_map", |b| { - let s = v4_udp(); - b.iter_proptest_combinators(s, filter_map, BATCH_SIZE) - }); - - group.bench_function("combinators::map_then_filter", |b| { - let s = v4_udp(); - b.iter_proptest_combinators(s, map_then_filter, BATCH_SIZE) - }); - - group.finish() -} - -fn map(batch: impl Batch) -> impl Batch { - batch.map(|p| p.parse::()) -} - -fn no_batch_map(mbuf: Mbuf) -> Result { - mbuf.parse::() -} - -#[capsule::bench(mempool_capacity = 511)] -fn map_batch_vs_parse(c: &mut Criterion) { - let mut group = c.benchmark_group("combinators::map_batch_vs_parse"); - - group.bench_function("combinators::map", |b| { - let s = v4_udp(); - b.iter_proptest_combinators(s, map, BATCH_SIZE) - }); - - group.bench_function("combinators::no_batch_map", |b| { - let s = v4_udp(); - b.iter_proptest_batched(s, no_batch_map, BATCH_SIZE) - }); -} - -#[capsule::bench(mempool_capacity = 1023)] -fn map_batches(c: &mut Criterion) { - let mut group = c.benchmark_group("combinators::map_on_diff_batch_sizes"); - - group.bench_function("combinators::map_10", |b| { - let s = v4_udp(); - b.iter_proptest_combinators(s, map, 10) - }); - - group.bench_function("combinators::map_50", |b| { - let s = v4_udp(); - b.iter_proptest_combinators(s, map, 50) - }); - - group.bench_function("combinators::map_150", |b| { - let s = v4_udp(); - b.iter_proptest_combinators(s, map, 150) - }); - - group.bench_function("combinators::map_500", |b| { - let s = v4_udp(); - b.iter_proptest_combinators(s, map, 500) - }); - - group.bench_function("combinators::map_1000", |b| { - let s = v4_udp(); - b.iter_proptest_combinators(s, map, 1000) - }); - - group.finish() -} - -fn map_parse_errors(batch: impl Batch) -> impl Batch { - batch.map(|p| p.parse::()?.parse::()) -} - -#[capsule::bench(mempool_capacity = 511)] -fn map_errors(c: &mut Criterion) { - let mut group = c.benchmark_group("combinators::map_errors_vs_no_errors"); - - group.bench_function("combinators::map_no_errors", |b| { - let s = v4_udp(); - b.iter_proptest_combinators(s, map_parse_errors, BATCH_SIZE) - }); - - group.bench_function("combinators::map_with_errors", |b| { - let s = strategy::Union::new_weighted(vec![(8, v4_udp().boxed()), (2, v6_udp().boxed())]); - b.iter_proptest_combinators(s, map_parse_errors, BATCH_SIZE) - }); -} - -static mut COUNTER: u32 = 0; -fn group_by(batch: impl Batch) -> impl Batch { - unsafe { COUNTER += 1 }; - - unsafe { - batch.group_by( - |_p| COUNTER % 2, - |groups| { - compose!(groups { - 0 => |group| { - group - } - _ => |group| { - group - } - }) - }, - ) - } -} - -#[capsule::bench(mempool_capacity = 511)] -fn group_by_batch(c: &mut Criterion) { - c.bench_function("combinators::group_by", |b| { - let s = any::(); - b.iter_proptest_combinators(s, group_by, BATCH_SIZE) - }); -} - -fn replace(batch: impl Batch) -> impl Batch { - batch.replace(|_p| Mbuf::new()) -} - -fn no_batch_replace(_mbuf: Mbuf) -> Result { - Mbuf::new() -} - -#[capsule::bench(mempool_capacity = 511)] -fn replace_batch(c: &mut Criterion) { - let mut group = c.benchmark_group("combinators::replace_with_new_mbuf_vs_create_new_mbuf"); - - group.bench_function("combinators::replace", |b| { - let s = any::(); - b.iter_proptest_combinators(s, replace, BATCH_SIZE) - }); - - group.bench_function("combinators::no_batch_replace", |b| { - let s = any::(); - b.iter_proptest_batched(s, no_batch_replace, BATCH_SIZE) - }); - - group.finish() -} - -fn bench_config() -> Criterion { - Criterion::default().with_plots() -} - -criterion_group! { - name = benches; - config=bench_config(); - targets=filters_batch, - filter_map_vs_map_then_filter_batch, - map_batch_vs_parse, - group_by_batch, - replace_batch, - map_batches, - map_errors, -} - -criterion_main!(benches); diff --git a/bench/mbuf.rs b/bench/mbuf.rs index c8258e02..62f0cebd 100644 --- a/bench/mbuf.rs +++ b/bench/mbuf.rs @@ -17,7 +17,7 @@ */ use anyhow::Result; -use capsule::Mbuf; +use capsule::packets::Mbuf; use criterion::{criterion_group, criterion_main, Criterion}; const BATCH_SIZE: usize = 100; diff --git a/bench/packets.rs b/bench/packets.rs index a7a381c4..61ce7c65 100644 --- a/bench/packets.rs +++ b/bench/packets.rs @@ -17,13 +17,15 @@ */ use anyhow::Result; +use capsule::fieldmap; +use capsule::packets::ethernet::Ethernet; use capsule::packets::ip::v4::Ipv4; use capsule::packets::ip::v6::{Ipv6, SegmentRouting}; -use capsule::packets::{Ethernet, Packet, Udp4}; +use capsule::packets::udp::Udp4; +use capsule::packets::{Mbuf, Packet}; use capsule::testils::criterion::BencherExt; use capsule::testils::proptest::*; use capsule::testils::{PacketExt, Rvg}; -use capsule::{fieldmap, Mbuf}; use criterion::{criterion_group, criterion_main, Criterion}; use proptest::prelude::*; use std::net::Ipv6Addr; diff --git a/core/Cargo.toml b/core/Cargo.toml index abdfe1ac..951da38b 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "capsule" -version = "0.1.5" +version = "0.2.0" authors = ["Capsule Developers "] license = "Apache-2.0" edition = "2018" @@ -23,24 +23,17 @@ doctest = false anyhow = "1.0" async-channel = "1.6" async-executor = "1.4" -capsule-ffi = { version = "0.1.5", path = "../ffi" } -capsule-macros = { version = "0.1.5", path = "../macros" } +capsule-ffi = { version = "0.2.0", path = "../ffi" } +capsule-macros = { version = "0.2.0", path = "../macros" } clap = "2.33" criterion = { version = "0.3", optional = true } -futures-lite = "1.11" -futures-preview = "=0.3.0-alpha.19" +futures-lite = "1.12" libc = "0.2" -metrics-core = { version = "0.5", optional = true } -metrics-runtime = { version = "0.13", optional = true, default-features = false } -once_cell = "1.7" +once_cell = "1.9" proptest = { version = "1.0", optional = true } -regex = "1" +regex = "1.5" serde = { version = "1.0", features = ["derive"] } thiserror = "1.0" -tokio = "=0.2.0-alpha.6" -tokio-executor = { version = "=0.2.0-alpha.6", features = ["current-thread", "threadpool"] } -tokio-net = { version = "=0.2.0-alpha.6", features = ["signal"] } -tokio-timer = "=0.3.0-alpha.6" toml = "0.5" tracing = "0.1" @@ -49,10 +42,9 @@ criterion = "0.3" proptest = { version = "1.0", default-features = false, features = ["default-code-coverage"] } [features] -default = ["metrics"] +default = [] compile_failure = [] # compiler tests to check mutability rules are followed -full = ["metrics", "pcap-dump", "testils"] -metrics = ["metrics-core", "metrics-runtime"] +full = ["pcap-dump", "testils"] pcap-dump = [] testils = ["criterion", "proptest"] diff --git a/core/src/batch/emit.rs b/core/src/batch/emit.rs deleted file mode 100644 index a7c677fd..00000000 --- a/core/src/batch/emit.rs +++ /dev/null @@ -1,56 +0,0 @@ -/* -* Copyright 2019 Comcast Cable Communications Management, LLC -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* SPDX-License-Identifier: Apache-2.0 -*/ - -use super::{Batch, Disposition, PacketTx}; -use crate::packets::Packet; - -/// A batch that transmits the packets through the specified [`PacketTx`]. -/// -/// [`PacketTx`]: crate::batch::PacketTx -#[allow(missing_debug_implementations)] -pub struct Emit { - batch: B, - tx: Tx, -} - -impl Emit { - /// Creates a new `Emit` batch. - #[inline] - pub fn new(batch: B, tx: Tx) -> Self { - Emit { batch, tx } - } -} - -impl Batch for Emit { - type Item = B::Item; - - #[inline] - fn replenish(&mut self) { - self.batch.replenish(); - } - - #[inline] - fn next(&mut self) -> Option> { - self.batch.next().map(|disp| { - disp.map(|pkt| { - self.tx.transmit(vec![pkt.reset()]); - Disposition::Emit - }) - }) - } -} diff --git a/core/src/batch/filter.rs b/core/src/batch/filter.rs deleted file mode 100644 index 119d14a5..00000000 --- a/core/src/batch/filter.rs +++ /dev/null @@ -1,69 +0,0 @@ -/* -* Copyright 2019 Comcast Cable Communications Management, LLC -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* SPDX-License-Identifier: Apache-2.0 -*/ - -use super::{Batch, Disposition}; -use crate::packets::Packet; - -/// A batch that filters the packets of the underlying batch. -/// -/// If the predicate evaluates to `false`, the packet is marked as dropped -/// and will short-circuit the remainder of the pipeline. -#[allow(missing_debug_implementations)] -pub struct Filter -where - P: FnMut(&B::Item) -> bool, -{ - batch: B, - predicate: P, -} - -impl Filter -where - P: FnMut(&B::Item) -> bool, -{ - /// Creates a new `Filter` batch. - #[inline] - pub fn new(batch: B, predicate: P) -> Self { - Filter { batch, predicate } - } -} - -impl Batch for Filter -where - P: FnMut(&B::Item) -> bool, -{ - type Item = B::Item; - - #[inline] - fn replenish(&mut self) { - self.batch.replenish(); - } - - #[inline] - fn next(&mut self) -> Option> { - self.batch.next().map(|disp| { - disp.map(|pkt| { - if (self.predicate)(&pkt) { - Disposition::Act(pkt) - } else { - Disposition::Drop(pkt.reset()) - } - }) - }) - } -} diff --git a/core/src/batch/filter_map.rs b/core/src/batch/filter_map.rs deleted file mode 100644 index ceebafba..00000000 --- a/core/src/batch/filter_map.rs +++ /dev/null @@ -1,82 +0,0 @@ -/* -* Copyright 2019 Comcast Cable Communications Management, LLC -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* SPDX-License-Identifier: Apache-2.0 -*/ - -use super::{Batch, Disposition}; -use crate::packets::Packet; -use crate::Mbuf; -use anyhow::Result; - -/// The result of a [`filter_map`]. -/// -/// [`filter_map`]: crate::batch::Batch::filter_map -#[allow(missing_debug_implementations)] -pub enum Either { - /// Keeps the packet as mapped result. - Keep(T), - - /// Drops the packet. - Drop(Mbuf), -} - -/// A batch that both filters and maps the packets of the underlying batch. -/// -/// If the closure returns `Drop`, the packet is marked as dropped. On -/// error, the packet is marked as aborted. In both scenarios, it will -/// short-circuit the remainder of the pipeline. -#[allow(missing_debug_implementations)] -pub struct FilterMap -where - F: FnMut(B::Item) -> Result>, -{ - batch: B, - f: F, -} - -impl FilterMap -where - F: FnMut(B::Item) -> Result>, -{ - /// Creates a new `FilterMap` batch. - #[inline] - pub fn new(batch: B, f: F) -> Self { - FilterMap { batch, f } - } -} - -impl Batch for FilterMap -where - F: FnMut(B::Item) -> Result>, -{ - type Item = T; - - #[inline] - fn replenish(&mut self) { - self.batch.replenish(); - } - - #[inline] - fn next(&mut self) -> Option> { - self.batch.next().map(|disp| { - disp.map(|orig| match (self.f)(orig) { - Ok(Either::Keep(new)) => Disposition::Act(new), - Ok(Either::Drop(mbuf)) => Disposition::Drop(mbuf), - Err(e) => Disposition::Abort(e), - }) - }) - } -} diff --git a/core/src/batch/for_each.rs b/core/src/batch/for_each.rs deleted file mode 100644 index eb4c0f4c..00000000 --- a/core/src/batch/for_each.rs +++ /dev/null @@ -1,63 +0,0 @@ -/* -* Copyright 2019 Comcast Cable Communications Management, LLC -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* SPDX-License-Identifier: Apache-2.0 -*/ - -use super::{Batch, Disposition}; -use anyhow::Result; - -/// A batch that calls a closure on packets in the underlying batch. -#[allow(missing_debug_implementations)] -pub struct ForEach -where - F: FnMut(&B::Item) -> Result<()>, -{ - batch: B, - f: F, -} - -impl ForEach -where - F: FnMut(&B::Item) -> Result<()>, -{ - /// Creates a new `ForEach` batch. - #[inline] - pub fn new(batch: B, f: F) -> Self { - ForEach { batch, f } - } -} - -impl Batch for ForEach -where - F: FnMut(&B::Item) -> Result<()>, -{ - type Item = B::Item; - - #[inline] - fn replenish(&mut self) { - self.batch.replenish(); - } - - #[inline] - fn next(&mut self) -> Option> { - self.batch.next().map(|disp| { - disp.map(|pkt| match (self.f)(&pkt) { - Ok(_) => Disposition::Act(pkt), - Err(e) => Disposition::Abort(e), - }) - }) - } -} diff --git a/core/src/batch/group_by.rs b/core/src/batch/group_by.rs deleted file mode 100644 index 3836f4e8..00000000 --- a/core/src/batch/group_by.rs +++ /dev/null @@ -1,207 +0,0 @@ -/* -* Copyright 2019 Comcast Cable Communications Management, LLC -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* SPDX-License-Identifier: Apache-2.0 -*/ - -use super::{Batch, Disposition}; -use crate::packets::Packet; -use std::cell::Cell; -use std::collections::{HashMap, VecDeque}; -use std::hash::Hash; -use std::rc::Rc; - -/// A bridge between the main batch pipeline and the branch pipelines -/// created by the [`GroupBy`] combinator. Packets can be fed one at a time -/// through the bridge. Because the pipeline execution is depth first, -/// this is the most efficient way storage wise. -#[allow(missing_debug_implementations)] -#[derive(Default)] -pub struct Bridge(Rc>>); - -impl Bridge { - /// Creates a new, empty bridge. - pub fn new() -> Self { - Bridge(Rc::new(Cell::new(None))) - } - - /// Feeds a packet into the bridge container. - pub fn set(&self, pkt: T) { - self.0.set(Some(pkt)); - } -} - -impl Clone for Bridge { - fn clone(&self) -> Self { - Bridge(Rc::clone(&self.0)) - } -} - -impl Batch for Bridge { - type Item = T; - - fn replenish(&mut self) { - // nothing to do - } - - fn next(&mut self) -> Option> { - self.0.take().map(Disposition::Act) - } -} - -/// Builder closure for a sub batch from a bridge. -pub type GroupByBatchBuilder = dyn FnOnce(Bridge) -> Box>; - -/// A batch that splits the underlying batch into multiple sub batches. -/// -/// A closure is used to extract the discriminator used to determine how to -/// split the packets in the batch. If a packet is unmatched, it will be -/// marked as dropped. On error, the packet is marked as aborted. -/// -/// All the sub batches must have the same packet type as the underlying -/// batch. -#[allow(missing_debug_implementations)] -pub struct GroupBy -where - D: Eq + Clone + Hash, - S: Fn(&B::Item) -> D, -{ - batch: B, - selector: S, - bridge: Bridge, - groups: HashMap>>, - catchall: Box>, - fanouts: VecDeque>, -} - -impl GroupBy -where - D: Eq + Clone + Hash, - S: Fn(&B::Item) -> D, -{ - /// Creates a new `GroupBy` batch. - #[inline] - pub fn new(batch: B, selector: S, composer: C) -> Self - where - C: FnOnce(&mut HashMap, Box>>), - { - // get the builders for the sub batches - let mut builders = HashMap::new(); - composer(&mut builders); - - let bridge = Bridge::new(); - - // build the catchall batch pipeline - let catchall = builders.remove(&None).unwrap()(bridge.clone()); - - // build the rest of the batch pipelines - let groups = builders - .into_iter() - .map(|(key, build)| { - let key = key.unwrap(); - let group = build(bridge.clone()); - (key, group) - }) - .collect::>(); - - GroupBy { - batch, - selector, - bridge, - groups, - catchall, - fanouts: VecDeque::new(), - } - } -} - -impl Batch for GroupBy -where - D: Eq + Clone + Hash, - S: Fn(&B::Item) -> D, -{ - type Item = B::Item; - - #[inline] - fn replenish(&mut self) { - self.batch.replenish(); - } - - #[inline] - fn next(&mut self) -> Option> { - if let Some(disp) = self.fanouts.pop_front() { - Some(disp) - } else { - self.batch.next().map(|disp| { - disp.map(|pkt| { - // gets the discriminator key - let key = (self.selector)(&pkt); - - // feeds this packet through the bridge - self.bridge.set(pkt); - - // runs the packet through. the sub-batch could be a fanout - // that produces multiple packets from one input. they are - // temporarily stored in a queue and returned in the subsequent - // iterations. - let batch = match self.groups.get_mut(&key) { - Some(group) => group, - None => &mut self.catchall, - }; - - while let Some(next) = batch.next() { - self.fanouts.push_back(next) - } - - self.fanouts.pop_front().unwrap() - }) - }) - } - } -} - -#[doc(hidden)] -#[macro_export] -macro_rules! __compose { - ($map:ident, $($key:expr => |$arg:tt| $body:block),*) => {{ - $( - $map.insert(Some($key), Box::new(|$arg| Box::new($body))); - )* - }}; -} - -/// Composes the batch builders for the [`group_by`] combinator. -/// -/// [`group_by`]: crate::batch::Batch::group_by -#[macro_export] -macro_rules! compose { - ($map:ident { $($key:expr => |$arg:tt| $body:block)+ }) => {{ - $crate::__compose!($map, $($key => |$arg| $body),*); - $map.insert(None, Box::new(|group| Box::new(group))); - }}; - ($map:ident { $($key:expr => |$arg:tt| $body:block)+ _ => |$_arg:tt| $_body:block }) => {{ - $crate::__compose!($map, $($key => |$arg| $body),*); - $map.insert(None, Box::new(|$_arg| Box::new($_body))); - }}; - ($map:ident { $($key:expr),+ => |$arg:tt| $body:block }) => {{ - $crate::compose!($map { $($key => |$arg| $body)+ }); - }}; - ($map:ident { $($key:expr),+ => |$arg:tt| $body:block _ => |$_arg:tt| $_body:block }) => {{ - $crate::compose!($map { $($key => |$arg| $body)+ _ => |$_arg| $_body }); - }}; - ($map:ident { _ => |$_arg:tt| $_body:block }) => {{ - $map.insert(None, Box::new(|$_arg| Box::new($_body))); - }}; -} diff --git a/core/src/batch/inspect.rs b/core/src/batch/inspect.rs deleted file mode 100644 index 82fa4395..00000000 --- a/core/src/batch/inspect.rs +++ /dev/null @@ -1,61 +0,0 @@ -/* -* Copyright 2019 Comcast Cable Communications Management, LLC -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* SPDX-License-Identifier: Apache-2.0 -*/ - -use super::{Batch, Disposition}; - -/// A batch that calls a closure on packets in the underlying batch, including -/// ones that are already dropped, emitted or aborted. -#[allow(missing_debug_implementations)] -pub struct Inspect -where - F: FnMut(&Disposition), -{ - batch: B, - f: F, -} - -impl Inspect -where - F: FnMut(&Disposition), -{ - /// Creates a new `Inspect` batch. - #[inline] - pub fn new(batch: B, f: F) -> Self { - Inspect { batch, f } - } -} - -impl Batch for Inspect -where - F: FnMut(&Disposition), -{ - type Item = B::Item; - - #[inline] - fn replenish(&mut self) { - self.batch.replenish(); - } - - #[inline] - fn next(&mut self) -> Option> { - self.batch.next().map(|disp| { - (self.f)(&disp); - disp - }) - } -} diff --git a/core/src/batch/map.rs b/core/src/batch/map.rs deleted file mode 100644 index d52c4dfe..00000000 --- a/core/src/batch/map.rs +++ /dev/null @@ -1,67 +0,0 @@ -/* -* Copyright 2019 Comcast Cable Communications Management, LLC -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* SPDX-License-Identifier: Apache-2.0 -*/ - -use super::{Batch, Disposition}; -use crate::packets::Packet; -use anyhow::Result; - -/// A batch that maps the packets of the underlying batch. -/// -/// On error, the packet is marked as `aborted` and will short-circuit the -/// remainder of the pipeline. -#[allow(missing_debug_implementations)] -pub struct Map -where - F: FnMut(B::Item) -> Result, -{ - batch: B, - f: F, -} - -impl Map -where - F: FnMut(B::Item) -> Result, -{ - /// Creates a new `Map` batch. - #[inline] - pub fn new(batch: B, f: F) -> Self { - Map { batch, f } - } -} - -impl Batch for Map -where - F: FnMut(B::Item) -> Result, -{ - type Item = T; - - #[inline] - fn replenish(&mut self) { - self.batch.replenish(); - } - - #[inline] - fn next(&mut self) -> Option> { - self.batch.next().map(|disp| { - disp.map(|orig| match (self.f)(orig) { - Ok(new) => Disposition::Act(new), - Err(e) => Disposition::Abort(e), - }) - }) - } -} diff --git a/core/src/batch/mod.rs b/core/src/batch/mod.rs deleted file mode 100644 index e1a82b80..00000000 --- a/core/src/batch/mod.rs +++ /dev/null @@ -1,736 +0,0 @@ -/* -* Copyright 2019 Comcast Cable Communications Management, LLC -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* SPDX-License-Identifier: Apache-2.0 -*/ - -//! Combinators that can be applied to batches of packets within a pipeline. - -mod emit; -mod filter; -mod filter_map; -mod for_each; -mod group_by; -mod inspect; -mod map; -mod poll; -mod replace; -mod rxtx; -mod send; - -pub use self::emit::*; -pub use self::filter::*; -pub use self::filter_map::*; -pub use self::for_each::*; -pub use self::group_by::*; -pub use self::inspect::*; -pub use self::map::*; -pub use self::poll::*; -pub use self::replace::*; -pub use self::rxtx::*; -pub use self::send::*; - -use crate::packets::Packet; -use crate::Mbuf; -use anyhow::{Error, Result}; -use std::collections::HashMap; -use std::hash::Hash; - -/// Way to categorize the packets of a batch inside a processing pipeline. -/// The disposition instructs the combinators how to process a packet. -#[allow(missing_debug_implementations)] -pub enum Disposition { - /// Indicating the packet should be processed. - Act(T), - - /// Indicating the packet has already been sent, possibly through a - /// different [`PacketTx`]. - /// - /// [`PacketTx`]: crate::batch::PacketTx - Emit, - - /// Indicating the packet is intentionally dropped from the output. - Drop(Mbuf), - - /// Indicating an error has occurred during processing. The packet will - /// be dropped from the output. Aborted packets are not bulk freed. - /// The packet is returned to mempool when it goes out of scope. - Abort(Error), -} - -impl Disposition { - /// Easy way to map a `Disposition` to a `Disposition` by reducing - /// it down to a map from `T` to `Disposition`. - fn map(self, f: F) -> Disposition - where - F: FnOnce(T) -> Disposition, - { - match self { - Disposition::Act(packet) => f(packet), - Disposition::Emit => Disposition::Emit, - Disposition::Drop(mbuf) => Disposition::Drop(mbuf), - Disposition::Abort(err) => Disposition::Abort(err), - } - } - - /// Returns whether the disposition is `Act`. - pub fn is_act(&self) -> bool { - matches!(self, Disposition::Act(_)) - } - - /// Returns whether the disposition is `Emit`. - pub fn is_emit(&self) -> bool { - matches!(self, Disposition::Emit) - } - - /// Returns whether the disposition is `Drop`. - pub fn is_drop(&self) -> bool { - matches!(self, Disposition::Drop(_)) - } - - /// Returns whether the disposition is `Abort`. - pub fn is_abort(&self) -> bool { - matches!(self, Disposition::Abort(_)) - } -} - -/// Types that can receive packets. -pub trait PacketRx { - /// Receives a batch of packets. - fn receive(&mut self) -> Vec; -} - -/// Types that can trasmit packets. -pub trait PacketTx { - /// Transmits a batch of packets. - fn transmit(&mut self, packets: Vec); -} - -/// Common behaviors to apply on batches of packets. -pub trait Batch { - /// The packet type. - type Item: Packet; - - /// Replenishes the batch with new packets from the source. - fn replenish(&mut self); - - /// Returns the disposition of the next packet in the batch. - /// - /// A value of `None` indicates that the batch is exhausted. To start - /// the next cycle, call [`replenish`] first. - /// - /// [`replenish`]: Batch::replenish - fn next(&mut self) -> Option>; - - /// Creates a batch that transmits all packets through the specified - /// [`PacketTx`]. - /// - /// Use when packets need to be delivered to a destination different - /// from the pipeline's main outbound queue. The send is immediate and - /// is not in batch. Packets sent with `emit` will be out of order - /// relative to other packets in the batch. - /// - /// # Example - /// - /// ``` - /// let (tx, _) = mpsc::channel(); - /// let mut batch = batch.emit(tx); - /// ``` - /// - /// [`PacketTx`]: crate::batch::PacketTx - fn emit(self, tx: Tx) -> Emit - where - Self: Sized, - { - Emit::new(self, tx) - } - - /// Creates a batch that uses a predicate to determine if a packet - /// should be processed or dropped. If the predicate evaluates to `false`, - /// the packet is marked as dropped. - /// - /// # Example - /// - /// ``` - /// let mut batch = batch.filter(|packet| { - /// let v4 = packet.parse::()?.parse::()?; - /// v4.ttl() > 0 - /// }); - /// ``` - #[inline] - fn filter

(self, predicate: P) -> Filter - where - P: FnMut(&Self::Item) -> bool, - Self: Sized, - { - Filter::new(self, predicate) - } - - /// Creates a batch that both [`filters`] and [`maps`]. - /// - /// # Example - /// - /// ``` - /// let mut batch = batch.filter_map(|packet| { - /// let v4 = packet.parse::()?.parse::()?; - /// if v4.protocol() == ProtocolNumbers::Udp { - /// Ok(Either::Keep(v4)) - /// } else { - /// Ok(Either::Drop(v4.reset())) - /// } - /// }); - /// ``` - /// - /// [`filters`]: Batch::filter - /// [`maps`]: Batch::map - #[inline] - fn filter_map(self, f: F) -> FilterMap - where - F: FnMut(Self::Item) -> Result>, - Self: Sized, - { - FilterMap::new(self, f) - } - - /// Creates a batch that maps the packets to another packet type. - /// - /// # Example - /// - /// ``` - /// let mut batch = batch.map(|packet| { - /// packet.parse::()?.parse::() - /// }); - /// ``` - #[inline] - fn map(self, f: F) -> Map - where - F: FnMut(Self::Item) -> Result, - Self: Sized, - { - Map::new(self, f) - } - - /// Calls a closure on each packet of the batch. - /// - /// Can be use for side-effect actions without the need to mutate the - /// packet. However, an error will abort the packet. - /// - /// # Example - /// - /// ``` - /// let mut batch = batch.for_each(|packet| { - /// println!("{:?}", packet); - /// Ok(()) - /// }); - /// ```` - #[inline] - fn for_each(self, f: F) -> ForEach - where - F: FnMut(&Self::Item) -> Result<()>, - Self: Sized, - { - ForEach::new(self, f) - } - - /// Calls a closure on each packet of the batch, including ones that are - /// already dropped, emitted or aborted. - /// - /// Unlike [`for_each`], `inspect` does not affect the packet disposition. - /// Useful as a debugging tool. - /// - /// # Example - /// - /// ``` - /// let mut batch = batch.inspect(|disp| { - /// if let Disposition::Act(v6) = disp { - /// if v6.hop_limit() > A_HOP_LIMIT { - /// debug!(...); - /// } - /// } - /// }); - /// ``` - /// - /// [`for_each`]: Batch::for_each - #[inline] - fn inspect(self, f: F) -> Inspect - where - F: FnMut(&Disposition), - Self: Sized, - { - Inspect::new(self, f) - } - - /// Splits the packets into multiple sub batches. Each sub batch runs - /// through a separate pipeline, and are then merged back together. - /// - /// `selector` is a closure that receives a reference to the packet and - /// evaluates to a discriminator value. The underlying batch will be split - /// into sub batches based on this value. - /// - /// `composer` is a closure that constructs a hash map of batch pipeline - /// builders for each individual sub pipeline. The [`compose!`] macro is an - /// ergonomic way to write the composer closure. The syntax of the macro - /// loosely resembles the std `match` expression. Each match arm consists of - /// a single discriminator value mapped to a builder closure. - /// - /// If a packet does not match with an arm, it will be passed through to - /// the next combinator. Use the catch all arm `_` to make the matching - /// exhaustive. - /// - /// # Example - /// - /// ``` - /// let mut batch = batch.group_by( - /// |packet| packet.protocol(), - /// |groups| { - /// compose!( groups { - /// ProtocolNumbers::Tcp => |group| { - /// group.map(do_tcp) - /// } - /// ProtocolNumbers::Udp => |group| { - /// group.map(do_udp) - /// } - /// _ => |group| { - /// group.map(unmatched) - /// } - /// }) - /// }, - /// ); - /// ``` - /// - /// [`compose!`]: macro@compose - #[inline] - fn group_by(self, selector: S, composer: C) -> GroupBy - where - D: Eq + Clone + Hash, - S: Fn(&Self::Item) -> D, - C: FnOnce(&mut HashMap, Box>>), - Self: Sized, - { - GroupBy::new(self, selector, composer) - } - - /// A batch that replaces each packet with another packet. - /// - /// Use for pipelines that generate new outbound packets based on inbound - /// packets and drop the inbound. - /// - /// # Example - /// - /// ``` - /// let mut batch = batch.replace(|request| { - /// let reply = Mbuf::new()?; - /// let ethernet = request.peek::()?; - /// let mut reply = reply.push::()?; - /// reply.set_src(ethernet.dst()); - /// reply.set_dst(ethernet.src()); - /// - /// ... - /// - /// Ok(reply) - /// }); - fn replace(self, f: F) -> Replace - where - F: FnMut(&Self::Item) -> Result, - Self: Sized, - { - Replace::new(self, f) - } - - /// Turns the batch pipeline into an executable task with default name. - /// - /// Send marks the end of the batch pipeline. No more combinators can be - /// appended after send. - /// - /// To give the pipeline a unique name, use - /// [`send_named`] instead. - /// - /// # Example - /// ``` - /// Poll::new(q.clone()).map(map_fn).send(q); - /// ``` - /// - /// [`send_named`]: Batch::send_named - #[inline] - fn send(self, tx: Tx) -> Send - where - Self: Sized, - { - Batch::send_named(self, "default", tx) - } - - /// Turns the batch pipeline into an executable task. - /// - /// `name` is used for logging and metrics. It does not need to be unique. - /// Multiple pipeline instances with the same name are aggregated together - /// into one set of metrics. Give each pipeline a different name to keep - /// metrics separated. - #[inline] - fn send_named(self, name: &str, tx: Tx) -> Send - where - Self: Sized, - { - Send::new(name.to_owned(), self, tx) - } -} - -/// Trait bound for batch pipelines. Can be used as a convenience for writing -/// pipeline installers. -/// -/// # Example -/// -/// ``` -/// fn install(q: PortQueue) -> impl Pipeline { -/// // install logic -/// } -/// ``` -pub trait Pipeline: futures::Future { - /// Returns the name of the pipeline. - fn name(&self) -> &str; - - /// Runs the pipeline once to process one batch of packets. - fn run_once(&mut self); -} - -/// Splices a [`PacketRx`] directly to a [`PacketTx`] without any intermediary -/// combinators. -/// -/// Useful for pipelines that perform simple forwarding without any packet -/// processing. -/// -/// # Example -/// -/// ``` -/// Runtime::build(config)? -/// .add_pipeline_to_port("kni0", |q| { -/// batch::splice(q.clone(), q.kni().unwrap().clone()) -/// }); -/// ``` -/// -/// [`PacketRx`]: crate::batch::PacketRx -/// [`PacketTx`]: crate::batch::PacketTx -pub fn splice(rx: Rx, tx: Tx) -> impl Pipeline { - Poll::new(rx).send(tx) -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::compose; - use crate::packets::ip::v4::Ipv4; - use crate::packets::ip::ProtocolNumbers; - use crate::packets::Ethernet; - use crate::testils::byte_arrays::{ICMPV4_PACKET, IPV4_TCP_PACKET, IPV4_UDP_PACKET}; - use std::sync::mpsc::{self, TryRecvError}; - - fn new_batch(data: &[&[u8]]) -> impl Batch { - let packets = data - .iter() - .map(|bytes| Mbuf::from_bytes(bytes).unwrap()) - .collect::>(); - - let (mut tx, rx) = mpsc::channel(); - tx.transmit(packets); - let mut batch = Poll::new(rx); - batch.replenish(); - batch - } - - #[capsule::test] - fn emit_batch() { - let (tx, mut rx) = mpsc::channel(); - - let mut batch = new_batch(&[&IPV4_UDP_PACKET]) - .map(|p| p.parse::()) - .emit(tx) - .for_each(|_| panic!("emit broken!")); - - assert!(batch.next().unwrap().is_emit()); - - // sent to the tx - assert_eq!(1, rx.receive().len()); - } - - #[capsule::test] - fn filter_batch() { - let mut batch = new_batch(&[&IPV4_UDP_PACKET]).filter(|_| true); - assert!(batch.next().unwrap().is_act()); - - let mut batch = new_batch(&[&IPV4_UDP_PACKET]).filter(|_| false); - assert!(batch.next().unwrap().is_drop()); - } - - #[capsule::test] - fn filter_map_batch() { - let mut batch = new_batch(&[&IPV4_UDP_PACKET, &ICMPV4_PACKET]).filter_map(|p| { - let v4 = p.parse::()?.parse::()?; - if v4.protocol() == ProtocolNumbers::Udp { - Ok(Either::Keep(v4)) - } else { - Ok(Either::Drop(v4.reset())) - } - }); - - // udp is let through - assert!(batch.next().unwrap().is_act()); - // icmp is dropped - assert!(batch.next().unwrap().is_drop()); - // at the end - assert!(batch.next().is_none()); - } - - #[capsule::test] - fn map_batch() { - let mut batch = new_batch(&[&IPV4_UDP_PACKET]).map(|p| p.parse::()); - assert!(batch.next().unwrap().is_act()); - - // can't shrink the mbuf that much - let mut batch = new_batch(&[&IPV4_UDP_PACKET]).map(|mut p| { - p.shrink(0, 999_999)?; - Ok(p) - }); - assert!(batch.next().unwrap().is_abort()); - } - - #[capsule::test] - fn for_each_batch() { - let mut side_effect = false; - - let mut batch = new_batch(&[&IPV4_UDP_PACKET]).for_each(|_| { - side_effect = true; - Ok(()) - }); - - assert!(batch.next().unwrap().is_act()); - assert!(side_effect); - } - - #[capsule::test] - fn inspect_batch() { - let mut side_effect = false; - - let mut batch = new_batch(&[&IPV4_UDP_PACKET]).inspect(|_| { - side_effect = true; - }); - - assert!(batch.next().unwrap().is_act()); - assert!(side_effect); - } - - #[capsule::test] - fn group_by_batch() { - let mut batch = new_batch(&[&IPV4_TCP_PACKET, &IPV4_UDP_PACKET, &ICMPV4_PACKET]) - .map(|p| p.parse::()?.parse::()) - .group_by( - |p| p.protocol(), - |groups| { - compose!( groups { - ProtocolNumbers::Tcp => |group| { - group.map(|mut p| { - p.set_ttl(1); - Ok(p) - }) - } - ProtocolNumbers::Udp => |group| { - group.map(|mut p| { - p.set_ttl(2); - Ok(p) - }) - } - _ => |group| { - group.filter(|_| { - false - }) - } - }) - }, - ); - - // first one is the tcp arm - let disp = batch.next().unwrap(); - assert!(disp.is_act()); - if let Disposition::Act(pkt) = disp { - assert_eq!(1, pkt.ttl()); - } - - // next one is the udp arm - let disp = batch.next().unwrap(); - assert!(disp.is_act()); - if let Disposition::Act(pkt) = disp { - assert_eq!(2, pkt.ttl()); - } - - // last one is the catch all arm - assert!(batch.next().unwrap().is_drop()); - } - - #[capsule::test] - fn group_by_no_catchall() { - let mut batch = new_batch(&[&ICMPV4_PACKET]) - .map(|p| p.parse::()?.parse::()) - .group_by( - |p| p.protocol(), - |groups| { - compose!( groups { - ProtocolNumbers::Tcp => |group| { - group.filter(|_| false) - } - }) - }, - ); - - // did not match, passes through - assert!(batch.next().unwrap().is_act()); - } - - #[capsule::test] - fn group_by_or() { - let mut batch = new_batch(&[&IPV4_TCP_PACKET, &IPV4_UDP_PACKET, &ICMPV4_PACKET]) - .map(|p| p.parse::()?.parse::()) - .group_by( - |p| p.protocol(), - |groups| { - compose!( groups { - ProtocolNumbers::Tcp, ProtocolNumbers::Udp => |group| { - group.map(|mut p| { - p.set_ttl(1); - Ok(p) - }) - } - _ => |group| { - group.filter(|_| { - false - }) - } - }) - }, - ); - - // first one is the tcp arm - let disp = batch.next().unwrap(); - assert!(disp.is_act()); - if let Disposition::Act(pkt) = disp { - assert_eq!(1, pkt.ttl()); - } - - // next one is the udp arm - let disp = batch.next().unwrap(); - assert!(disp.is_act()); - if let Disposition::Act(pkt) = disp { - assert_eq!(1, pkt.ttl()); - } - - // last one is the catch all arm - assert!(batch.next().unwrap().is_drop()); - } - - #[capsule::test] - fn group_by_or_no_catchall() { - let mut batch = new_batch(&[&IPV4_TCP_PACKET, &IPV4_UDP_PACKET]) - .map(|p| p.parse::()?.parse::()) - .group_by( - |p| p.protocol(), - |groups| { - compose!( groups { - ProtocolNumbers::Tcp, ProtocolNumbers::Udp => |group| { - group.map(|mut p| { - p.set_ttl(1); - Ok(p) - }) - } - }) - }, - ); - - // first one is the tcp arm - let disp = batch.next().unwrap(); - assert!(disp.is_act()); - if let Disposition::Act(pkt) = disp { - assert_eq!(1, pkt.ttl()); - } - - // next one is the udp arm - let disp = batch.next().unwrap(); - assert!(disp.is_act()); - if let Disposition::Act(pkt) = disp { - assert_eq!(1, pkt.ttl()); - } - } - - #[capsule::test] - fn group_by_fanout() { - let mut batch = new_batch(&[&IPV4_TCP_PACKET]) - .map(|p| p.parse::()?.parse::()) - .group_by( - |p| p.protocol(), - |groups| { - compose!( groups { - ProtocolNumbers::Tcp => |group| { - group.replace(|_| { - Mbuf::from_bytes(&IPV4_UDP_PACKET)? - .parse::()? - .parse::() - }) - } - }) - }, - ); - - // replace inside group_by will produce a new UDP packet - // and marks the original TCP packet as dropped. - assert!(batch.next().unwrap().is_act()); - assert!(batch.next().unwrap().is_drop()); - assert!(batch.next().is_none()); - } - - #[capsule::test] - fn replace_batch() { - let mut batch = - new_batch(&[&IPV4_UDP_PACKET]).replace(|_| Mbuf::from_bytes(&IPV4_TCP_PACKET)); - - // first one is the replacement - assert!(batch.next().unwrap().is_act()); - // next one is the original - assert!(batch.next().unwrap().is_drop()); - // at the end - assert!(batch.next().is_none()); - } - - #[capsule::test] - fn poll_fn_batch() { - let mut batch = poll_fn(|| vec![Mbuf::new().unwrap()]); - batch.replenish(); - - assert!(batch.next().unwrap().is_act()); - assert!(batch.next().is_none()); - } - - #[capsule::test] - fn splice_pipeline() { - let (mut tx1, rx1) = mpsc::channel(); - let (tx2, rx2) = mpsc::channel(); - - // no packet yet - let mut pipeline = splice(rx1, tx2); - pipeline.run_once(); - assert_eq!(TryRecvError::Empty, rx2.try_recv().unwrap_err()); - - // send one packet - let packet = Mbuf::from_bytes(&IPV4_UDP_PACKET).unwrap(); - tx1.transmit(vec![packet]); - pipeline.run_once(); - assert!(rx2.try_recv().is_ok()); - } -} diff --git a/core/src/batch/poll.rs b/core/src/batch/poll.rs deleted file mode 100644 index 72023c92..00000000 --- a/core/src/batch/poll.rs +++ /dev/null @@ -1,71 +0,0 @@ -/* -* Copyright 2019 Comcast Cable Communications Management, LLC -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* SPDX-License-Identifier: Apache-2.0 -*/ - -use super::{Batch, Disposition, PacketRx, PollRx}; -use crate::Mbuf; -use std::collections::VecDeque; - -/// A batch that polls a receiving source for new packets. -/// -/// This marks the beginning of the pipeline. -#[allow(missing_debug_implementations)] -pub struct Poll { - rx: Rx, - packets: Option>, -} - -impl Poll { - /// Creates a new `Poll` batch. - #[inline] - pub fn new(rx: Rx) -> Self { - Poll { rx, packets: None } - } -} - -impl Batch for Poll { - type Item = Mbuf; - - /// Replenishes the batch with new packets from the RX source. - /// - /// If there are still packets left in the current queue, they are lost. - #[inline] - fn replenish(&mut self) { - // `VecDeque` is not the ideal structure here. We are relying on the - // conversion from `Vec` to `VecDeque` to be allocation-free. but - // unfortunately that's not always the case. We need an efficient and - // allocation-free data structure with pop semantic. - self.packets = Some(self.rx.receive().into()); - } - - #[inline] - fn next(&mut self) -> Option> { - if let Some(q) = self.packets.as_mut() { - q.pop_front().map(Disposition::Act) - } else { - None - } - } -} - -/// Creates a new poll batch from a closure. -pub fn poll_fn(f: F) -> Poll> -where - F: Fn() -> Vec, -{ - Poll::new(PollRx { f }) -} diff --git a/core/src/batch/replace.rs b/core/src/batch/replace.rs deleted file mode 100644 index 2efa0e7a..00000000 --- a/core/src/batch/replace.rs +++ /dev/null @@ -1,89 +0,0 @@ -/* -* Copyright 2019 Comcast Cable Communications Management, LLC -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* SPDX-License-Identifier: Apache-2.0 -*/ - -use super::{Batch, Disposition}; -use crate::packets::Packet; -use anyhow::Result; - -/// A batch that replaces each packet of the batch with another packet. -/// -/// The original packet is dropped from the batch with the new packet in its -/// place. On error, the packet is `aborted` and will short-circuit the -/// remainder of the pipeline. -#[allow(missing_debug_implementations)] -pub struct Replace -where - F: FnMut(&B::Item) -> Result, -{ - batch: B, - f: F, - slot: Option, -} - -impl Replace -where - F: FnMut(&B::Item) -> Result, -{ - /// Creates a new `Replace` batch. - #[inline] - pub fn new(batch: B, f: F) -> Self { - Replace { - batch, - f, - slot: None, - } - } -} - -impl Batch for Replace -where - F: FnMut(&B::Item) -> Result, -{ - type Item = T; - - #[inline] - fn replenish(&mut self) { - self.batch.replenish(); - } - - #[inline] - fn next(&mut self) -> Option> { - // internally the replace combinator will add a new packet to the - // batch and mark the original as dropped. the iteration grows to - // 2x in length because each item becomes 2 items. - if let Some(pkt) = self.slot.take() { - // has a packet in the temp slot. marks it as dropped. - Some(Disposition::Drop(pkt.reset())) - } else { - // nothing in the slot, fetches a new packet from source. - self.batch.next().map(|disp| { - disp.map(|orig| { - match (self.f)(&orig) { - Ok(new) => { - // keeps the original in the temp slot, we will mark it dropped - // in the iteration that immediately follows. - self.slot.replace(orig); - Disposition::Act(new) - } - Err(e) => Disposition::Abort(e), - } - }) - }) - } - } -} diff --git a/core/src/batch/rxtx.rs b/core/src/batch/rxtx.rs deleted file mode 100644 index c78d65c0..00000000 --- a/core/src/batch/rxtx.rs +++ /dev/null @@ -1,89 +0,0 @@ -/* -* Copyright 2019 Comcast Cable Communications Management, LLC -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* SPDX-License-Identifier: Apache-2.0 -*/ - -//! Implementations of `PacketRx` and `PacketTx`. -//! -//! Implemented for `PortQueue`. -//! -//! `PacketRx` implemented for `KniRx`. -//! -//! `PacketTx` implemented for `KniTxQueue`. -//! -//! Implemented for the MPSC channel so it can be used as a batch source -//! mostly in tests. - -use super::{PacketRx, PacketTx}; -use crate::{KniRx, KniTxQueue, Mbuf, PortQueue}; -use std::iter; -use std::sync::mpsc::{Receiver, Sender}; - -impl PacketRx for PortQueue { - fn receive(&mut self) -> Vec { - PortQueue::receive(self) - } -} - -impl PacketTx for PortQueue { - fn transmit(&mut self, packets: Vec) { - PortQueue::transmit(self, packets) - } -} - -impl PacketRx for KniRx { - fn receive(&mut self) -> Vec { - KniRx::receive(self) - } -} - -impl PacketTx for KniTxQueue { - fn transmit(&mut self, packets: Vec) { - KniTxQueue::transmit(self, packets) - } -} - -impl PacketRx for Receiver { - fn receive(&mut self) -> Vec { - iter::from_fn(|| self.try_recv().ok()).collect::>() - } -} - -impl PacketTx for Sender { - fn transmit(&mut self, packets: Vec) { - packets.into_iter().for_each(|packet| { - let _ = self.send(packet); - }); - } -} - -/// A batch that polls a closure for packets. -#[allow(missing_debug_implementations)] -pub struct PollRx -where - F: Fn() -> Vec, -{ - pub(crate) f: F, -} - -impl PacketRx for PollRx -where - F: Fn() -> Vec, -{ - fn receive(&mut self) -> Vec { - (self.f)() - } -} diff --git a/core/src/batch/send.rs b/core/src/batch/send.rs deleted file mode 100644 index e96b67a7..00000000 --- a/core/src/batch/send.rs +++ /dev/null @@ -1,151 +0,0 @@ -/* -* Copyright 2019 Comcast Cable Communications Management, LLC -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* SPDX-License-Identifier: Apache-2.0 -*/ - -use super::{Batch, Disposition, PacketTx, Pipeline}; -use crate::dpdk::CoreId; -#[cfg(feature = "metrics")] -use crate::metrics::{labels, Counter, SINK}; -use crate::packets::Packet; -use crate::Mbuf; -use futures::{future, Future}; -use std::pin::Pin; -use std::task::{Context, Poll}; -use tokio_executor::current_thread; - -/// Creates a new pipeline counter. -#[cfg(feature = "metrics")] -fn new_counter(name: &'static str, pipeline: &str) -> Counter { - SINK.scoped("pipeline").counter_with_labels( - name, - labels!( - "pipeline" => pipeline.to_owned(), - "core" => CoreId::current().raw().to_string(), - ), - ) -} - -/// A batch that can be executed as a runtime task. -#[allow(missing_debug_implementations)] -pub struct Send { - name: String, - batch: B, - tx: Tx, - #[cfg(feature = "metrics")] - runs: Counter, - #[cfg(feature = "metrics")] - processed: Counter, - #[cfg(feature = "metrics")] - dropped: Counter, - #[cfg(feature = "metrics")] - errors: Counter, -} - -impl Send { - /// Creates a new `Send` batch. - #[cfg(not(feature = "metrics"))] - #[inline] - pub fn new(name: String, batch: B, tx: Tx) -> Self { - Send { name, batch, tx } - } - - /// Creates a new `Send` batch. - #[cfg(feature = "metrics")] - #[inline] - pub fn new(name: String, batch: B, tx: Tx) -> Self { - let runs = new_counter("runs", &name); - let processed = new_counter("processed", &name); - let dropped = new_counter("dropped", &name); - let errors = new_counter("errors", &name); - Send { - name, - batch, - tx, - runs, - processed, - dropped, - errors, - } - } - - fn run(&mut self) { - // let's get a new batch - self.batch.replenish(); - - let mut transmit_q = Vec::with_capacity(64); - let mut drop_q = Vec::with_capacity(64); - let mut emitted = 0u64; - let mut aborted = 0u64; - - // consume the whole batch to completion - while let Some(disp) = self.batch.next() { - match disp { - Disposition::Act(packet) => transmit_q.push(packet.reset()), - Disposition::Drop(mbuf) => drop_q.push(mbuf), - Disposition::Emit => emitted += 1, - Disposition::Abort(_) => aborted += 1, - } - } - - #[cfg(feature = "metrics")] - { - self.runs.record(1); - self.processed.record(transmit_q.len() as u64 + emitted); - self.dropped.record(drop_q.len() as u64); - self.errors.record(aborted); - } - - if !transmit_q.is_empty() { - self.tx.transmit(transmit_q); - } - - if !drop_q.is_empty() { - Mbuf::free_bulk(drop_q); - } - } -} - -/// By implementing the `Future` trait, `Send` can be spawned onto the tokio -/// executor. Each time the future is polled, it processes one batch of -/// packets before returning the `Poll::Pending` status and yields. -impl Future for Send { - type Output = (); - - fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - // executes a batch of packets. - self.get_mut().run(); - - // now schedules the waker as a future and yields the core so other - // futures have a chance to run. - let waker = cx.waker().clone(); - current_thread::spawn(future::lazy(|_| waker.wake())); - - Poll::Pending - } -} - -impl Pipeline for Send { - #[inline] - fn name(&self) -> &str { - &self.name - } - - #[inline] - fn run_once(&mut self) { - self.run() - } -} diff --git a/core/src/config.rs b/core/src/config.rs deleted file mode 100644 index 5ae8b14d..00000000 --- a/core/src/config.rs +++ /dev/null @@ -1,513 +0,0 @@ -/* -* Copyright 2019 Comcast Cable Communications Management, LLC -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* SPDX-License-Identifier: Apache-2.0 -*/ - -//! Toml-based configuration for use with Capsule applications. -//! -//! # Example -//! -//! A configuration from our [`pktdump`] example: -//! ``` -//! app_name = "pktdump" -//! master_core = 0 -//! duration = 5 -//! -//! [mempool] -//! capacity = 65535 -//! cache_size = 256 -//! -//! [[ports]] -//! name = "eth1" -//! device = "net_pcap0" -//! args = "rx_pcap=tcp4.pcap,tx_iface=lo" -//! cores = [0] -//! -//! [[ports]] -//! name = "eth2" -//! device = "net_pcap1" -//! args = "rx_pcap=tcp6.pcap,tx_iface=lo" -//! cores = [0] -//! ``` -//! -//! [`pktdump`]: https://github.com/capsule-rs/capsule/tree/master/examples/pktdump - -use crate::dpdk::CoreId; -use crate::net::{Ipv4Cidr, Ipv6Cidr, MacAddr}; -use anyhow::Result; -use clap::{clap_app, crate_version}; -use regex::Regex; -use serde::{de, Deserialize, Deserializer}; -use std::fmt; -use std::fs; -use std::str::FromStr; -use std::time::Duration; - -// make `CoreId` serde deserializable. -impl<'de> Deserialize<'de> for CoreId { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - let i = usize::deserialize(deserializer)?; - Ok(CoreId::new(i)) - } -} - -// make `MacAddr` serde deserializable. -impl<'de> Deserialize<'de> for MacAddr { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - let s = String::deserialize(deserializer)?; - MacAddr::from_str(&s).map_err(de::Error::custom) - } -} - -// make `Ipv4Cidr` serde deserializable. -impl<'de> Deserialize<'de> for Ipv4Cidr { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - let s = String::deserialize(deserializer)?; - Ipv4Cidr::from_str(&s).map_err(de::Error::custom) - } -} - -// make `Ipv6Cidr` serde deserializable. -impl<'de> Deserialize<'de> for Ipv6Cidr { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - let s = String::deserialize(deserializer)?; - Ipv6Cidr::from_str(&s).map_err(de::Error::custom) - } -} - -/// Deserializes a duration from seconds expressed as `u64`. -pub fn duration_from_secs<'de, D>(deserializer: D) -> Result -where - D: Deserializer<'de>, -{ - let secs = u64::deserialize(deserializer)?; - Ok(Duration::from_secs(secs)) -} - -/// Deserializes an option of duration from seconds expressed as `u64`. -pub fn duration_option_from_secs<'de, D>(deserializer: D) -> Result, D::Error> -where - D: Deserializer<'de>, -{ - // for now this is the cleanest way to deserialize an option, till a better - // way is implemented, https://github.com/serde-rs/serde/issues/723 - #[derive(Deserialize)] - struct Wrapper(#[serde(deserialize_with = "duration_from_secs")] Duration); - - let option = Option::deserialize(deserializer)?.and_then(|Wrapper(dur)| { - if dur.as_secs() > 0 { - Some(dur) - } else { - None - } - }); - Ok(option) -} - -/// Runtime configuration settings. -#[derive(Clone, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct RuntimeConfig { - /// Application name. This must be unique if you want to run multiple - /// DPDK applications on the same system. - pub app_name: String, - - /// Indicating whether the process is a secondary process. Secondary - /// process cannot initialize shared memory, but can attach to pre- - /// initialized shared memory by the primary process and create objects - /// in it. Defaults to `false`. - #[serde(default)] - pub secondary: bool, - - /// Application group name. Use this to group primary and secondary - /// processes together in a multi-process setup; and allow them to share - /// the same memory regions. The default value is the `app_name`. Each - /// process works independently. - #[serde(default)] - pub app_group: Option, - - /// The identifier of the master core. This is the core the main thread - /// will run on. - pub master_core: CoreId, - - /// Additional cores that are available to the application, and can be - /// used for running general tasks. Packet pipelines cannot be run on - /// these cores unless the core is also assigned to a port separately. - /// Defaults to empty list. - #[serde(default)] - pub cores: Vec, - - /// Per mempool settings. On a system with multiple sockets, aka NUMA - /// nodes, one mempool will be allocated for each socket the apllication - /// uses. - #[serde(default)] - pub mempool: MempoolConfig, - - /// The ports to use for the application. Must have at least one. - pub ports: Vec, - - /// Additional DPDK [`parameters`] to pass on for EAL initialization. When - /// set, the values are passed through as is without validation. - /// - /// [`parameters`]: https://doc.dpdk.org/guides/linux_gsg/linux_eal_parameters.html - #[serde(default)] - pub dpdk_args: Option, - - /// If set, the application will stop after the duration expires. Useful - /// for setting a timeout for integration tests. - #[serde(default, deserialize_with = "duration_option_from_secs")] - pub duration: Option, -} - -impl RuntimeConfig { - /// Returns all the cores assigned to the runtime. - pub(crate) fn all_cores(&self) -> Vec { - let mut cores = vec![]; - cores.push(self.master_core); - cores.extend(self.cores.iter()); - - self.ports.iter().for_each(|port| { - cores.extend(port.cores.iter()); - }); - - cores.sort(); - cores.dedup(); - cores - } - - /// Extracts the EAL arguments from runtime settings. - pub(crate) fn to_eal_args(&self) -> Vec { - let mut eal_args = vec![]; - - // adds the app name - eal_args.push(self.app_name.clone()); - - let proc_type = if self.secondary { - "secondary".to_owned() - } else { - "primary".to_owned() - }; - - // adds the proc type - eal_args.push("--proc-type".to_owned()); - eal_args.push(proc_type); - - // adds the mem file prefix - let prefix = self.app_group.as_ref().unwrap_or(&self.app_name); - eal_args.push("--file-prefix".to_owned()); - eal_args.push(prefix.clone()); - - // adds all the ports - let pcie = Regex::new(r"^\d{4}:\d{2}:\d{2}\.\d$").unwrap(); - self.ports.iter().for_each(|port| { - if pcie.is_match(port.device.as_str()) { - eal_args.push("--pci-whitelist".to_owned()); - eal_args.push(port.device.clone()); - } else { - let vdev = if let Some(args) = &port.args { - format!("{},{}", port.device, args) - } else { - port.device.clone() - }; - eal_args.push("--vdev".to_owned()); - eal_args.push(vdev); - } - }); - - // adds the master core - eal_args.push("--master-lcore".to_owned()); - eal_args.push(self.master_core.raw().to_string()); - - // limits the EAL to only the master core. actual threads are - // managed by the runtime not the EAL. - eal_args.push("-l".to_owned()); - eal_args.push(self.master_core.raw().to_string()); - - // adds additional DPDK args - if let Some(args) = &self.dpdk_args { - eal_args.extend(args.split_ascii_whitespace().map(str::to_owned)); - } - - eal_args - } - - /// Returns the number of KNI enabled ports - pub(crate) fn num_knis(&self) -> usize { - self.ports.iter().filter(|p| p.kni).count() - } -} - -impl fmt::Debug for RuntimeConfig { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let mut d = f.debug_struct("runtime"); - d.field("app_name", &self.app_name) - .field("secondary", &self.secondary) - .field( - "app_group", - self.app_group.as_ref().unwrap_or(&self.app_name), - ) - .field("master_core", &self.master_core) - .field("cores", &self.cores) - .field("mempool", &self.mempool) - .field("ports", &self.ports); - if let Some(dpdk_args) = &self.dpdk_args { - d.field("dpdk_args", dpdk_args); - } - if let Some(duration) = &self.duration { - d.field("duration", duration); - } - d.finish() - } -} - -/// Mempool configuration settings. -#[derive(Clone, Deserialize)] -pub struct MempoolConfig { - /// The maximum number of Mbufs the mempool can allocate. The optimum - /// size (in terms of memory usage) is when n is a power of two minus - /// one. Defaults to `65535` or `2 ^ 16 - 1`. - #[serde(default = "default_capacity")] - pub capacity: usize, - - /// The size of the per core object cache. If cache_size is non-zero, - /// the library will try to limit the accesses to the common lockless - /// pool. The cache can be disabled if the argument is set to 0. Defaults - /// to `0`. - #[serde(default = "default_cache_size")] - pub cache_size: usize, -} - -fn default_capacity() -> usize { - 65535 -} - -fn default_cache_size() -> usize { - 0 -} - -impl Default for MempoolConfig { - fn default() -> Self { - MempoolConfig { - capacity: default_capacity(), - cache_size: default_cache_size(), - } - } -} - -impl fmt::Debug for MempoolConfig { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("mempool") - .field("capacity", &self.capacity) - .field("cache_size", &self.cache_size) - .finish() - } -} - -/// Port configuration settings. -#[derive(Clone, Deserialize)] -pub struct PortConfig { - /// The application assigned logical name of the port. - /// - /// For applications with more than one port, this name can be used to - /// identifer the port. - pub name: String, - - /// The device name of the port. It can be the following formats, - /// - /// * PCIe address, for example `0000:02:00.0` - /// * DPDK virtual device, for example `net_[pcap0|null0|tap0]` - pub device: String, - - /// Additional arguments to configure a virtual device. - #[serde(default)] - pub args: Option, - - /// The cores assigned to the port for running the pipelines. The values - /// can overlap with the runtime cores. - pub cores: Vec, - - /// The receive queue capacity. Defaults to `128`. - #[serde(default = "default_port_rxd")] - pub rxd: usize, - - /// The transmit queue capacity. Defaults to `128`. - #[serde(default = "default_port_txd")] - pub txd: usize, - - /// Whether promiscuous mode is enabled for this port. Defaults to `false`. - #[serde(default)] - pub promiscuous: bool, - - /// Whether multicast packet reception is enabled for this port. Defaults - /// to `true`. - #[serde(default = "default_multicast_mode")] - pub multicast: bool, - - /// Whether kernel NIC interface is enabled for this port. with KNI, this - /// port can exchange packets with the kernel networking stack. Defaults - /// to `false`. - #[serde(default)] - pub kni: bool, -} - -fn default_port_rxd() -> usize { - 128 -} - -fn default_port_txd() -> usize { - 128 -} - -fn default_multicast_mode() -> bool { - true -} - -impl fmt::Debug for PortConfig { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let mut d = f.debug_struct("port"); - d.field("name", &self.name); - d.field("device", &self.device); - if let Some(args) = &self.args { - d.field("args", args); - } - d.field("cores", &self.cores) - .field("rxd", &self.rxd) - .field("txd", &self.txd) - .field("promiscuous", &self.promiscuous) - .field("multicast", &self.multicast) - .field("kni", &self.kni) - .finish() - } -} - -/// Loads the app config from a TOML file. -/// -/// # Example -/// -/// ``` -/// home$ ./myapp -f config.toml -/// ``` -pub fn load_config() -> Result { - let matches = clap_app!(capsule => - (version: crate_version!()) - (@arg file: -f --file +required +takes_value "configuration file") - ) - .get_matches(); - - let path = matches.value_of("file").unwrap(); - let content = fs::read_to_string(path)?; - toml::from_str(&content).map_err(|err| err.into()) -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn config_defaults() { - const CONFIG: &str = r#" - app_name = "myapp" - master_core = 0 - - [[ports]] - name = "eth0" - device = "0000:00:01.0" - cores = [2, 3] - "#; - - let config: RuntimeConfig = toml::from_str(CONFIG).unwrap(); - - assert_eq!(false, config.secondary); - assert_eq!(None, config.app_group); - assert!(config.cores.is_empty()); - assert_eq!(None, config.dpdk_args); - assert_eq!(default_capacity(), config.mempool.capacity); - assert_eq!(default_cache_size(), config.mempool.cache_size); - assert_eq!(None, config.ports[0].args); - assert_eq!(default_port_rxd(), config.ports[0].rxd); - assert_eq!(default_port_txd(), config.ports[0].txd); - assert_eq!(false, config.ports[0].promiscuous); - assert_eq!(default_multicast_mode(), config.ports[0].multicast); - assert_eq!(false, config.ports[0].kni); - } - - #[test] - fn config_to_eal_args() { - const CONFIG: &str = r#" - app_name = "myapp" - secondary = false - app_group = "mygroup" - master_core = 0 - cores = [1] - dpdk_args = "-v --log-level eal:8" - - [mempool] - capacity = 255 - cache_size = 16 - - [[ports]] - name = "eth0" - device = "0000:00:01.0" - cores = [2, 3] - rxd = 32 - txd = 32 - - [[ports]] - name = "eth1" - device = "net_pcap0" - args = "rx=lo,tx=lo" - cores = [0, 4] - rxd = 32 - txd = 32 - "#; - - let config: RuntimeConfig = toml::from_str(CONFIG).unwrap(); - - assert_eq!( - &[ - "myapp", - "--proc-type", - "primary", - "--file-prefix", - "mygroup", - "--pci-whitelist", - "0000:00:01.0", - "--vdev", - "net_pcap0,rx=lo,tx=lo", - "--master-lcore", - "0", - "-l", - "0", - "-v", - "--log-level", - "eal:8" - ], - config.to_eal_args().as_slice(), - ) - } -} diff --git a/core/src/dpdk/kni.rs b/core/src/dpdk/kni.rs deleted file mode 100644 index edf6919e..00000000 --- a/core/src/dpdk/kni.rs +++ /dev/null @@ -1,411 +0,0 @@ -/* -* Copyright 2019 Comcast Cable Communications Management, LLC -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* SPDX-License-Identifier: Apache-2.0 -*/ - -use super::{Mbuf, PortId}; -use crate::dpdk::DpdkError; -use crate::ffi::{self, AsStr, ToResult}; - -#[cfg(feature = "metrics")] -use crate::metrics::{labels, Counter, SINK}; -use crate::net::MacAddr; -use crate::{debug, error, warn}; -use anyhow::Result; -use futures::{future, Future, StreamExt}; -use std::cmp; -use std::mem; -use std::os::raw; -use std::ptr::{self, NonNull}; -use thiserror::Error; -use tokio::sync::mpsc::{self, UnboundedReceiver, UnboundedSender}; - -/// Creates a new KNI counter. -#[cfg(feature = "metrics")] -fn new_counter(name: &'static str, kni: &str, dir: &'static str) -> Counter { - SINK.scoped("kni").counter_with_labels( - name, - labels!( - "kni" => kni.to_string(), - "dir" => dir, - ), - ) -} - -/// The KNI receive handle. Because the underlying interface is single -/// threaded, we must ensure that only one rx handle is created for each -/// interface. -#[allow(missing_debug_implementations)] -pub struct KniRx { - raw: NonNull, - #[cfg(feature = "metrics")] - packets: Counter, - #[cfg(feature = "metrics")] - octets: Counter, -} - -impl KniRx { - /// Creates a new `KniRx`. - #[cfg(not(feature = "metrics"))] - pub fn new(raw: NonNull) -> Self { - KniRx { raw } - } - - /// Creates a new `KniRx`. - #[cfg(feature = "metrics")] - pub fn new(raw: NonNull) -> Self { - let name = unsafe { ffi::rte_kni_get_name(raw.as_ref()).as_str().to_owned() }; - let packets = new_counter("packets", &name, "rx"); - let octets = new_counter("octets", &name, "rx"); - KniRx { - raw, - packets, - octets, - } - } - - /// Receives a burst of packets from the kernel, up to a maximum of - /// **32** packets. - pub fn receive(&mut self) -> Vec { - const RX_BURST_MAX: usize = 32; - let mut ptrs = Vec::with_capacity(RX_BURST_MAX); - - let len = unsafe { - ffi::rte_kni_rx_burst( - self.raw.as_mut(), - ptrs.as_mut_ptr(), - RX_BURST_MAX as raw::c_uint, - ) - }; - - let mbufs = unsafe { - ptrs.set_len(len as usize); - ptrs.into_iter() - .map(|ptr| Mbuf::from_ptr(ptr)) - .collect::>() - }; - - unsafe { - // checks if there are any link change requests, and handle them. - if let Err(err) = - ffi::rte_kni_handle_request(self.raw.as_mut()).into_result(|_| DpdkError::new()) - { - warn!(message = "failed to handle change link requests.", ?err); - } - } - - #[cfg(feature = "metrics")] - { - self.packets.record(mbufs.len() as u64); - - let bytes: usize = mbufs.iter().map(Mbuf::data_len).sum(); - self.octets.record(bytes as u64); - } - - mbufs - } -} - -/// In memory queue for the cores to deliver packets that are destined for -/// the kernel. Then another pipeline will collect these and forward them -/// on in a thread safe way. -#[allow(missing_debug_implementations)] -#[derive(Clone)] -pub struct KniTxQueue { - tx_enque: UnboundedSender>, -} - -impl KniTxQueue { - /// Transmits packets to the KNI tx queue. - pub fn transmit(&mut self, packets: Vec) { - if let Err(err) = self.tx_enque.try_send(packets) { - warn!(message = "failed to send to kni tx queue."); - Mbuf::free_bulk(err.into_inner()); - } - } -} - -/// The KNI transmit handle. Because the underlying interface is single -/// threaded, we must ensure that only one tx handle is created for each -/// interface. -pub(crate) struct KniTx { - raw: NonNull, - tx_deque: Option>>, - #[cfg(feature = "metrics")] - packets: Counter, - #[cfg(feature = "metrics")] - octets: Counter, - #[cfg(feature = "metrics")] - dropped: Counter, -} - -impl KniTx { - /// Creates a new `KniTx`. - #[cfg(not(feature = "metrics"))] - pub(crate) fn new(raw: NonNull, tx_deque: UnboundedReceiver>) -> Self { - KniTx { - raw, - tx_deque: Some(tx_deque), - } - } - - /// Creates a new `KniTx` with stats. - #[cfg(feature = "metrics")] - pub(crate) fn new(raw: NonNull, tx_deque: UnboundedReceiver>) -> Self { - let name = unsafe { ffi::rte_kni_get_name(raw.as_ref()).as_str().to_owned() }; - let packets = new_counter("packets", &name, "tx"); - let octets = new_counter("octets", &name, "tx"); - let dropped = new_counter("dropped", &name, "tx"); - KniTx { - raw, - tx_deque: Some(tx_deque), - packets, - octets, - dropped, - } - } - - /// Sends the packets to the kernel. - pub(crate) fn transmit(&mut self, packets: Vec) { - let mut ptrs = packets.into_iter().map(Mbuf::into_ptr).collect::>(); - - loop { - let to_send = ptrs.len() as raw::c_uint; - let sent = - unsafe { ffi::rte_kni_tx_burst(self.raw.as_mut(), ptrs.as_mut_ptr(), to_send) }; - - if sent > 0 { - #[cfg(feature = "metrics")] - { - self.packets.record(sent as u64); - - let bytes: u64 = ptrs[..sent as usize] - .iter() - .map(|&ptr| unsafe { (*ptr).data_len as u64 }) - .sum(); - self.octets.record(bytes); - } - - if to_send - sent > 0 { - // still have packets not sent. tx queue is full but still making - // progress. we will keep trying until all packets are sent. drains - // the ones already sent first and try again on the rest. - let _ = ptrs.drain(..sent as usize); - } else { - break; - } - } else { - // tx queue is full and we can't make progress, start dropping packets - // to avoid potentially stuck in an endless loop. - #[cfg(feature = "metrics")] - self.dropped.record(to_send as u64); - - super::mbuf_free_bulk(ptrs); - break; - } - } - } - - /// Converts the TX handle into a spawnable pipeline. - pub(crate) fn into_pipeline(mut self) -> impl Future { - self.tx_deque.take().unwrap().for_each(move |packets| { - self.transmit(packets); - future::ready(()) - }) - } -} - -// we need to send tx and rx across threads to run them. -unsafe impl Send for KniRx {} -unsafe impl Send for KniTx {} - -/// KNI errors. -#[derive(Debug, Error)] -pub(crate) enum KniError { - #[error("KNI is not enabled for the port.")] - Disabled, - - #[error("Another core owns the handle.")] - NotAcquired, -} - -/// Kernel NIC interface. This allows the DPDK application to exchange -/// packets with the kernel networking stack. -/// -/// The DPDK implementation is single-threaded TX and RX. Only one thread -/// can receive and one thread can transmit on the interface at a time. To -/// support a multi-queued port with a single virtual interface, a multi -/// producer, single consumer channel is used to collect all the kernel -/// bound packets onto one thread for transmit. -pub(crate) struct Kni { - raw: NonNull, - rx: Option, - tx: Option, - txq: KniTxQueue, -} - -impl Kni { - /// Creates a new KNI. - pub(crate) fn new(raw: NonNull) -> Kni { - let (send, recv) = mpsc::unbounded_channel(); - - // making 3 clones of the same raw pointer. but we know it is safe - // to do because rx and tx happen on two independent queues. so while - // each one is single-threaded, they can function in parallel. - let rx = KniRx::new(raw); - let tx = KniTx::new(raw, recv); - let txq = KniTxQueue { tx_enque: send }; - - Kni { - raw, - rx: Some(rx), - tx: Some(tx), - txq, - } - } - - /// Takes ownership of the RX handle. - pub(crate) fn take_rx(&mut self) -> Result { - self.rx.take().ok_or_else(|| KniError::NotAcquired.into()) - } - - /// Takes ownership of the TX handle. - pub(crate) fn take_tx(&mut self) -> Result { - self.tx.take().ok_or_else(|| KniError::NotAcquired.into()) - } - - /// Returns a TX queue handle to send packets to kernel. - pub(crate) fn txq(&self) -> KniTxQueue { - self.txq.clone() - } - - /// Returns the raw struct needed for FFI calls. - #[inline] - pub(crate) fn raw_mut(&mut self) -> &mut ffi::rte_kni { - unsafe { self.raw.as_mut() } - } -} - -impl Drop for Kni { - fn drop(&mut self) { - debug!("freeing kernel interface."); - - if let Err(err) = - unsafe { ffi::rte_kni_release(self.raw_mut()).into_result(|_| DpdkError::new()) } - { - error!(message = "failed to release KNI device.", ?err); - } - } -} - -/// Does not support changing the link MTU. -extern "C" fn change_mtu(port_id: u16, new_mtu: raw::c_uint) -> raw::c_int { - warn!("ignored change port {} mtu to {}.", port_id, new_mtu); - -1 -} - -/// Does not change the link up/down status, but will return 0 so the -/// command succeeds. -extern "C" fn config_network_if(port_id: u16, if_up: u8) -> raw::c_int { - warn!("ignored change port {} status to {}.", port_id, if_up); - 0 -} - -/// Does not support changing the link MAC address. -extern "C" fn config_mac_address(port_id: u16, _mac_addr: *mut u8) -> raw::c_int { - warn!("ignored change port {} mac address.", port_id); - -1 -} - -/// Does not support changing the link promiscusity. -extern "C" fn config_promiscusity(port_id: u16, to_on: u8) -> raw::c_int { - warn!("ignored change port {} promiscusity to {}.", port_id, to_on); - -1 -} - -/// Builds a KNI device from the configuration values. -pub(crate) struct KniBuilder<'a> { - mempool: &'a mut ffi::rte_mempool, - conf: ffi::rte_kni_conf, - ops: ffi::rte_kni_ops, -} - -impl<'a> KniBuilder<'a> { - /// Creates a new KNI device builder with the mempool for allocating - /// new packets. - pub(crate) fn new(mempool: &'a mut ffi::rte_mempool) -> Self { - KniBuilder { - mempool, - conf: ffi::rte_kni_conf::default(), - ops: ffi::rte_kni_ops::default(), - } - } - - pub(crate) fn name(&mut self, name: &str) -> &mut Self { - unsafe { - self.conf.name = mem::zeroed(); - ptr::copy( - name.as_ptr(), - self.conf.name.as_mut_ptr() as *mut u8, - cmp::min(name.len(), self.conf.name.len()), - ); - } - self - } - - pub(crate) fn port_id(&mut self, port_id: PortId) -> &mut Self { - self.conf.group_id = port_id.raw(); - self.ops.port_id = port_id.raw(); - self - } - - pub(crate) fn mac_addr(&mut self, mac: MacAddr) -> &mut Self { - unsafe { - self.conf.mac_addr = mem::transmute(mac); - } - self - } - - pub(crate) fn finish(&mut self) -> Result { - self.conf.mbuf_size = ffi::RTE_MBUF_DEFAULT_BUF_SIZE; - self.ops.change_mtu = Some(change_mtu); - self.ops.config_network_if = Some(config_network_if); - self.ops.config_mac_address = Some(config_mac_address); - self.ops.config_promiscusity = Some(config_promiscusity); - - unsafe { - ffi::rte_kni_alloc(self.mempool, &self.conf, &mut self.ops) - .into_result(|_| DpdkError::new()) - .map(Kni::new) - } - } -} - -/// Initializes and preallocates the KNI subsystem. -pub(crate) fn kni_init(max: usize) -> Result<()> { - unsafe { - ffi::rte_kni_init(max as raw::c_uint) - .into_result(DpdkError::from_errno) - .map(|_| ()) - } -} - -/// Closes the KNI subsystem. -pub(crate) fn kni_close() { - unsafe { - ffi::rte_kni_close(); - } -} diff --git a/core/src/dpdk/mempool.rs b/core/src/dpdk/mempool.rs deleted file mode 100644 index be3f2d78..00000000 --- a/core/src/dpdk/mempool.rs +++ /dev/null @@ -1,180 +0,0 @@ -/* -* Copyright 2019 Comcast Cable Communications Management, LLC -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* SPDX-License-Identifier: Apache-2.0 -*/ - -use super::SocketId; -use crate::dpdk::DpdkError; -use crate::ffi::{self, AsStr, ToCString, ToResult}; -use crate::{debug, info}; -use anyhow::Result; -use std::cell::Cell; -use std::collections::HashMap; -use std::fmt; -use std::os::raw; -use std::ptr::{self, NonNull}; -use std::sync::atomic::{AtomicUsize, Ordering}; -use thiserror::Error; - -/// A memory pool is an allocator of message buffers, or `Mbuf`. For best -/// performance, each socket should have a dedicated `Mempool`. -pub(crate) struct Mempool { - raw: NonNull, -} - -impl Mempool { - /// Creates a new `Mempool` for `Mbuf`. - /// - /// `capacity` is the maximum number of `Mbuf` the `Mempool` can hold. - /// The optimum size (in terms of memory usage) is when n is a power - /// of two minus one. - /// - /// `cache_size` is the per core object cache. If cache_size is non-zero, - /// the library will try to limit the accesses to the common lockless - /// pool. The cache can be disabled if the argument is set to 0. - /// - /// `socket_id` is the socket where the memory should be allocated. The - /// value can be `SocketId::ANY` if there is no constraint. - /// - /// # Errors - /// - /// If allocation fails, then `DpdkError` is returned. - pub(crate) fn new(capacity: usize, cache_size: usize, socket_id: SocketId) -> Result { - static MEMPOOL_COUNT: AtomicUsize = AtomicUsize::new(0); - let n = MEMPOOL_COUNT.fetch_add(1, Ordering::Relaxed); - let name = format!("mempool{}", n); - - let raw = unsafe { - ffi::rte_pktmbuf_pool_create( - name.clone().into_cstring().as_ptr(), - capacity as raw::c_uint, - cache_size as raw::c_uint, - 0, - ffi::RTE_MBUF_DEFAULT_BUF_SIZE as u16, - socket_id.raw(), - ) - .into_result(|_| DpdkError::new())? - }; - - info!("created {}.", name); - Ok(Self { raw }) - } - - /// Returns the raw struct needed for FFI calls. - #[inline] - pub(crate) fn raw(&self) -> &ffi::rte_mempool { - unsafe { self.raw.as_ref() } - } - - /// Returns the raw struct needed for FFI calls. - #[inline] - pub(crate) fn raw_mut(&mut self) -> &mut ffi::rte_mempool { - unsafe { self.raw.as_mut() } - } - - /// Returns the name of the `Mempool`. - #[inline] - pub(crate) fn name(&self) -> &str { - self.raw().name[..].as_str() - } - - #[cfg(feature = "metrics")] - pub(crate) fn stats(&self) -> super::MempoolStats { - super::MempoolStats::build(self) - } -} - -impl fmt::Debug for Mempool { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let raw = self.raw(); - f.debug_struct(self.name()) - .field("capacity", &raw.size) - .field("cache_size", &raw.cache_size) - .field("flags", &format_args!("{:#x}", raw.flags)) - .field("socket", &raw.socket_id) - .finish() - } -} - -impl Drop for Mempool { - fn drop(&mut self) { - debug!("freeing {}.", self.name()); - - unsafe { - ffi::rte_mempool_free(self.raw_mut()); - } - } -} - -thread_local! { - /// `Mempool` on the same socket as the current core. - /// - /// It's set when the core is first initialized. New `Mbuf` is allocated - /// from this `Mempool` when executed on this core. - pub static MEMPOOL: Cell<*mut ffi::rte_mempool> = Cell::new(ptr::null_mut()); -} - -/// Error indicating the `Mempool` is not found or is exhaused. -#[derive(Debug, Error)] -pub(crate) enum MempoolError { - #[error("Cannot allocate a new mbuf from mempool")] - Exhausted, - - #[error("Mempool for {0:?} not found.")] - NotFound(SocketId), -} - -/// A specialized hash map of `SocketId` to `&mut Mempool`. -#[derive(Debug)] -pub(crate) struct MempoolMap<'a> { - inner: HashMap, -} - -impl<'a> MempoolMap<'a> { - /// Creates a new map from a mutable slice. - pub(crate) fn new(mempools: &'a mut [Mempool]) -> Self { - let map = mempools - .iter_mut() - .map(|pool| { - let socket = SocketId(pool.raw().socket_id); - (socket, pool) - }) - .collect::>(); - - Self { inner: map } - } - - /// Returns a mutable reference to the raw mempool corresponding to the - /// socket id. - /// - /// # Errors - /// - /// If the value is not found, `MempoolError::NotFound` is returned. - pub(crate) fn get_raw(&mut self, socket_id: SocketId) -> Result<&mut ffi::rte_mempool> { - self.inner - .get_mut(&socket_id) - .ok_or_else(|| MempoolError::NotFound(socket_id).into()) - .map(|pool| pool.raw_mut()) - } -} - -impl<'a> Default for MempoolMap<'a> { - fn default() -> MempoolMap<'a> { - MempoolMap { - inner: HashMap::new(), - } - } -} diff --git a/core/src/dpdk/mod.rs b/core/src/dpdk/mod.rs deleted file mode 100644 index b0b7929a..00000000 --- a/core/src/dpdk/mod.rs +++ /dev/null @@ -1,244 +0,0 @@ -/* -* Copyright 2019 Comcast Cable Communications Management, LLC -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* SPDX-License-Identifier: Apache-2.0 -*/ - -mod kni; -mod mbuf; -mod mempool; -mod port; -#[cfg(feature = "metrics")] -mod stats; - -#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411 -pub use self::kni::*; -#[allow(unreachable_pub)] -pub use self::mbuf::*; -pub(crate) use self::mempool::*; -#[allow(unreachable_pub)] -pub use self::port::*; -#[cfg(feature = "metrics")] -pub(crate) use self::stats::*; - -use crate::debug; -use crate::ffi::{self, AsStr, ToCString, ToResult}; -use crate::net::MacAddr; -use anyhow::Result; -use std::cell::Cell; -use std::fmt; -use std::mem; -use std::os::raw; -use thiserror::Error; - -/// An error generated in `libdpdk`. -/// -/// When an FFI call fails, the `errno` is translated into `DpdkError`. -#[derive(Debug, Error)] -#[error("{0}")] -pub(crate) struct DpdkError(String); - -impl DpdkError { - /// Returns the `DpdkError` for the most recent failure on the current - /// thread. - #[inline] - pub(crate) fn new() -> Self { - DpdkError::from_errno(-1) - } - - /// Returns the `DpdkError` for a specific `errno`. - #[inline] - fn from_errno(errno: raw::c_int) -> Self { - let errno = if errno == -1 { - unsafe { ffi::_rte_errno() } - } else { - -errno - }; - DpdkError(unsafe { ffi::rte_strerror(errno).as_str().into() }) - } -} - -/// An opaque identifier for a physical CPU socket. -/// -/// A socket is also known as a NUMA node. On a multi-socket system, for best -/// performance, ensure that the cores and memory used for packet processing -/// are in the same socket as the network interface card. -#[derive(Copy, Clone, Eq, Hash, PartialEq)] -pub struct SocketId(raw::c_int); - -impl SocketId { - /// A socket ID representing any NUMA node. - pub const ANY: Self = SocketId(-1); - - /// Returns the ID of the socket the current core is on. - #[inline] - pub fn current() -> SocketId { - unsafe { SocketId(ffi::rte_socket_id() as raw::c_int) } - } - - /// Returns all the socket IDs detected on the system. - #[inline] - pub fn all() -> Vec { - unsafe { - (0..ffi::rte_socket_count()) - .map(|idx| ffi::rte_socket_id_by_idx(idx)) - .filter(|&sid| sid != -1) - .map(SocketId) - .collect::>() - } - } - - /// Returns the raw value needed for FFI calls. - #[allow(clippy::trivially_copy_pass_by_ref)] - #[inline] - pub(crate) fn raw(&self) -> raw::c_int { - self.0 - } -} - -impl fmt::Debug for SocketId { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "socket{}", self.0) - } -} - -/// An opaque identifier for a physical CPU core. -#[derive(Copy, Clone, Eq, Hash, Ord, PartialEq, PartialOrd)] -pub struct CoreId(usize); - -impl CoreId { - /// Any lcore to indicate that no thread affinity is set. - pub const ANY: Self = CoreId(std::usize::MAX); - - /// Creates a new CoreId from the numeric ID assigned to the core - /// by the system. - #[inline] - pub(crate) fn new(i: usize) -> CoreId { - CoreId(i) - } - - /// Returns the ID of the current core. - #[inline] - pub fn current() -> CoreId { - CURRENT_CORE_ID.with(|tls| tls.get()) - } - - /// Returns the ID of the socket the core is on. - #[allow(clippy::trivially_copy_pass_by_ref)] - #[inline] - pub fn socket_id(&self) -> SocketId { - unsafe { SocketId(ffi::numa_node_of_cpu(self.0 as raw::c_int)) } - } - - /// Returns the raw value. - #[allow(clippy::trivially_copy_pass_by_ref)] - #[inline] - pub(crate) fn raw(&self) -> usize { - self.0 - } - - /// Sets the current thread's affinity to this core. - #[allow(clippy::trivially_copy_pass_by_ref)] - #[inline] - pub(crate) fn set_thread_affinity(&self) -> Result<()> { - unsafe { - // the two types that represent `cpu_set` have identical layout, - // hence it is safe to transmute between them. - let mut set: libc::cpu_set_t = mem::zeroed(); - libc::CPU_SET(self.0, &mut set); - let mut set: ffi::rte_cpuset_t = mem::transmute(set); - ffi::rte_thread_set_affinity(&mut set).into_result(DpdkError::from_errno)?; - } - - CURRENT_CORE_ID.with(|tls| tls.set(*self)); - Ok(()) - } -} - -impl fmt::Debug for CoreId { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "core{}", self.0) - } -} - -thread_local! { - static CURRENT_CORE_ID: Cell = Cell::new(CoreId::ANY); -} - -/// Initializes the Environment Abstraction Layer (EAL). -pub(crate) fn eal_init(args: Vec) -> Result<()> { - debug!(arguments=?args); - - let len = args.len() as raw::c_int; - let args = args - .into_iter() - .map(|s| s.into_cstring()) - .collect::>(); - let mut ptrs = args - .iter() - .map(|s| s.as_ptr() as *mut raw::c_char) - .collect::>(); - - let res = unsafe { ffi::rte_eal_init(len, ptrs.as_mut_ptr()) }; - debug!("EAL parsed {} arguments.", res); - - res.into_result(DpdkError::from_errno).map(|_| ()) -} - -/// Cleans up the Environment Abstraction Layer (EAL). -pub(crate) fn eal_cleanup() -> Result<()> { - unsafe { - ffi::rte_eal_cleanup() - .into_result(DpdkError::from_errno) - .map(|_| ()) - } -} - -/// Returns the `MacAddr` of a port. -fn eth_macaddr_get(port_id: u16) -> MacAddr { - let mut addr = ffi::rte_ether_addr::default(); - unsafe { - ffi::rte_eth_macaddr_get(port_id, &mut addr); - } - addr.addr_bytes.into() -} - -/// Frees the `rte_mbuf` in bulk. -pub(crate) fn mbuf_free_bulk(mbufs: Vec<*mut ffi::rte_mbuf>) { - assert!(!mbufs.is_empty()); - - let mut to_free = Vec::with_capacity(mbufs.len()); - let pool = unsafe { (*mbufs[0]).pool }; - - for mbuf in mbufs.into_iter() { - if pool == unsafe { (*mbuf).pool } { - to_free.push(mbuf as *mut raw::c_void); - } else { - unsafe { - let len = to_free.len(); - ffi::_rte_mempool_put_bulk(pool, to_free.as_ptr(), len as u32); - to_free.set_len(0); - } - - to_free.push(mbuf as *mut raw::c_void); - } - } - - unsafe { - let len = to_free.len(); - ffi::_rte_mempool_put_bulk(pool, to_free.as_ptr(), len as u32); - to_free.set_len(0); - } -} diff --git a/core/src/dpdk/port.rs b/core/src/dpdk/port.rs deleted file mode 100644 index 302051ec..00000000 --- a/core/src/dpdk/port.rs +++ /dev/null @@ -1,651 +0,0 @@ -/* -* Copyright 2019 Comcast Cable Communications Management, LLC -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* SPDX-License-Identifier: Apache-2.0 -*/ - -use super::{CoreId, Kni, KniBuilder, KniTxQueue, Mbuf, Mempool, MempoolMap, SocketId}; -use crate::dpdk::DpdkError; -use crate::ffi::{self, AsStr, ToCString, ToResult}; -#[cfg(feature = "metrics")] -use crate::metrics::{labels, Counter, SINK}; -use crate::net::MacAddr; -#[cfg(feature = "pcap-dump")] -use crate::pcap; -use crate::{debug, ensure, info, warn}; -use anyhow::Result; -use std::collections::HashMap; -use std::fmt; -use std::os::raw; -use std::ptr; -use thiserror::Error; - -const DEFAULT_RSS_HF: u64 = - (ffi::ETH_RSS_IP | ffi::ETH_RSS_TCP | ffi::ETH_RSS_UDP | ffi::ETH_RSS_SCTP) as u64; - -/// An opaque identifier for an Ethernet device port. -#[derive(Copy, Clone)] -pub(crate) struct PortId(u16); - -impl PortId { - /// Returns the ID of the socket the port is connected to. - /// - /// Virtual devices do not have real socket IDs. The value returned - /// will be discarded if it does not match any of the system's physical - /// socket IDs. - #[inline] - pub(crate) fn socket_id(self) -> Option { - let id = unsafe { SocketId(ffi::rte_eth_dev_socket_id(self.0)) }; - if SocketId::all().contains(&id) { - Some(id) - } else { - None - } - } - - /// Returns the raw value needed for FFI calls. - #[allow(clippy::trivially_copy_pass_by_ref)] - #[inline] - pub(crate) fn raw(&self) -> u16 { - self.0 - } -} - -impl fmt::Debug for PortId { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "port{}", self.0) - } -} - -/// The index of a receive queue. -#[derive(Copy, Clone)] -pub(crate) struct RxQueueIndex(u16); - -impl RxQueueIndex { - /// Returns the raw value needed for FFI calls. - #[allow(clippy::trivially_copy_pass_by_ref, dead_code)] - #[inline] - pub(crate) fn raw(&self) -> u16 { - self.0 - } -} - -/// The index of a transmit queue. -#[derive(Copy, Clone)] -pub(crate) struct TxQueueIndex(u16); - -impl TxQueueIndex { - /// Returns the raw value needed for FFI calls. - #[allow(clippy::trivially_copy_pass_by_ref, dead_code)] - #[inline] - pub(crate) fn raw(&self) -> u16 { - self.0 - } -} - -/// Either queue type (receive or transmit) with associated index. -#[allow(dead_code)] -pub(crate) enum RxTxQueue { - Rx(RxQueueIndex), - Tx(TxQueueIndex), -} - -/// The receive and transmit queue abstraction. Instead of modeling them -/// as two standalone queues, in the run-to-completion mode, they are modeled -/// as a queue pair associated with the core that runs the pipeline from -/// receive to send. -#[allow(missing_debug_implementations)] -#[derive(Clone)] -pub struct PortQueue { - port_id: PortId, - rxq: RxQueueIndex, - txq: TxQueueIndex, - kni: Option, - #[cfg(feature = "metrics")] - received: Option, - #[cfg(feature = "metrics")] - transmitted: Option, - #[cfg(feature = "metrics")] - dropped: Option, -} - -impl PortQueue { - #[cfg(not(feature = "metrics"))] - fn new(port: PortId, rxq: RxQueueIndex, txq: TxQueueIndex) -> Self { - PortQueue { - port_id: port, - rxq, - txq, - kni: None, - } - } - - #[cfg(feature = "metrics")] - fn new(port: PortId, rxq: RxQueueIndex, txq: TxQueueIndex) -> Self { - PortQueue { - port_id: port, - rxq, - txq, - kni: None, - received: None, - transmitted: None, - dropped: None, - } - } - /// Receives a burst of packets from the receive queue, up to a maximum - /// of 32 packets. - pub(crate) fn receive(&self) -> Vec { - const RX_BURST_MAX: usize = 32; - let mut ptrs = Vec::with_capacity(RX_BURST_MAX); - - let len = unsafe { - ffi::_rte_eth_rx_burst( - self.port_id.0, - self.rxq.0, - ptrs.as_mut_ptr(), - RX_BURST_MAX as u16, - ) - }; - - #[cfg(feature = "metrics")] - self.received.as_ref().unwrap().record(len as u64); - - unsafe { - ptrs.set_len(len as usize); - ptrs.into_iter() - .map(|ptr| Mbuf::from_ptr(ptr)) - .collect::>() - } - } - - /// Sends the packets to the transmit queue. - pub(crate) fn transmit(&self, packets: Vec) { - let mut ptrs = packets.into_iter().map(Mbuf::into_ptr).collect::>(); - - loop { - let to_send = ptrs.len() as u16; - let sent = unsafe { - ffi::_rte_eth_tx_burst(self.port_id.0, self.txq.0, ptrs.as_mut_ptr(), to_send) - }; - - if sent > 0 { - #[cfg(feature = "metrics")] - self.transmitted.as_ref().unwrap().record(sent as u64); - - if to_send - sent > 0 { - // still have packets not sent. tx queue is full but still making - // progress. we will keep trying until all packets are sent. drains - // the ones already sent first and try again on the rest. - let _drained = ptrs.drain(..sent as usize).collect::>(); - } else { - break; - } - } else { - // tx queue is full and we can't make progress, start dropping packets - // to avoid potentially stuck in an endless loop. - #[cfg(feature = "metrics")] - self.dropped.as_ref().unwrap().record(ptrs.len() as u64); - - super::mbuf_free_bulk(ptrs); - break; - } - } - } - - /// Returns a handle to send packets to the associated KNI interface. - pub fn kni(&self) -> Option<&KniTxQueue> { - self.kni.as_ref() - } - - /// Sets the TX queue for the KNI interface. - fn set_kni(&mut self, kni: KniTxQueue) { - self.kni = Some(kni); - } - - /// Sets the per queue counters. Some device drivers don't track TX - /// and RX packets per queue. Instead we will track them here for all - /// devices. Additionally we also track the TX packet drops when the - /// TX queue is full. - #[cfg(feature = "metrics")] - fn set_counters(&mut self, port: &str, core_id: CoreId) { - let counter = SINK.scoped("port").counter_with_labels( - "packets", - labels!( - "port" => port.to_owned(), - "dir" => "rx", - "core" => core_id.0.to_string(), - ), - ); - self.received = Some(counter); - - let counter = SINK.scoped("port").counter_with_labels( - "packets", - labels!( - "port" => port.to_owned(), - "dir" => "tx", - "core" => core_id.0.to_string(), - ), - ); - self.transmitted = Some(counter); - - let counter = SINK.scoped("port").counter_with_labels( - "dropped", - labels!( - "port" => port.to_owned(), - "dir" => "tx", - "core" => core_id.0.to_string(), - ), - ); - self.dropped = Some(counter); - } - - /// Returns the MAC address of the port. - pub fn mac_addr(&self) -> MacAddr { - super::eth_macaddr_get(self.port_id.0) - } -} - -/// Error indicating failed to initialize the port. -#[derive(Debug, Error)] -pub(crate) enum PortError { - /// Port is not found. - #[error("Port {0} is not found.")] - NotFound(String), - - #[error("Port is not bound to any cores.")] - CoreNotBound, - - /// The maximum number of RX queues is less than the number of cores - /// assigned to the port. - #[error("Insufficient number of RX queues '{0}'.")] - InsufficientRxQueues(usize), - - /// The maximum number of TX queues is less than the number of cores - /// assigned to the port. - #[error("Insufficient number of TX queues '{0}'.")] - InsufficientTxQueues(usize), -} - -/// An Ethernet device port. -pub(crate) struct Port { - id: PortId, - name: String, - device: String, - queues: HashMap, - kni: Option, - dev_info: ffi::rte_eth_dev_info, -} - -impl Port { - /// Returns the port id. - pub(crate) fn id(&self) -> PortId { - self.id - } - - /// Returns the application assigned logical name of the port. - /// - /// For applications with more than one port, this name can be used to - /// identifer the port. - pub(crate) fn name(&self) -> &str { - self.name.as_str() - } - - /// Returns the MAC address of the port. - pub(crate) fn mac_addr(&self) -> MacAddr { - super::eth_macaddr_get(self.id.0) - } - - /// Returns the available port queues. - pub(crate) fn queues(&self) -> &HashMap { - &self.queues - } - - /// Returns the KNI. - pub(crate) fn kni(&mut self) -> Option<&mut Kni> { - self.kni.as_mut() - } - - /// Starts the port. This is the final step before packets can be - /// received or transmitted on this port. Promiscuous mode is also - /// enabled automatically. - /// - /// # Errors - /// - /// If the port fails to start, `DpdkError` is returned. - pub(crate) fn start(&mut self) -> Result<()> { - unsafe { - ffi::rte_eth_dev_start(self.id.0).into_result(DpdkError::from_errno)?; - } - - info!("started port {}.", self.name()); - Ok(()) - } - - /// Stops the port. - pub(crate) fn stop(&mut self) { - unsafe { - ffi::rte_eth_dev_stop(self.id.0); - } - - info!("stopped port {}.", self.name()); - } - - #[cfg(feature = "metrics")] - pub(crate) fn stats(&self) -> super::PortStats { - super::PortStats::build(self) - } -} - -impl fmt::Debug for Port { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let info = self.dev_info; - f.debug_struct(&self.name()) - .field("device", &self.device) - .field("port", &self.id.0) - .field("mac", &format_args!("\"{}\"", self.mac_addr())) - .field("driver", &info.driver_name.as_str()) - .field("rx_offload", &format_args!("{:#x}", info.rx_offload_capa)) - .field("tx_offload", &format_args!("{:#x}", info.tx_offload_capa)) - .field("max_rxq", &info.max_rx_queues) - .field("max_txq", &info.max_tx_queues) - .field("socket", &self.id.socket_id().map_or(-1, |s| s.0)) - .finish() - } -} - -impl Drop for Port { - fn drop(&mut self) { - debug!("freeing {}.", self.name); - - unsafe { - ffi::rte_eth_dev_close(self.id.0); - } - } -} - -/// Builds a port from the configuration values. -pub(crate) struct PortBuilder<'a> { - name: String, - device: String, - port_id: PortId, - dev_info: ffi::rte_eth_dev_info, - cores: Vec, - mempools: MempoolMap<'a>, - rxd: u16, - txd: u16, -} - -impl<'a> PortBuilder<'a> { - /// Creates a new `PortBuilder` with a logical name and device name. - /// - /// The device name can be the following - /// * PCIe address, for example `0000:02:00.0` - /// * DPDK virtual device, for example `net_[pcap0|null0|tap0]` - /// - /// # Errors - /// - /// If the device is not found, `DpdkError` is returned. - pub(crate) fn new(name: String, device: String) -> Result { - let mut port_id = 0u16; - unsafe { - ffi::rte_eth_dev_get_port_by_name(device.clone().into_cstring().as_ptr(), &mut port_id) - .into_result(DpdkError::from_errno)?; - } - - let port_id = PortId(port_id); - debug!("{} is {:?}.", name, port_id); - - let mut dev_info = ffi::rte_eth_dev_info::default(); - unsafe { - ffi::rte_eth_dev_info_get(port_id.0, &mut dev_info); - } - - Ok(PortBuilder { - name, - device, - port_id, - dev_info, - cores: vec![CoreId::new(0)], - mempools: Default::default(), - rxd: 0, - txd: 0, - }) - } - - /// Sets the processing cores assigned to the port. - /// - /// Each core assigned will receive from and transmit through the port - /// independently using the run-to-completion model. - /// - /// # Errors - /// - /// If either the maximum number of RX or TX queues is less than the - /// number of cores assigned, `PortError` is returned. - pub(crate) fn cores(&mut self, cores: &[CoreId]) -> Result<&mut Self> { - ensure!(!cores.is_empty(), PortError::CoreNotBound); - - let mut cores = cores.to_vec(); - cores.sort(); - cores.dedup(); - let len = cores.len() as u16; - - ensure!( - self.dev_info.max_rx_queues >= len, - PortError::InsufficientRxQueues(self.dev_info.max_rx_queues as usize) - ); - ensure!( - self.dev_info.max_tx_queues >= len, - PortError::InsufficientTxQueues(self.dev_info.max_tx_queues as usize) - ); - - self.cores = cores; - Ok(self) - } - - /// Sets the receive and transmit queues' capacity. - /// - /// `rxd` is the receive queue capacity and `txd` is the trasmit queue - /// capacity. The values are checked against the descriptor limits of - /// the Ethernet device, and are adjusted if they exceed the boundaries. - /// - /// # Errors - /// - /// If the adjustment failed, `DpdkError` is returned. - pub(crate) fn rx_tx_queue_capacity(&mut self, rxd: usize, txd: usize) -> Result<&mut Self> { - let mut rxd2 = rxd as u16; - let mut txd2 = txd as u16; - - unsafe { - ffi::rte_eth_dev_adjust_nb_rx_tx_desc(self.port_id.0, &mut rxd2, &mut txd2) - .into_result(DpdkError::from_errno)?; - } - - info!( - cond: rxd2 != rxd as u16, - message = "adjusted rxd.", - before = rxd, - after = rxd2 - ); - info!( - cond: txd2 != txd as u16, - message = "adjusted txd.", - before = txd, - after = txd2 - ); - - self.rxd = rxd2; - self.txd = txd2; - Ok(self) - } - - /// Sets the available mempools. - pub(crate) fn mempools(&'a mut self, mempools: &'a mut [Mempool]) -> &'a mut Self { - self.mempools = MempoolMap::new(mempools); - self - } - - /// Creates the `Port`. - #[allow(clippy::cognitive_complexity)] - pub(crate) fn finish( - &mut self, - promiscuous: bool, - multicast: bool, - with_kni: bool, - ) -> anyhow::Result { - let len = self.cores.len() as u16; - let mut conf = ffi::rte_eth_conf::default(); - - // turns on receive side scaling if port has multiple cores. - if len > 1 { - conf.rxmode.mq_mode = ffi::rte_eth_rx_mq_mode::ETH_MQ_RX_RSS; - conf.rx_adv_conf.rss_conf.rss_hf = - DEFAULT_RSS_HF & self.dev_info.flow_type_rss_offloads; - } - - // turns on optimization for fast release of mbufs. - if self.dev_info.tx_offload_capa & ffi::DEV_TX_OFFLOAD_MBUF_FAST_FREE as u64 > 0 { - conf.txmode.offloads |= ffi::DEV_TX_OFFLOAD_MBUF_FAST_FREE as u64; - debug!("turned on optimization for fast release of mbufs."); - } - - // must configure the device first before everything else. - unsafe { - ffi::rte_eth_dev_configure(self.port_id.0, len, len, &conf) - .into_result(DpdkError::from_errno)?; - } - - // if the port is virtual, we will allocate it to the socket of - // the first assigned core. - let socket_id = self - .port_id - .socket_id() - .unwrap_or_else(|| self.cores[0].socket_id()); - debug!("{} connected to {:?}.", self.name, socket_id); - - // the socket determines which pool to allocate mbufs from. - let mempool = self.mempools.get_raw(socket_id)?; - - // if the port has kni enabled, we will allocate an interface. - let kni = if with_kni { - let kni = KniBuilder::new(mempool) - .name(&self.name) - .port_id(self.port_id) - .mac_addr(super::eth_macaddr_get(self.port_id.raw())) - .finish()?; - Some(kni) - } else { - None - }; - - let mut queues = HashMap::new(); - - // for each core, we setup a rx/tx queue pair. for simplicity, we - // will use the same index for both queues. - for (idx, &core_id) in self.cores.iter().enumerate() { - // for best performance, the port and cores should connect to - // the same socket. - warn!( - cond: core_id.socket_id() != socket_id, - message = "core socket does not match port socket.", - core = ?core_id, - core_socket = core_id.socket_id().0, - port_socket = socket_id.0 - ); - - // configures the RX queue with defaults - let rxq = RxQueueIndex(idx as u16); - unsafe { - ffi::rte_eth_rx_queue_setup( - self.port_id.0, - rxq.0, - self.rxd, - socket_id.0 as raw::c_uint, - ptr::null(), - mempool, - ) - .into_result(DpdkError::from_errno)?; - } - - // configures the TX queue with defaults - let txq = TxQueueIndex(idx as u16); - unsafe { - ffi::rte_eth_tx_queue_setup( - self.port_id.0, - txq.0, - self.txd, - socket_id.0 as raw::c_uint, - ptr::null(), - ) - .into_result(DpdkError::from_errno)?; - } - - #[cfg(feature = "pcap-dump")] - { - pcap::capture_queue( - self.port_id, - self.name.as_str(), - core_id, - RxTxQueue::Rx(rxq), - )?; - - pcap::capture_queue( - self.port_id, - self.name.as_str(), - core_id, - RxTxQueue::Tx(txq), - )?; - } - - let mut q = PortQueue::new(self.port_id, rxq, txq); - - if let Some(kni) = &kni { - q.set_kni(kni.txq()); - } - - #[cfg(feature = "metrics")] - q.set_counters(&self.name, core_id); - - queues.insert(core_id, q); - debug!("initialized port queue for {:?}.", core_id); - } - - unsafe { - // sets the port's promiscuous mode. - if promiscuous { - ffi::rte_eth_promiscuous_enable(self.port_id.0); - } else { - ffi::rte_eth_promiscuous_disable(self.port_id.0); - } - - // sets the port's multicast mode. - if multicast { - ffi::rte_eth_allmulticast_enable(self.port_id.0); - } else { - ffi::rte_eth_allmulticast_disable(self.port_id.0); - } - } - - info!("initialized port {}.", self.name); - - Ok(Port { - id: self.port_id, - name: self.name.clone(), - device: self.device.clone(), - queues, - kni, - dev_info: self.dev_info, - }) - } -} diff --git a/core/src/dpdk/stats.rs b/core/src/dpdk/stats.rs deleted file mode 100644 index a12f41e8..00000000 --- a/core/src/dpdk/stats.rs +++ /dev/null @@ -1,130 +0,0 @@ -/* -* Copyright 2019 Comcast Cable Communications Management, LLC -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* SPDX-License-Identifier: Apache-2.0 -*/ - -use super::{Mempool, Port, PortId}; -use crate::dpdk::DpdkError; -use crate::ffi::{self, AsStr, ToResult}; -use crate::metrics::{labels, Key, Measurement}; -use anyhow::Result; -use std::ptr::NonNull; - -/// Port stats collector. -pub(crate) struct PortStats { - id: PortId, - name: String, -} - -impl PortStats { - /// Builds a collector from the port. - pub(crate) fn build(port: &Port) -> Self { - PortStats { - id: port.id(), - name: port.name().to_owned(), - } - } - - /// Returns the port name. - pub(crate) fn name(&self) -> &str { - self.name.as_str() - } - - /// Returns a counter with port and direction labels. - fn new_counter(&self, name: &'static str, value: u64, dir: &'static str) -> (Key, Measurement) { - ( - Key::from_name_and_labels( - name, - labels!( - "port" => self.name.clone(), - "dir" => dir, - ), - ), - Measurement::Counter(value), - ) - } - - /// Collects the port stats tracked by DPDK. - pub(crate) fn collect(&self) -> Result> { - let mut stats = ffi::rte_eth_stats::default(); - unsafe { - ffi::rte_eth_stats_get(self.id.raw(), &mut stats).into_result(DpdkError::from_errno)?; - } - - let mut values = Vec::new(); - - values.push(self.new_counter("octets", stats.ibytes, "rx")); - values.push(self.new_counter("octets", stats.obytes, "tx")); - values.push(self.new_counter("dropped", stats.imissed, "rx")); - values.push(self.new_counter("errors", stats.ierrors, "rx")); - values.push(self.new_counter("errors", stats.oerrors, "tx")); - values.push(self.new_counter("no_mbuf", stats.rx_nombuf, "rx")); - - Ok(values) - } -} - -/// Mempool stats collector. -pub(crate) struct MempoolStats { - raw: NonNull, -} - -impl MempoolStats { - /// Builds a collector from the port. - pub(crate) fn build(mempool: &Mempool) -> Self { - MempoolStats { - raw: unsafe { - NonNull::new_unchecked( - mempool.raw() as *const ffi::rte_mempool as *mut ffi::rte_mempool - ) - }, - } - } - - fn raw(&self) -> &ffi::rte_mempool { - unsafe { self.raw.as_ref() } - } - - /// Returns the name of the `Mempool`. - fn name(&self) -> &str { - self.raw().name[..].as_str() - } - - /// Returns a gauge. - fn new_gauge(&self, name: &'static str, value: i64) -> (Key, Measurement) { - ( - Key::from_name_and_labels( - name, - labels!( - "pool" => self.name().to_string(), - ), - ), - Measurement::Gauge(value), - ) - } - - /// Collects the mempool stats. - pub(crate) fn collect(&self) -> Vec<(Key, Measurement)> { - let used = unsafe { ffi::rte_mempool_in_use_count(self.raw()) as i64 }; - let free = self.raw().size as i64 - used; - - vec![self.new_gauge("used", used), self.new_gauge("free", free)] - } -} - -/// Send mempool stats across threads. -unsafe impl Send for MempoolStats {} -unsafe impl Sync for MempoolStats {} diff --git a/core/src/ffi/dpdk.rs b/core/src/ffi/dpdk.rs index 1f54ff31..e4a7591f 100644 --- a/core/src/ffi/dpdk.rs +++ b/core/src/ffi/dpdk.rs @@ -67,13 +67,8 @@ pub(crate) struct SocketId(raw::c_int); impl SocketId { /// A socket ID representing any NUMA socket. + #[allow(dead_code)] pub(crate) const ANY: Self = SocketId(-1); - - /// Returns the ID of the socket the current core is on. - #[inline] - pub(crate) fn current() -> SocketId { - unsafe { SocketId(cffi::rte_socket_id() as raw::c_int) } - } } impl fmt::Debug for SocketId { @@ -93,7 +88,7 @@ pub(crate) type MempoolPtr = EasyPtr; impl Clone for MempoolPtr { fn clone(&self) -> Self { - self.0.clone().into() + self.0.into() } } @@ -137,6 +132,7 @@ pub(crate) fn mempool_lookup>(name: S) -> Result { } /// Returns the number of elements which have been allocated from the mempool. +#[allow(dead_code)] pub(crate) fn mempool_in_use_count(mp: &MempoolPtr) -> usize { unsafe { cffi::rte_mempool_in_use_count(mp.deref()) as usize } } @@ -152,6 +148,7 @@ pub(crate) struct LcoreId(raw::c_uint); impl LcoreId { /// Any lcore to indicate that no thread affinity is set. + #[cfg(test)] pub(crate) const ANY: Self = LcoreId(raw::c_uint::MAX); /// Returns the ID of the current execution unit or `LcoreId::ANY` when @@ -201,14 +198,14 @@ pub(crate) fn get_next_lcore( match unsafe { cffi::rte_get_next_lcore(i, skip_master, wrap) } { cffi::RTE_MAX_LCORE => None, - id @ _ => Some(LcoreId(id)), + id => Some(LcoreId(id)), } } /// The function passed to `rte_eal_remote_launch`. unsafe extern "C" fn lcore_fn(arg: *mut raw::c_void) -> raw::c_int where - F: FnOnce() -> () + Send + 'static, + F: FnOnce() + Send + 'static, { let f = Box::from_raw(arg as *mut F); @@ -225,7 +222,7 @@ where /// Launches a function on another lcore. pub(crate) fn eal_remote_launch(worker_id: LcoreId, f: F) -> Result<()> where - F: FnOnce() -> () + Send + 'static, + F: FnOnce() + Send + 'static, { let ptr = Box::into_raw(Box::new(f)) as *mut raw::c_void; @@ -303,11 +300,10 @@ pub(crate) fn eth_dev_adjust_nb_rx_tx_desc( /// Returns the value of promiscuous mode for a device. pub(crate) fn eth_promiscuous_get(port_id: PortId) -> bool { - match unsafe { cffi::rte_eth_promiscuous_get(port_id.0).into_result(DpdkError::from_errno) } { - Ok(1) => true, - // assuming port_id is valid, we treat error as mode disabled. - _ => false, - } + let mode = + unsafe { cffi::rte_eth_promiscuous_get(port_id.0).into_result(DpdkError::from_errno) }; + // assuming port_id is valid, treats Ok(0) and Err(_) both as disabled. + matches!(mode, Ok(1)) } /// Enables receipt in promiscuous mode for a device. @@ -330,11 +326,10 @@ pub(crate) fn eth_promiscuous_disable(port_id: PortId) -> Result<()> { /// Returns the value of allmulticast mode for a device. pub(crate) fn eth_allmulticast_get(port_id: PortId) -> bool { - match unsafe { cffi::rte_eth_allmulticast_get(port_id.0).into_result(DpdkError::from_errno) } { - Ok(1) => true, - // assuming port_id is valid, we treat error as mode disabled. - _ => false, - } + let mode = + unsafe { cffi::rte_eth_allmulticast_get(port_id.0).into_result(DpdkError::from_errno) }; + // assuming port_id is valid, treats Ok(0) and Err(_) both as disabled. + matches!(mode, Ok(1)) } /// Enables the receipt of any multicast frame by a device. diff --git a/core/src/ffi/mod.rs b/core/src/ffi/mod.rs index b0cac1a1..0f93d846 100644 --- a/core/src/ffi/mod.rs +++ b/core/src/ffi/mod.rs @@ -20,8 +20,6 @@ pub(crate) mod dpdk; #[cfg(feature = "pcap-dump")] pub(crate) mod pcap; -pub(crate) use capsule_ffi::*; - use crate::warn; use anyhow::Result; use std::error::Error; @@ -163,14 +161,12 @@ impl DerefMut for EasyPtr { } } -// delete later? impl From> for EasyPtr { fn from(ptr: NonNull) -> Self { EasyPtr(ptr) } } -// delete later? impl From> for NonNull { fn from(ptr: EasyPtr) -> Self { ptr.0 diff --git a/core/src/ffi/pcap.rs b/core/src/ffi/pcap.rs index 812b043a..6eeb74a9 100644 --- a/core/src/ffi/pcap.rs +++ b/core/src/ffi/pcap.rs @@ -20,7 +20,6 @@ use super::{AsStr, EasyPtr, ToCString, ToResult}; use crate::ffi::dpdk::MbufPtr; use anyhow::Result; use capsule_ffi as cffi; -use libc; use std::ops::DerefMut; use std::os::raw; use std::ptr; @@ -104,6 +103,26 @@ pub(crate) fn close(handle: &mut PcapPtr) { } } +/// An error generated in `libpcap`. +#[derive(Debug, Error)] +#[error("{0}")] +pub(crate) struct PcapError(String); + +impl PcapError { + /// Returns the `PcapError` with the given error message. + #[inline] + fn new(msg: &str) -> Self { + PcapError(msg.into()) + } + + /// Returns the `PcapError` pertaining to the last `libpcap` error. + #[inline] + fn get_error(handle: &mut PcapPtr) -> Self { + let msg = unsafe { cffi::pcap_geterr(handle.deref_mut()) }; + PcapError::new((msg as *const raw::c_char).as_str()) + } +} + /// Opens a saved capture file for reading. #[cfg(test)] pub(crate) fn open_offline>(filename: S) -> Result { @@ -134,23 +153,3 @@ pub(crate) fn next(handle: &mut PcapPtr) -> Result<&[u8]> { } } } - -/// An error generated in `libpcap`. -#[derive(Debug, Error)] -#[error("{0}")] -pub(crate) struct PcapError(String); - -impl PcapError { - /// Returns the `PcapError` with the given error message. - #[inline] - fn new(msg: &str) -> Self { - PcapError(msg.into()) - } - - /// Returns the `PcapError` pertaining to the last `libpcap` error. - #[inline] - fn get_error(handle: &mut PcapPtr) -> Self { - let msg = unsafe { cffi::pcap_geterr(handle.deref_mut()) }; - PcapError::new((msg as *const raw::c_char).as_str()) - } -} diff --git a/core/src/lib.rs b/core/src/lib.rs index b42ac8ab..8fdeb4b2 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -82,8 +82,7 @@ //! //! ## Feature flags //! -//! - `default`: Enables metrics by default. -//! - `metrics`: Enables automatic [`metrics`] collection. +//! - `default`: None of the features are enabled. //! - `pcap-dump`: Enables capturing port traffic to `pcap` files. //! - `testils`: Enables utilities for unit testing and benchmarking. //! - `full`: Enables all features. @@ -94,7 +93,6 @@ //! - [nat64]: IPv6 to IPv4 NAT gateway example. //! - [ping4d]: Ping4 daemon example. //! - [pktdump]: Packet dump example. -//! - [signals]: Linux signal handling example. //! - [skeleton]: Base skeleton example. //! - [syn-flood]: TCP SYN flood example. //! @@ -109,40 +107,25 @@ //! [rr]: https://rr-project.org/ //! [README]: https://github.com/capsule-rs/capsule/blob/master/README.md //! [sandbox repo]: https://github.com/capsule-rs/sandbox -//! [`metrics`]: crate::metrics //! [kni]: https://github.com/capsule-rs/capsule/tree/master/examples/kni //! [nat64]: https://github.com/capsule-rs/capsule/tree/master/examples/nat64 //! [ping4d]: https://github.com/capsule-rs/capsule/tree/master/examples/ping4d //! [pktdump]: https://github.com/capsule-rs/capsule/tree/master/examples/pktdump -//! [signals]: https://github.com/capsule-rs/capsule/tree/master/examples/signals //! [skeleton]: https://github.com/capsule-rs/capsule/tree/master/examples/skeleton //! [syn-flood]: https://github.com/capsule-rs/capsule/tree/master/examples/syn-flood // alias for the macros extern crate self as capsule; -pub mod batch; -pub mod config; -mod dpdk; pub(crate) mod ffi; mod macros; -#[cfg(feature = "metrics")] -#[cfg_attr(docsrs, doc(cfg(all(feature = "default", feature = "metrics"))))] -pub mod metrics; pub mod net; pub mod packets; -#[cfg(feature = "pcap-dump")] -#[cfg_attr(docsrs, doc(cfg(feature = "pcap-dump")))] -mod pcap; -pub mod rt2; -mod runtime; +pub mod runtime; #[cfg(any(test, feature = "testils"))] #[cfg_attr(docsrs, doc(cfg(feature = "testils")))] pub mod testils; -pub use self::dpdk::{KniRx, KniTxQueue, Mbuf, PortQueue, SizeOf}; -pub use self::runtime::{Runtime, UnixSignal}; -pub use capsule_macros::SizeOf; #[cfg(any(test, feature = "testils"))] #[cfg_attr(docsrs, doc(cfg(feature = "testils")))] pub use capsule_macros::{bench, test}; diff --git a/core/src/metrics.rs b/core/src/metrics.rs deleted file mode 100644 index 83232974..00000000 --- a/core/src/metrics.rs +++ /dev/null @@ -1,140 +0,0 @@ -/* -* Copyright 2019 Comcast Cable Communications Management, LLC -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* SPDX-License-Identifier: Apache-2.0 -*/ - -//! Exposes framework metrics, including port, kni, mempool, and pipeline -//! metrics. -//! -//! # Port Metrics -//! -//! * `port.packets`, total number of successfully received or transmitted -//! packets. -//! * `port.octets`, total number of successfully received or transmitted -//! bytes. -//! * `port.dropped`, total number of packets dropped because the receive -//! or transmit queues are full. -//! * `port.errors`, total number of erroneous received packets or packets -//! failed to transmit. -//! * `port.no_mbuf`, total number of packets dropped due to mbuf allocation -//! failures. -//! -//! Each metric is labeled with the port name and a direction, which can be -//! either RX or TX. `port.packets` and `port.dropped` are tracked per core -//! and labeled with the core id. The others are tracked by only the overall -//! metrics. -//! -//! -//! # KNI Metrics -//! -//! * `kni.packets`, total number of successfully received or transmitted -//! packets. -//! * `kni.octets`, total number of successfully received or transmitted bytes. -//! * `kni.dropped`, total number of packets dropped because the transmit -//! queue is full. -//! -//! Each metric is labeled with the KNI interface name and a direction, which -//! can be either RX or TX. -//! -//! -//! # Mempool Metrics -//! -//! * `mempool.used`, total number of mbufs which have been allocated from -//! the mempool. -//! * `mempool.free`, total number of mbufs available for allocation. -//! -//! Each metric is labeled with the mempool name. -//! -//! -//! # Pipeline Metrics -//! -//! * `pipeline.runs`, total number of times the pipeline executes. -//! * `pipeline.processed`, total number of successfully processed packets. -//! * `pipeline.dropped`, total number of packets intentionally dropped. -//! * `pipeline.errors`, total number of packet dropped due to processing -//! errors. -//! -//! Each metric is tracked per core and labeled with the core id and the -//! pipeline name. If the pipeline doesn't have a name, it will be labeled -//! as "default". - -// re-export some metrics types to make feature gated imports easier. -pub(crate) use metrics_core::{labels, Key}; -pub(crate) use metrics_runtime::data::Counter; -pub(crate) use metrics_runtime::Measurement; - -use crate::dpdk::{Mempool, MempoolStats, Port}; -use crate::warn; -use anyhow::{anyhow, Result}; -use metrics_runtime::{Receiver, Sink}; -use once_cell::sync::{Lazy, OnceCell}; - -/// The metrics store. -static RECEIVER: OnceCell = OnceCell::new(); - -/// Safely initializes the metrics store. Because the receiver builder could -/// potentially fail, the `Lazy` convenience type is not safe. -/// -/// Also very important that `init` is not called twice. -pub(crate) fn init() -> Result<()> { - let receiver = Receiver::builder().build()?; - - RECEIVER - .set(receiver) - .map_err(|_| anyhow!("already initialized."))?; - Ok(()) -} - -/// Registers DPDK collected port stats with the metrics store. -pub(crate) fn register_port_stats(ports: &[Port]) { - let stats = ports.iter().map(Port::stats).collect::>(); - SINK.clone().proxy("port", move || { - stats - .iter() - .flat_map(|s| { - s.collect().unwrap_or_else(|err| { - warn!(message = "failed to collect stats.", port = s.name(), ?err); - Vec::new() - }) - }) - .collect() - }); -} - -/// Registers collected mempool stats with the metrics store. -pub(crate) fn register_mempool_stats(mempools: &[Mempool]) { - let stats = mempools.iter().map(Mempool::stats).collect::>(); - SINK.clone().proxy("mempool", move || { - stats.iter().flat_map(MempoolStats::collect).collect() - }); -} - -/// Returns the global metrics store. -/// -/// Metrics are managed using [metrics-rs]. The application can use this to -/// access framework metrics or to add new application metrics. -/// -/// # Panics -/// -/// Panics if `Runtime::build` is not called first. -/// -/// [metrics-rs]: https://github.com/metrics-rs -pub fn global() -> &'static Receiver { - unsafe { RECEIVER.get_unchecked() } -} - -/// The root sink for all framework metrics. -pub(crate) static SINK: Lazy = Lazy::new(|| global().sink().scoped("capsule")); diff --git a/core/src/net/cidr/v4.rs b/core/src/net/cidr/v4.rs index 1da5bc6f..a417067a 100644 --- a/core/src/net/cidr/v4.rs +++ b/core/src/net/cidr/v4.rs @@ -160,7 +160,7 @@ impl FromStr for Ipv4Cidr { let address = Ipv4Addr::from_str(addr).map_err(|e| CidrError::Malformed(e.to_string()))?; - if let Ok(len) = usize::from_str_radix(len_or_netmask, 10) { + if let Ok(len) = len_or_netmask.parse::() { Ipv4Cidr::new(address, len) } else { let netmask = Ipv4Addr::from_str(len_or_netmask) diff --git a/core/src/net/cidr/v6.rs b/core/src/net/cidr/v6.rs index 30e7c842..b960e243 100644 --- a/core/src/net/cidr/v6.rs +++ b/core/src/net/cidr/v6.rs @@ -160,7 +160,7 @@ impl FromStr for Ipv6Cidr { let address = Ipv6Addr::from_str(addr).map_err(|e| CidrError::Malformed(e.to_string()))?; - if let Ok(len) = usize::from_str_radix(len_or_netmask, 10) { + if let Ok(len) = len_or_netmask.parse::() { Ipv6Cidr::new(address, len) } else { let netmask = Ipv6Addr::from_str(len_or_netmask) diff --git a/core/src/packets/arp.rs b/core/src/packets/arp.rs index d6744044..ab2d1041 100644 --- a/core/src/packets/arp.rs +++ b/core/src/packets/arp.rs @@ -18,10 +18,11 @@ //! Address Resolution Protocol. +use crate::ensure; use crate::net::MacAddr; +use crate::packets::ethernet::{EtherTypes, Ethernet}; use crate::packets::types::u16be; -use crate::packets::{EtherTypes, Ethernet, Internal, Packet}; -use crate::{ensure, SizeOf}; +use crate::packets::{Internal, Packet, SizeOf}; use anyhow::{anyhow, Result}; use std::fmt; use std::net::Ipv4Addr; @@ -533,12 +534,6 @@ pub trait HardwareAddr: SizeOf + Copy + fmt::Display { fn default() -> Self; } -impl SizeOf for MacAddr { - fn size_of() -> usize { - 6 - } -} - impl HardwareAddr for MacAddr { fn addr_type() -> HardwareType { HardwareTypes::Ethernet @@ -561,12 +556,6 @@ pub trait ProtocolAddr: SizeOf + Copy + fmt::Display { fn default() -> Self; } -impl SizeOf for Ipv4Addr { - fn size_of() -> usize { - 4 - } -} - impl ProtocolAddr for Ipv4Addr { fn addr_type() -> ProtocolType { ProtocolTypes::Ipv4 @@ -631,8 +620,8 @@ impl Default for ArpHeader { #[cfg(test)] mod tests { use super::*; + use crate::packets::Mbuf; use crate::testils::byte_arrays::ARP4_PACKET; - use crate::Mbuf; #[test] fn size_of_arp_header() { diff --git a/core/src/packets/ethernet.rs b/core/src/packets/ethernet.rs index eb3a6e93..6f6c6475 100644 --- a/core/src/packets/ethernet.rs +++ b/core/src/packets/ethernet.rs @@ -16,12 +16,13 @@ * SPDX-License-Identifier: Apache-2.0 */ -use crate::dpdk::BufferError; +//! Ethernet Protocol. + +use crate::ensure; use crate::net::MacAddr; use crate::packets::types::u16be; -use crate::packets::{Internal, Packet}; -use crate::{ensure, Mbuf, SizeOf}; -use anyhow::Result; +use crate::packets::{Internal, Mbuf, Packet, SizeOf}; +use anyhow::{anyhow, Result}; use std::fmt; use std::ptr::NonNull; @@ -293,7 +294,7 @@ impl Packet for Ethernet { // header will cause a panic. ensure!( packet.mbuf().data_len() >= packet.header_len(), - BufferError::OutOfBuffer(packet.header_len(), packet.mbuf().data_len()) + anyhow!("header size exceeds remaining buffer size.") ); Ok(packet) diff --git a/core/src/packets/icmp/v4/echo_reply.rs b/core/src/packets/icmp/v4/echo_reply.rs index 71c3ac6a..35738ba5 100644 --- a/core/src/packets/icmp/v4/echo_reply.rs +++ b/core/src/packets/icmp/v4/echo_reply.rs @@ -18,8 +18,7 @@ use crate::packets::icmp::v4::{Icmpv4, Icmpv4Message, Icmpv4Packet, Icmpv4Type, Icmpv4Types}; use crate::packets::types::u16be; -use crate::packets::{Internal, Packet}; -use crate::SizeOf; +use crate::packets::{Internal, Packet, SizeOf}; use anyhow::Result; use std::fmt; use std::ptr::NonNull; @@ -219,9 +218,9 @@ struct EchoReplyBody { #[cfg(test)] mod tests { use super::*; + use crate::packets::ethernet::Ethernet; use crate::packets::ip::v4::Ipv4; - use crate::packets::Ethernet; - use crate::Mbuf; + use crate::packets::Mbuf; #[test] fn size_of_echo_reply_body() { diff --git a/core/src/packets/icmp/v4/echo_request.rs b/core/src/packets/icmp/v4/echo_request.rs index cd08593a..e388abdb 100644 --- a/core/src/packets/icmp/v4/echo_request.rs +++ b/core/src/packets/icmp/v4/echo_request.rs @@ -18,8 +18,7 @@ use crate::packets::icmp::v4::{Icmpv4, Icmpv4Message, Icmpv4Packet, Icmpv4Type, Icmpv4Types}; use crate::packets::types::u16be; -use crate::packets::{Internal, Packet}; -use crate::SizeOf; +use crate::packets::{Internal, Packet, SizeOf}; use anyhow::Result; use std::fmt; use std::ptr::NonNull; @@ -220,9 +219,9 @@ struct EchoRequestBody { #[cfg(test)] mod tests { use super::*; + use crate::packets::ethernet::Ethernet; use crate::packets::ip::v4::Ipv4; - use crate::packets::Ethernet; - use crate::Mbuf; + use crate::packets::Mbuf; #[test] fn size_of_echo_request_body() { diff --git a/core/src/packets/icmp/v4/mod.rs b/core/src/packets/icmp/v4/mod.rs index 511e872c..43753583 100644 --- a/core/src/packets/icmp/v4/mod.rs +++ b/core/src/packets/icmp/v4/mod.rs @@ -29,11 +29,11 @@ pub use self::redirect::*; pub use self::time_exceeded::*; pub use capsule_macros::Icmpv4Packet; +use crate::ensure; use crate::packets::ip::v4::Ipv4; use crate::packets::ip::ProtocolNumbers; use crate::packets::types::u16be; -use crate::packets::{checksum, Internal, Packet}; -use crate::{ensure, SizeOf}; +use crate::packets::{checksum, Internal, Packet, SizeOf}; use anyhow::{anyhow, Result}; use std::fmt; use std::ptr::NonNull; @@ -446,10 +446,10 @@ pub trait Icmpv4Packet { #[cfg(test)] mod tests { use super::*; + use crate::packets::ethernet::Ethernet; use crate::packets::ip::v4::Ipv4; - use crate::packets::Ethernet; + use crate::packets::Mbuf; use crate::testils::byte_arrays::{ICMPV4_PACKET, IPV4_UDP_PACKET}; - use crate::Mbuf; #[test] fn size_of_icmpv4_header() { diff --git a/core/src/packets/icmp/v4/redirect.rs b/core/src/packets/icmp/v4/redirect.rs index 8de0c154..9177800e 100644 --- a/core/src/packets/icmp/v4/redirect.rs +++ b/core/src/packets/icmp/v4/redirect.rs @@ -18,8 +18,7 @@ use crate::packets::icmp::v4::{Icmpv4, Icmpv4Message, Icmpv4Packet, Icmpv4Type, Icmpv4Types}; use crate::packets::ip::v4::IPV4_MIN_MTU; -use crate::packets::{Internal, Packet}; -use crate::SizeOf; +use crate::packets::{Internal, Packet, SizeOf}; use anyhow::Result; use std::fmt; use std::net::Ipv4Addr; @@ -216,10 +215,10 @@ impl Default for RedirectBody { #[cfg(test)] mod tests { use super::*; + use crate::packets::ethernet::Ethernet; use crate::packets::ip::v4::Ipv4; - use crate::packets::Ethernet; + use crate::packets::Mbuf; use crate::testils::byte_arrays::IPV4_TCP_PACKET; - use crate::Mbuf; #[test] fn size_of_redirect_body() { diff --git a/core/src/packets/icmp/v4/time_exceeded.rs b/core/src/packets/icmp/v4/time_exceeded.rs index affd0ad9..8a5e697b 100644 --- a/core/src/packets/icmp/v4/time_exceeded.rs +++ b/core/src/packets/icmp/v4/time_exceeded.rs @@ -19,8 +19,7 @@ use crate::packets::icmp::v4::{Icmpv4, Icmpv4Message, Icmpv4Packet, Icmpv4Type, Icmpv4Types}; use crate::packets::ip::v4::IPV4_MIN_MTU; use crate::packets::types::u32be; -use crate::packets::{Internal, Packet}; -use crate::SizeOf; +use crate::packets::{Internal, Packet, SizeOf}; use anyhow::Result; use std::fmt; use std::ptr::NonNull; @@ -180,10 +179,10 @@ struct TimeExceededBody { #[cfg(test)] mod tests { use super::*; + use crate::packets::ethernet::Ethernet; use crate::packets::ip::v4::Ipv4; - use crate::packets::Ethernet; + use crate::packets::Mbuf; use crate::testils::byte_arrays::IPV4_TCP_PACKET; - use crate::Mbuf; #[test] fn size_of_time_exceeded_body() { diff --git a/core/src/packets/icmp/v6/echo_reply.rs b/core/src/packets/icmp/v6/echo_reply.rs index c2ab433d..02d2d435 100644 --- a/core/src/packets/icmp/v6/echo_reply.rs +++ b/core/src/packets/icmp/v6/echo_reply.rs @@ -19,8 +19,7 @@ use crate::packets::icmp::v6::{Icmpv6, Icmpv6Message, Icmpv6Packet, Icmpv6Type, Icmpv6Types}; use crate::packets::ip::v6::Ipv6Packet; use crate::packets::types::u16be; -use crate::packets::{Internal, Packet}; -use crate::SizeOf; +use crate::packets::{Internal, Packet, SizeOf}; use anyhow::Result; use std::fmt; use std::ptr::NonNull; @@ -218,9 +217,9 @@ struct EchoReplyBody { #[cfg(test)] mod tests { use super::*; + use crate::packets::ethernet::Ethernet; use crate::packets::ip::v6::Ipv6; - use crate::packets::Ethernet; - use crate::Mbuf; + use crate::packets::Mbuf; #[test] fn size_of_echo_reply_body() { diff --git a/core/src/packets/icmp/v6/echo_request.rs b/core/src/packets/icmp/v6/echo_request.rs index 5e098131..d2885215 100644 --- a/core/src/packets/icmp/v6/echo_request.rs +++ b/core/src/packets/icmp/v6/echo_request.rs @@ -19,8 +19,7 @@ use crate::packets::icmp::v6::{Icmpv6, Icmpv6Message, Icmpv6Packet, Icmpv6Type, Icmpv6Types}; use crate::packets::ip::v6::Ipv6Packet; use crate::packets::types::u16be; -use crate::packets::{Internal, Packet}; -use crate::SizeOf; +use crate::packets::{Internal, Packet, SizeOf}; use anyhow::Result; use std::fmt; use std::ptr::NonNull; @@ -219,9 +218,9 @@ struct EchoRequestBody { #[cfg(test)] mod tests { use super::*; + use crate::packets::ethernet::Ethernet; use crate::packets::ip::v6::Ipv6; - use crate::packets::Ethernet; - use crate::Mbuf; + use crate::packets::Mbuf; #[test] fn size_of_echo_request_body() { diff --git a/core/src/packets/icmp/v6/mod.rs b/core/src/packets/icmp/v6/mod.rs index 2fa68144..bdd33631 100644 --- a/core/src/packets/icmp/v6/mod.rs +++ b/core/src/packets/icmp/v6/mod.rs @@ -18,25 +18,25 @@ //! Internet Control Message Protocol for IPv6. -mod destination_unreachable; mod echo_reply; mod echo_request; pub mod ndp; mod time_exceeded; mod too_big; +mod unreachable; -pub use self::destination_unreachable::*; pub use self::echo_reply::*; pub use self::echo_request::*; pub use self::time_exceeded::*; pub use self::too_big::*; +pub use self::unreachable::*; pub use capsule_macros::Icmpv6Packet; +use crate::ensure; use crate::packets::ip::v6::Ipv6Packet; use crate::packets::ip::ProtocolNumbers; use crate::packets::types::u16be; -use crate::packets::{checksum, Internal, Packet}; -use crate::{ensure, SizeOf}; +use crate::packets::{checksum, Internal, Packet, SizeOf}; use anyhow::{anyhow, Result}; use std::fmt; use std::ptr::NonNull; @@ -498,11 +498,11 @@ pub trait Icmpv6Packet { #[cfg(test)] mod tests { use super::*; + use crate::packets::ethernet::Ethernet; use crate::packets::icmp::v6::ndp::RouterAdvertisement; use crate::packets::ip::v6::Ipv6; - use crate::packets::Ethernet; + use crate::packets::Mbuf; use crate::testils::byte_arrays::{ICMPV6_PACKET, IPV6_TCP_PACKET, ROUTER_ADVERT_PACKET}; - use crate::Mbuf; #[test] fn size_of_icmpv6_header() { diff --git a/core/src/packets/icmp/v6/ndp/mod.rs b/core/src/packets/icmp/v6/ndp/mod.rs index f9558210..4797829b 100644 --- a/core/src/packets/icmp/v6/ndp/mod.rs +++ b/core/src/packets/icmp/v6/ndp/mod.rs @@ -43,10 +43,9 @@ pub use self::redirect::*; pub use self::router_advert::*; pub use self::router_solicit::*; -use crate::dpdk::BufferError; -use crate::packets::{Immutable, Internal, Packet}; -use crate::{ensure, Mbuf, SizeOf}; -use anyhow::Result; +use crate::ensure; +use crate::packets::{Immutable, Internal, Mbuf, Packet, SizeOf}; +use anyhow::{anyhow, Result}; use std::fmt; use std::marker::PhantomData; use std::ptr::NonNull; @@ -174,8 +173,7 @@ impl<'a> ImmutableNdpOption<'a> { /// /// # Errors /// - /// Returns `BufferError::OutOfBuffer` if the buffer does not have - /// enough free space. + /// Returns an error if the buffer does not have enough free space. #[inline] fn new(mbuf: &'a mut Mbuf, offset: usize) -> Result { let tuple = mbuf.read_data(offset)?; @@ -189,7 +187,7 @@ impl<'a> ImmutableNdpOption<'a> { // indicated by the length field stored in the option itself ensure!( option.mbuf.len() >= option.end_offset(), - BufferError::OutOfBuffer(option.end_offset(), option.mbuf.len()) + anyhow!("option size exceeds remaining buffer size.") ); Ok(option) @@ -297,8 +295,7 @@ impl<'a> MutableNdpOption<'a> { /// /// # Errors /// - /// Returns `BufferError::OutOfBuffer` if the buffer does not have - /// enough free space. + /// Returns an error if the buffer does not have enough free space. #[inline] fn new(mbuf: &'a mut Mbuf, offset: usize) -> Result { let tuple = mbuf.read_data(offset)?; @@ -312,7 +309,7 @@ impl<'a> MutableNdpOption<'a> { // indicated by the length field stored in the option itself ensure!( option.mbuf.len() >= option.end_offset(), - BufferError::OutOfBuffer(option.end_offset(), option.mbuf.len()) + anyhow!("option size exceeds remaining buffer size.") ); Ok(option) @@ -385,7 +382,7 @@ impl MutableNdpOptionsIterator<'_> { #[allow(clippy::should_implement_trait)] pub fn next(&mut self) -> Result>> { if self.mbuf.data_len() > self.offset { - match MutableNdpOption::new(&mut self.mbuf, self.offset) { + match MutableNdpOption::new(self.mbuf, self.offset) { Ok(option) => { // advances the offset to the next option self.offset = option.end_offset(); @@ -554,8 +551,8 @@ pub trait NdpOption<'a> { #[cfg(test)] mod tests { use super::*; + use crate::packets::ethernet::Ethernet; use crate::packets::ip::v6::Ipv6; - use crate::packets::Ethernet; use crate::testils::byte_arrays::ROUTER_ADVERT_PACKET; #[capsule::test] diff --git a/core/src/packets/icmp/v6/ndp/neighbor_advert.rs b/core/src/packets/icmp/v6/ndp/neighbor_advert.rs index c8c93655..9c532fa7 100644 --- a/core/src/packets/icmp/v6/ndp/neighbor_advert.rs +++ b/core/src/packets/icmp/v6/ndp/neighbor_advert.rs @@ -20,8 +20,7 @@ use super::NdpPacket; use crate::packets::icmp::v6::{Icmpv6, Icmpv6Message, Icmpv6Packet, Icmpv6Type, Icmpv6Types}; use crate::packets::ip::v6::Ipv6Packet; use crate::packets::types::u16be; -use crate::packets::{Internal, Packet}; -use crate::SizeOf; +use crate::packets::{Internal, Packet, SizeOf}; use anyhow::Result; use std::fmt; use std::net::Ipv6Addr; @@ -271,9 +270,9 @@ impl Default for NeighborAdvertisementBody { #[cfg(test)] mod tests { use super::*; + use crate::packets::ethernet::Ethernet; use crate::packets::ip::v6::Ipv6; - use crate::packets::Ethernet; - use crate::Mbuf; + use crate::packets::Mbuf; #[test] fn size_of_neighbor_advertisement_body() { diff --git a/core/src/packets/icmp/v6/ndp/neighbor_solicit.rs b/core/src/packets/icmp/v6/ndp/neighbor_solicit.rs index bc96e6b9..18f09f50 100644 --- a/core/src/packets/icmp/v6/ndp/neighbor_solicit.rs +++ b/core/src/packets/icmp/v6/ndp/neighbor_solicit.rs @@ -20,8 +20,7 @@ use super::NdpPacket; use crate::packets::icmp::v6::{Icmpv6, Icmpv6Message, Icmpv6Packet, Icmpv6Type, Icmpv6Types}; use crate::packets::ip::v6::Ipv6Packet; use crate::packets::types::u32be; -use crate::packets::{Internal, Packet}; -use crate::SizeOf; +use crate::packets::{Internal, Packet, SizeOf}; use anyhow::Result; use std::fmt; use std::net::Ipv6Addr; @@ -186,9 +185,9 @@ impl Default for NeighborSolicitationBody { #[cfg(test)] mod tests { use super::*; + use crate::packets::ethernet::Ethernet; use crate::packets::ip::v6::Ipv6; - use crate::packets::Ethernet; - use crate::Mbuf; + use crate::packets::Mbuf; #[test] fn size_of_neighbor_solicitation_body() { diff --git a/core/src/packets/icmp/v6/ndp/options/link_layer_addr.rs b/core/src/packets/icmp/v6/ndp/options/link_layer_addr.rs index 1c5eeb9c..c196745c 100644 --- a/core/src/packets/icmp/v6/ndp/options/link_layer_addr.rs +++ b/core/src/packets/icmp/v6/ndp/options/link_layer_addr.rs @@ -16,10 +16,10 @@ * SPDX-License-Identifier: Apache-2.0 */ +use crate::ensure; use crate::net::MacAddr; use crate::packets::icmp::v6::ndp::{NdpOption, NdpOptionType, NdpOptionTypes}; -use crate::packets::Internal; -use crate::{ensure, Mbuf, SizeOf}; +use crate::packets::{Internal, Mbuf, SizeOf}; use anyhow::{anyhow, Result}; use std::fmt; use std::ptr::NonNull; @@ -190,9 +190,10 @@ impl Default for LinkLayerAddressFields { #[cfg(test)] mod tests { use super::*; + use crate::packets::ethernet::Ethernet; use crate::packets::icmp::v6::ndp::{NdpPacket, RouterAdvertisement}; use crate::packets::ip::v6::Ipv6; - use crate::packets::{Ethernet, Packet}; + use crate::packets::Packet; use crate::testils::byte_arrays::ROUTER_ADVERT_PACKET; #[test] diff --git a/core/src/packets/icmp/v6/ndp/options/mtu.rs b/core/src/packets/icmp/v6/ndp/options/mtu.rs index 0d2f8e2b..dc533af7 100644 --- a/core/src/packets/icmp/v6/ndp/options/mtu.rs +++ b/core/src/packets/icmp/v6/ndp/options/mtu.rs @@ -16,10 +16,10 @@ * SPDX-License-Identifier: Apache-2.0 */ +use crate::ensure; use crate::packets::icmp::v6::ndp::{NdpOption, NdpOptionType, NdpOptionTypes}; use crate::packets::types::{u16be, u32be}; -use crate::packets::Internal; -use crate::{ensure, Mbuf, SizeOf}; +use crate::packets::{Internal, Mbuf, SizeOf}; use anyhow::{anyhow, Result}; use std::fmt; use std::ptr::NonNull; @@ -170,9 +170,10 @@ impl Default for MtuFields { #[cfg(test)] mod tests { use super::*; + use crate::packets::ethernet::Ethernet; use crate::packets::icmp::v6::ndp::{NdpPacket, RouterAdvertisement}; use crate::packets::ip::v6::Ipv6; - use crate::packets::{Ethernet, Packet}; + use crate::packets::Packet; use crate::testils::byte_arrays::ROUTER_ADVERT_PACKET; #[test] diff --git a/core/src/packets/icmp/v6/ndp/options/prefix_info.rs b/core/src/packets/icmp/v6/ndp/options/prefix_info.rs index bcd3167a..d721ca52 100644 --- a/core/src/packets/icmp/v6/ndp/options/prefix_info.rs +++ b/core/src/packets/icmp/v6/ndp/options/prefix_info.rs @@ -16,10 +16,10 @@ * SPDX-License-Identifier: Apache-2.0 */ +use crate::ensure; use crate::packets::icmp::v6::ndp::{NdpOption, NdpOptionType, NdpOptionTypes}; use crate::packets::types::u32be; -use crate::packets::Internal; -use crate::{ensure, Mbuf, SizeOf}; +use crate::packets::{Internal, Mbuf, SizeOf}; use anyhow::{anyhow, Result}; use std::fmt; use std::net::Ipv6Addr; @@ -308,9 +308,10 @@ impl Default for PrefixInformationFields { #[cfg(test)] mod tests { use super::*; + use crate::packets::ethernet::Ethernet; use crate::packets::icmp::v6::ndp::{NdpPacket, RouterAdvertisement}; use crate::packets::ip::v6::Ipv6; - use crate::packets::{Ethernet, Packet}; + use crate::packets::Packet; use crate::testils::byte_arrays::ROUTER_ADVERT_PACKET; #[test] diff --git a/core/src/packets/icmp/v6/ndp/options/redirected.rs b/core/src/packets/icmp/v6/ndp/options/redirected.rs index b16e094f..6ba9d199 100644 --- a/core/src/packets/icmp/v6/ndp/options/redirected.rs +++ b/core/src/packets/icmp/v6/ndp/options/redirected.rs @@ -16,10 +16,10 @@ * SPDX-License-Identifier: Apache-2.0 */ +use crate::ensure; use crate::packets::icmp::v6::ndp::{NdpOption, NdpOptionType, NdpOptionTypes}; use crate::packets::types::{u16be, u32be}; -use crate::packets::Internal; -use crate::{ensure, Mbuf, SizeOf}; +use crate::packets::{Internal, Mbuf, SizeOf}; use anyhow::{anyhow, Result}; use std::fmt; use std::ptr::NonNull; @@ -232,9 +232,10 @@ impl Default for RedirectedHeaderFields { #[cfg(test)] mod tests { use super::*; + use crate::packets::ethernet::Ethernet; use crate::packets::icmp::v6::ndp::{NdpPacket, Redirect}; use crate::packets::ip::v6::Ipv6; - use crate::packets::{Ethernet, Packet}; + use crate::packets::Packet; #[test] fn size_of_redirected_header_fields() { diff --git a/core/src/packets/icmp/v6/ndp/redirect.rs b/core/src/packets/icmp/v6/ndp/redirect.rs index 3c253827..1f3fe658 100644 --- a/core/src/packets/icmp/v6/ndp/redirect.rs +++ b/core/src/packets/icmp/v6/ndp/redirect.rs @@ -20,8 +20,7 @@ use super::{NdpPacket, RedirectedHeader}; use crate::packets::icmp::v6::{Icmpv6, Icmpv6Message, Icmpv6Packet, Icmpv6Type, Icmpv6Types}; use crate::packets::ip::v6::{Ipv6Packet, IPV6_MIN_MTU}; use crate::packets::types::u32be; -use crate::packets::{Internal, Packet}; -use crate::SizeOf; +use crate::packets::{Internal, Packet, SizeOf}; use anyhow::Result; use std::fmt; use std::net::Ipv6Addr; @@ -242,9 +241,9 @@ impl Default for RedirectBody { #[cfg(test)] mod tests { use super::*; + use crate::packets::ethernet::Ethernet; use crate::packets::ip::v6::Ipv6; - use crate::packets::Ethernet; - use crate::Mbuf; + use crate::packets::Mbuf; #[test] fn size_of_redirect_body() { diff --git a/core/src/packets/icmp/v6/ndp/router_advert.rs b/core/src/packets/icmp/v6/ndp/router_advert.rs index 630af35e..4e1d1291 100644 --- a/core/src/packets/icmp/v6/ndp/router_advert.rs +++ b/core/src/packets/icmp/v6/ndp/router_advert.rs @@ -20,8 +20,7 @@ use super::NdpPacket; use crate::packets::icmp::v6::{Icmpv6, Icmpv6Message, Icmpv6Packet, Icmpv6Type, Icmpv6Types}; use crate::packets::ip::v6::Ipv6Packet; use crate::packets::types::{u16be, u32be}; -use crate::packets::{Internal, Packet}; -use crate::SizeOf; +use crate::packets::{Internal, Packet, SizeOf}; use anyhow::Result; use std::fmt; use std::ptr::NonNull; @@ -302,9 +301,9 @@ struct RouterAdvertisementBody { #[cfg(test)] mod tests { use super::*; + use crate::packets::ethernet::Ethernet; use crate::packets::ip::v6::Ipv6; - use crate::packets::Ethernet; - use crate::Mbuf; + use crate::packets::Mbuf; #[test] fn size_of_router_advertisement_body() { diff --git a/core/src/packets/icmp/v6/ndp/router_solicit.rs b/core/src/packets/icmp/v6/ndp/router_solicit.rs index adf9a03a..bf122b05 100644 --- a/core/src/packets/icmp/v6/ndp/router_solicit.rs +++ b/core/src/packets/icmp/v6/ndp/router_solicit.rs @@ -20,8 +20,7 @@ use super::NdpPacket; use crate::packets::icmp::v6::{Icmpv6, Icmpv6Message, Icmpv6Packet, Icmpv6Type, Icmpv6Types}; use crate::packets::ip::v6::Ipv6Packet; use crate::packets::types::u32be; -use crate::packets::{Internal, Packet}; -use crate::SizeOf; +use crate::packets::{Internal, Packet, SizeOf}; use anyhow::Result; use std::fmt; use std::ptr::NonNull; @@ -144,9 +143,9 @@ struct RouterSolicitationBody { #[cfg(test)] mod tests { use super::*; + use crate::packets::ethernet::Ethernet; use crate::packets::ip::v6::Ipv6; - use crate::packets::Ethernet; - use crate::Mbuf; + use crate::packets::Mbuf; #[test] fn size_of_router_solicitation_body() { diff --git a/core/src/packets/icmp/v6/time_exceeded.rs b/core/src/packets/icmp/v6/time_exceeded.rs index e1c1e269..57e572dc 100644 --- a/core/src/packets/icmp/v6/time_exceeded.rs +++ b/core/src/packets/icmp/v6/time_exceeded.rs @@ -19,8 +19,7 @@ use crate::packets::icmp::v6::{Icmpv6, Icmpv6Message, Icmpv6Packet, Icmpv6Type, Icmpv6Types}; use crate::packets::ip::v6::{Ipv6Packet, IPV6_MIN_MTU}; use crate::packets::types::u32be; -use crate::packets::{Internal, Packet}; -use crate::SizeOf; +use crate::packets::{Internal, Packet, SizeOf}; use anyhow::Result; use std::fmt; use std::ptr::NonNull; @@ -164,10 +163,10 @@ struct TimeExceededBody { #[cfg(test)] mod tests { use super::*; + use crate::packets::ethernet::Ethernet; use crate::packets::ip::v6::Ipv6; - use crate::packets::Ethernet; + use crate::packets::Mbuf; use crate::testils::byte_arrays::IPV6_TCP_PACKET; - use crate::Mbuf; #[test] fn size_of_time_exceeded_body() { diff --git a/core/src/packets/icmp/v6/too_big.rs b/core/src/packets/icmp/v6/too_big.rs index bc5c5cd3..71d1cf54 100644 --- a/core/src/packets/icmp/v6/too_big.rs +++ b/core/src/packets/icmp/v6/too_big.rs @@ -19,8 +19,7 @@ use crate::packets::icmp::v6::{Icmpv6, Icmpv6Message, Icmpv6Packet, Icmpv6Type, Icmpv6Types}; use crate::packets::ip::v6::{Ipv6Packet, IPV6_MIN_MTU}; use crate::packets::types::u32be; -use crate::packets::{Internal, Packet}; -use crate::SizeOf; +use crate::packets::{Internal, Packet, SizeOf}; use anyhow::Result; use std::fmt; use std::ptr::NonNull; @@ -189,10 +188,10 @@ struct PacketTooBigBody { #[cfg(test)] mod tests { use super::*; + use crate::packets::ethernet::Ethernet; use crate::packets::ip::v6::Ipv6; - use crate::packets::Ethernet; + use crate::packets::Mbuf; use crate::testils::byte_arrays::IPV6_TCP_PACKET; - use crate::Mbuf; #[test] fn size_of_packet_too_big() { diff --git a/core/src/packets/icmp/v6/destination_unreachable.rs b/core/src/packets/icmp/v6/unreachable.rs similarity index 98% rename from core/src/packets/icmp/v6/destination_unreachable.rs rename to core/src/packets/icmp/v6/unreachable.rs index e23d29a1..827682e4 100644 --- a/core/src/packets/icmp/v6/destination_unreachable.rs +++ b/core/src/packets/icmp/v6/unreachable.rs @@ -19,8 +19,7 @@ use crate::packets::icmp::v6::{Icmpv6, Icmpv6Message, Icmpv6Packet, Icmpv6Type, Icmpv6Types}; use crate::packets::ip::v6::{Ipv6Packet, IPV6_MIN_MTU}; use crate::packets::types::u32be; -use crate::packets::{Internal, Packet}; -use crate::SizeOf; +use crate::packets::{Internal, Packet, SizeOf}; use anyhow::Result; use std::fmt; use std::ptr::NonNull; @@ -164,10 +163,10 @@ struct DestinationUnreachableBody { #[cfg(test)] mod tests { use super::*; + use crate::packets::ethernet::Ethernet; use crate::packets::ip::v6::Ipv6; - use crate::packets::Ethernet; + use crate::packets::Mbuf; use crate::testils::byte_arrays::IPV6_TCP_PACKET; - use crate::Mbuf; #[test] fn size_of_destination_unreachable_body() { diff --git a/core/src/packets/ip/v4.rs b/core/src/packets/ip/v4.rs index 3605e3bc..05286428 100644 --- a/core/src/packets/ip/v4.rs +++ b/core/src/packets/ip/v4.rs @@ -18,11 +18,12 @@ //! Internet Protocol v4. +use crate::ensure; use crate::packets::checksum::{self, PseudoHeader}; +use crate::packets::ethernet::{EtherTypes, Ethernet}; use crate::packets::ip::{IpPacket, ProtocolNumber, DEFAULT_IP_TTL}; use crate::packets::types::u16be; -use crate::packets::{EtherTypes, Ethernet, Internal, Packet}; -use crate::{ensure, SizeOf}; +use crate::packets::{Internal, Packet, SizeOf}; use anyhow::{anyhow, Result}; use std::fmt; use std::net::{IpAddr, Ipv4Addr}; @@ -612,8 +613,8 @@ impl Default for Ipv4Header { mod tests { use super::*; use crate::packets::ip::ProtocolNumbers; + use crate::packets::Mbuf; use crate::testils::byte_arrays::{IPV4_UDP_PACKET, IPV6_TCP_PACKET}; - use crate::Mbuf; #[test] fn size_of_ipv4_header() { @@ -630,8 +631,8 @@ mod tests { assert_eq!(5, ipv4.ihl()); assert_eq!(38, ipv4.total_length()); assert_eq!(43849, ipv4.identification()); - assert_eq!(true, ipv4.dont_fragment()); - assert_eq!(false, ipv4.more_fragments()); + assert!(ipv4.dont_fragment()); + assert!(!ipv4.more_fragments()); assert_eq!(0, ipv4.fragment_offset()); assert_eq!(0, ipv4.dscp()); assert_eq!(0, ipv4.ecn()); @@ -660,18 +661,18 @@ mod tests { ipv4.set_ihl(ipv4.ihl()); // Flags - assert_eq!(true, ipv4.dont_fragment()); - assert_eq!(false, ipv4.more_fragments()); + assert!(ipv4.dont_fragment()); + assert!(!ipv4.more_fragments()); ipv4.unset_dont_fragment(); - assert_eq!(false, ipv4.dont_fragment()); + assert!(!ipv4.dont_fragment()); ipv4.set_dont_fragment(); - assert_eq!(true, ipv4.dont_fragment()); + assert!(ipv4.dont_fragment()); ipv4.set_more_fragments(); - assert_eq!(true, ipv4.more_fragments()); + assert!(ipv4.more_fragments()); ipv4.unset_more_fragments(); - assert_eq!(false, ipv4.more_fragments()); + assert!(!ipv4.more_fragments()); ipv4.set_fragment_offset(5); assert_eq!(5, ipv4.fragment_offset()); diff --git a/core/src/packets/ip/v6/fragment.rs b/core/src/packets/ip/v6/fragment.rs index 15e90ce7..7d523c4d 100644 --- a/core/src/packets/ip/v6/fragment.rs +++ b/core/src/packets/ip/v6/fragment.rs @@ -16,12 +16,12 @@ * SPDX-License-Identifier: Apache-2.0 */ +use crate::ensure; use crate::packets::checksum::PseudoHeader; use crate::packets::ip::v6::Ipv6Packet; use crate::packets::ip::{IpPacket, ProtocolNumber, ProtocolNumbers}; use crate::packets::types::{u16be, u32be}; -use crate::packets::{Internal, Packet}; -use crate::{ensure, SizeOf}; +use crate::packets::{Internal, Packet, SizeOf}; use anyhow::{anyhow, Result}; use std::fmt; use std::net::IpAddr; @@ -329,10 +329,10 @@ struct FragmentHeader { #[cfg(test)] mod tests { use super::*; + use crate::packets::ethernet::Ethernet; use crate::packets::ip::v6::Ipv6; - use crate::packets::Ethernet; + use crate::packets::Mbuf; use crate::testils::byte_arrays::{IPV6_FRAGMENT_PACKET, IPV6_TCP_PACKET}; - use crate::Mbuf; #[test] fn size_of_fragment_header() { diff --git a/core/src/packets/ip/v6/mod.rs b/core/src/packets/ip/v6/mod.rs index 5cf78f79..5c10414c 100644 --- a/core/src/packets/ip/v6/mod.rs +++ b/core/src/packets/ip/v6/mod.rs @@ -24,11 +24,12 @@ mod srh; pub use self::fragment::*; pub use self::srh::*; +use crate::ensure; use crate::packets::checksum::PseudoHeader; +use crate::packets::ethernet::{EtherTypes, Ethernet}; use crate::packets::ip::{IpPacket, ProtocolNumber, DEFAULT_IP_TTL}; use crate::packets::types::{u16be, u32be}; -use crate::packets::{EtherTypes, Ethernet, Internal, Packet}; -use crate::{ensure, SizeOf}; +use crate::packets::{Internal, Packet, SizeOf}; use anyhow::{anyhow, Result}; use std::fmt; use std::net::{IpAddr, Ipv6Addr}; @@ -467,8 +468,8 @@ impl Default for Ipv6Header { mod tests { use super::*; use crate::packets::ip::ProtocolNumbers; + use crate::packets::Mbuf; use crate::testils::byte_arrays::{IPV4_UDP_PACKET, IPV6_TCP_PACKET}; - use crate::Mbuf; #[test] fn size_of_ipv6_header() { diff --git a/core/src/packets/ip/v6/srh.rs b/core/src/packets/ip/v6/srh.rs index 9cefbb9d..bdad10b6 100644 --- a/core/src/packets/ip/v6/srh.rs +++ b/core/src/packets/ip/v6/srh.rs @@ -16,12 +16,12 @@ * SPDX-License-Identifier: Apache-2.0 */ +use crate::ensure; use crate::packets::checksum::PseudoHeader; use crate::packets::ip::v6::Ipv6Packet; use crate::packets::ip::{IpPacket, ProtocolNumber, ProtocolNumbers}; use crate::packets::types::u16be; -use crate::packets::{Internal, Packet}; -use crate::{ensure, SizeOf}; +use crate::packets::{Internal, Packet, SizeOf}; use anyhow::{anyhow, Result}; use std::fmt; use std::net::{IpAddr, Ipv6Addr}; @@ -523,11 +523,12 @@ impl Default for SegmentRoutingHeader { #[cfg(test)] mod tests { use super::*; + use crate::packets::ethernet::Ethernet; use crate::packets::ip::v6::Ipv6; use crate::packets::ip::ProtocolNumbers; - use crate::packets::{Ethernet, Tcp, Tcp6}; + use crate::packets::tcp::{Tcp, Tcp6}; + use crate::packets::Mbuf; use crate::testils::byte_arrays::{IPV6_TCP_PACKET, SR_TCP_PACKET}; - use crate::Mbuf; #[test] fn size_of_segment_routing_header() { diff --git a/core/src/dpdk/mbuf.rs b/core/src/packets/mbuf.rs similarity index 91% rename from core/src/dpdk/mbuf.rs rename to core/src/packets/mbuf.rs index 74ed1b75..544bd0a4 100644 --- a/core/src/dpdk/mbuf.rs +++ b/core/src/packets/mbuf.rs @@ -17,8 +17,8 @@ */ use crate::ffi::dpdk::{self, MbufPtr}; -use crate::packets::{Internal, Packet}; -use crate::rt2::Mempool; +use crate::packets::{Internal, Packet, SizeOf}; +use crate::runtime::Mempool; use crate::{ensure, trace}; use anyhow::Result; use capsule_ffi as cffi; @@ -28,58 +28,6 @@ use std::ptr::{self, NonNull}; use std::slice; use thiserror::Error; -/// A trait for returning the size of a type in bytes. -/// -/// Size of the structs are used for bound checks when reading and writing -/// packets. -/// -/// -/// # Derivable -/// -/// The `SizeOf` trait can be used with `#[derive]` and defaults to -/// `std::mem::size_of::()`. -/// -/// ``` -/// #[derive(SizeOf)] -/// pub struct Ipv4Header { -/// ... -/// } -/// ``` -pub trait SizeOf { - /// Returns the size of a type in bytes. - fn size_of() -> usize; -} - -impl SizeOf for () { - fn size_of() -> usize { - std::mem::size_of::<()>() - } -} - -impl SizeOf for u8 { - fn size_of() -> usize { - std::mem::size_of::() - } -} - -impl SizeOf for [u8; 2] { - fn size_of() -> usize { - std::mem::size_of::<[u8; 2]>() - } -} - -impl SizeOf for [u8; 16] { - fn size_of() -> usize { - std::mem::size_of::<[u8; 16]>() - } -} - -impl SizeOf for ::std::net::Ipv6Addr { - fn size_of() -> usize { - std::mem::size_of::() - } -} - /// Error indicating buffer access failures. #[derive(Debug, Error)] pub(crate) enum BufferError { @@ -178,14 +126,6 @@ impl Mbuf { } } - /// Creates a new `Mbuf` from a raw pointer. - #[inline] - pub(crate) unsafe fn from_ptr(ptr: *mut cffi::rte_mbuf) -> Self { - Mbuf { - inner: MbufInner::Original(NonNull::new_unchecked(ptr)), - } - } - /// Returns the raw struct needed for FFI calls. #[inline] fn raw(&self) -> &cffi::rte_mbuf { @@ -425,22 +365,11 @@ impl Mbuf { /// free the raw pointer after use. Otherwise the buffer is leaked. #[inline] pub(crate) fn into_easyptr(self) -> MbufPtr { - let ptr = self.inner.ptr().clone(); + let ptr = *self.inner.ptr(); mem::forget(self); ptr.into() } - /// Acquires the underlying raw struct pointer. - /// - /// The `Mbuf` is consumed. It is the caller's the responsibility to - /// free the raw pointer after use. Otherwise the buffer is leaked. - #[inline] - pub(crate) fn into_ptr(self) -> *mut cffi::rte_mbuf { - let ptr = self.inner.ptr().as_ptr(); - mem::forget(self); - ptr - } - /// Allocates a Vec of `Mbuf`s of `len` size. /// /// # Errors @@ -483,7 +412,7 @@ impl Drop for Mbuf { match self.inner { MbufInner::Original(_) => { trace!("freeing mbuf@{:p}.", self.raw().buf_addr); - dpdk::pktmbuf_free(self.inner.ptr().clone().into()); + dpdk::pktmbuf_free((*self.inner.ptr()).into()); } MbufInner::Clone(_) => (), } diff --git a/core/src/packets/mod.rs b/core/src/packets/mod.rs index de17b304..39a5758a 100644 --- a/core/src/packets/mod.rs +++ b/core/src/packets/mod.rs @@ -20,17 +20,18 @@ pub mod arp; pub mod checksum; -mod ethernet; +pub mod ethernet; pub mod icmp; pub mod ip; -mod tcp; +mod mbuf; +mod size_of; +pub mod tcp; pub mod types; -mod udp; +pub mod udp; -pub use self::ethernet::*; -pub use self::tcp::*; -pub use self::udp::*; -pub use crate::dpdk::Mbuf; +pub use self::mbuf::*; +pub use self::size_of::*; +pub use capsule_macros::SizeOf; use anyhow::{Context, Result}; use std::fmt; @@ -354,7 +355,9 @@ pub enum Postmark { mod tests { use super::*; use crate::net::MacAddr; + use crate::packets::ethernet::Ethernet; use crate::packets::ip::v4::Ipv4; + use crate::packets::udp::Udp4; use crate::testils::byte_arrays::IPV4_UDP_PACKET; #[capsule::test] diff --git a/core/src/packets/size_of.rs b/core/src/packets/size_of.rs new file mode 100644 index 00000000..f7a6a308 --- /dev/null +++ b/core/src/packets/size_of.rs @@ -0,0 +1,85 @@ +/* +* Copyright 2019 Comcast Cable Communications Management, LLC +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* SPDX-License-Identifier: Apache-2.0 +*/ + +use crate::net::MacAddr; +use std::mem; +use std::net::{Ipv4Addr, Ipv6Addr}; + +/// A trait for returning the size of a type in bytes. +/// +/// Size of the structs are used for bound checks when reading and writing +/// packets. +/// +/// +/// # Derivable +/// +/// The `SizeOf` trait can be used with `#[derive]` and defaults to +/// `std::mem::size_of::()`. +/// +/// ``` +/// #[derive(SizeOf)] +/// pub struct Ipv4Header { +/// ... +/// } +/// ``` +pub trait SizeOf { + /// Returns the size of a type in bytes. + fn size_of() -> usize; +} + +impl SizeOf for () { + fn size_of() -> usize { + mem::size_of::<()>() + } +} + +impl SizeOf for u8 { + fn size_of() -> usize { + mem::size_of::() + } +} + +impl SizeOf for [u8; 2] { + fn size_of() -> usize { + mem::size_of::<[u8; 2]>() + } +} + +impl SizeOf for [u8; 16] { + fn size_of() -> usize { + mem::size_of::<[u8; 16]>() + } +} + +impl SizeOf for MacAddr { + fn size_of() -> usize { + mem::size_of::() + } +} + +impl SizeOf for Ipv4Addr { + fn size_of() -> usize { + mem::size_of::() + } +} + +impl SizeOf for Ipv6Addr { + fn size_of() -> usize { + mem::size_of::() + } +} diff --git a/core/src/packets/tcp.rs b/core/src/packets/tcp.rs index d0cec42e..b7d11e93 100644 --- a/core/src/packets/tcp.rs +++ b/core/src/packets/tcp.rs @@ -16,12 +16,14 @@ * SPDX-License-Identifier: Apache-2.0 */ +//! Transmission Control Protocol. + +use crate::ensure; use crate::packets::ip::v4::Ipv4; use crate::packets::ip::v6::Ipv6; use crate::packets::ip::{Flow, IpPacket, ProtocolNumbers}; use crate::packets::types::{u16be, u32be}; -use crate::packets::{checksum, Internal, Packet}; -use crate::{ensure, SizeOf}; +use crate::packets::{checksum, Internal, Packet, SizeOf}; use anyhow::{anyhow, Result}; use std::fmt; use std::net::IpAddr; @@ -664,10 +666,10 @@ impl Default for TcpHeader { #[cfg(test)] mod tests { use super::*; + use crate::packets::ethernet::Ethernet; use crate::packets::ip::v6::SegmentRouting; - use crate::packets::Ethernet; + use crate::packets::Mbuf; use crate::testils::byte_arrays::{IPV4_TCP_PACKET, IPV4_UDP_PACKET, SR_TCP_PACKET}; - use crate::Mbuf; use std::net::{Ipv4Addr, Ipv6Addr}; #[test] diff --git a/core/src/packets/udp.rs b/core/src/packets/udp.rs index c146328b..541fd1db 100644 --- a/core/src/packets/udp.rs +++ b/core/src/packets/udp.rs @@ -16,12 +16,14 @@ * SPDX-License-Identifier: Apache-2.0 */ +//! User Datagram Protocol. + +use crate::ensure; use crate::packets::ip::v4::Ipv4; use crate::packets::ip::v6::Ipv6; use crate::packets::ip::{Flow, IpPacket, ProtocolNumbers}; use crate::packets::types::u16be; -use crate::packets::{checksum, Internal, Packet}; -use crate::{ensure, SizeOf}; +use crate::packets::{checksum, Internal, Packet, SizeOf}; use anyhow::{anyhow, Result}; use std::fmt; use std::net::IpAddr; @@ -386,9 +388,9 @@ struct UdpHeader { #[cfg(test)] mod tests { use super::*; - use crate::packets::Ethernet; + use crate::packets::ethernet::Ethernet; + use crate::packets::Mbuf; use crate::testils::byte_arrays::{IPV4_TCP_PACKET, IPV4_UDP_PACKET}; - use crate::Mbuf; use std::net::{Ipv4Addr, Ipv6Addr}; #[test] diff --git a/core/src/pcap.rs b/core/src/pcap.rs deleted file mode 100644 index 0be10325..00000000 --- a/core/src/pcap.rs +++ /dev/null @@ -1,340 +0,0 @@ -/* -* Copyright 2019 Comcast Cable Communications Management, LLC -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* SPDX-License-Identifier: Apache-2.0 -*/ - -use crate::dpdk::{CoreId, DpdkError, PortId, RxTxQueue}; -use crate::ffi::{self, AsStr, ToCString, ToResult}; -use crate::{debug, error}; -use anyhow::Result; -use std::fmt; -use std::os::raw; -use std::ptr::NonNull; -use thiserror::Error; - -// DLT_EN10MB; LINKTYPE_ETHERNET=1; 10MB is historical -const DLT_EN10MB: raw::c_int = 1; -const PCAP_SNAPSHOT_LEN: raw::c_int = ffi::RTE_MBUF_DEFAULT_BUF_SIZE as raw::c_int; - -/// An error generated in `libpcap`. -/// -/// When an FFI call fails, either a specified error message or an `errno` is -/// translated into a `PcapError`. -#[derive(Debug, Error)] -#[error("{0}")] -struct PcapError(String); - -impl PcapError { - /// Returns the `PcapError` with the given error message. - #[inline] - fn new(msg: &str) -> Self { - PcapError(msg.into()) - } - - /// Returns the `PcapError` pertaining to the last `libpcap` error. - #[inline] - fn get_error(handle: NonNull) -> Self { - let msg = unsafe { ffi::pcap_geterr(handle.as_ptr()) }; - PcapError::new((msg as *const raw::c_char).as_str()) - } -} - -/// Packet Capture (`pcap`) writer/dumper for packets -struct Pcap { - path: String, - handle: NonNull, - dumper: NonNull, -} - -impl Pcap { - /// Creates a file for dumping packets into from a given file path. - fn create(path: &str) -> Result { - unsafe { - let handle = ffi::pcap_open_dead(DLT_EN10MB, PCAP_SNAPSHOT_LEN) - .into_result(|_| PcapError::new("Cannot create packet capture handle."))?; - let dumper = ffi::pcap_dump_open(handle.as_ptr(), path.into_cstring().as_ptr()) - .into_result(|_| PcapError::get_error(handle)) - .map_err(|err| { - ffi::pcap_close(handle.as_ptr()); - err - })?; - - debug!("PCAP file {} created", path); - - Ok(Pcap { - path: path.to_string(), - handle, - dumper, - }) - } - } - - /// Append to already-existing file for dumping packets into from a given - /// file path. - fn append(path: &str) -> Result { - if !std::path::Path::new(path).exists() { - return Err(PcapError::new("Pcap filename path does not exist.").into()); - } - - unsafe { - let handle = ffi::pcap_open_dead(DLT_EN10MB, PCAP_SNAPSHOT_LEN) - .into_result(|_| PcapError::new("Cannot create packet capture handle."))?; - let dumper = ffi::pcap_dump_open_append(handle.as_ptr(), path.into_cstring().as_ptr()) - .into_result(|_| PcapError::get_error(handle)) - .map_err(|err| { - ffi::pcap_close(handle.as_ptr()); - err - })?; - Ok(Pcap { - path: path.to_string(), - handle, - dumper, - }) - } - } - - /// Write packets to `pcap` file handler. - unsafe fn write(&self, ptrs: &[*mut ffi::rte_mbuf]) -> Result<()> { - ptrs.iter().for_each(|&p| self.dump_packet(p)); - - self.flush() - } - - unsafe fn dump_packet(&self, ptr: *mut ffi::rte_mbuf) { - let mut pcap_hdr = ffi::pcap_pkthdr::default(); - pcap_hdr.len = (*ptr).data_len as u32; - pcap_hdr.caplen = pcap_hdr.len; - - // If this errors, we'll still want to write packet(s) to the pcap, - let _ = libc::gettimeofday( - &mut pcap_hdr.ts as *mut ffi::timeval as *mut libc::timeval, - std::ptr::null_mut(), - ); - - ffi::pcap_dump( - self.dumper.as_ptr() as *mut raw::c_uchar, - &pcap_hdr, - ((*ptr).buf_addr as *mut u8).offset((*ptr).data_off as isize), - ); - } - - fn flush(&self) -> Result<()> { - unsafe { - ffi::pcap_dump_flush(self.dumper.as_ptr()) - .into_result(|_| PcapError::new("Cannot flush packets to packet capture")) - .map(|_| ()) - } - } -} - -impl<'a> fmt::Debug for Pcap { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("pcap").field("path", &self.path).finish() - } -} - -impl Drop for Pcap { - fn drop(&mut self) { - unsafe { - ffi::pcap_dump_close(self.dumper.as_ptr()); - ffi::pcap_close(self.handle.as_ptr()); - } - } -} - -/// Default formatting for pcap files. -fn format_pcap_file(port_name: &str, core_id: usize, tx_or_rx: &str) -> String { - format!("port-{}-core{}-{}.pcap", port_name, core_id, tx_or_rx) -} - -/// Generate PCAP files for rx/tx queues per port and per core. -pub(crate) fn capture_queue( - port_id: PortId, - port_name: &str, - core: CoreId, - q: RxTxQueue, -) -> Result<()> { - match q { - RxTxQueue::Rx(rxq) => { - Pcap::create(&format_pcap_file(port_name, core.raw(), "rx"))?; - unsafe { - ffi::rte_eth_add_rx_callback( - port_id.raw(), - rxq.raw(), - Some(append_and_write_rx), - port_name.into_cstring().into_raw() as *mut raw::c_void, - ) - .into_result(|_| DpdkError::new())?; - } - } - RxTxQueue::Tx(txq) => { - Pcap::create(&format_pcap_file(port_name, core.raw(), "tx"))?; - unsafe { - ffi::rte_eth_add_tx_callback( - port_id.raw(), - txq.raw(), - Some(append_and_write_tx), - port_name.into_cstring().into_raw() as *mut raw::c_void, - ) - .into_result(|_| DpdkError::new())?; - } - } - } - - Ok(()) -} - -/// Callback fn passed to `rte_eth_add_rx_callback`, which is called on RX -/// with a burst of packets that have been received on a given port and queue. -unsafe extern "C" fn append_and_write_rx( - _port_id: u16, - _queue_id: u16, - pkts: *mut *mut ffi::rte_mbuf, - num_pkts: u16, - _max_pkts: u16, - user_param: *mut raw::c_void, -) -> u16 { - append_and_write( - (user_param as *const raw::c_char).as_str(), - "rx", - std::slice::from_raw_parts_mut(pkts, num_pkts as usize), - ); - num_pkts -} - -/// Callback fn passed to `rte_eth_add_tx_callback`, which is called on TX -/// with a burst of packets immediately before the packets are put onto -/// the hardware queue for transmission. -unsafe extern "C" fn append_and_write_tx( - _port_id: u16, - _queue_id: u16, - pkts: *mut *mut ffi::rte_mbuf, - num_pkts: u16, - user_param: *mut raw::c_void, -) -> u16 { - append_and_write( - (user_param as *const raw::c_char).as_str(), - "tx", - std::slice::from_raw_parts_mut(pkts, num_pkts as usize), - ); - num_pkts -} - -/// Executed within the rx/tx callback functions for writing out to pcap -/// file(s). -fn append_and_write(port: &str, tx_or_rx: &str, ptrs: &[*mut ffi::rte_mbuf]) { - let path = format_pcap_file(port, CoreId::current().raw(), tx_or_rx); - if let Err(err) = Pcap::append(path.as_str()).and_then(|pcap| unsafe { pcap.write(&ptrs) }) { - error!( - message = "Cannot write/append to pcap file.", - pcap = path.as_str(), - ?err - ) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::testils::byte_arrays::IPV4_UDP_PACKET; - use crate::Mbuf; - use std::fs; - use std::ptr; - - fn read_pcap_plen(path: &str) -> u32 { - let mut errbuf = [0i8; ffi::RTE_MBUF_DEFAULT_BUF_SIZE as usize]; - let handle = - unsafe { ffi::pcap_open_offline(path.into_cstring().as_ptr(), errbuf.as_mut_ptr()) }; - - let mut header: *mut ffi::pcap_pkthdr = ptr::null_mut(); - let mut buf: *const libc::c_uchar = ptr::null(); - - let mut ret = 0; - - while let 1 = unsafe { ffi::pcap_next_ex(handle, &mut header, &mut buf) } { - ret += unsafe { (*header).caplen } - } - - unsafe { - ffi::pcap_close(handle); - } - - ret - } - - fn cleanup(path: &str) { - fs::remove_file(path).unwrap(); - } - - #[capsule::test] - fn create_pcap_and_write_packet() { - let writer = Pcap::create("foo.pcap").unwrap(); - let udp = Mbuf::from_bytes(&IPV4_UDP_PACKET).unwrap(); - let data_len = udp.data_len(); - - let res = unsafe { writer.write(&[udp.into_ptr()]) }; - - assert!(res.is_ok()); - let len = read_pcap_plen("foo.pcap"); - assert_eq!(data_len as u32, len); - cleanup("foo.pcap"); - } - - #[capsule::test] - fn create_pcap_and_write_packets() { - let writer = Pcap::create("foo1.pcap").unwrap(); - let udp = Mbuf::from_bytes(&IPV4_UDP_PACKET).unwrap(); - let data_len1 = udp.data_len(); - let udp2 = Mbuf::from_bytes(&IPV4_UDP_PACKET).unwrap(); - let data_len2 = udp2.data_len(); - - let packets = vec![udp.into_ptr(), udp2.into_ptr()]; - let res = unsafe { writer.write(&packets) }; - assert!(res.is_ok()); - let len = read_pcap_plen("foo1.pcap"); - assert_eq!((data_len1 + data_len2) as u32, len); - cleanup("foo1.pcap"); - } - - #[capsule::test] - fn append_to_pcap_and_write_packet() { - let open = Pcap::create("foo2.pcap"); - assert!(open.is_ok()); - - let udp = Mbuf::from_bytes(&IPV4_UDP_PACKET).unwrap(); - let data_len = udp.data_len(); - - let writer = Pcap::append("foo2.pcap").unwrap(); - let res = unsafe { writer.write(&[udp.into_ptr()]) }; - - assert!(res.is_ok()); - let len = read_pcap_plen("foo2.pcap"); - assert_eq!(data_len as u32, len); - cleanup("foo2.pcap"); - } - - #[capsule::test] - fn append_to_wrong_pcap() { - let open = Pcap::create("foo3.pcap"); - assert!(open.is_ok()); - - // fails on append to uninitiated pcap - let res = Pcap::append("foo4.pcap"); - assert!(res.is_err()); - - cleanup("foo3.pcap"); - } -} diff --git a/core/src/rt2/mod.rs b/core/src/rt2/mod.rs deleted file mode 100644 index cd63ef92..00000000 --- a/core/src/rt2/mod.rs +++ /dev/null @@ -1,234 +0,0 @@ -/* -* Copyright 2019 Comcast Cable Communications Management, LLC -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* SPDX-License-Identifier: Apache-2.0 -*/ - -//! Capsule runtime. - -mod config; -mod lcore; -mod mempool; -#[cfg(feature = "pcap-dump")] -#[cfg_attr(docsrs, doc(cfg(feature = "pcap-dump")))] -mod pcap_dump; -mod port; - -pub use self::config::*; -pub(crate) use self::lcore::*; -pub use self::lcore::{Lcore, LcoreMap, LcoreNotFound}; -pub use self::mempool::Mempool; -pub(crate) use self::mempool::*; -pub use self::port::{Outbox, Port, PortError, PortMap}; - -use crate::ffi::dpdk::{self, LcoreId}; -use crate::packets::{Mbuf, Postmark}; -use crate::{debug, info}; -use anyhow::Result; -use async_channel::{self, Receiver, Sender}; -use std::fmt; -use std::mem::ManuallyDrop; -use std::ops::DerefMut; - -/// Trigger for the shutdown. -pub(crate) struct ShutdownTrigger(Sender<()>, Receiver<()>); - -impl ShutdownTrigger { - /// Creates a new shutdown trigger. - /// - /// Leverages the behavior of an async channel. When the sender is dropped - /// from scope, it closes the channel and causes the receiver side future - /// in the executor queue to resolve. - pub(crate) fn new() -> Self { - let (s, r) = async_channel::unbounded(); - Self(s, r) - } - - /// Returns a wait handle. - pub(crate) fn get_wait(&self) -> ShutdownWait { - ShutdownWait(self.1.clone()) - } - - /// Returns whether the trigger is being waited on. - pub(crate) fn is_waited(&self) -> bool { - // a receiver count greater than 1 indicating that there are receiver - // clones in scope, hence the trigger is being waited on. - self.0.receiver_count() > 1 - } - - /// Triggers the shutdown. - pub(crate) fn fire(self) { - drop(self.0) - } -} - -/// Shutdown wait handle. -pub(crate) struct ShutdownWait(Receiver<()>); - -impl ShutdownWait { - /// A future that waits till the shutdown trigger is fired. - pub(crate) async fn wait(&self) { - self.0.recv().await.unwrap_or(()) - } -} - -/// The Capsule runtime. -/// -/// The runtime initializes the underlying DPDK environment, and it also manages -/// the task scheduler that executes the packet processing tasks. -pub struct Runtime { - mempool: ManuallyDrop, - lcores: ManuallyDrop, - ports: ManuallyDrop, - #[cfg(feature = "pcap-dump")] - pcap_dump: ManuallyDrop, -} - -impl Runtime { - /// Returns the mempool. - /// - /// For simplicity, we currently only support one global Mempool. Multi- - /// socket support may be added in the future. - pub fn mempool(&self) -> &Mempool { - &self.mempool - } - - /// Returns the lcores. - pub fn lcores(&self) -> &LcoreMap { - &self.lcores - } - - /// Returns the configured ports. - pub fn ports(&self) -> &PortMap { - &self.ports - } - - /// Initializes a new runtime from config settings. - pub fn from_config(config: RuntimeConfig) -> Result { - info!("starting runtime."); - - debug!("initializing EAL ..."); - dpdk::eal_init(config.to_eal_args())?; - - debug!("initializing mempool ..."); - let socket = LcoreId::main().socket(); - let mut mempool = Mempool::new( - "mempool", - config.mempool.capacity, - config.mempool.cache_size, - socket, - )?; - debug!(?mempool); - - debug!("initializing lcore schedulers ..."); - let lcores = self::lcore_pool(); - - for lcore in lcores.iter() { - let mut ptr = mempool.ptr_mut().clone(); - lcore.block_on(async move { MEMPOOL.with(|tls| tls.set(ptr.deref_mut())) }); - } - - info!("initializing ports ..."); - let mut ports = Vec::new(); - for port in config.ports.iter() { - let mut port = port::Builder::for_device(&port.name, &port.device)? - .set_rxqs_txqs(port.rxqs, port.txqs)? - .set_promiscuous(port.promiscuous)? - .set_multicast(port.multicast)? - .set_rx_lcores(port.rx_cores.clone())? - .set_tx_lcores(port.tx_cores.clone())? - .build(&mut mempool)?; - - debug!(?port); - - if !port.tx_lcores().is_empty() { - port.spawn_tx_loops(&lcores)?; - } - - port.start()?; - ports.push(port); - } - let ports: PortMap = ports.into(); - - #[cfg(feature = "pcap-dump")] - let pcap_dump = self::pcap_dump::enable_pcap_dump(&config.data_dir(), &ports, &lcores)?; - - info!("runtime ready."); - - Ok(Runtime { - mempool: ManuallyDrop::new(mempool), - lcores: ManuallyDrop::new(lcores), - ports: ManuallyDrop::new(ports), - #[cfg(feature = "pcap-dump")] - pcap_dump: ManuallyDrop::new(pcap_dump), - }) - } - - /// Sets the packet processing pipeline for port. - pub fn set_port_pipeline(&self, port: &str, f: F) -> Result<()> - where - F: Fn(Mbuf) -> Result + Clone + Send + Sync + 'static, - { - let port = self.ports.get(port)?; - port.spawn_rx_loops(f, &self.lcores)?; - Ok(()) - } - - /// Starts the runtime execution. - pub fn execute(self) -> Result { - Ok(RuntimeGuard { runtime: self }) - } -} - -impl fmt::Debug for Runtime { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("Runtime") - .field("mempool", &self.mempool) - .finish() - } -} - -/// The RAII guard to stop and cleanup the runtime resources on drop. -pub struct RuntimeGuard { - runtime: Runtime, -} - -impl Drop for RuntimeGuard { - fn drop(&mut self) { - info!("shutting down runtime."); - - for port in self.runtime.ports.iter_mut() { - port.stop(); - } - - unsafe { - #[cfg(feature = "pcap-dump")] - ManuallyDrop::drop(&mut self.runtime.pcap_dump); - ManuallyDrop::drop(&mut self.runtime.ports); - ManuallyDrop::drop(&mut self.runtime.lcores); - ManuallyDrop::drop(&mut self.runtime.mempool); - } - - debug!("freeing EAL ..."); - let _ = dpdk::eal_cleanup(); - info!("runtime shutdown."); - } -} - -impl fmt::Debug for RuntimeGuard { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "RuntimeGuard") - } -} diff --git a/core/src/rt2/config.rs b/core/src/runtime/config.rs similarity index 98% rename from core/src/rt2/config.rs rename to core/src/runtime/config.rs index c5b201e3..4e700967 100644 --- a/core/src/rt2/config.rs +++ b/core/src/runtime/config.rs @@ -53,7 +53,7 @@ use capsule_ffi as cffi; use clap::{clap_app, crate_version}; use regex::Regex; use serde::Deserialize; -use std::fmt; +use std::fmt::{self, Write}; use std::fs; /// Runtime configuration settings. @@ -123,17 +123,15 @@ impl RuntimeConfig { } }); - cores.sort(); + cores.sort_unstable(); cores.dedup(); cores } /// Extracts the EAL arguments from runtime settings. pub(crate) fn to_eal_args(&self) -> Vec { - let mut eal_args = vec![]; - // adds the app name. - eal_args.push(self.app_name.clone()); + let mut eal_args = vec![self.app_name.clone()]; // adds the proc type. let proc_type = if self.secondary { @@ -188,7 +186,7 @@ impl RuntimeConfig { .map(ToString::to_string) .collect::>() .join(","); - cores.push_str(&format!(",{}@{}", main, self.main_core)); + let _ = write!(cores, ",{}@{}", main, self.main_core); eal_args.push("--lcores".to_owned()); eal_args.push(cores); @@ -397,7 +395,7 @@ mod tests { let config: RuntimeConfig = toml::from_str(CONFIG)?; - assert_eq!(false, config.secondary); + assert!(!config.secondary); assert_eq!(None, config.app_group); assert_eq!(None, config.data_dir); assert_eq!(None, config.dpdk_args); diff --git a/core/src/runtime/core_map.rs b/core/src/runtime/core_map.rs deleted file mode 100644 index bbf10ff6..00000000 --- a/core/src/runtime/core_map.rs +++ /dev/null @@ -1,386 +0,0 @@ -/* -* Copyright 2019 Comcast Cable Communications Management, LLC -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* SPDX-License-Identifier: Apache-2.0 -*/ - -use crate::dpdk::{CoreId, Mempool, MempoolMap, MEMPOOL}; -use crate::{debug, error, ffi, info}; -use anyhow::Result; -use futures::Future; -use std::collections::{HashMap, HashSet}; -use std::sync::mpsc::{self, Receiver, SyncSender}; -use std::thread::{self, JoinHandle}; -use thiserror::Error; -use tokio::sync::oneshot; -use tokio_executor::current_thread::{self, CurrentThread}; -use tokio_executor::park::ParkThread; -use tokio_net::driver::{self, Reactor}; -use tokio_timer::timer::{self, Timer}; - -/// A sync-channel based park handle. -/// -/// This is designed to be a single use handle. We only need to park the -/// core one time at initialization time. Once unparked, we will never -/// park the core again. -pub(crate) struct Park { - core_id: CoreId, - sender: SyncSender<()>, - receiver: Receiver<()>, -} - -impl Park { - fn new(core_id: CoreId) -> Self { - let (sender, receiver) = mpsc::sync_channel(0); - Park { - core_id, - sender, - receiver, - } - } - - fn unpark(&self) -> Unpark { - Unpark { - core_id: self.core_id, - sender: self.sender.clone(), - } - } - - fn park(&self) { - if let Err(err) = self.receiver.recv() { - // we are not expecting failures, but we will log it in case. - error!(message = "park failed.", core=?self.core_id, ?err); - } - } -} - -/// A sync-channel based unpark handle. -/// -/// This is designed to be a single use handle. We will unpark a core one -/// time after all initialization completes. Do not reinvoke this. -pub(crate) struct Unpark { - core_id: CoreId, - sender: SyncSender<()>, -} - -impl Unpark { - pub(crate) fn unpark(&self) { - if let Err(err) = self.sender.send(()) { - // we are not expecting failures, but we will log it in case. - error!(message = "unpark failed.", core=?self.core_id, ?err); - } - } -} - -/// A tokio oneshot channel based shutdown mechanism. -pub(crate) struct Shutdown { - receiver: oneshot::Receiver<()>, -} - -impl Shutdown { - fn new(core_id: CoreId) -> (Self, ShutdownTrigger) { - let (sender, receiver) = oneshot::channel(); - let shutdown = Shutdown { receiver }; - let trigger = ShutdownTrigger { core_id, sender }; - (shutdown, trigger) - } - - fn into_task(self) -> impl Future { - self.receiver - } -} - -/// A sync-channel based shutdown trigger to terminate a background thread. -pub(crate) struct ShutdownTrigger { - core_id: CoreId, - sender: oneshot::Sender<()>, -} - -impl ShutdownTrigger { - pub(crate) fn shutdown(self) { - if let Err(err) = self.sender.send(()) { - // we are not expecting failures, but we will log it in case. - error!(message = "shutdown failed.", core=?self.core_id, ?err); - } - } -} - -/// A abstraction used to interact with the master/main thread. -/// -/// This is an additional handle to the master thread for performing tasks. -/// Use this `thread` handle to run the main loop. Use the `reactor` handle -/// to catch Unix signals to terminate the main loop. Use the `timer` handle -/// to create new time based tasks with either a `Delay` or `Interval`. -pub(crate) struct MasterExecutor { - pub(crate) reactor: driver::Handle, - pub(crate) timer: timer::Handle, - pub(crate) thread: CurrentThread>, -} - -/// A thread/core abstraction used to interact with a background thread -/// from the master/main thread. -/// -/// When a background thread is first spawned, it is parked and waiting for -/// tasks. Use the `timer` handle to create new time based tasks with either -/// a `Delay` or `Interval`. Use the thread handle to spawn tasks onto the -/// background thread. Use `unpark` when they are ready to execute tasks. -/// -/// The master thread also has an associated `CoreExecutor`, but `unpark` -/// won't do anything because the thread is not parked. Tasks can be spawned -/// onto it with this handle just like a background thread. -pub(crate) struct CoreExecutor { - pub(crate) timer: timer::Handle, - pub(crate) thread: current_thread::Handle, - pub(crate) unpark: Option, - pub(crate) shutdown: Option, - pub(crate) join: Option>, -} - -/// Core errors. -#[derive(Debug, Error)] -pub(crate) enum CoreError { - /// Core is not found. - #[error("{0:?} is not found.")] - NotFound(CoreId), - - /// Core is not assigned to any ports. - #[error("{0:?} is not assigned to any ports.")] - NotAssigned(CoreId), -} - -/// Map of all the core handles. -pub(crate) struct CoreMap { - pub(crate) master_core: MasterExecutor, - pub(crate) cores: HashMap, -} - -/// By default, raw pointers do not implement `Send`. We need a simple -/// wrapper so we can send the mempool pointer to a background thread and -/// assigned it to that thread. Otherwise, we wont' be able to create new -/// `Mbuf`s on the background threads. -struct SendablePtr(*mut ffi::rte_mempool); - -unsafe impl std::marker::Send for SendablePtr {} - -/// Builder for core map. -pub(crate) struct CoreMapBuilder<'a> { - app_name: String, - cores: HashSet, - master_core: CoreId, - mempools: MempoolMap<'a>, -} - -impl<'a> CoreMapBuilder<'a> { - pub(crate) fn new() -> Self { - CoreMapBuilder { - app_name: String::new(), - cores: Default::default(), - master_core: CoreId::new(0), - mempools: Default::default(), - } - } - - pub(crate) fn app_name(&mut self, app_name: &str) -> &mut Self { - self.app_name = app_name.to_owned(); - self - } - - pub(crate) fn cores(&mut self, cores: &[CoreId]) -> &mut Self { - self.cores = cores.iter().cloned().collect(); - self - } - - pub(crate) fn master_core(&mut self, master_core: CoreId) -> &mut Self { - self.master_core = master_core; - self - } - - pub(crate) fn mempools(&'a mut self, mempools: &'a mut [Mempool]) -> &'a mut Self { - self.mempools = MempoolMap::new(mempools); - self - } - - #[allow(clippy::cognitive_complexity)] - pub(crate) fn finish(&'a mut self) -> Result { - let mut map = HashMap::new(); - - // first initializes the master core, which the current running - // thread should be affinitized to. - let socket_id = self.master_core.socket_id(); - let mempool = self.mempools.get_raw(socket_id)?; - - let (master_thread, core_executor) = init_master_core(self.master_core, mempool)?; - - // adds the master core to the map. tasks can be spawned onto the - // master core like any other cores. - map.insert(self.master_core, core_executor); - - info!("initialized master on {:?}.", self.master_core); - - // the core list may also include the master core, to avoid double - // init, let's try remove it just in case. - self.cores.remove(&self.master_core); - - // next initializes all the cores other than the master core - for &core_id in self.cores.iter() { - // finds the mempool that matches the core's socket, and wraps the - // reference in a sendable pointer because we are sending it to - // a background thread - let socket_id = core_id.socket_id(); - let mempool = self.mempools.get_raw(socket_id)?; - let ptr = SendablePtr(mempool); - - // creates a synchronous channel so we can retrieve the executor for - // the background core. - let (sender, receiver) = mpsc::sync_channel(0); - - // spawns a new background thread and initializes a core executor on - // that thread. - let join = thread::Builder::new() - .name(format!("{}-{:?}", self.app_name, core_id)) - .spawn(move || { - debug!("spawned background thread {:?}.", thread::current().id()); - - match init_background_core(core_id, ptr.0) { - Ok((mut thread, park, shutdown, executor)) => { - info!("initialized thread on {:?}.", core_id); - - // keeps a timer handle for later use. - let timer_handle = executor.timer.clone(); - - // sends the executor back to the master core. it's safe to unwrap - // the result because the receiving end is guaranteed to be in scope. - sender.send(Ok(executor)).unwrap(); - - info!("parking {:?}.", core_id); - - // sleeps the thread for now since there's nothing to be done yet. - // once new tasks are spawned, the master core can unpark this and - // let the execution continue. - park.park(); - - info!("unparked {:?}.", core_id); - - // once the thread wakes up, we will run all the spawned tasks and - // wait until a shutdown is triggered from the master core. - let _timer = timer::set_default(&timer_handle); - let _ = thread.block_on(shutdown.into_task()); - - info!("unblocked {:?}.", core_id); - } - // propogates the error back to the master core. - Err(err) => sender.send(Err(err)).unwrap(), - } - })?; - - // blocks and waits for the background thread to finish initialize. - // when done, we add the executor to the map. - let mut executor = receiver.recv().unwrap()?; - executor.join = Some(join); - map.insert(core_id, executor); - } - - Ok(CoreMap { - master_core: master_thread, - cores: map, - }) - } -} - -fn init_master_core( - id: CoreId, - mempool: *mut ffi::rte_mempool, -) -> Result<(MasterExecutor, CoreExecutor)> { - // affinitize the running thread to this core. - id.set_thread_affinity()?; - - // sets the mempool - MEMPOOL.with(|tls| tls.set(mempool)); - - // starts a reactor so we can receive signals on the master core. - let reactor = Reactor::new()?; - let reactor_handle = reactor.handle(); - - // starts a per-core timer so we can schedule timed tasks. - let timer = Timer::new(reactor); - let timer_handle = timer.handle(); - - // starts the single-threaded executor, we can use this handle - // to spawn tasks onto this core from the master core. - let thread = CurrentThread::new_with_park(timer); - let thread_handle = thread.handle(); - - let main = MasterExecutor { - reactor: reactor_handle, - timer: timer_handle.clone(), - thread, - }; - - let executor = CoreExecutor { - timer: timer_handle, - thread: thread_handle, - unpark: None, - shutdown: None, - join: None, - }; - - Ok((main, executor)) -} - -fn init_background_core( - id: CoreId, - mempool: *mut ffi::rte_mempool, -) -> Result<( - CurrentThread>, - Park, - Shutdown, - CoreExecutor, -)> { - // affinitize the running thread to this core. - id.set_thread_affinity()?; - - // sets the mempool - MEMPOOL.with(|tls| tls.set(mempool)); - - // starts a per-core timer so we can schedule timed tasks. - let park = ParkThread::new(); - let timer = Timer::new(park); - let timer_handle = timer.handle(); - - // starts the single-threaded executor, we can use this handle - // to spawn tasks onto this core from the master core. - let thread = CurrentThread::new_with_park(timer); - let thread_handle = thread.handle(); - - // problem with using the regular thread park is when a task is - // spawned, the handle will implicitly unpark the thread. we have - // no way to control that behavior. so instead, we use a channel - // based unpark mechanism to block the thread from further - // execution until we are ready to proceed. - let park = Park::new(id); - - // shutdown handle for the core. - let (shutdown, trigger) = Shutdown::new(id); - - let executor = CoreExecutor { - timer: timer_handle, - thread: thread_handle, - unpark: Some(park.unpark()), - shutdown: Some(trigger), - join: None, - }; - - Ok((thread, park, shutdown, executor)) -} diff --git a/core/src/rt2/lcore.rs b/core/src/runtime/lcore.rs similarity index 98% rename from core/src/rt2/lcore.rs rename to core/src/runtime/lcore.rs index 15a353dd..7fb11595 100644 --- a/core/src/rt2/lcore.rs +++ b/core/src/runtime/lcore.rs @@ -156,7 +156,7 @@ mod tests { #[capsule::test] fn get_current_lcore_id_from_non_eal() { - let lcore_id = thread::spawn(|| LcoreId::current()).join().expect("panic!"); + let lcore_id = thread::spawn(LcoreId::current).join().expect("panic!"); assert_eq!(LcoreId::ANY, lcore_id); } diff --git a/core/src/rt2/mempool.rs b/core/src/runtime/mempool.rs similarity index 100% rename from core/src/rt2/mempool.rs rename to core/src/runtime/mempool.rs diff --git a/core/src/runtime/mod.rs b/core/src/runtime/mod.rs index 351d54b3..cd63ef92 100644 --- a/core/src/runtime/mod.rs +++ b/core/src/runtime/mod.rs @@ -16,615 +16,219 @@ * SPDX-License-Identifier: Apache-2.0 */ -mod core_map; - -pub(crate) use self::core_map::*; - -use crate::batch::Pipeline; -use crate::config::RuntimeConfig; -use crate::dpdk::{ - self, CoreId, KniError, KniRx, Mempool, Port, PortBuilder, PortError, PortQueue, -}; -use crate::{debug, ensure, info}; +//! Capsule runtime. + +mod config; +mod lcore; +mod mempool; +#[cfg(feature = "pcap-dump")] +#[cfg_attr(docsrs, doc(cfg(feature = "pcap-dump")))] +mod pcap_dump; +mod port; + +pub use self::config::*; +pub(crate) use self::lcore::*; +pub use self::lcore::{Lcore, LcoreMap, LcoreNotFound}; +pub use self::mempool::Mempool; +pub(crate) use self::mempool::*; +pub use self::port::{Outbox, Port, PortError, PortMap}; + +use crate::ffi::dpdk::{self, LcoreId}; +use crate::packets::{Mbuf, Postmark}; +use crate::{debug, info}; use anyhow::Result; -use futures::{future, stream, StreamExt}; -use std::collections::{HashMap, HashSet}; +use async_channel::{self, Receiver, Sender}; use std::fmt; use std::mem::ManuallyDrop; -use std::sync::Arc; -use std::time::{Duration, Instant}; -use tokio_executor::current_thread; -use tokio_net::driver; -use tokio_net::signal::unix::{self, SignalKind}; -use tokio_timer::{timer, Interval}; - -/// Supported [Unix signals]. -/// -/// [Unix signals]: https://en.wikipedia.org/wiki/Signal_(IPC)#POSIX_signals -#[derive(Copy, Clone, Debug)] -pub enum UnixSignal { - /// This signal is sent to a process when its controlling terminal is closed. - /// In modern systems, this signal usually means that the controlling pseudo - /// or virtual terminal has been closed. Many daemons will reload their - /// configuration files and reopen their log files instead of exiting when - /// receiving this signal. `nohup` is a command to make a command ignore the - /// signal. - SIGHUP = libc::SIGHUP as isize, - /// This signal is sent to a process by its controlling terminal when a user - /// wishes to interrupt the process. This is typically initiated by pressing - /// `Ctrl-C`, but on some systems, the "delete" character or "break" key can - /// be used. - SIGINT = libc::SIGINT as isize, - /// This signal is sent to a process to request its termination. Unlike the - /// `SIGKILL` signal, it can be caught and interpreted or ignored by the - /// process. This allows the process to perform nice termination releasing - /// resources and saving state if appropriate. `SIGINT` is nearly identical - /// to `SIGTERM`. - SIGTERM = libc::SIGTERM as isize, -} +use std::ops::DerefMut; -/// The Capsule runtime. -/// -/// The runtime initializes the underlying DPDK environment, and it also manages -/// the task scheduler that executes the packet processing pipelines. -pub struct Runtime { - ports: ManuallyDrop>, - mempools: ManuallyDrop>, - core_map: CoreMap, - on_signal: Arc bool>, - config: RuntimeConfig, -} - -impl Runtime { - /// Builds a runtime from config settings. - #[allow(clippy::cognitive_complexity)] - pub fn build(config: RuntimeConfig) -> Result { - info!("initializing EAL..."); - dpdk::eal_init(config.to_eal_args())?; - - #[cfg(feature = "metrics")] - { - info!("initializing metrics subsystem..."); - crate::metrics::init()?; - } - - let cores = config.all_cores(); - - info!("initializing mempools..."); - let sockets = cores.iter().map(CoreId::socket_id).collect::>(); - let mut mempools = vec![]; - for socket in sockets { - let mempool = Mempool::new(config.mempool.capacity, config.mempool.cache_size, socket)?; - debug!(?mempool); - mempools.push(mempool); - } - - info!("intializing cores..."); - let core_map = CoreMapBuilder::new() - .app_name(&config.app_name) - .cores(&cores) - .master_core(config.master_core) - .mempools(&mut mempools) - .finish()?; - - let len = config.num_knis(); - if len > 0 { - info!("initializing KNI subsystem..."); - dpdk::kni_init(len)?; - } - - info!("initializing ports..."); - let mut ports = vec![]; - for conf in config.ports.iter() { - let port = PortBuilder::new(conf.name.clone(), conf.device.clone())? - .cores(&conf.cores)? - .mempools(&mut mempools) - .rx_tx_queue_capacity(conf.rxd, conf.txd)? - .finish(conf.promiscuous, conf.multicast, conf.kni)?; - - debug!(?port); - ports.push(port); - } - - #[cfg(feature = "metrics")] - { - crate::metrics::register_port_stats(&ports); - crate::metrics::register_mempool_stats(&mempools); - } - - info!("runtime ready."); - - Ok(Runtime { - ports: ManuallyDrop::new(ports), - mempools: ManuallyDrop::new(mempools), - core_map, - on_signal: Arc::new(|_| true), - config, - }) - } +/// Trigger for the shutdown. +pub(crate) struct ShutdownTrigger(Sender<()>, Receiver<()>); - #[inline] - fn get_port(&self, name: &str) -> Result<&Port> { - self.ports - .iter() - .find(|p| p.name() == name) - .ok_or_else(|| PortError::NotFound(name.to_owned()).into()) - } - - #[inline] - fn get_port_mut(&mut self, name: &str) -> Result<&mut Port> { - self.ports - .iter_mut() - .find(|p| p.name() == name) - .ok_or_else(|| PortError::NotFound(name.to_owned()).into()) +impl ShutdownTrigger { + /// Creates a new shutdown trigger. + /// + /// Leverages the behavior of an async channel. When the sender is dropped + /// from scope, it closes the channel and causes the receiver side future + /// in the executor queue to resolve. + pub(crate) fn new() -> Self { + let (s, r) = async_channel::unbounded(); + Self(s, r) } - #[inline] - fn get_core(&self, core_id: CoreId) -> Result<&CoreExecutor> { - self.core_map - .cores - .get(&core_id) - .ok_or_else(|| CoreError::NotFound(core_id).into()) + /// Returns a wait handle. + pub(crate) fn get_wait(&self) -> ShutdownWait { + ShutdownWait(self.1.clone()) } - #[inline] - fn get_port_qs(&self, core_id: CoreId) -> Result> { - let map = self - .ports - .iter() - .filter_map(|p| { - p.queues() - .get(&core_id) - .map(|q| (p.name().to_owned(), q.clone())) - }) - .collect::>(); - - ensure!(!map.is_empty(), CoreError::NotAssigned(core_id)); - - Ok(map) + /// Returns whether the trigger is being waited on. + pub(crate) fn is_waited(&self) -> bool { + // a receiver count greater than 1 indicating that there are receiver + // clones in scope, hence the trigger is being waited on. + self.0.receiver_count() > 1 } - /// Sets the Unix signal handler. - /// - /// `SIGHUP`, `SIGINT` and `SIGTERM` are the supported Unix signals. - /// The return of the handler determines whether to terminate the - /// process. `true` indicates the signal is received and the process - /// should be terminated. `false` indicates to discard the signal and - /// keep the process running. - /// - /// # Example - /// - /// ``` - /// Runtime::build(&config)?; - /// .set_on_signal(|signal| match signal { - /// SIGHUP => { - /// reload_config(); - /// false - /// } - /// _ => true, - /// }) - /// .execute(); - /// ``` - pub fn set_on_signal(&mut self, f: F) -> &mut Self - where - F: Fn(UnixSignal) -> bool + 'static, - { - self.on_signal = Arc::new(f); - self + /// Triggers the shutdown. + pub(crate) fn fire(self) { + drop(self.0) } +} - /// Installs a pipeline to a port. The pipeline will run on all the - /// cores assigned to the port. - /// - /// `port` is the logical name that identifies the port. The `installer` - /// is a closure that takes in a [`PortQueue`] and returns a [`Pipeline`] - /// that will be spawned onto the thread executor. - /// - /// # Example - /// - /// ``` - /// Runtime::build(config)? - /// .add_add_pipeline_to_port("eth1", install)? - /// .execute() - /// ``` - /// - /// [`PortQueue`]: crate::PortQueue - /// [`Pipeline`]: crate::batch::Pipeline - pub fn add_pipeline_to_port( - &mut self, - port: &str, - installer: F, - ) -> Result<&mut Self> - where - F: Fn(PortQueue) -> T + Send + Sync + 'static, - { - let port = self.get_port(port)?; - let f = Arc::new(installer); - - for (core_id, port_q) in port.queues() { - let f = f.clone(); - let port_q = port_q.clone(); - let thread = &self.get_core(*core_id)?.thread; - - // spawns the bootstrap. we want the bootstrapping to execute on the - // target core instead of the master core. that way the actual task - // is spawned locally and the type bounds are less restricting. - thread.spawn(future::lazy(move |_| { - let fut = f(port_q); - debug!("spawned pipeline {}.", fut.name()); - current_thread::spawn(fut); - }))?; - - debug!("installed pipeline on port_q for {:?}.", core_id); - } - - info!("installed pipeline for port {}.", port.name()); - - Ok(self) - } +/// Shutdown wait handle. +pub(crate) struct ShutdownWait(Receiver<()>); - /// Installs a pipeline to a KNI enabled port to receive packets coming - /// from the kernel. This pipeline will run on a randomly select core - /// that's assigned to the port. - /// - /// # Remarks - /// - /// This function has be to invoked once per port. Otherwise the packets - /// coming from the kernel will be silently dropped. For the most common - /// use case where the application only needs simple packet forwarding, - /// use [`batch::splice`] to join the kernel's RX with the port's TX. - /// - /// # Example - /// - /// ``` - /// Runtime::build(config)? - /// .add_add_pipeline_to_port("kni0", install)? - /// .add_kni_rx_pipeline_to_port("kni0", batch::splice)? - /// .execute() - /// ``` - /// - /// [`batch::splice`]: crate::batch::splice - pub fn add_kni_rx_pipeline_to_port( - &mut self, - port: &str, - installer: F, - ) -> Result<&mut Self> - where - F: FnOnce(KniRx, PortQueue) -> T + Send + Sync + 'static, - { - // takes ownership of the kni rx handle. - let kni_rx = self - .get_port_mut(port)? - .kni() - .ok_or(KniError::Disabled)? - .take_rx()?; - - // selects a core to run a rx pipeline for this port. the selection is - // randomly choosing the last core we find. if the port has more than one - // core assigned, this will be different from the core that's running the - // tx pipeline. - let port = self.get_port(port)?; - let core_id = port.queues().keys().last().unwrap(); - let port_q = port.queues()[core_id].clone(); - let thread = &self.get_core(*core_id)?.thread; - - // spawns the bootstrap. we want the bootstrapping to execute on the - // target core instead of the master core. - thread.spawn(future::lazy(move |_| { - let fut = installer(kni_rx, port_q); - debug!("spawned kni rx pipeline {}.", fut.name()); - current_thread::spawn(fut); - }))?; - - info!("installed kni rx pipeline for port {}.", port.name()); - - Ok(self) +impl ShutdownWait { + /// A future that waits till the shutdown trigger is fired. + pub(crate) async fn wait(&self) { + self.0.recv().await.unwrap_or(()) } +} - /// Installs a pipeline to a core. All the ports the core is assigned - /// to will be available to the pipeline. - /// - /// `core` is the logical id that identifies the core. The `installer` - /// is a closure that takes in a hashmap of [`PortQueues`] and returns a - /// [`Pipeline`] that will be spawned onto the thread executor of the core. - /// - /// # Example - /// - /// ``` - /// Runtime::build(config)? - /// .add_pipeline_to_core(1, install)? - /// .execute() - /// ``` - /// - /// [`PortQueues`]: crate::PortQueue - /// [`Pipeline`]: crate::batch::Pipeline - pub fn add_pipeline_to_core( - &mut self, - core: usize, - installer: F, - ) -> Result<&mut Self> - where - F: FnOnce(HashMap) -> T + Send + Sync + 'static, - { - let core_id = CoreId::new(core); - let thread = &self.get_core(core_id)?.thread; - let port_qs = self.get_port_qs(core_id)?; - - // spawns the bootstrap. we want the bootstrapping to execute on the - // target core instead of the master core. - thread.spawn(future::lazy(move |_| { - let fut = installer(port_qs); - debug!("spawned pipeline {}.", fut.name()); - current_thread::spawn(fut); - }))?; - - info!("installed pipeline for {:?}.", core_id); - - Ok(self) - } +/// The Capsule runtime. +/// +/// The runtime initializes the underlying DPDK environment, and it also manages +/// the task scheduler that executes the packet processing tasks. +pub struct Runtime { + mempool: ManuallyDrop, + lcores: ManuallyDrop, + ports: ManuallyDrop, + #[cfg(feature = "pcap-dump")] + pcap_dump: ManuallyDrop, +} - /// Installs a periodic pipeline to a core. - /// - /// `core` is the logical id that identifies the core. The `installer` is a - /// closure that takes in a hashmap of [`PortQueues`] and returns a - /// [`Pipeline`] that will be run periodically every `dur` interval. - /// - /// # Remarks - /// - /// All the ports the core is assigned to will be available to this - /// pipeline. However they should only be used to transmit packets. This - /// variant is for pipelines that generate new packets periodically. - /// A new packet batch can be created with [`batch::poll_fn`] and ingested - /// into the pipeline. - /// - /// # Example - /// - /// ``` - /// Runtime::build(config)? - /// .add_periodic_pipeline_to_core(1, install, Duration::from_millis(10))? - /// .execute() - /// ``` +impl Runtime { + /// Returns the mempool. /// - /// [`PortQueues`]: crate::PortQueue - /// [`Pipeline`]: crate::batch::Pipeline - /// [`batch::poll_fn`]: crate::batch::poll_fn - pub fn add_periodic_pipeline_to_core( - &mut self, - core: usize, - installer: F, - dur: Duration, - ) -> Result<&mut Self> - where - F: FnOnce(HashMap) -> T + Send + Sync + 'static, - { - let core_id = CoreId::new(core); - let thread = &self.get_core(core_id)?.thread; - let port_qs = self.get_port_qs(core_id)?; - - // spawns the bootstrap. we want the bootstrapping to execute on the - // target core instead of the master core so the periodic task is - // associated with the correct timer instance. - thread.spawn(future::lazy(move |_| { - let mut pipeline = installer(port_qs); - debug!("spawned periodic pipeline {}.", pipeline.name()); - let fut = Interval::new_interval(dur).for_each(move |_| { - pipeline.run_once(); - future::ready(()) - }); - current_thread::spawn(fut); - }))?; - - info!("installed periodic pipeline for {:?}.", core_id); - - Ok(self) + /// For simplicity, we currently only support one global Mempool. Multi- + /// socket support may be added in the future. + pub fn mempool(&self) -> &Mempool { + &self.mempool } - /// Installs a periodic task to a core. - /// - /// `core` is the logical id that identifies the core. `task` is the - /// closure to execute. The task will rerun every `dur` interval. - /// - /// # Example - /// - /// ``` - /// Runtime::build(config)? - /// .add_periodic_task_to_core(0, print_stats, Duration::from_secs(1))? - /// .execute() - /// ``` - pub fn add_periodic_task_to_core( - &mut self, - core: usize, - mut task: F, - dur: Duration, - ) -> Result<&mut Self> - where - F: FnMut() + Send + Sync + 'static, - { - let core_id = CoreId::new(core); - let thread = &self.get_core(core_id)?.thread; - - // spawns the bootstrap. we want the bootstrapping to execute on the - // target core instead of the master core so the periodic task is - // associated with the correct timer instance. - thread.spawn(future::lazy(move |_| { - let fut = Interval::new_interval(dur).for_each(move |_| { - task(); - future::ready(()) - }); - debug!("spawned periodic task."); - current_thread::spawn(fut); - }))?; - - info!("installed periodic task for {:?}.", core_id); - - Ok(self) + /// Returns the lcores. + pub fn lcores(&self) -> &LcoreMap { + &self.lcores } - /// Blocks the main thread until a timeout expires. - /// - /// This mode is useful for running integration tests. The timeout - /// duration can be set in `RuntimeSettings`. - fn wait_for_timeout(&mut self, timeout: Duration) { - let MasterExecutor { - ref timer, - ref mut thread, - .. - } = self.core_map.master_core; - - let when = Instant::now() + timeout; - let delay = timer.delay(when); - - debug!("waiting for {:?}...", timeout); - let _timer = timer::set_default(&timer); - thread.block_on(delay); - info!("timed out after {:?}.", timeout); + /// Returns the configured ports. + pub fn ports(&self) -> &PortMap { + &self.ports } - /// Blocks the main thread until receives a signal to terminate. - fn wait_for_signal(&mut self) -> Result<()> { - let sighup = unix::signal(SignalKind::hangup())?.map(|_| UnixSignal::SIGHUP); - let sigint = unix::signal(SignalKind::interrupt())?.map(|_| UnixSignal::SIGINT); - let sigterm = unix::signal(SignalKind::terminate())?.map(|_| UnixSignal::SIGTERM); - - // combines the streams together - let stream = stream::select(stream::select(sighup, sigint), sigterm); - - // passes each signal through the `on_signal` closure, and discard - // any that shouldn't stop the execution. - let f = self.on_signal.clone(); - let mut stream = stream.filter(|&signal| future::ready(f(signal))); - - let MasterExecutor { - ref reactor, - ref timer, - ref mut thread, - .. - } = self.core_map.master_core; - - // sets the reactor so we receive the signals and runs the future - // on the master core. the execution stops on the first signal that - // wasn't filtered out. - debug!("waiting for a Unix signal..."); - let _guard = driver::set_default(&reactor); - let _timer = timer::set_default(&timer); - let _ = thread.block_on(stream.next()); - info!("signaled to stop."); + /// Initializes a new runtime from config settings. + pub fn from_config(config: RuntimeConfig) -> Result { + info!("starting runtime."); - Ok(()) - } + debug!("initializing EAL ..."); + dpdk::eal_init(config.to_eal_args())?; - /// Installs the KNI TX pipelines. - fn add_kni_tx_pipelines(&mut self) -> Result<()> { - let mut map = HashMap::new(); - for port in self.ports.iter_mut() { - // selects a core if we need to run a tx pipeline for this port. the - // selection is randomly choosing the first core we find. if the port - // has more than one core assigned, this will be different from the - // core that's running the rx pipeline. - let core_id = *port.queues().keys().next().unwrap(); - - // if the port is kni enabled, then we will take ownership of the - // tx handle. - if let Some(kni) = port.kni() { - map.insert(core_id, kni.take_tx()?); - } + debug!("initializing mempool ..."); + let socket = LcoreId::main().socket(); + let mut mempool = Mempool::new( + "mempool", + config.mempool.capacity, + config.mempool.cache_size, + socket, + )?; + debug!(?mempool); + + debug!("initializing lcore schedulers ..."); + let lcores = self::lcore_pool(); + + for lcore in lcores.iter() { + let mut ptr = mempool.ptr_mut().clone(); + lcore.block_on(async move { MEMPOOL.with(|tls| tls.set(ptr.deref_mut())) }); } - // spawns all the pipelines. - for (core_id, kni_tx) in map.into_iter() { - let thread = &self.get_core(core_id)?.thread; - thread.spawn(kni_tx.into_pipeline())?; + info!("initializing ports ..."); + let mut ports = Vec::new(); + for port in config.ports.iter() { + let mut port = port::Builder::for_device(&port.name, &port.device)? + .set_rxqs_txqs(port.rxqs, port.txqs)? + .set_promiscuous(port.promiscuous)? + .set_multicast(port.multicast)? + .set_rx_lcores(port.rx_cores.clone())? + .set_tx_lcores(port.tx_cores.clone())? + .build(&mut mempool)?; - info!("installed kni tx pipeline on {:?}.", core_id); - } + debug!(?port); - Ok(()) - } + if !port.tx_lcores().is_empty() { + port.spawn_tx_loops(&lcores)?; + } - /// Starts all the ports to receive packets. - fn start_ports(&mut self) -> Result<()> { - for port in self.ports.iter_mut() { port.start()?; + ports.push(port); } + let ports: PortMap = ports.into(); - Ok(()) - } + #[cfg(feature = "pcap-dump")] + let pcap_dump = self::pcap_dump::enable_pcap_dump(&config.data_dir(), &ports, &lcores)?; - /// Unparks all the cores to start task execution. - fn unpark_cores(&mut self) { - for core in self.core_map.cores.values() { - if let Some(unpark) = &core.unpark { - unpark.unpark(); - } - } - } + info!("runtime ready."); - /// Shuts down all the cores to stop task execution. - #[allow(clippy::cognitive_complexity)] - fn shutdown_cores(&mut self) { - for (core_id, core) in &mut self.core_map.cores { - if let Some(trigger) = core.shutdown.take() { - debug!("shutting down {:?}.", core_id); - trigger.shutdown(); - debug!("sent {:?} shutdown trigger.", core_id); - let handle = core.join.take().unwrap(); - let _ = handle.join(); - info!("terminated {:?}.", core_id); - } - } + Ok(Runtime { + mempool: ManuallyDrop::new(mempool), + lcores: ManuallyDrop::new(lcores), + ports: ManuallyDrop::new(ports), + #[cfg(feature = "pcap-dump")] + pcap_dump: ManuallyDrop::new(pcap_dump), + }) } - /// Stops all the ports. - fn stop_ports(&mut self) { - for port in self.ports.iter_mut() { - port.stop(); - } + /// Sets the packet processing pipeline for port. + pub fn set_port_pipeline(&self, port: &str, f: F) -> Result<()> + where + F: Fn(Mbuf) -> Result + Clone + Send + Sync + 'static, + { + let port = self.ports.get(port)?; + port.spawn_rx_loops(f, &self.lcores)?; + Ok(()) } - /// Executes the pipeline(s) until a stop signal is received. - pub fn execute(&mut self) -> Result<()> { - self.add_kni_tx_pipelines()?; - self.start_ports()?; - self.unpark_cores(); - - // runs the app until main loop finishes. - match self.config.duration { - None => self.wait_for_signal()?, - Some(d) => self.wait_for_timeout(d), - }; - - self.shutdown_cores(); - self.stop_ports(); - info!("runtime terminated."); - - Ok(()) + /// Starts the runtime execution. + pub fn execute(self) -> Result { + Ok(RuntimeGuard { runtime: self }) } } -impl<'a> fmt::Debug for Runtime { +impl fmt::Debug for Runtime { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("runtime") - .field("runtime configuration", &format!("{:?}", self.config)) + f.debug_struct("Runtime") + .field("mempool", &self.mempool) .finish() } } -impl Drop for Runtime { +/// The RAII guard to stop and cleanup the runtime resources on drop. +pub struct RuntimeGuard { + runtime: Runtime, +} + +impl Drop for RuntimeGuard { fn drop(&mut self) { - // the default rust drop order is self before fields, which is the wrong - // order for what EAL needs. To control the order, we manually drop the - // fields first. - unsafe { - ManuallyDrop::drop(&mut self.ports); - ManuallyDrop::drop(&mut self.mempools); + info!("shutting down runtime."); + + for port in self.runtime.ports.iter_mut() { + port.stop(); } - if self.config.num_knis() > 0 { - debug!("freeing KNI subsystem."); - dpdk::kni_close(); + unsafe { + #[cfg(feature = "pcap-dump")] + ManuallyDrop::drop(&mut self.runtime.pcap_dump); + ManuallyDrop::drop(&mut self.runtime.ports); + ManuallyDrop::drop(&mut self.runtime.lcores); + ManuallyDrop::drop(&mut self.runtime.mempool); } - debug!("freeing EAL."); - dpdk::eal_cleanup().unwrap(); + debug!("freeing EAL ..."); + let _ = dpdk::eal_cleanup(); + info!("runtime shutdown."); + } +} + +impl fmt::Debug for RuntimeGuard { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "RuntimeGuard") } } diff --git a/core/src/rt2/pcap_dump.rs b/core/src/runtime/pcap_dump.rs similarity index 96% rename from core/src/rt2/pcap_dump.rs rename to core/src/runtime/pcap_dump.rs index 8c0a39bf..f54c8927 100644 --- a/core/src/rt2/pcap_dump.rs +++ b/core/src/runtime/pcap_dump.rs @@ -72,6 +72,9 @@ impl Drop for CaptureFile { /// The pcap dump manager. pub(crate) struct PcapDump { output_dir: String, + // we need the extra level of indirection because we need stable + // pointers to pass to ffi code. + #[allow(clippy::vec_box)] captures: Vec>, } @@ -164,7 +167,7 @@ unsafe extern "C" fn rx_callback_fn( ) -> u16 { let capture = Box::leak(Box::from_raw(user_param as *mut CaptureFile)); let mbufs = slice::from_raw_parts_mut(pkts as *mut MbufPtr, num_pkts as usize); - dump_mbufs(&mut capture.dumper, &mbufs); + dump_mbufs(&mut capture.dumper, mbufs); num_pkts } @@ -177,7 +180,7 @@ unsafe extern "C" fn tx_callback_fn( ) -> u16 { let capture = Box::leak(Box::from_raw(user_param as *mut CaptureFile)); let mbufs = slice::from_raw_parts_mut(pkts as *mut MbufPtr, num_pkts as usize); - dump_mbufs(&mut capture.dumper, &mbufs); + dump_mbufs(&mut capture.dumper, mbufs); num_pkts } diff --git a/core/src/rt2/port.rs b/core/src/runtime/port.rs similarity index 96% rename from core/src/rt2/port.rs rename to core/src/runtime/port.rs index 3e65a68a..0a941e5f 100644 --- a/core/src/rt2/port.rs +++ b/core/src/runtime/port.rs @@ -90,7 +90,7 @@ impl Port { self.outbox .as_ref() .map(|s| Outbox(self.name.clone(), s.clone())) - .ok_or(PortError::TxNotEnabled.into()) + .ok_or_else(|| PortError::TxNotEnabled.into()) } /// Spawns the port receiving loop. @@ -102,7 +102,7 @@ impl Port { let shutdown = self.shutdown.as_ref().unwrap(); // can't run loop without assigned rx cores. - ensure!(self.rx_lcores.len() > 0, PortError::RxNotEnabled); + ensure!(!self.rx_lcores.is_empty(), PortError::RxNotEnabled); // pipeline already set if the trigger is waited on. ensure!(!shutdown.is_waited(), PortError::PipelineSet); @@ -292,29 +292,23 @@ async fn tx_loop( let txq = PortTxQueue { port_id, queue_id }; let mut ptrs = Vec::with_capacity(batch_size); - loop { - if let Ok(ptr) = receiver.recv().await { - ptrs.push(ptr); - - // try to batch the packets up to batch size. - for _ in 1..batch_size { - match receiver.try_recv() { - Ok(ptr) => ptrs.push(ptr), - // no more packets to batch, ready to transmit. - Err(_) => break, - } + while let Ok(ptr) = receiver.recv().await { + ptrs.push(ptr); + + // try to batch the packets up to batch size. + for _ in 1..batch_size { + match receiver.try_recv() { + Ok(ptr) => ptrs.push(ptr), + // no more packets to batch, ready to transmit. + Err(_) => break, } + } - txq.transmit(&mut ptrs); + txq.transmit(&mut ptrs); - // cooperatively moves to the back of the execution queue, - // making room for other tasks before transmitting again. - future::yield_now().await; - } else { - // this branch can only be reached if the channel is closed, - // indicating the tx loop should exit. - break; - } + // cooperatively moves to the back of the execution queue, + // making room for other tasks before transmitting again. + future::yield_now().await; } debug!(port = ?port_name, lcore = ?LcoreId::current(), "tx loop exited."); diff --git a/core/src/testils/criterion.rs b/core/src/testils/criterion.rs index 8bd66dc6..d45268dd 100644 --- a/core/src/testils/criterion.rs +++ b/core/src/testils/criterion.rs @@ -22,12 +22,9 @@ //! [criterion]: https://crates.io/crates/criterion use super::Rvg; -use crate::batch::{Batch, PacketTx, Poll}; -use crate::Mbuf; use criterion::{black_box, Bencher}; use proptest::strategy::Strategy; use std::cmp; -use std::sync::mpsc::{self, Receiver}; use std::time::{Duration, Instant}; /// Criterion `Bencher` extension trait. @@ -42,19 +39,6 @@ pub trait BencherExt { where R: FnMut(S::Value) -> O, S: Strategy; - - /// Times a `routine` with an input generated via a `proptest strategy` - /// batch of input that can be polled for benchmarking pipeline combinators - /// in [`Batch`] and then times the iteration of the benchmark - /// over the input. See [`BatchSize`] for details on choosing the batch size. - /// - /// [`BatchSize`]: https://docs.rs/criterion/latest/criterion/enum.BatchSize.html - /// [`Batch`]: crate::batch::Batch - fn iter_proptest_combinators(&mut self, strategy: S, routine: R, batch_size: usize) - where - R: FnMut(Poll>) -> O, - S: Strategy, - O: Batch; } impl BencherExt for Bencher<'_> { @@ -84,43 +68,4 @@ impl BencherExt for Bencher<'_> { total_elapsed }) } - - fn iter_proptest_combinators, O: Batch>( - &mut self, - strategy: S, - mut routine: R, - batch_size: usize, - ) where - R: FnMut(Poll>) -> O, - { - self.iter_custom(|mut iters| { - let mut total_elapsed = Duration::from_secs(0); - let mut gen = Rvg::deterministic(); - while iters > 0 { - let batch_size = cmp::min(batch_size, iters as usize); - let inputs = black_box(gen.generate_vec(&strategy, batch_size)); - let mut outputs = Vec::with_capacity(batch_size); - - let (mut tx, rx) = mpsc::channel(); - tx.transmit(inputs.into_iter().collect::>()); - let mut new_batch = Poll::new(rx); - new_batch.replenish(); - - let start = Instant::now(); - let mut batch = routine(new_batch); - - while let Some(disp) = batch.next() { - outputs.push(disp) - } - - total_elapsed += start.elapsed(); - - black_box(batch); - black_box(outputs); - - iters -= batch_size as u64; - } - total_elapsed - }) - } } diff --git a/core/src/testils/mod.rs b/core/src/testils/mod.rs index 24455756..da4393e4 100644 --- a/core/src/testils/mod.rs +++ b/core/src/testils/mod.rs @@ -28,8 +28,7 @@ pub use self::packet::*; pub use self::rvg::*; use crate::ffi::dpdk::{self, SocketId}; -use crate::metrics; -use crate::rt2::{Mempool, MEMPOOL}; +use crate::runtime::{Mempool, MEMPOOL}; use std::ops::DerefMut; use std::ptr; use std::sync::Once; @@ -62,7 +61,6 @@ pub fn cargo_test_init() { "net_tap0", ]) .unwrap(); - let _ = metrics::init(); }); } diff --git a/core/src/testils/packet.rs b/core/src/testils/packet.rs index fbdb710e..c0e4d86c 100644 --- a/core/src/testils/packet.rs +++ b/core/src/testils/packet.rs @@ -16,9 +16,12 @@ * SPDX-License-Identifier: Apache-2.0 */ +use crate::packets::ethernet::Ethernet; use crate::packets::ip::v4::Ipv4; use crate::packets::ip::v6::{Ipv6, SegmentRouting}; -use crate::packets::{Ethernet, Packet, Tcp, Tcp4, Tcp6, Udp4, Udp6}; +use crate::packets::tcp::{Tcp, Tcp4, Tcp6}; +use crate::packets::udp::{Udp4, Udp6}; +use crate::packets::Packet; /// [`Packet`] extension trait. /// diff --git a/core/src/testils/proptest/arbitrary.rs b/core/src/testils/proptest/arbitrary.rs index b4b3a399..35c24aed 100644 --- a/core/src/testils/proptest/arbitrary.rs +++ b/core/src/testils/proptest/arbitrary.rs @@ -19,8 +19,8 @@ //! Implementations of `proptest.arbitrary.Arbitrary` trait for //! various types. -use crate::dpdk::Mbuf; use crate::net::MacAddr; +use crate::packets::Mbuf; use proptest::arbitrary::{any, Arbitrary, StrategyFor}; use proptest::strategy::{MapInto, Strategy}; diff --git a/core/src/testils/proptest/strategy.rs b/core/src/testils/proptest/strategy.rs index c70c0645..fc5344df 100644 --- a/core/src/testils/proptest/strategy.rs +++ b/core/src/testils/proptest/strategy.rs @@ -19,12 +19,14 @@ //! Proptest strategies. use crate::net::MacAddr; +use crate::packets::ethernet::{EtherType, EtherTypes, Ethernet}; use crate::packets::ip::v4::Ipv4; use crate::packets::ip::v6::{Ipv6, Ipv6Packet, SegmentRouting}; use crate::packets::ip::{Flow, IpPacket, ProtocolNumber, ProtocolNumbers}; -use crate::packets::{EtherType, EtherTypes, Ethernet, Packet, Tcp, Udp}; +use crate::packets::tcp::Tcp; +use crate::packets::udp::Udp; +use crate::packets::{Mbuf, Packet}; use crate::testils::Rvg; -use crate::Mbuf; use proptest::arbitrary::{any, Arbitrary}; use proptest::collection::vec; use proptest::prop_oneof; @@ -112,7 +114,7 @@ impl StrategyMap { } fn checked_value(&self, key: &field) -> Option { - if let Some(ref v) = self.0.get(key) { + if let Some(v) = self.0.get(key) { let v = v .downcast_ref::() .unwrap_or_else(|| panic!("value doesn't match type for field '{:?}'", key)); diff --git a/examples/kni/Cargo.toml b/examples/kni/Cargo.toml index a27935c4..317d5a39 100644 --- a/examples/kni/Cargo.toml +++ b/examples/kni/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kni" -version = "0.1.0" +version = "0.2.0" authors = ["Capsule Developers "] license = "Apache-2.0" edition = "2018" @@ -17,7 +17,7 @@ doctest = false [dependencies] anyhow = "1.0" -capsule = { version = "0.1", path = "../../core" } +capsule = { version = "0.2", path = "../../core" } colored = "2.0" signal-hook = "0.3" tracing = "0.1" diff --git a/examples/kni/README.md b/examples/kni/README.md index 22a5f4bf..6ff5b0b6 100644 --- a/examples/kni/README.md +++ b/examples/kni/README.md @@ -33,14 +33,14 @@ While the application is running, in a seperate Vagrant VM terminal, check that ```bash vagrant$ ip link show dev kni0 -14: kni0: mtu 2034 qdisc noop state DOWN mode DEFAULT group default qlen 1000 - link/ether 6a:80:63:c3:01:42 brd ff:ff:ff:ff:ff:ff +27: kni0: mtu 2034 qdisc noop state DOWN mode DEFAULT group default qlen 1000 + link/ether ce:49:b6:ff:f7:1f brd ff:ff:ff:ff:ff:ff ``` Change the MAC address of `kni0` to match the MAC address of the physical interface first; then bring up the link, ```bash -vagrant$ sudo ip link set dev kni0 address 02:00:00:ff:ff:00 +vagrant$ sudo ip link set dev kni0 address 02:00:c0:a8:38:0a vagrant$ sudo ip link set dev kni0 up ``` @@ -49,16 +49,16 @@ Once `kni0` is up, it should be automatically assigned an IPv6 address, we will ```bash vagrant$ ip addr show dev kni0 -14: kni0: mtu 2034 qdisc pfifo_fast state UP group default qlen 1000 - link/ether 02:00:00:ff:ff:00 brd ff:ff:ff:ff:ff:ff - inet6 fe80::ff:feff:ff00/64 scope link +27: kni0: mtu 2034 qdisc pfifo_fast state UP group default qlen 1000 + link/ether 02:00:c0:a8:38:0a brd ff:ff:ff:ff:ff:ff + inet6 fe80::c0ff:fea8:380a/64 scope link dadfailed tentative valid_lft forever preferred_lft forever ``` Finally use `socat` to read from `stdin`, and send the input messages as UDP packets to this IPv6 address. These packets will be routed to the running Capsule application, ```bash -vagrant$ socat -d -d -u - udp6:[fe80::ff:feff:ff00%eth3]:6667 +vagrant$ socat -d -d -u - udp6:[fe80::c0ff:fea8:380a%eth3]:6667 Hello? Is there anybody in there? @@ -79,9 +79,9 @@ Mar 28 19:59:39.475 INFO kni: you said: Is there anybody in there? Capsule leverages the KNI poll mode driver instead of the `librte_kni` API directly. This lets the application to interact with KNI the same way as any other physical or virtual port device. -The example is configured with one PCI port, `cap0`, and one KNI port, `kni0`. As new packets arrive through `cap0`'s rx, the application will forward all ICMPv6 packets to the `kni0`'s tx. For the sake of simplicity, it is assumed that all ICMPv6 packets received in this example will be NDP messages, and the application is delegating this link layer address discovery process to the kernel stack. In the reverse direction, kernel stack's NDP responses will come in through `kni0`'s rx, and immediately forwarded out through `cap0`'s tx without modifications. Because we assigned `cap0`'s link layer MAC address, `02:00:00:ff:ff:00`, to `kni0` with the `ip link set` command, the NDP responses already contain the correct link layer information. +The example is configured with one PCI port, `cap0`, and one KNI port, `kni0`. As new packets arrive through `cap0`'s rx, the application will forward all ICMPv6 packets to the `kni0`'s tx. For the sake of simplicity, it is assumed that all ICMPv6 packets received in this example will be NDP messages, and the application is delegating this link layer address discovery process to the kernel stack. In the reverse direction, kernel stack's NDP responses will come in through `kni0`'s rx, and immediately forwarded out through `cap0`'s tx without modifications. Because we assigned `cap0`'s link layer MAC address, `02:00:c0:a8:38:0a`, to `kni0` with the `ip link set` command, the NDP responses already contain the correct link layer information. -When `socat` sends out an UDP packet via `eth3` to `kni0`'s IPv6 address `fe80::ff:feff:ff00`, a lookup is performed trying to find the link layer address of the destination. On the very first attempt, that link layer address is not found through the lookup. A neighbor solicitation message is broadcasted instead to initiate the discovery process. +When `socat` sends out an UDP packet via `eth3` to `kni0`'s IPv6 address `fe80::c0ff:fea8:380a`, a lookup is performed trying to find the link layer address of the destination. On the very first attempt, that link layer address is not found through the lookup. A neighbor solicitation message is broadcasted instead to initiate the discovery process. `cap0` receives the broadcasted neighbor solicitation message and forwards it to the kernel stack via `kni0`. Kernel responds with a neighbor advertisement message because the IPv6 address matches the address of the `kni0` interface. This response is sent back to `eth3` through `kni0`'s rx then `cap0`'s tx, completing the discovery. diff --git a/examples/kni/main.rs b/examples/kni/main.rs index 8b0ac94b..15c9a7b0 100644 --- a/examples/kni/main.rs +++ b/examples/kni/main.rs @@ -17,11 +17,13 @@ */ use anyhow::Result; +use capsule::packets::ethernet::Ethernet; use capsule::packets::icmp::v6::Icmpv6; use capsule::packets::ip::v6::{Ipv6, Ipv6Packet}; use capsule::packets::ip::ProtocolNumbers; -use capsule::packets::{Ethernet, Mbuf, Packet, Postmark, Udp6}; -use capsule::rt2::{self, Outbox, Runtime}; +use capsule::packets::udp::Udp6; +use capsule::packets::{Mbuf, Packet, Postmark}; +use capsule::runtime::{self, Outbox, Runtime}; use colored::Colorize; use signal_hook::consts; use signal_hook::flag; @@ -75,7 +77,7 @@ fn main() -> Result<()> { .finish(); tracing::subscriber::set_global_default(subscriber)?; - let config = rt2::load_config()?; + let config = runtime::load_config()?; let runtime = Runtime::from_config(config)?; let kni0 = runtime.ports().get("kni0")?.outbox()?; diff --git a/examples/nat64/Cargo.toml b/examples/nat64/Cargo.toml index c9bf0d1c..8cc66e3e 100644 --- a/examples/nat64/Cargo.toml +++ b/examples/nat64/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nat64" -version = "0.1.0" +version = "0.2.0" authors = ["Capsule Developers "] license = "Apache-2.0" edition = "2018" @@ -18,7 +18,7 @@ doctest = false [dependencies] anyhow = "1.0" bimap = "0.6" -capsule = { version = "0.1", path = "../../core" } +capsule = { version = "0.2", path = "../../core" } colored = "2.0" once_cell = "1.7" signal-hook = "0.3" diff --git a/examples/nat64/README.md b/examples/nat64/README.md index 84c7b4e5..1fb52bce 100644 --- a/examples/nat64/README.md +++ b/examples/nat64/README.md @@ -23,9 +23,9 @@ A simple network topology may consist of a gateway with two interfaces connected The example will not replicate the above network topology. Instead it will send to and receive from the same dual-stacked network interface `eth3`, and perform translations between the two stacks. Conceptually it will work the same way as a gateway for two single-stacked networks. Also, non-TCP or fragmented TCP packets are dropped. -To represent IPv4 addresses to the IPv6 network, the example uses the well-known prefix `64:ff9b::/96` as defined in [IETF RFC 6052](https://tools.ietf.org/html/rfc6052#section-2.1). For example, for the server listening on the address `10.100.1.254`, it's mapped IPv6 address is `64:ff9b::a64:1fe`. +To represent IPv4 addresses to the IPv6 network, the example uses the well-known prefix `64:ff9b::/96` as defined in [IETF RFC 6052](https://tools.ietf.org/html/rfc6052#section-2.1). For example, for the server listening on the address `192.168.56.129`, it's mapped IPv6 address is `64:ff9b::c0a8:3881`. -The gateway also has the address `10.100.1.11` assigned to it on the IPv4 network. +The gateway also has the address `192.168.56.11` assigned to it on the IPv4 network. ## Running the application @@ -35,35 +35,35 @@ The example is located in the `examples/nat64` sub-directory. To run the applica /examples/nat64$ cargo run -- -f nat64.toml ``` -In a separate Vagrant VM terminal, add a static entry to map the gateway's IPv4 address, `10.100.1.11`, to its link layer address on the IPv4 network, +In a separate Vagrant VM terminal, add a static entry to map the gateway's IPv4 address, `192.168.56.11`, to its link layer address on the IPv4 network, ```bash -vagrant$ sudo ip neigh add 10.100.1.11 lladdr 02:00:00:ff:ff:01 dev eth3 nud permanent +vagrant$ sudo ip neigh add 192.168.56.11 lladdr 02:00:c0:a8:38:0b dev eth3 nud permanent ``` -Also add a routing rule for the `64:ff9b::/96` subnet, and a static entry to map the server's IPv6 representation, `64:ff9b::a64:1fe`, to the gateway's link layer address on the IPv6 network. +Also add a routing rule for the `64:ff9b::/96` subnet, and a static entry to map the server's IPv6 representation, `64:ff9b::c0a8:3881`, to the gateway's link layer address on the IPv6 network. ``` vagrant$ sudo ip route add 64:ff9b::/96 dev eth3 -vagrant$ sudo ip neigh add 64:ff9b::a64:1fe lladdr 02:00:00:ff:ff:00 dev eth3 nud permanent +vagrant$ sudo ip neigh add 64:ff9b::c0a8:3881 lladdr 02:00:c0:a8:38:0a dev eth3 nud permanent ``` -Finally start a HTTP server on the IPv4 network, binding to its IP address `10.100.1.254`, +Finally start a HTTP server on the IPv4 network, binding to its IP address `192.168.56.129`, ```bash -vagrant$ python3 -m http.server 8080 --bind 10.100.1.254 +vagrant$ python3 -m http.server 8080 --bind 192.168.56.129 -Serving HTTP on 10.100.1.254 port 8080 (http://10.100.1.254:8080/) ... +Serving HTTP on 192.168.56.129 port 8080 (http://192.168.56.129:8080/) ... ``` To test the gateway, `curl` the IPv6 representation of the server address, ```bash -vagrant$ curl -g -6 -v 'http://[64:ff9b::a64:1fe]:8080' +vagrant$ curl -g -6 -v 'http://[64:ff9b::c0a8:3881]:8080' ... > GET / HTTP/1.1 -> Host: [64:ff9b::a64:1fe]:8080 +> Host: [64:ff9b::c0a8:3881]:8080 > User-Agent: curl/7.64.0 > Accept: */* > @@ -78,11 +78,11 @@ vagrant$ curl -g -6 -v 'http://[64:ff9b::a64:1fe]:8080' ## Explanation -The gateway example is configured with two ports. Conceptually, `cap0` is the port on the IPv6 network receiving packets intended for the `64:ff9b::/96` subnet. `cap1` is the port on the IPv4 network with the address `10.100.1.11`. +The gateway example is configured with two ports. Conceptually, `cap0` is the port on the IPv6 network receiving packets intended for the `64:ff9b::/96` subnet. `cap1` is the port on the IPv4 network with the address `192.168.56.11`. ### 6-to-4 translation -The interaction starts with a client, the `curl` program, on the IPv6 network tries to connect to a python HTTP server on the IPv4 network. When `cap0` receives the TCP packet, it will translate the destination address to the IPv4 counterpart by stripping away the `64:ff9b::/96` prefix. The source address will be replaced by the gateway's IPv4 address `10.100.1.11`, and the source port will be replaced by a free port on the gateway. The original source address and port are saved and will be used later to translate the response packets. +The interaction starts with a client, the `curl` program, on the IPv6 network tries to connect to a python HTTP server on the IPv4 network. When `cap0` receives the TCP packet, it will translate the destination address to the IPv4 counterpart by stripping away the `64:ff9b::/96` prefix. The source address will be replaced by the gateway's IPv4 address `192.168.56.11`, and the source port will be replaced by a free port on the gateway. The original source address and port are saved and will be used later to translate the response packets. The IPv6 header is removed and replaced by an IPv4 header using the steps outlined in [IETF RFC 6145](https://tools.ietf.org/html/rfc6145#section-5.1). @@ -90,10 +90,10 @@ Once the translation is complete, the packet is transmitted through `cap1` and r ### 4-to-6 translation -The response from the python HTTP server is routed to the gateway's IPv4 address because from the server's perspective, the request was originated from `10.100.1.11`, as shown in the access log. +The response from the python HTTP server is routed to the gateway's IPv4 address because from the server's perspective, the request was originated from `192.168.56.11`, as shown in the access log. ``` -10.100.1.11 - - [28/Mar/2021 17:47:08] "GET / HTTP/1.1" 200 - +192.168.56.11 - - [28/Mar/2021 17:47:08] "GET / HTTP/1.1" 200 - ``` The response TCP packets are received by `cap1`. It will translate the source address to the IPv6 counterpart by adding the `64:ff9b::/96` prefix. A lookup is performed with the TCP destination port to retrieve the source address and port of the original client on the IPv6 network. @@ -109,7 +109,7 @@ A HTTP request-response cycle consists of multiple TCP packets, from connection To clean up the static routes, ```bash -vagrant$ sudo ip neigh del 10.100.1.11 dev eth3 -vagrant$ sudo ip neigh del 64:ff9b::a64:1fe dev eth3 +vagrant$ sudo ip neigh del 192.168.56.11 dev eth3 +vagrant$ sudo ip neigh del 64:ff9b::c0a8:3881 dev eth3 vagrant$ sudo ip route del 64:ff9b::/96 dev eth3 ``` diff --git a/examples/nat64/main.rs b/examples/nat64/main.rs index 4b68d21c..41fbce8f 100644 --- a/examples/nat64/main.rs +++ b/examples/nat64/main.rs @@ -19,11 +19,13 @@ use anyhow::Result; use bimap::BiMap; use capsule::net::MacAddr; +use capsule::packets::ethernet::Ethernet; use capsule::packets::ip::v4::Ipv4; use capsule::packets::ip::v6::{Ipv6, Ipv6Packet}; use capsule::packets::ip::ProtocolNumbers; -use capsule::packets::{Ethernet, Mbuf, Packet, Postmark, Tcp4, Tcp6}; -use capsule::rt2::{self, Outbox, Runtime}; +use capsule::packets::tcp::{Tcp4, Tcp6}; +use capsule::packets::{Mbuf, Packet, Postmark}; +use capsule::runtime::{self, Outbox, Runtime}; use colored::Colorize; use once_cell::sync::Lazy; use signal_hook::consts; @@ -64,8 +66,8 @@ fn get_v4_port(mac: MacAddr, ip: Ipv6Addr, port: u16) -> u16 { } fn nat_6to4(packet: Mbuf, cap1: &Outbox) -> Result { - const SRC_IP: Ipv4Addr = Ipv4Addr::new(10, 100, 1, 11); - const DST_MAC: MacAddr = MacAddr::new(0x02, 0x00, 0x00, 0xff, 0xff, 0xff); + const SRC_IP: Ipv4Addr = Ipv4Addr::new(192, 168, 56, 11); + const DST_MAC: MacAddr = MacAddr::new(0x02, 0x00, 0xc0, 0xa8, 0x38, 0x81); let ethernet = packet.parse::()?; let v6 = ethernet.parse::()?; @@ -184,7 +186,7 @@ fn main() -> Result<()> { .finish(); tracing::subscriber::set_global_default(subscriber)?; - let config = rt2::load_config()?; + let config = runtime::load_config()?; let runtime = Runtime::from_config(config)?; let cap1 = runtime.ports().get("cap1")?.outbox()?; diff --git a/examples/ping4d/Cargo.toml b/examples/ping4d/Cargo.toml index 708cba93..8c4935c8 100644 --- a/examples/ping4d/Cargo.toml +++ b/examples/ping4d/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ping4d" -version = "0.1.0" +version = "0.2.0" authors = ["Capsule Developers "] license = "Apache-2.0" edition = "2018" @@ -17,7 +17,7 @@ doctest = false [dependencies] anyhow = "1.0" -capsule = { version = "0.1", path = "../../core" } +capsule = { version = "0.2", path = "../../core" } signal-hook = "0.3" tracing = "0.1" tracing-subscriber = "0.2" diff --git a/examples/ping4d/README.md b/examples/ping4d/README.md index e2c109e4..0e2cbd95 100644 --- a/examples/ping4d/README.md +++ b/examples/ping4d/README.md @@ -10,10 +10,10 @@ The example is located in the `examples/ping4d` sub-directory. To run the applic /examples/ping4d$ cargo run -- -f ping4d.toml ``` -In a separate Vagrant VM terminal, first add a static entry to the ARP table so packets are routed to the interface `0000:00:08.0` for address `10.100.1.10`, +In a separate Vagrant VM terminal, first add a static entry to the ARP table so packets are routed to the interface `0000:00:08.0` for address `192.168.56.10`, ```bash -vagrant$ sudo ip neigh add 10.100.1.10 lladdr 02:00:00:ff:ff:00 dev eth3 nud permanent +vagrant$ sudo ip neigh add 192.168.56.10 lladdr 02:00:c0:a8:38:0a dev eth3 nud permanent ``` Check the ARP table to verify that the new entry is added, @@ -21,18 +21,18 @@ Check the ARP table to verify that the new entry is added, ```bash vagrant$ ip neigh show dev eth3 -10.100.1.10 lladdr 02:00:00:ff:ff:00 PERMANENT +192.168.56.10 lladdr 02:00:c0:a8:38:0a PERMANENT ``` -Now while the application is still running, ping `10.100.1.10`, +Now while the application is still running, ping `192.168.56.10`, ```bash -vagrant$ ping -I eth3 10.100.1.10 +vagrant$ ping -I eth3 192.168.56.10 -PING 10.100.1.10 (10.100.1.10) from 10.100.1.254 eth3: 56(84) bytes of data. -64 bytes from 10.100.1.10: icmp_seq=1 ttl=255 time=3.96 ms -64 bytes from 10.100.1.10: icmp_seq=2 ttl=255 time=0.799 ms -64 bytes from 10.100.1.10: icmp_seq=3 ttl=255 time=0.525 ms +PING 192.168.56.10 (192.168.56.10) from 192.168.56.129 eth3: 56(84) bytes of data. +64 bytes from 192.168.56.10: icmp_seq=1 ttl=255 time=9.02 ms +64 bytes from 192.168.56.10: icmp_seq=2 ttl=255 time=3.79 ms +64 bytes from 192.168.56.10: icmp_seq=3 ttl=255 time=0.562 ms ... ``` @@ -40,7 +40,7 @@ PING 10.100.1.10 (10.100.1.10) from 10.100.1.254 eth3: 56(84) bytes of data. `cap0` is configured to receive packets on lcore `0` and transmit packets on lcore `1`. -The `ping` utility sends out ICMPv4 echo request packets to address `10.100.1.10`. With the static ARP entry, the packets are routed to `cap0`. For each echo request, the application generates and sends out an ICMPv4 echo reply packet in response and drops the original echo request. +The `ping` utility sends out ICMPv4 echo request packets to address `192.168.56.10`. With the static ARP entry, the packets are routed to `cap0`. For each echo request, the application generates and sends out an ICMPv4 echo reply packet in response and drops the original echo request. The `ping` utility calculates the latency as it receives each echo reply. @@ -49,5 +49,5 @@ The `ping` utility calculates the latency as it receives each echo reply. To clean up the ARP table, ```bash -vagrant$ sudo ip neigh del 10.100.1.10 dev eth3 +vagrant$ sudo ip neigh del 192.168.56.10 dev eth3 ``` diff --git a/examples/ping4d/main.rs b/examples/ping4d/main.rs index 14fde502..acbf9cd5 100644 --- a/examples/ping4d/main.rs +++ b/examples/ping4d/main.rs @@ -17,10 +17,11 @@ */ use anyhow::Result; +use capsule::packets::ethernet::Ethernet; use capsule::packets::icmp::v4::{EchoReply, EchoRequest}; use capsule::packets::ip::v4::Ipv4; -use capsule::packets::{Ethernet, Mbuf, Packet, Postmark}; -use capsule::rt2::{self, Outbox, Runtime}; +use capsule::packets::{Mbuf, Packet, Postmark}; +use capsule::runtime::{self, Outbox, Runtime}; use signal_hook::consts; use signal_hook::flag; use std::sync::atomic::{AtomicBool, Ordering}; @@ -63,7 +64,7 @@ fn main() -> Result<()> { .finish(); tracing::subscriber::set_global_default(subscriber)?; - let config = rt2::load_config()?; + let config = runtime::load_config()?; let runtime = Runtime::from_config(config)?; let outbox = runtime.ports().get("cap0")?.outbox()?; diff --git a/examples/pktdump/Cargo.toml b/examples/pktdump/Cargo.toml index f421f28e..9f2c9a3d 100644 --- a/examples/pktdump/Cargo.toml +++ b/examples/pktdump/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pktdump" -version = "0.1.0" +version = "0.2.0" authors = ["Capsule Developers "] license = "Apache-2.0" edition = "2018" @@ -17,8 +17,7 @@ doctest = false [dependencies] anyhow = "1.0" -capsule = { version = "0.1", path = "../../core" } +capsule = { version = "0.2", path = "../../core" } colored = "2.0" -signal-hook = "0.3" tracing = "0.1" tracing-subscriber = "0.2" diff --git a/examples/pktdump/README.md b/examples/pktdump/README.md index ed030d44..ba995a23 100644 --- a/examples/pktdump/README.md +++ b/examples/pktdump/README.md @@ -18,4 +18,4 @@ The parse functions showcase the packet type system. Both IPv4 and IPv6 packet t Packets are dropped at the end of `dump_pkt`. -`ctrl-c` terminates the application. +The application waits for 5 seconds then self terminates. diff --git a/examples/pktdump/main.rs b/examples/pktdump/main.rs index fbaeaf32..6b4bd5f7 100644 --- a/examples/pktdump/main.rs +++ b/examples/pktdump/main.rs @@ -17,16 +17,16 @@ */ use anyhow::{anyhow, Result}; +use capsule::packets::ethernet::{EtherTypes, Ethernet}; use capsule::packets::ip::v4::Ipv4; use capsule::packets::ip::v6::Ipv6; use capsule::packets::ip::IpPacket; -use capsule::packets::{EtherTypes, Ethernet, Mbuf, Packet, Postmark, Tcp, Tcp4, Tcp6}; -use capsule::rt2::{self, Runtime}; +use capsule::packets::tcp::{Tcp, Tcp4, Tcp6}; +use capsule::packets::{Mbuf, Packet, Postmark}; +use capsule::runtime::{self, Runtime}; use colored::Colorize; -use signal_hook::consts; -use signal_hook::flag; -use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::Arc; +use std::thread; +use std::time::Duration; use tracing::{info, Level}; use tracing_subscriber::fmt; @@ -81,16 +81,13 @@ fn main() -> Result<()> { .finish(); tracing::subscriber::set_global_default(subscriber)?; - let config = rt2::load_config()?; + let config = runtime::load_config()?; let runtime = Runtime::from_config(config)?; runtime.set_port_pipeline("cap0", dump_pkt)?; runtime.set_port_pipeline("cap1", dump_pkt)?; let _guard = runtime.execute()?; - let term = Arc::new(AtomicBool::new(false)); - flag::register(consts::SIGINT, Arc::clone(&term))?; - info!("ctrl-c to quit ..."); - while !term.load(Ordering::Relaxed) {} + thread::sleep(Duration::from_secs(5)); Ok(()) } diff --git a/examples/skeleton/Cargo.toml b/examples/skeleton/Cargo.toml index cbc69250..3906f04b 100644 --- a/examples/skeleton/Cargo.toml +++ b/examples/skeleton/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "skeleton" -version = "0.1.0" +version = "0.2.0" authors = ["Capsule Developers "] license = "Apache-2.0" edition = "2018" @@ -17,6 +17,6 @@ doctest = false [dependencies] anyhow = "1.0" -capsule = { version = "0.1", path = "../../core" } +capsule = { version = "0.2", path = "../../core" } tracing = "0.1" tracing-subscriber = "0.2" diff --git a/examples/skeleton/main.rs b/examples/skeleton/main.rs index 0763f8a6..ccb0de88 100644 --- a/examples/skeleton/main.rs +++ b/examples/skeleton/main.rs @@ -17,7 +17,7 @@ */ use anyhow::Result; -use capsule::rt2::{self, Runtime}; +use capsule::runtime::{self, Runtime}; use tracing::{debug, Level}; use tracing_subscriber::fmt; @@ -27,7 +27,7 @@ fn main() -> Result<()> { .finish(); tracing::subscriber::set_global_default(subscriber)?; - let config = rt2::load_config()?; + let config = runtime::load_config()?; debug!(?config); let runtime = Runtime::from_config(config)?; diff --git a/examples/syn-flood/Cargo.toml b/examples/syn-flood/Cargo.toml index 355dd441..f9fa98b1 100644 --- a/examples/syn-flood/Cargo.toml +++ b/examples/syn-flood/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "syn-flood" -version = "0.1.0" +version = "0.2.0" authors = ["Capsule Developers "] license = "Apache-2.0" edition = "2018" @@ -18,7 +18,7 @@ doctest = false [dependencies] anyhow = "1.0" async-io = "1.3" -capsule = { version = "0.1", path = "../../core" } +capsule = { version = "0.2", path = "../../core" } futures-lite = "1.11" rand = "0.8" signal-hook = "0.3" diff --git a/examples/syn-flood/README.md b/examples/syn-flood/README.md index 3c71bc97..116c7b55 100644 --- a/examples/syn-flood/README.md +++ b/examples/syn-flood/README.md @@ -19,13 +19,13 @@ The example is located in the `examples/syn-flood` sub-directory. To run the app To observe the `SYN` flood traffic, in the vagrant VM, run `tcpdump` to capture packets sent to the destination IP address and port, ```bash -vagrant$ sudo tcpdump -i eth3 -nn host 10.100.1.254 and port 80 +vagrant$ sudo tcpdump -i eth3 -nn host 192.168.56.129 and port 80 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth3, link-type EN10MB (Ethernet), capture size 262144 bytes -18:59:27.140269 IP 136.178.185.105.0 > 10.100.1.254.80: Flags [S], seq 1, win 10, length 0 -18:59:27.140275 IP 225.67.11.246.0 > 10.100.1.254.80: Flags [S], seq 1, win 10, length 0 -18:59:27.140279 IP 12.164.180.121.0 > 10.100.1.254.80: Flags [S], seq 1, win 10, length 0 +18:59:27.140269 IP 136.178.185.105.0 > 192.168.56.129.80: Flags [S], seq 1, win 10, length 0 +18:59:27.140275 IP 225.67.11.246.0 > 192.168.56.129.80: Flags [S], seq 1, win 10, length 0 +18:59:27.140279 IP 12.164.180.121.0 > 192.168.56.129.80: Flags [S], seq 1, win 10, length 0 ... ``` @@ -33,14 +33,14 @@ listening on eth3, link-type EN10MB (Ethernet), capture size 262144 bytes `cap0` is configured to transmit on lcore `0` with queue depth set at `2048`. -The example spawns a separate worker task on lcore `1` that will at 50ms interval generate a batch of 128 TCP SYN packets and send them through `cap0`. Each generated TCP SYN will have a random source IP address. The destination is set to `10.100.1.254` on port `80`, which is the address of the `eth3` interface on the host. (On a side note, the 50ms delay is necessary because emulated `virtio` driver is too slow on tx. Without a delay, the mempool is exhausted.) +The example spawns a separate worker task on lcore `1` that will at 50ms interval generate a batch of 128 TCP SYN packets and send them through `cap0`. Each generated TCP SYN will have a random source IP address. The destination is set to `192.168.56.129` on port `80`, which is the address of the `eth3` interface on the host. (On a side note, the 50ms delay is necessary because emulated `virtio` driver is too slow on tx. Without a delay, the mempool is exhausted.) ```bash vagrant$ ip addr show dev eth3 5: eth3: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 - link/ether 02:00:00:ff:ff:ff brd ff:ff:ff:ff:ff:ff - inet 10.100.1.254/24 brd 10.100.1.255 scope global eth3 + link/ether 02:00:c0:a8:38:81 brd ff:ff:ff:ff:ff:ff + inet 192.168.56.129/24 brd 192.168.56.255 scope global eth3 valid_lft forever preferred_lft forever ``` diff --git a/examples/syn-flood/main.rs b/examples/syn-flood/main.rs index c0062a48..ef5c48d0 100644 --- a/examples/syn-flood/main.rs +++ b/examples/syn-flood/main.rs @@ -19,9 +19,11 @@ use anyhow::Result; use async_io::Timer; use capsule::net::MacAddr; +use capsule::packets::ethernet::Ethernet; use capsule::packets::ip::v4::Ipv4; -use capsule::packets::{Ethernet, Mbuf, Packet, Tcp4}; -use capsule::rt2::{self, Outbox, Runtime}; +use capsule::packets::tcp::Tcp4; +use capsule::packets::{Mbuf, Packet}; +use capsule::runtime::{self, Outbox, Runtime}; use futures_lite::stream::StreamExt; use signal_hook::consts; use signal_hook::flag; @@ -33,8 +35,8 @@ use tracing::{error, info, Level}; use tracing_subscriber::fmt; async fn syn_flood(src_mac: MacAddr, cap0: Outbox, term: Arc) { - let dst_ip = Ipv4Addr::new(10, 100, 1, 254); - let dst_mac = MacAddr::new(0x02, 0x00, 0x00, 0xff, 0xff, 0xff); + let dst_ip = Ipv4Addr::new(192, 168, 56, 129); + let dst_mac = MacAddr::new(0x02, 0x00, 0xc0, 0xa8, 0x38, 0x81); // 50ms delay between batches. let mut timer = Timer::interval(Duration::from_millis(50)); @@ -79,7 +81,7 @@ fn main() -> Result<()> { .finish(); tracing::subscriber::set_global_default(subscriber)?; - let config = rt2::load_config()?; + let config = runtime::load_config()?; let runtime = Runtime::from_config(config)?; let term = Arc::new(AtomicBool::new(false)); diff --git a/ffi/Cargo.toml b/ffi/Cargo.toml index d72a4a5e..0c1f8da0 100644 --- a/ffi/Cargo.toml +++ b/ffi/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "capsule-ffi" -version = "0.1.5" +version = "0.2.0" authors = ["Capsule Developers "] license = "Apache-2.0" edition = "2018" @@ -16,7 +16,7 @@ name = "capsule_ffi" doctest = false [build-dependencies] -bindgen = "0.57" +bindgen = "0.60" cc = "1.0" libc = "0.2" diff --git a/ffi/build.rs b/ffi/build.rs index 2c34692d..f926ad2e 100644 --- a/ffi/build.rs +++ b/ffi/build.rs @@ -181,9 +181,9 @@ fn bind(path: &Path) { // treat as opaque as per issue w/ combining align/packed: // https://github.com/rust-lang/rust-bindgen/issues/1538 .opaque_type(r"rte_arp_ipv4|rte_arp_hdr") - .whitelist_type(r"(rte|eth|pcap)_.*") - .whitelist_function(r"(_rte|rte|eth|numa|pcap)_.*") - .whitelist_var(r"(RTE|DEV|ETH|MEMPOOL|PKT|rte)_.*") + .allowlist_type(r"(rte|eth|pcap)_.*") + .allowlist_function(r"(_rte|rte|eth|numa|pcap)_.*") + .allowlist_var(r"(RTE|DEV|ETH|MEMPOOL|PKT|rte)_.*") .derive_copy(true) .derive_debug(true) .derive_default(true) diff --git a/ffi/src/bindings_rustdoc.rs b/ffi/src/bindings_rustdoc.rs index 1c97bdb3..556b65bc 100644 --- a/ffi/src/bindings_rustdoc.rs +++ b/ffi/src/bindings_rustdoc.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.57.0 */ +/* automatically generated by rust-bindgen 0.60.1 */ #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -115,8 +115,7 @@ pub const RTE_ARCH_X86_64: u32 = 1; pub const RTE_CACHE_LINE_SIZE: u32 = 64; pub const RTE_DRIVER_MEMPOOL_BUCKET_SIZE_KB: u32 = 64; pub const RTE_EAL_NUMA_AWARE_HUGEPAGES: u32 = 1; -pub const RTE_EAL_PMD_PATH: &'static [u8; 47usize] = - b"/usr/local/lib/x86_64-linux-gnu/dpdk/pmds-20.0\0"; +pub const RTE_EAL_PMD_PATH: &[u8; 47usize] = b"/usr/local/lib/x86_64-linux-gnu/dpdk/pmds-20.0\0"; pub const RTE_EXEC_ENV_LINUX: u32 = 1; pub const RTE_HAS_LIBNUMA: u32 = 1; pub const RTE_IXGBE_INC_VECTOR: u32 = 1; @@ -270,16 +269,16 @@ pub const RTE_MAX_MEM_MB: u32 = 524288; pub const RTE_MAX_NUMA_NODES: u32 = 4; pub const RTE_MAX_VFIO_GROUPS: u32 = 64; pub const RTE_PORT_PCAP: u32 = 1; -pub const RTE_TOOLCHAIN: &'static [u8; 4usize] = b"gcc\0"; +pub const RTE_TOOLCHAIN: &[u8; 4usize] = b"gcc\0"; pub const RTE_TOOLCHAIN_GCC: u32 = 1; pub const RTE_VER_MINOR: u32 = 6; pub const RTE_VER_MONTH: u32 = 11; pub const RTE_VER_RELEASE: u32 = 99; -pub const RTE_VER_SUFFIX: &'static [u8; 1usize] = b"\0"; +pub const RTE_VER_SUFFIX: &[u8; 1usize] = b"\0"; pub const RTE_VER_YEAR: u32 = 19; pub const RTE_VIRTIO_USER: u32 = 1; pub const RTE_EXEC_ENV_LINUXAPP: u32 = 1; -pub const RTE_VER_PREFIX: &'static [u8; 5usize] = b"DPDK\0"; +pub const RTE_VER_PREFIX: &[u8; 5usize] = b"DPDK\0"; pub const RTE_MAX_HEAPS: u32 = 32; pub const RTE_MAX_MEMSEG_LISTS: u32 = 128; pub const RTE_MAX_MEMSEG_PER_LIST: u32 = 8192; @@ -294,7 +293,7 @@ pub const RTE_CONTIGMEM_MAX_NUM_BUFS: u32 = 64; pub const RTE_CONTIGMEM_DEFAULT_NUM_BUFS: u32 = 1; pub const RTE_CONTIGMEM_DEFAULT_BUF_SIZE: u32 = 536870912; pub const RTE_MEMPOOL_CACHE_MAX_SIZE: u32 = 512; -pub const RTE_MBUF_DEFAULT_MEMPOOL_OPS: &'static [u8; 11usize] = b"ring_mp_mc\0"; +pub const RTE_MBUF_DEFAULT_MEMPOOL_OPS: &[u8; 11usize] = b"ring_mp_mc\0"; pub const RTE_MBUF_REFCNT_ATOMIC: u32 = 1; pub const RTE_PKTMBUF_HEADROOM: u32 = 128; pub const RTE_MAX_QUEUES_PER_PORT: u32 = 1024; @@ -327,7 +326,7 @@ pub const RTE_LIBRTE_I40E_QUEUE_NUM_PER_VF: u32 = 4; pub const RTE_LIBRTE_I40E_QUEUE_NUM_PER_VM: u32 = 4; pub const RTE_PMD_RING_MAX_RX_RINGS: u32 = 16; pub const RTE_PMD_RING_MAX_TX_RINGS: u32 = 16; -pub const RTE_LIBRTE_QEDE_FW: &'static [u8; 1usize] = b"\0"; +pub const RTE_LIBRTE_QEDE_FW: &[u8; 1usize] = b"\0"; pub const RTE_PRIORITY_LOG: u32 = 101; pub const RTE_PRIORITY_BUS: u32 = 110; pub const RTE_PRIORITY_CLASS: u32 = 120; @@ -409,14 +408,14 @@ pub const RTE_MEMZONE_4GB: u32 = 524288; pub const RTE_MEMZONE_SIZE_HINT_ONLY: u32 = 4; pub const RTE_MEMZONE_IOVA_CONTIG: u32 = 1048576; pub const RTE_MEMZONE_NAMESIZE: u32 = 32; -pub const RTE_TAILQ_RING_NAME: &'static [u8; 9usize] = b"RTE_RING\0"; -pub const RTE_RING_MZ_PREFIX: &'static [u8; 4usize] = b"RG_\0"; +pub const RTE_TAILQ_RING_NAME: &[u8; 9usize] = b"RTE_RING\0"; +pub const RTE_RING_MZ_PREFIX: &[u8; 4usize] = b"RG_\0"; pub const RTE_RING_SZ_MASK: u32 = 2147483647; pub const RTE_MEMPOOL_HEADER_COOKIE1: i64 = -4982197544707871147; pub const RTE_MEMPOOL_HEADER_COOKIE2: i64 = -941548164385788331; pub const RTE_MEMPOOL_TRAILER_COOKIE: i64 = -5921418378119291987; -pub const RTE_MEMPOOL_MZ_PREFIX: &'static [u8; 4usize] = b"MP_\0"; -pub const RTE_MEMPOOL_MZ_FORMAT: &'static [u8; 6usize] = b"MP_%s\0"; +pub const RTE_MEMPOOL_MZ_PREFIX: &[u8; 4usize] = b"MP_\0"; +pub const RTE_MEMPOOL_MZ_FORMAT: &[u8; 6usize] = b"MP_%s\0"; pub const MEMPOOL_PG_NUM_DEFAULT: u32 = 1; pub const RTE_MEMPOOL_ALIGN: u32 = 64; pub const RTE_MEMPOOL_ALIGN_MASK: u32 = 63; @@ -769,8 +768,8 @@ pub const RTE_TCP_RST_FLAG: u32 = 4; pub const RTE_TCP_SYN_FLAG: u32 = 2; pub const RTE_TCP_FIN_FLAG: u32 = 1; pub const RTE_MBUF_DYN_NAMESIZE: u32 = 64; -pub const RTE_MBUF_DYNFIELD_METADATA_NAME: &'static [u8; 27usize] = b"rte_flow_dynfield_metadata\0"; -pub const RTE_MBUF_DYNFLAG_METADATA_NAME: &'static [u8; 26usize] = b"rte_flow_dynflag_metadata\0"; +pub const RTE_MBUF_DYNFIELD_METADATA_NAME: &[u8; 27usize] = b"rte_flow_dynfield_metadata\0"; +pub const RTE_MBUF_DYNFLAG_METADATA_NAME: &[u8; 26usize] = b"rte_flow_dynflag_metadata\0"; pub const RTE_ETHTYPE_FLAGS_MAC: u32 = 1; pub const RTE_ETHTYPE_FLAGS_DROP: u32 = 2; pub const RTE_FLEX_FILTER_MAXLEN: u32 = 128; @@ -908,26 +907,40 @@ fn bindgen_test_layout_timespec() { 8usize, concat!("Alignment of ", stringify!(timespec)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tv_sec as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(timespec), - "::", - stringify!(tv_sec) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tv_nsec as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(timespec), - "::", - stringify!(tv_nsec) - ) - ); + fn test_field_tv_sec() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tv_sec) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(timespec), + "::", + stringify!(tv_sec) + ) + ); + } + test_field_tv_sec(); + fn test_field_tv_nsec() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tv_nsec) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(timespec), + "::", + stringify!(tv_nsec) + ) + ); + } + test_field_tv_nsec(); } pub type pid_t = __pid_t; pub type __cpu_mask = ::std::os::raw::c_ulong; @@ -948,16 +961,23 @@ fn bindgen_test_layout_cpu_set_t() { 8usize, concat!("Alignment of ", stringify!(cpu_set_t)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).__bits as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(cpu_set_t), - "::", - stringify!(__bits) - ) - ); + fn test_field___bits() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).__bits) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(cpu_set_t), + "::", + stringify!(__bits) + ) + ); + } + test_field___bits(); } pub type pthread_t = ::std::os::raw::c_ulong; #[repr(C)] @@ -965,7 +985,6 @@ pub type pthread_t = ::std::os::raw::c_ulong; pub union pthread_attr_t { pub __size: [::std::os::raw::c_char; 56usize], pub __align: ::std::os::raw::c_long, - _bindgen_union_align: [u64; 7usize], } #[test] fn bindgen_test_layout_pthread_attr_t() { @@ -979,30 +998,48 @@ fn bindgen_test_layout_pthread_attr_t() { 8usize, concat!("Alignment of ", stringify!(pthread_attr_t)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).__size as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(pthread_attr_t), - "::", - stringify!(__size) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).__align as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(pthread_attr_t), - "::", - stringify!(__align) - ) - ); + fn test_field___size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).__size) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pthread_attr_t), + "::", + stringify!(__size) + ) + ); + } + test_field___size(); + fn test_field___align() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).__align) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pthread_attr_t), + "::", + stringify!(__align) + ) + ); + } + test_field___align(); } impl Default for pthread_attr_t { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type va_list = __builtin_va_list; @@ -1068,300 +1105,507 @@ fn bindgen_test_layout__IO_FILE() { 8usize, concat!("Alignment of ", stringify!(_IO_FILE)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>()))._flags as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_flags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>()))._IO_read_ptr as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_IO_read_ptr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>()))._IO_read_end as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_IO_read_end) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>()))._IO_read_base as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_IO_read_base) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>()))._IO_write_base as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_IO_write_base) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>()))._IO_write_ptr as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_IO_write_ptr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>()))._IO_write_end as *const _ as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_IO_write_end) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>()))._IO_buf_base as *const _ as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_IO_buf_base) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>()))._IO_buf_end as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_IO_buf_end) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>()))._IO_save_base as *const _ as usize }, - 72usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_IO_save_base) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>()))._IO_backup_base as *const _ as usize }, - 80usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_IO_backup_base) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>()))._IO_save_end as *const _ as usize }, - 88usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_IO_save_end) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>()))._markers as *const _ as usize }, - 96usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_markers) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>()))._chain as *const _ as usize }, - 104usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_chain) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>()))._fileno as *const _ as usize }, - 112usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_fileno) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>()))._flags2 as *const _ as usize }, - 116usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_flags2) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>()))._old_offset as *const _ as usize }, - 120usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_old_offset) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>()))._cur_column as *const _ as usize }, - 128usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_cur_column) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>()))._vtable_offset as *const _ as usize }, - 130usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_vtable_offset) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>()))._shortbuf as *const _ as usize }, - 131usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_shortbuf) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>()))._lock as *const _ as usize }, - 136usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_lock) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>()))._offset as *const _ as usize }, - 144usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_offset) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>()))._codecvt as *const _ as usize }, - 152usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_codecvt) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>()))._wide_data as *const _ as usize }, - 160usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_wide_data) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>()))._freeres_list as *const _ as usize }, - 168usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_freeres_list) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>()))._freeres_buf as *const _ as usize }, - 176usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_freeres_buf) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>())).__pad5 as *const _ as usize }, - 184usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(__pad5) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>()))._mode as *const _ as usize }, - 192usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_mode) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_IO_FILE>()))._unused2 as *const _ as usize }, - 196usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_unused2) - ) - ); + fn test_field__flags() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._flags) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_flags) + ) + ); + } + test_field__flags(); + fn test_field__IO_read_ptr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._IO_read_ptr) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_IO_read_ptr) + ) + ); + } + test_field__IO_read_ptr(); + fn test_field__IO_read_end() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._IO_read_end) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_IO_read_end) + ) + ); + } + test_field__IO_read_end(); + fn test_field__IO_read_base() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._IO_read_base) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_IO_read_base) + ) + ); + } + test_field__IO_read_base(); + fn test_field__IO_write_base() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._IO_write_base) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_IO_write_base) + ) + ); + } + test_field__IO_write_base(); + fn test_field__IO_write_ptr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._IO_write_ptr) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_IO_write_ptr) + ) + ); + } + test_field__IO_write_ptr(); + fn test_field__IO_write_end() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._IO_write_end) as usize - ptr as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_IO_write_end) + ) + ); + } + test_field__IO_write_end(); + fn test_field__IO_buf_base() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._IO_buf_base) as usize - ptr as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_IO_buf_base) + ) + ); + } + test_field__IO_buf_base(); + fn test_field__IO_buf_end() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._IO_buf_end) as usize - ptr as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_IO_buf_end) + ) + ); + } + test_field__IO_buf_end(); + fn test_field__IO_save_base() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._IO_save_base) as usize - ptr as usize + }, + 72usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_IO_save_base) + ) + ); + } + test_field__IO_save_base(); + fn test_field__IO_backup_base() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._IO_backup_base) as usize - ptr as usize + }, + 80usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_IO_backup_base) + ) + ); + } + test_field__IO_backup_base(); + fn test_field__IO_save_end() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._IO_save_end) as usize - ptr as usize + }, + 88usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_IO_save_end) + ) + ); + } + test_field__IO_save_end(); + fn test_field__markers() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._markers) as usize - ptr as usize + }, + 96usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_markers) + ) + ); + } + test_field__markers(); + fn test_field__chain() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._chain) as usize - ptr as usize + }, + 104usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_chain) + ) + ); + } + test_field__chain(); + fn test_field__fileno() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._fileno) as usize - ptr as usize + }, + 112usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_fileno) + ) + ); + } + test_field__fileno(); + fn test_field__flags2() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._flags2) as usize - ptr as usize + }, + 116usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_flags2) + ) + ); + } + test_field__flags2(); + fn test_field__old_offset() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._old_offset) as usize - ptr as usize + }, + 120usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_old_offset) + ) + ); + } + test_field__old_offset(); + fn test_field__cur_column() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._cur_column) as usize - ptr as usize + }, + 128usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_cur_column) + ) + ); + } + test_field__cur_column(); + fn test_field__vtable_offset() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._vtable_offset) as usize - ptr as usize + }, + 130usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_vtable_offset) + ) + ); + } + test_field__vtable_offset(); + fn test_field__shortbuf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._shortbuf) as usize - ptr as usize + }, + 131usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_shortbuf) + ) + ); + } + test_field__shortbuf(); + fn test_field__lock() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._lock) as usize - ptr as usize + }, + 136usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_lock) + ) + ); + } + test_field__lock(); + fn test_field__offset() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._offset) as usize - ptr as usize + }, + 144usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_offset) + ) + ); + } + test_field__offset(); + fn test_field__codecvt() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._codecvt) as usize - ptr as usize + }, + 152usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_codecvt) + ) + ); + } + test_field__codecvt(); + fn test_field__wide_data() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._wide_data) as usize - ptr as usize + }, + 160usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_wide_data) + ) + ); + } + test_field__wide_data(); + fn test_field__freeres_list() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._freeres_list) as usize - ptr as usize + }, + 168usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_freeres_list) + ) + ); + } + test_field__freeres_list(); + fn test_field__freeres_buf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._freeres_buf) as usize - ptr as usize + }, + 176usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_freeres_buf) + ) + ); + } + test_field__freeres_buf(); + fn test_field___pad5() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).__pad5) as usize - ptr as usize + }, + 184usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(__pad5) + ) + ); + } + test_field___pad5(); + fn test_field__mode() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._mode) as usize - ptr as usize + }, + 192usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_mode) + ) + ); + } + test_field__mode(); + fn test_field__unused2() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<_IO_FILE>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._unused2) as usize - ptr as usize + }, + 196usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_unused2) + ) + ); + } + test_field__unused2(); } impl Default for _IO_FILE { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type ssize_t = __ssize_t; @@ -1386,26 +1630,40 @@ fn bindgen_test_layout_timeval() { 8usize, concat!("Alignment of ", stringify!(timeval)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tv_sec as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(timeval), - "::", - stringify!(tv_sec) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tv_usec as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(timeval), - "::", - stringify!(tv_usec) - ) - ); + fn test_field_tv_sec() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tv_sec) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(timeval), + "::", + stringify!(tv_sec) + ) + ); + } + test_field_tv_sec(); + fn test_field_tv_usec() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tv_usec) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(timeval), + "::", + stringify!(tv_usec) + ) + ); + } + test_field_tv_usec(); } pub type rte_cpuset_t = cpu_set_t; pub type phys_addr_t = u64; @@ -1439,60 +1697,99 @@ fn bindgen_test_layout_rte_logs() { 8usize, concat!("Alignment of ", stringify!(rte_logs)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_logs), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).level as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_logs), - "::", - stringify!(level) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).file as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_logs), - "::", - stringify!(file) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dynamic_types_len as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_logs), - "::", - stringify!(dynamic_types_len) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dynamic_types as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(rte_logs), - "::", - stringify!(dynamic_types) - ) - ); + fn test_field_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_logs), + "::", + stringify!(type_) + ) + ); + } + test_field_type(); + fn test_field_level() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).level) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_logs), + "::", + stringify!(level) + ) + ); + } + test_field_level(); + fn test_field_file() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).file) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_logs), + "::", + stringify!(file) + ) + ); + } + test_field_file(); + fn test_field_dynamic_types_len() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dynamic_types_len) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_logs), + "::", + stringify!(dynamic_types_len) + ) + ); + } + test_field_dynamic_types_len(); + fn test_field_dynamic_types() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dynamic_types) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rte_logs), + "::", + stringify!(dynamic_types) + ) + ); + } + test_field_dynamic_types(); } impl Default for rte_logs { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } extern "C" { @@ -1587,40 +1884,65 @@ fn bindgen_test_layout_rte_dev_event() { 8usize, concat!("Alignment of ", stringify!(rte_dev_event)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_dev_event), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).subsystem as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_dev_event), - "::", - stringify!(subsystem) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).devname as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_dev_event), - "::", - stringify!(devname) - ) - ); -} -impl Default for rte_dev_event { - fn default() -> Self { - unsafe { ::std::mem::zeroed() } + fn test_field_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_dev_event), + "::", + stringify!(type_) + ) + ); + } + test_field_type(); + fn test_field_subsystem() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).subsystem) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_dev_event), + "::", + stringify!(subsystem) + ) + ); + } + test_field_subsystem(); + fn test_field_devname() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).devname) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_dev_event), + "::", + stringify!(devname) + ) + ); + } + test_field_devname(); +} +impl Default for rte_dev_event { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type rte_dev_event_cb_fn = ::std::option::Option< @@ -1663,40 +1985,65 @@ fn bindgen_test_layout_rte_mem_resource() { 8usize, concat!("Alignment of ", stringify!(rte_mem_resource)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).phys_addr as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mem_resource), - "::", - stringify!(phys_addr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).len as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_mem_resource), - "::", - stringify!(len) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_mem_resource), - "::", - stringify!(addr) - ) - ); + fn test_field_phys_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).phys_addr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mem_resource), + "::", + stringify!(phys_addr) + ) + ); + } + test_field_phys_addr(); + fn test_field_len() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_mem_resource), + "::", + stringify!(len) + ) + ); + } + test_field_len(); + fn test_field_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_mem_resource), + "::", + stringify!(addr) + ) + ); + } + test_field_addr(); } impl Default for rte_mem_resource { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -1724,34 +2071,48 @@ fn bindgen_test_layout_rte_driver__bindgen_ty_1() { 8usize, concat!("Alignment of ", stringify!(rte_driver__bindgen_ty_1)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).tqe_next as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_driver__bindgen_ty_1), - "::", - stringify!(tqe_next) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).tqe_prev as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_driver__bindgen_ty_1), - "::", - stringify!(tqe_prev) - ) - ); + fn test_field_tqe_next() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tqe_next) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_driver__bindgen_ty_1), + "::", + stringify!(tqe_next) + ) + ); + } + test_field_tqe_next(); + fn test_field_tqe_prev() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tqe_prev) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_driver__bindgen_ty_1), + "::", + stringify!(tqe_prev) + ) + ); + } + test_field_tqe_prev(); } impl Default for rte_driver__bindgen_ty_1 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[test] @@ -1766,40 +2127,65 @@ fn bindgen_test_layout_rte_driver() { 8usize, concat!("Alignment of ", stringify!(rte_driver)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).next as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_driver), - "::", - stringify!(next) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).name as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_driver), - "::", - stringify!(name) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).alias as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(rte_driver), - "::", - stringify!(alias) - ) - ); + fn test_field_next() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).next) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_driver), + "::", + stringify!(next) + ) + ); + } + test_field_next(); + fn test_field_name() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_driver), + "::", + stringify!(name) + ) + ); + } + test_field_name(); + fn test_field_alias() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).alias) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rte_driver), + "::", + stringify!(alias) + ) + ); + } + test_field_alias(); } impl Default for rte_driver { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -1830,34 +2216,48 @@ fn bindgen_test_layout_rte_device__bindgen_ty_1() { 8usize, concat!("Alignment of ", stringify!(rte_device__bindgen_ty_1)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).tqe_next as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_device__bindgen_ty_1), - "::", - stringify!(tqe_next) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).tqe_prev as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_device__bindgen_ty_1), - "::", - stringify!(tqe_prev) - ) - ); + fn test_field_tqe_next() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tqe_next) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_device__bindgen_ty_1), + "::", + stringify!(tqe_next) + ) + ); + } + test_field_tqe_next(); + fn test_field_tqe_prev() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tqe_prev) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_device__bindgen_ty_1), + "::", + stringify!(tqe_prev) + ) + ); + } + test_field_tqe_prev(); } impl Default for rte_device__bindgen_ty_1 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[test] @@ -1872,70 +2272,116 @@ fn bindgen_test_layout_rte_device() { 8usize, concat!("Alignment of ", stringify!(rte_device)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).next as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_device), - "::", - stringify!(next) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).name as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_device), - "::", - stringify!(name) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).driver as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(rte_device), - "::", - stringify!(driver) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).bus as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(rte_device), - "::", - stringify!(bus) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).numa_node as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(rte_device), - "::", - stringify!(numa_node) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).devargs as *const _ as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(rte_device), - "::", - stringify!(devargs) - ) - ); + fn test_field_next() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).next) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_device), + "::", + stringify!(next) + ) + ); + } + test_field_next(); + fn test_field_name() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_device), + "::", + stringify!(name) + ) + ); + } + test_field_name(); + fn test_field_driver() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).driver) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rte_device), + "::", + stringify!(driver) + ) + ); + } + test_field_driver(); + fn test_field_bus() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).bus) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(rte_device), + "::", + stringify!(bus) + ) + ); + } + test_field_bus(); + fn test_field_numa_node() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).numa_node) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(rte_device), + "::", + stringify!(numa_node) + ) + ); + } + test_field_numa_node(); + fn test_field_devargs() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).devargs) as usize - ptr as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(rte_device), + "::", + stringify!(devargs) + ) + ); + } + test_field_devargs(); } impl Default for rte_device { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } extern "C" { @@ -1989,80 +2435,133 @@ fn bindgen_test_layout_rte_dev_iterator() { 8usize, concat!("Alignment of ", stringify!(rte_dev_iterator)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dev_str as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_dev_iterator), - "::", - stringify!(dev_str) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).bus_str as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_dev_iterator), - "::", - stringify!(bus_str) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).cls_str as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_dev_iterator), - "::", - stringify!(cls_str) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).bus as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(rte_dev_iterator), - "::", - stringify!(bus) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).cls as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(rte_dev_iterator), - "::", - stringify!(cls) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).device as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(rte_dev_iterator), - "::", - stringify!(device) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).class_device as *const _ as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(rte_dev_iterator), - "::", - stringify!(class_device) - ) - ); + fn test_field_dev_str() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dev_str) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_dev_iterator), + "::", + stringify!(dev_str) + ) + ); + } + test_field_dev_str(); + fn test_field_bus_str() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).bus_str) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_dev_iterator), + "::", + stringify!(bus_str) + ) + ); + } + test_field_bus_str(); + fn test_field_cls_str() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).cls_str) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_dev_iterator), + "::", + stringify!(cls_str) + ) + ); + } + test_field_cls_str(); + fn test_field_bus() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).bus) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rte_dev_iterator), + "::", + stringify!(bus) + ) + ); + } + test_field_bus(); + fn test_field_cls() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).cls) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(rte_dev_iterator), + "::", + stringify!(cls) + ) + ); + } + test_field_cls(); + fn test_field_device() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).device) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(rte_dev_iterator), + "::", + stringify!(device) + ) + ); + } + test_field_device(); + fn test_field_class_device() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).class_device) as usize - ptr as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(rte_dev_iterator), + "::", + stringify!(class_device) + ) + ); + } + test_field_class_device(); } impl Default for rte_dev_iterator { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type rte_dev_iterate_t = ::std::option::Option< @@ -2147,30 +2646,48 @@ fn bindgen_test_layout_rte_bus_list() { 8usize, concat!("Alignment of ", stringify!(rte_bus_list)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tqh_first as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_bus_list), - "::", - stringify!(tqh_first) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tqh_last as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_bus_list), - "::", - stringify!(tqh_last) - ) - ); + fn test_field_tqh_first() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tqh_first) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_bus_list), + "::", + stringify!(tqh_first) + ) + ); + } + test_field_tqh_first(); + fn test_field_tqh_last() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tqh_last) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_bus_list), + "::", + stringify!(tqh_last) + ) + ); + } + test_field_tqh_last(); } impl Default for rte_bus_list { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub mod rte_iova_mode { @@ -2242,20 +2759,31 @@ fn bindgen_test_layout_rte_bus_conf() { 4usize, concat!("Alignment of ", stringify!(rte_bus_conf)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).scan_mode as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_bus_conf), - "::", - stringify!(scan_mode) - ) - ); + fn test_field_scan_mode() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).scan_mode) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_bus_conf), + "::", + stringify!(scan_mode) + ) + ); + } + test_field_scan_mode(); } impl Default for rte_bus_conf { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type rte_bus_get_iommu_class_t = @@ -2297,30 +2825,48 @@ fn bindgen_test_layout_rte_bus__bindgen_ty_1() { 8usize, concat!("Alignment of ", stringify!(rte_bus__bindgen_ty_1)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tqe_next as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_bus__bindgen_ty_1), - "::", - stringify!(tqe_next) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tqe_prev as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_bus__bindgen_ty_1), - "::", - stringify!(tqe_prev) - ) - ); + fn test_field_tqe_next() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tqe_next) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_bus__bindgen_ty_1), + "::", + stringify!(tqe_next) + ) + ); + } + test_field_tqe_next(); + fn test_field_tqe_prev() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tqe_prev) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_bus__bindgen_ty_1), + "::", + stringify!(tqe_prev) + ) + ); + } + test_field_tqe_prev(); } impl Default for rte_bus__bindgen_ty_1 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[test] @@ -2335,160 +2881,269 @@ fn bindgen_test_layout_rte_bus() { 8usize, concat!("Alignment of ", stringify!(rte_bus)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).next as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_bus), - "::", - stringify!(next) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).name as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_bus), - "::", - stringify!(name) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).scan as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(rte_bus), - "::", - stringify!(scan) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).probe as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(rte_bus), - "::", - stringify!(probe) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).find_device as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(rte_bus), - "::", - stringify!(find_device) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).plug as *const _ as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(rte_bus), - "::", - stringify!(plug) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).unplug as *const _ as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(rte_bus), - "::", - stringify!(unplug) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).parse as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(rte_bus), - "::", - stringify!(parse) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dma_map as *const _ as usize }, - 72usize, - concat!( - "Offset of field: ", - stringify!(rte_bus), - "::", - stringify!(dma_map) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dma_unmap as *const _ as usize }, - 80usize, - concat!( - "Offset of field: ", - stringify!(rte_bus), - "::", - stringify!(dma_unmap) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).conf as *const _ as usize }, - 88usize, - concat!( - "Offset of field: ", - stringify!(rte_bus), - "::", - stringify!(conf) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).get_iommu_class as *const _ as usize }, - 96usize, - concat!( - "Offset of field: ", - stringify!(rte_bus), - "::", - stringify!(get_iommu_class) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dev_iterate as *const _ as usize }, - 104usize, - concat!( - "Offset of field: ", - stringify!(rte_bus), - "::", - stringify!(dev_iterate) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).hot_unplug_handler as *const _ as usize }, - 112usize, - concat!( - "Offset of field: ", - stringify!(rte_bus), - "::", - stringify!(hot_unplug_handler) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).sigbus_handler as *const _ as usize }, - 120usize, - concat!( - "Offset of field: ", - stringify!(rte_bus), - "::", - stringify!(sigbus_handler) - ) - ); + fn test_field_next() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).next) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_bus), + "::", + stringify!(next) + ) + ); + } + test_field_next(); + fn test_field_name() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_bus), + "::", + stringify!(name) + ) + ); + } + test_field_name(); + fn test_field_scan() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).scan) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rte_bus), + "::", + stringify!(scan) + ) + ); + } + test_field_scan(); + fn test_field_probe() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).probe) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(rte_bus), + "::", + stringify!(probe) + ) + ); + } + test_field_probe(); + fn test_field_find_device() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).find_device) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(rte_bus), + "::", + stringify!(find_device) + ) + ); + } + test_field_find_device(); + fn test_field_plug() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).plug) as usize - ptr as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(rte_bus), + "::", + stringify!(plug) + ) + ); + } + test_field_plug(); + fn test_field_unplug() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).unplug) as usize - ptr as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(rte_bus), + "::", + stringify!(unplug) + ) + ); + } + test_field_unplug(); + fn test_field_parse() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).parse) as usize - ptr as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(rte_bus), + "::", + stringify!(parse) + ) + ); + } + test_field_parse(); + fn test_field_dma_map() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dma_map) as usize - ptr as usize + }, + 72usize, + concat!( + "Offset of field: ", + stringify!(rte_bus), + "::", + stringify!(dma_map) + ) + ); + } + test_field_dma_map(); + fn test_field_dma_unmap() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dma_unmap) as usize - ptr as usize + }, + 80usize, + concat!( + "Offset of field: ", + stringify!(rte_bus), + "::", + stringify!(dma_unmap) + ) + ); + } + test_field_dma_unmap(); + fn test_field_conf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).conf) as usize - ptr as usize + }, + 88usize, + concat!( + "Offset of field: ", + stringify!(rte_bus), + "::", + stringify!(conf) + ) + ); + } + test_field_conf(); + fn test_field_get_iommu_class() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).get_iommu_class) as usize - ptr as usize + }, + 96usize, + concat!( + "Offset of field: ", + stringify!(rte_bus), + "::", + stringify!(get_iommu_class) + ) + ); + } + test_field_get_iommu_class(); + fn test_field_dev_iterate() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dev_iterate) as usize - ptr as usize + }, + 104usize, + concat!( + "Offset of field: ", + stringify!(rte_bus), + "::", + stringify!(dev_iterate) + ) + ); + } + test_field_dev_iterate(); + fn test_field_hot_unplug_handler() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).hot_unplug_handler) as usize - ptr as usize + }, + 112usize, + concat!( + "Offset of field: ", + stringify!(rte_bus), + "::", + stringify!(hot_unplug_handler) + ) + ); + } + test_field_hot_unplug_handler(); + fn test_field_sigbus_handler() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).sigbus_handler) as usize - ptr as usize + }, + 120usize, + concat!( + "Offset of field: ", + stringify!(rte_bus), + "::", + stringify!(sigbus_handler) + ) + ); + } + test_field_sigbus_handler(); } impl Default for rte_bus { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } extern "C" { @@ -2569,7 +3224,7 @@ extern "C" { ) -> ::std::os::raw::c_int; } #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct rte_mp_msg { pub name: [::std::os::raw::c_char; 64usize], pub len_param: ::std::os::raw::c_int, @@ -2589,60 +3244,99 @@ fn bindgen_test_layout_rte_mp_msg() { 4usize, concat!("Alignment of ", stringify!(rte_mp_msg)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).name as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mp_msg), - "::", - stringify!(name) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).len_param as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(rte_mp_msg), - "::", - stringify!(len_param) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).num_fds as *const _ as usize }, - 68usize, - concat!( - "Offset of field: ", - stringify!(rte_mp_msg), - "::", - stringify!(num_fds) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).param as *const _ as usize }, - 72usize, - concat!( - "Offset of field: ", - stringify!(rte_mp_msg), - "::", - stringify!(param) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).fds as *const _ as usize }, - 328usize, - concat!( - "Offset of field: ", - stringify!(rte_mp_msg), - "::", - stringify!(fds) - ) - ); + fn test_field_name() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mp_msg), + "::", + stringify!(name) + ) + ); + } + test_field_name(); + fn test_field_len_param() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).len_param) as usize - ptr as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(rte_mp_msg), + "::", + stringify!(len_param) + ) + ); + } + test_field_len_param(); + fn test_field_num_fds() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).num_fds) as usize - ptr as usize + }, + 68usize, + concat!( + "Offset of field: ", + stringify!(rte_mp_msg), + "::", + stringify!(num_fds) + ) + ); + } + test_field_num_fds(); + fn test_field_param() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).param) as usize - ptr as usize + }, + 72usize, + concat!( + "Offset of field: ", + stringify!(rte_mp_msg), + "::", + stringify!(param) + ) + ); + } + test_field_param(); + fn test_field_fds() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).fds) as usize - ptr as usize + }, + 328usize, + concat!( + "Offset of field: ", + stringify!(rte_mp_msg), + "::", + stringify!(fds) + ) + ); + } + test_field_fds(); } impl Default for rte_mp_msg { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -2664,40 +3358,65 @@ fn bindgen_test_layout_rte_mp_reply() { 8usize, concat!("Alignment of ", stringify!(rte_mp_reply)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).nb_sent as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mp_reply), - "::", - stringify!(nb_sent) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).nb_received as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_mp_reply), - "::", - stringify!(nb_received) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).msgs as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_mp_reply), - "::", - stringify!(msgs) - ) - ); + fn test_field_nb_sent() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_sent) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mp_reply), + "::", + stringify!(nb_sent) + ) + ); + } + test_field_nb_sent(); + fn test_field_nb_received() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_received) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_mp_reply), + "::", + stringify!(nb_received) + ) + ); + } + test_field_nb_received(); + fn test_field_msgs() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).msgs) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_mp_reply), + "::", + stringify!(msgs) + ) + ); + } + test_field_msgs(); } impl Default for rte_mp_reply { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type rte_mp_t = ::std::option::Option< @@ -2826,50 +3545,82 @@ fn bindgen_test_layout_rte_epoll_data() { 8usize, concat!("Alignment of ", stringify!(rte_epoll_data)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).event as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_epoll_data), - "::", - stringify!(event) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_epoll_data), - "::", - stringify!(data) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).cb_fun as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_epoll_data), - "::", - stringify!(cb_fun) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).cb_arg as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(rte_epoll_data), - "::", - stringify!(cb_arg) - ) - ); + fn test_field_event() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).event) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_epoll_data), + "::", + stringify!(event) + ) + ); + } + test_field_event(); + fn test_field_data() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_epoll_data), + "::", + stringify!(data) + ) + ); + } + test_field_data(); + fn test_field_cb_fun() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).cb_fun) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_epoll_data), + "::", + stringify!(cb_fun) + ) + ); + } + test_field_cb_fun(); + fn test_field_cb_arg() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).cb_arg) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rte_epoll_data), + "::", + stringify!(cb_arg) + ) + ); + } + test_field_cb_arg(); } impl Default for rte_epoll_data { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub mod _bindgen_ty_13 { @@ -2898,50 +3649,82 @@ fn bindgen_test_layout_rte_epoll_event() { 8usize, concat!("Alignment of ", stringify!(rte_epoll_event)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).status as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_epoll_event), - "::", - stringify!(status) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).fd as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_epoll_event), - "::", - stringify!(fd) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).epfd as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_epoll_event), - "::", - stringify!(epfd) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).epdata as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_epoll_event), - "::", - stringify!(epdata) - ) - ); + fn test_field_status() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).status) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_epoll_event), + "::", + stringify!(status) + ) + ); + } + test_field_status(); + fn test_field_fd() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).fd) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_epoll_event), + "::", + stringify!(fd) + ) + ); + } + test_field_fd(); + fn test_field_epfd() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).epfd) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_epoll_event), + "::", + stringify!(epfd) + ) + ); + } + test_field_epfd(); + fn test_field_epdata() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).epdata) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_epoll_event), + "::", + stringify!(epdata) + ) + ); + } + test_field_epdata(); } impl Default for rte_epoll_event { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -2962,7 +3745,6 @@ pub struct rte_intr_handle { pub union rte_intr_handle__bindgen_ty_1 { pub vfio_dev_fd: ::std::os::raw::c_int, pub uio_cfg_fd: ::std::os::raw::c_int, - _bindgen_union_align: u32, } #[test] fn bindgen_test_layout_rte_intr_handle__bindgen_ty_1() { @@ -2976,36 +3758,48 @@ fn bindgen_test_layout_rte_intr_handle__bindgen_ty_1() { 4usize, concat!("Alignment of ", stringify!(rte_intr_handle__bindgen_ty_1)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).vfio_dev_fd as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_intr_handle__bindgen_ty_1), - "::", - stringify!(vfio_dev_fd) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).uio_cfg_fd as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_intr_handle__bindgen_ty_1), - "::", - stringify!(uio_cfg_fd) - ) - ); + fn test_field_vfio_dev_fd() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vfio_dev_fd) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_intr_handle__bindgen_ty_1), + "::", + stringify!(vfio_dev_fd) + ) + ); + } + test_field_vfio_dev_fd(); + fn test_field_uio_cfg_fd() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).uio_cfg_fd) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_intr_handle__bindgen_ty_1), + "::", + stringify!(uio_cfg_fd) + ) + ); + } + test_field_uio_cfg_fd(); } impl Default for rte_intr_handle__bindgen_ty_1 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[test] @@ -3020,92 +3814,150 @@ fn bindgen_test_layout_rte_intr_handle() { 8usize, concat!("Alignment of ", stringify!(rte_intr_handle)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).fd as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_intr_handle), - "::", - stringify!(fd) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_intr_handle), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).max_intr as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(rte_intr_handle), - "::", - stringify!(max_intr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).nb_efd as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_intr_handle), - "::", - stringify!(nb_efd) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).efd_counter_size as *const _ as usize - }, - 20usize, - concat!( - "Offset of field: ", - stringify!(rte_intr_handle), - "::", - stringify!(efd_counter_size) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).efds as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(rte_intr_handle), - "::", - stringify!(efds) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).elist as *const _ as usize }, - 2072usize, - concat!( - "Offset of field: ", - stringify!(rte_intr_handle), - "::", - stringify!(elist) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).intr_vec as *const _ as usize }, - 26648usize, - concat!( - "Offset of field: ", - stringify!(rte_intr_handle), - "::", - stringify!(intr_vec) - ) - ); + fn test_field_fd() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).fd) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_intr_handle), + "::", + stringify!(fd) + ) + ); + } + test_field_fd(); + fn test_field_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_intr_handle), + "::", + stringify!(type_) + ) + ); + } + test_field_type(); + fn test_field_max_intr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).max_intr) as usize - ptr as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(rte_intr_handle), + "::", + stringify!(max_intr) + ) + ); + } + test_field_max_intr(); + fn test_field_nb_efd() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_efd) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_intr_handle), + "::", + stringify!(nb_efd) + ) + ); + } + test_field_nb_efd(); + fn test_field_efd_counter_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).efd_counter_size) as usize - ptr as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(rte_intr_handle), + "::", + stringify!(efd_counter_size) + ) + ); + } + test_field_efd_counter_size(); + fn test_field_efds() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).efds) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rte_intr_handle), + "::", + stringify!(efds) + ) + ); + } + test_field_efds(); + fn test_field_elist() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).elist) as usize - ptr as usize + }, + 2072usize, + concat!( + "Offset of field: ", + stringify!(rte_intr_handle), + "::", + stringify!(elist) + ) + ); + } + test_field_elist(); + fn test_field_intr_vec() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).intr_vec) as usize - ptr as usize + }, + 26648usize, + concat!( + "Offset of field: ", + stringify!(rte_intr_handle), + "::", + stringify!(intr_vec) + ) + ); + } + test_field_intr_vec(); } impl Default for rte_intr_handle { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } extern "C" { @@ -3226,34 +4078,48 @@ fn bindgen_test_layout_rte_devargs__bindgen_ty_1() { 8usize, concat!("Alignment of ", stringify!(rte_devargs__bindgen_ty_1)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).tqe_next as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_devargs__bindgen_ty_1), - "::", - stringify!(tqe_next) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).tqe_prev as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_devargs__bindgen_ty_1), - "::", - stringify!(tqe_prev) - ) - ); + fn test_field_tqe_next() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tqe_next) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_devargs__bindgen_ty_1), + "::", + stringify!(tqe_next) + ) + ); + } + test_field_tqe_next(); + fn test_field_tqe_prev() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tqe_prev) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_devargs__bindgen_ty_1), + "::", + stringify!(tqe_prev) + ) + ); + } + test_field_tqe_prev(); } impl Default for rte_devargs__bindgen_ty_1 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -3261,7 +4127,6 @@ impl Default for rte_devargs__bindgen_ty_1 { pub union rte_devargs__bindgen_ty_2 { pub args: *mut ::std::os::raw::c_char, pub drv_str: *const ::std::os::raw::c_char, - _bindgen_union_align: u64, } #[test] fn bindgen_test_layout_rte_devargs__bindgen_ty_2() { @@ -3275,32 +4140,48 @@ fn bindgen_test_layout_rte_devargs__bindgen_ty_2() { 8usize, concat!("Alignment of ", stringify!(rte_devargs__bindgen_ty_2)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).args as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_devargs__bindgen_ty_2), - "::", - stringify!(args) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).drv_str as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_devargs__bindgen_ty_2), - "::", - stringify!(drv_str) - ) - ); + fn test_field_args() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).args) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_devargs__bindgen_ty_2), + "::", + stringify!(args) + ) + ); + } + test_field_args(); + fn test_field_drv_str() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).drv_str) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_devargs__bindgen_ty_2), + "::", + stringify!(drv_str) + ) + ); + } + test_field_drv_str(); } impl Default for rte_devargs__bindgen_ty_2 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[test] @@ -3315,100 +4196,167 @@ fn bindgen_test_layout_rte_devargs() { 8usize, concat!("Alignment of ", stringify!(rte_devargs)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).next as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_devargs), - "::", - stringify!(next) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_devargs), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).policy as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(rte_devargs), - "::", - stringify!(policy) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).name as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(rte_devargs), - "::", - stringify!(name) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).bus as *const _ as usize }, - 96usize, - concat!( - "Offset of field: ", - stringify!(rte_devargs), - "::", - stringify!(bus) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).cls as *const _ as usize }, - 104usize, - concat!( - "Offset of field: ", - stringify!(rte_devargs), - "::", - stringify!(cls) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).bus_str as *const _ as usize }, - 112usize, - concat!( - "Offset of field: ", - stringify!(rte_devargs), - "::", - stringify!(bus_str) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).cls_str as *const _ as usize }, - 120usize, - concat!( - "Offset of field: ", - stringify!(rte_devargs), - "::", - stringify!(cls_str) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, - 128usize, - concat!( - "Offset of field: ", - stringify!(rte_devargs), - "::", - stringify!(data) - ) - ); + fn test_field_next() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).next) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_devargs), + "::", + stringify!(next) + ) + ); + } + test_field_next(); + fn test_field_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_devargs), + "::", + stringify!(type_) + ) + ); + } + test_field_type(); + fn test_field_policy() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).policy) as usize - ptr as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(rte_devargs), + "::", + stringify!(policy) + ) + ); + } + test_field_policy(); + fn test_field_name() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rte_devargs), + "::", + stringify!(name) + ) + ); + } + test_field_name(); + fn test_field_bus() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).bus) as usize - ptr as usize + }, + 96usize, + concat!( + "Offset of field: ", + stringify!(rte_devargs), + "::", + stringify!(bus) + ) + ); + } + test_field_bus(); + fn test_field_cls() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).cls) as usize - ptr as usize + }, + 104usize, + concat!( + "Offset of field: ", + stringify!(rte_devargs), + "::", + stringify!(cls) + ) + ); + } + test_field_cls(); + fn test_field_bus_str() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).bus_str) as usize - ptr as usize + }, + 112usize, + concat!( + "Offset of field: ", + stringify!(rte_devargs), + "::", + stringify!(bus_str) + ) + ); + } + test_field_bus_str(); + fn test_field_cls_str() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).cls_str) as usize - ptr as usize + }, + 120usize, + concat!( + "Offset of field: ", + stringify!(rte_devargs), + "::", + stringify!(cls_str) + ) + ); + } + test_field_cls_str(); + fn test_field_data() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize + }, + 128usize, + concat!( + "Offset of field: ", + stringify!(rte_devargs), + "::", + stringify!(data) + ) + ); + } + test_field_data(); } impl Default for rte_devargs { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } extern "C" { @@ -3483,7 +4431,6 @@ pub union rte_xmm { pub u32_: [u32; 4usize], pub u64_: [u64; 2usize], pub pd: [f64; 2usize], - _bindgen_union_align: u128, } #[test] fn bindgen_test_layout_rte_xmm() { @@ -3497,70 +4444,116 @@ fn bindgen_test_layout_rte_xmm() { 16usize, concat!("Alignment of ", stringify!(rte_xmm)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).x as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_xmm), - "::", - stringify!(x) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).u8_ as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_xmm), - "::", - stringify!(u8_) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).u16_ as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_xmm), - "::", - stringify!(u16_) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).u32_ as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_xmm), - "::", - stringify!(u32_) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).u64_ as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_xmm), - "::", - stringify!(u64_) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pd as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_xmm), - "::", - stringify!(pd) - ) - ); + fn test_field_x() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).x) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_xmm), + "::", + stringify!(x) + ) + ); + } + test_field_x(); + fn test_field_u8() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).u8_) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_xmm), + "::", + stringify!(u8_) + ) + ); + } + test_field_u8(); + fn test_field_u16() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).u16_) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_xmm), + "::", + stringify!(u16_) + ) + ); + } + test_field_u16(); + fn test_field_u32() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).u32_) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_xmm), + "::", + stringify!(u32_) + ) + ); + } + test_field_u32(); + fn test_field_u64() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).u64_) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_xmm), + "::", + stringify!(u64_) + ) + ); + } + test_field_u64(); + fn test_field_pd() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pd) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_xmm), + "::", + stringify!(pd) + ) + ); + } + test_field_pd(); } impl Default for rte_xmm { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type rte_xmm_t = rte_xmm; @@ -3576,7 +4569,6 @@ pub union rte_ymm { pub u32_: [u32; 8usize], pub u64_: [u64; 4usize], pub pd: [f64; 4usize], - _bindgen_union_align: [u8; 32usize], } #[test] fn bindgen_test_layout_rte_ymm() { @@ -3590,80 +4582,133 @@ fn bindgen_test_layout_rte_ymm() { 32usize, concat!("Alignment of ", stringify!(rte_ymm)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).y as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_ymm), - "::", - stringify!(y) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).x as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_ymm), - "::", - stringify!(x) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).u8_ as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_ymm), - "::", - stringify!(u8_) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).u16_ as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_ymm), - "::", - stringify!(u16_) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).u32_ as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_ymm), - "::", - stringify!(u32_) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).u64_ as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_ymm), - "::", - stringify!(u64_) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pd as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_ymm), - "::", - stringify!(pd) - ) - ); + fn test_field_y() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).y) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_ymm), + "::", + stringify!(y) + ) + ); + } + test_field_y(); + fn test_field_x() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).x) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_ymm), + "::", + stringify!(x) + ) + ); + } + test_field_x(); + fn test_field_u8() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).u8_) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_ymm), + "::", + stringify!(u8_) + ) + ); + } + test_field_u8(); + fn test_field_u16() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).u16_) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_ymm), + "::", + stringify!(u16_) + ) + ); + } + test_field_u16(); + fn test_field_u32() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).u32_) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_ymm), + "::", + stringify!(u32_) + ) + ); + } + test_field_u32(); + fn test_field_u64() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).u64_) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_ymm), + "::", + stringify!(u64_) + ) + ); + } + test_field_u64(); + fn test_field_pd() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pd) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_ymm), + "::", + stringify!(pd) + ) + ); + } + test_field_pd(); } impl Default for rte_ymm { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type rte_ymm_t = rte_ymm; @@ -3799,16 +4844,23 @@ fn bindgen_test_layout_rte_spinlock_t() { 4usize, concat!("Alignment of ", stringify!(rte_spinlock_t)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).locked as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_spinlock_t), - "::", - stringify!(locked) - ) - ); + fn test_field_locked() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).locked) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_spinlock_t), + "::", + stringify!(locked) + ) + ); + } + test_field_locked(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -3829,36 +4881,57 @@ fn bindgen_test_layout_rte_spinlock_recursive_t() { 4usize, concat!("Alignment of ", stringify!(rte_spinlock_recursive_t)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).sl as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_spinlock_recursive_t), - "::", - stringify!(sl) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).user as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_spinlock_recursive_t), - "::", - stringify!(user) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).count as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_spinlock_recursive_t), - "::", - stringify!(count) - ) - ); + fn test_field_sl() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).sl) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_spinlock_recursive_t), + "::", + stringify!(sl) + ) + ); + } + test_field_sl(); + fn test_field_user() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).user) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_spinlock_recursive_t), + "::", + stringify!(user) + ) + ); + } + test_field_user(); + fn test_field_count() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).count) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_spinlock_recursive_t), + "::", + stringify!(count) + ) + ); + } + test_field_count(); } pub mod rte_cpu_flag_t { pub type Type = ::std::os::raw::c_uint; @@ -3992,16 +5065,23 @@ fn bindgen_test_layout_rte_atomic16_t() { 2usize, concat!("Alignment of ", stringify!(rte_atomic16_t)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).cnt as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_atomic16_t), - "::", - stringify!(cnt) - ) - ); + fn test_field_cnt() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).cnt) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_atomic16_t), + "::", + stringify!(cnt) + ) + ); + } + test_field_cnt(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -4020,16 +5100,23 @@ fn bindgen_test_layout_rte_atomic32_t() { 4usize, concat!("Alignment of ", stringify!(rte_atomic32_t)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).cnt as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_atomic32_t), - "::", - stringify!(cnt) - ) - ); + fn test_field_cnt() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).cnt) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_atomic32_t), + "::", + stringify!(cnt) + ) + ); + } + test_field_cnt(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -4048,16 +5135,23 @@ fn bindgen_test_layout_rte_atomic64_t() { 8usize, concat!("Alignment of ", stringify!(rte_atomic64_t)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).cnt as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_atomic64_t), - "::", - stringify!(cnt) - ) - ); + fn test_field_cnt() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).cnt) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_atomic64_t), + "::", + stringify!(cnt) + ) + ); + } + test_field_cnt(); } #[repr(C)] #[repr(align(16))] @@ -4071,7 +5165,6 @@ pub struct rte_int128_t { pub union rte_int128_t__bindgen_ty_1 { pub val: [u64; 2usize], pub int128: i128, - _bindgen_union_align: u128, } #[test] fn bindgen_test_layout_rte_int128_t__bindgen_ty_1() { @@ -4085,32 +5178,48 @@ fn bindgen_test_layout_rte_int128_t__bindgen_ty_1() { 16usize, concat!("Alignment of ", stringify!(rte_int128_t__bindgen_ty_1)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).val as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_int128_t__bindgen_ty_1), - "::", - stringify!(val) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).int128 as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_int128_t__bindgen_ty_1), - "::", - stringify!(int128) - ) - ); + fn test_field_val() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).val) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_int128_t__bindgen_ty_1), + "::", + stringify!(val) + ) + ); + } + test_field_val(); + fn test_field_int128() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).int128) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_int128_t__bindgen_ty_1), + "::", + stringify!(int128) + ) + ); + } + test_field_int128(); } impl Default for rte_int128_t__bindgen_ty_1 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[test] @@ -4128,7 +5237,11 @@ fn bindgen_test_layout_rte_int128_t() { } impl Default for rte_int128_t { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } extern "C" { @@ -4169,19 +5282,26 @@ fn bindgen_test_layout_rte_rwlock_t() { 4usize, concat!("Alignment of ", stringify!(rte_rwlock_t)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).cnt as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_rwlock_t), - "::", - stringify!(cnt) - ) - ); + fn test_field_cnt() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).cnt) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_rwlock_t), + "::", + stringify!(cnt) + ) + ); + } + test_field_cnt(); } #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct rte_fbarray { pub name: [::std::os::raw::c_char; 64usize], pub count: ::std::os::raw::c_uint, @@ -4202,70 +5322,116 @@ fn bindgen_test_layout_rte_fbarray() { 8usize, concat!("Alignment of ", stringify!(rte_fbarray)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).name as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_fbarray), - "::", - stringify!(name) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).count as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(rte_fbarray), - "::", - stringify!(count) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).len as *const _ as usize }, - 68usize, - concat!( - "Offset of field: ", - stringify!(rte_fbarray), - "::", - stringify!(len) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).elt_sz as *const _ as usize }, - 72usize, - concat!( - "Offset of field: ", - stringify!(rte_fbarray), - "::", - stringify!(elt_sz) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, - 80usize, - concat!( - "Offset of field: ", - stringify!(rte_fbarray), - "::", - stringify!(data) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rwlock as *const _ as usize }, - 88usize, - concat!( - "Offset of field: ", - stringify!(rte_fbarray), - "::", - stringify!(rwlock) - ) - ); + fn test_field_name() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_fbarray), + "::", + stringify!(name) + ) + ); + } + test_field_name(); + fn test_field_count() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).count) as usize - ptr as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(rte_fbarray), + "::", + stringify!(count) + ) + ); + } + test_field_count(); + fn test_field_len() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize + }, + 68usize, + concat!( + "Offset of field: ", + stringify!(rte_fbarray), + "::", + stringify!(len) + ) + ); + } + test_field_len(); + fn test_field_elt_sz() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).elt_sz) as usize - ptr as usize + }, + 72usize, + concat!( + "Offset of field: ", + stringify!(rte_fbarray), + "::", + stringify!(elt_sz) + ) + ); + } + test_field_elt_sz(); + fn test_field_data() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize + }, + 80usize, + concat!( + "Offset of field: ", + stringify!(rte_fbarray), + "::", + stringify!(data) + ) + ); + } + test_field_data(); + fn test_field_rwlock() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rwlock) as usize - ptr as usize + }, + 88usize, + concat!( + "Offset of field: ", + stringify!(rte_fbarray), + "::", + stringify!(rwlock) + ) + ); + } + test_field_rwlock(); } impl Default for rte_fbarray { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } extern "C" { @@ -4448,7 +5614,6 @@ pub struct rte_memseg { pub union rte_memseg__bindgen_ty_1 { pub phys_addr: phys_addr_t, pub iova: rte_iova_t, - _bindgen_union_align: u64, } #[test] fn bindgen_test_layout_rte_memseg__bindgen_ty_1() { @@ -4462,32 +5627,48 @@ fn bindgen_test_layout_rte_memseg__bindgen_ty_1() { 8usize, concat!("Alignment of ", stringify!(rte_memseg__bindgen_ty_1)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).phys_addr as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_memseg__bindgen_ty_1), - "::", - stringify!(phys_addr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).iova as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_memseg__bindgen_ty_1), - "::", - stringify!(iova) - ) - ); + fn test_field_phys_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).phys_addr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_memseg__bindgen_ty_1), + "::", + stringify!(phys_addr) + ) + ); + } + test_field_phys_addr(); + fn test_field_iova() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).iova) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_memseg__bindgen_ty_1), + "::", + stringify!(iova) + ) + ); + } + test_field_iova(); } impl Default for rte_memseg__bindgen_ty_1 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -4495,7 +5676,6 @@ impl Default for rte_memseg__bindgen_ty_1 { pub union rte_memseg__bindgen_ty_2 { pub addr: *mut ::std::os::raw::c_void, pub addr_64: u64, - _bindgen_union_align: u64, } #[test] fn bindgen_test_layout_rte_memseg__bindgen_ty_2() { @@ -4509,32 +5689,48 @@ fn bindgen_test_layout_rte_memseg__bindgen_ty_2() { 8usize, concat!("Alignment of ", stringify!(rte_memseg__bindgen_ty_2)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_memseg__bindgen_ty_2), - "::", - stringify!(addr) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).addr_64 as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_memseg__bindgen_ty_2), - "::", - stringify!(addr_64) - ) - ); + fn test_field_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_memseg__bindgen_ty_2), + "::", + stringify!(addr) + ) + ); + } + test_field_addr(); + fn test_field_addr_64() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).addr_64) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_memseg__bindgen_ty_2), + "::", + stringify!(addr_64) + ) + ); + } + test_field_addr_64(); } impl Default for rte_memseg__bindgen_ty_2 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[test] @@ -4549,70 +5745,116 @@ fn bindgen_test_layout_rte_memseg() { 1usize, concat!("Alignment of ", stringify!(rte_memseg)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).len as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_memseg), - "::", - stringify!(len) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).hugepage_sz as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(rte_memseg), - "::", - stringify!(hugepage_sz) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).socket_id as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(rte_memseg), - "::", - stringify!(socket_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).nchannel as *const _ as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(rte_memseg), - "::", - stringify!(nchannel) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).nrank as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(rte_memseg), - "::", - stringify!(nrank) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 44usize, - concat!( - "Offset of field: ", - stringify!(rte_memseg), - "::", - stringify!(flags) - ) - ); + fn test_field_len() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_memseg), + "::", + stringify!(len) + ) + ); + } + test_field_len(); + fn test_field_hugepage_sz() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).hugepage_sz) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rte_memseg), + "::", + stringify!(hugepage_sz) + ) + ); + } + test_field_hugepage_sz(); + fn test_field_socket_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).socket_id) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(rte_memseg), + "::", + stringify!(socket_id) + ) + ); + } + test_field_socket_id(); + fn test_field_nchannel() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nchannel) as usize - ptr as usize + }, + 36usize, + concat!( + "Offset of field: ", + stringify!(rte_memseg), + "::", + stringify!(nchannel) + ) + ); + } + test_field_nchannel(); + fn test_field_nrank() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nrank) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(rte_memseg), + "::", + stringify!(nrank) + ) + ); + } + test_field_nrank(); + fn test_field_flags() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize + }, + 44usize, + concat!( + "Offset of field: ", + stringify!(rte_memseg), + "::", + stringify!(flags) + ) + ); + } + test_field_flags(); } impl Default for rte_memseg { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -4632,7 +5874,6 @@ pub struct rte_memseg_list { pub union rte_memseg_list__bindgen_ty_1 { pub base_va: *mut ::std::os::raw::c_void, pub addr_64: u64, - _bindgen_union_align: u64, } #[test] fn bindgen_test_layout_rte_memseg_list__bindgen_ty_1() { @@ -4646,34 +5887,48 @@ fn bindgen_test_layout_rte_memseg_list__bindgen_ty_1() { 8usize, concat!("Alignment of ", stringify!(rte_memseg_list__bindgen_ty_1)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).base_va as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_memseg_list__bindgen_ty_1), - "::", - stringify!(base_va) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).addr_64 as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_memseg_list__bindgen_ty_1), - "::", - stringify!(addr_64) - ) - ); + fn test_field_base_va() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).base_va) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_memseg_list__bindgen_ty_1), + "::", + stringify!(base_va) + ) + ); + } + test_field_base_va(); + fn test_field_addr_64() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).addr_64) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_memseg_list__bindgen_ty_1), + "::", + stringify!(addr_64) + ) + ); + } + test_field_addr_64(); } impl Default for rte_memseg_list__bindgen_ty_1 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[test] @@ -4688,80 +5943,133 @@ fn bindgen_test_layout_rte_memseg_list() { 8usize, concat!("Alignment of ", stringify!(rte_memseg_list)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).page_sz as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_memseg_list), - "::", - stringify!(page_sz) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).socket_id as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_memseg_list), - "::", - stringify!(socket_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).version as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(rte_memseg_list), - "::", - stringify!(version) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).len as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(rte_memseg_list), - "::", - stringify!(len) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).external as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(rte_memseg_list), - "::", - stringify!(external) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).heap as *const _ as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(rte_memseg_list), - "::", - stringify!(heap) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).memseg_arr as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(rte_memseg_list), - "::", - stringify!(memseg_arr) - ) - ); + fn test_field_page_sz() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).page_sz) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_memseg_list), + "::", + stringify!(page_sz) + ) + ); + } + test_field_page_sz(); + fn test_field_socket_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).socket_id) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_memseg_list), + "::", + stringify!(socket_id) + ) + ); + } + test_field_socket_id(); + fn test_field_version() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).version) as usize - ptr as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(rte_memseg_list), + "::", + stringify!(version) + ) + ); + } + test_field_version(); + fn test_field_len() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rte_memseg_list), + "::", + stringify!(len) + ) + ); + } + test_field_len(); + fn test_field_external() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).external) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(rte_memseg_list), + "::", + stringify!(external) + ) + ); + } + test_field_external(); + fn test_field_heap() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).heap) as usize - ptr as usize + }, + 36usize, + concat!( + "Offset of field: ", + stringify!(rte_memseg_list), + "::", + stringify!(heap) + ) + ); + } + test_field_heap(); + fn test_field_memseg_arr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).memseg_arr) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(rte_memseg_list), + "::", + stringify!(memseg_arr) + ) + ); + } + test_field_memseg_arr(); } impl Default for rte_memseg_list { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } extern "C" { @@ -4974,7 +6282,6 @@ pub struct rte_memzone { pub union rte_memzone__bindgen_ty_1 { pub phys_addr: phys_addr_t, pub iova: rte_iova_t, - _bindgen_union_align: u64, } #[test] fn bindgen_test_layout_rte_memzone__bindgen_ty_1() { @@ -4988,32 +6295,48 @@ fn bindgen_test_layout_rte_memzone__bindgen_ty_1() { 8usize, concat!("Alignment of ", stringify!(rte_memzone__bindgen_ty_1)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).phys_addr as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_memzone__bindgen_ty_1), - "::", - stringify!(phys_addr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).iova as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_memzone__bindgen_ty_1), - "::", - stringify!(iova) - ) - ); + fn test_field_phys_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).phys_addr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_memzone__bindgen_ty_1), + "::", + stringify!(phys_addr) + ) + ); + } + test_field_phys_addr(); + fn test_field_iova() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).iova) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_memzone__bindgen_ty_1), + "::", + stringify!(iova) + ) + ); + } + test_field_iova(); } impl Default for rte_memzone__bindgen_ty_1 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -5021,7 +6344,6 @@ impl Default for rte_memzone__bindgen_ty_1 { pub union rte_memzone__bindgen_ty_2 { pub addr: *mut ::std::os::raw::c_void, pub addr_64: u64, - _bindgen_union_align: u64, } #[test] fn bindgen_test_layout_rte_memzone__bindgen_ty_2() { @@ -5035,32 +6357,48 @@ fn bindgen_test_layout_rte_memzone__bindgen_ty_2() { 8usize, concat!("Alignment of ", stringify!(rte_memzone__bindgen_ty_2)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_memzone__bindgen_ty_2), - "::", - stringify!(addr) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).addr_64 as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_memzone__bindgen_ty_2), - "::", - stringify!(addr_64) - ) - ); + fn test_field_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_memzone__bindgen_ty_2), + "::", + stringify!(addr) + ) + ); + } + test_field_addr(); + fn test_field_addr_64() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).addr_64) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_memzone__bindgen_ty_2), + "::", + stringify!(addr_64) + ) + ); + } + test_field_addr_64(); } impl Default for rte_memzone__bindgen_ty_2 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[test] @@ -5075,60 +6413,99 @@ fn bindgen_test_layout_rte_memzone() { 1usize, concat!("Alignment of ", stringify!(rte_memzone)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).name as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_memzone), - "::", - stringify!(name) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).len as *const _ as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(rte_memzone), - "::", - stringify!(len) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).hugepage_sz as *const _ as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(rte_memzone), - "::", - stringify!(hugepage_sz) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).socket_id as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(rte_memzone), - "::", - stringify!(socket_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 68usize, - concat!( - "Offset of field: ", - stringify!(rte_memzone), - "::", - stringify!(flags) - ) - ); + fn test_field_name() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_memzone), + "::", + stringify!(name) + ) + ); + } + test_field_name(); + fn test_field_len() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(rte_memzone), + "::", + stringify!(len) + ) + ); + } + test_field_len(); + fn test_field_hugepage_sz() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).hugepage_sz) as usize - ptr as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(rte_memzone), + "::", + stringify!(hugepage_sz) + ) + ); + } + test_field_hugepage_sz(); + fn test_field_socket_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).socket_id) as usize - ptr as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(rte_memzone), + "::", + stringify!(socket_id) + ) + ); + } + test_field_socket_id(); + fn test_field_flags() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize + }, + 68usize, + concat!( + "Offset of field: ", + stringify!(rte_memzone), + "::", + stringify!(flags) + ) + ); + } + test_field_flags(); } impl Default for rte_memzone { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } extern "C" { @@ -5199,40 +6576,61 @@ fn bindgen_test_layout_rte_ring_headtail() { 4usize, concat!("Alignment of ", stringify!(rte_ring_headtail)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).head as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_ring_headtail), - "::", - stringify!(head) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tail as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_ring_headtail), - "::", - stringify!(tail) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).single as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_ring_headtail), - "::", - stringify!(single) - ) - ); + fn test_field_head() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).head) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_ring_headtail), + "::", + stringify!(head) + ) + ); + } + test_field_head(); + fn test_field_tail() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tail) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_ring_headtail), + "::", + stringify!(tail) + ) + ); + } + test_field_tail(); + fn test_field_single() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).single) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_ring_headtail), + "::", + stringify!(single) + ) + ); + } + test_field_single(); } #[repr(C)] #[repr(align(64))] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct rte_ring { pub name: [::std::os::raw::c_char; 32usize], pub flags: ::std::os::raw::c_int, @@ -5263,120 +6661,201 @@ fn bindgen_test_layout_rte_ring() { 64usize, concat!("Alignment of ", stringify!(rte_ring)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).name as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_ring), - "::", - stringify!(name) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(rte_ring), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).memzone as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(rte_ring), - "::", - stringify!(memzone) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).size as *const _ as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(rte_ring), - "::", - stringify!(size) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mask as *const _ as usize }, - 52usize, - concat!( - "Offset of field: ", - stringify!(rte_ring), - "::", - stringify!(mask) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).capacity as *const _ as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(rte_ring), - "::", - stringify!(capacity) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad0 as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(rte_ring), - "::", - stringify!(pad0) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).prod as *const _ as usize }, - 128usize, - concat!( - "Offset of field: ", - stringify!(rte_ring), - "::", - stringify!(prod) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad1 as *const _ as usize }, - 192usize, - concat!( - "Offset of field: ", - stringify!(rte_ring), - "::", - stringify!(pad1) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).cons as *const _ as usize }, - 256usize, - concat!( - "Offset of field: ", - stringify!(rte_ring), - "::", - stringify!(cons) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad2 as *const _ as usize }, - 320usize, - concat!( - "Offset of field: ", - stringify!(rte_ring), - "::", - stringify!(pad2) - ) - ); + fn test_field_name() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_ring), + "::", + stringify!(name) + ) + ); + } + test_field_name(); + fn test_field_flags() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(rte_ring), + "::", + stringify!(flags) + ) + ); + } + test_field_flags(); + fn test_field_memzone() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).memzone) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(rte_ring), + "::", + stringify!(memzone) + ) + ); + } + test_field_memzone(); + fn test_field_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(rte_ring), + "::", + stringify!(size) + ) + ); + } + test_field_size(); + fn test_field_mask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mask) as usize - ptr as usize + }, + 52usize, + concat!( + "Offset of field: ", + stringify!(rte_ring), + "::", + stringify!(mask) + ) + ); + } + test_field_mask(); + fn test_field_capacity() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).capacity) as usize - ptr as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(rte_ring), + "::", + stringify!(capacity) + ) + ); + } + test_field_capacity(); + fn test_field_pad0() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pad0) as usize - ptr as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(rte_ring), + "::", + stringify!(pad0) + ) + ); + } + test_field_pad0(); + fn test_field_prod() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).prod) as usize - ptr as usize + }, + 128usize, + concat!( + "Offset of field: ", + stringify!(rte_ring), + "::", + stringify!(prod) + ) + ); + } + test_field_prod(); + fn test_field_pad1() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pad1) as usize - ptr as usize + }, + 192usize, + concat!( + "Offset of field: ", + stringify!(rte_ring), + "::", + stringify!(pad1) + ) + ); + } + test_field_pad1(); + fn test_field_cons() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).cons) as usize - ptr as usize + }, + 256usize, + concat!( + "Offset of field: ", + stringify!(rte_ring), + "::", + stringify!(cons) + ) + ); + } + test_field_cons(); + fn test_field_pad2() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pad2) as usize - ptr as usize + }, + 320usize, + concat!( + "Offset of field: ", + stringify!(rte_ring), + "::", + stringify!(pad2) + ) + ); + } + test_field_pad2(); } impl Default for rte_ring { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } extern "C" { @@ -5415,7 +6894,7 @@ extern "C" { } #[repr(C)] #[repr(align(64))] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct rte_mempool_cache { pub size: u32, pub flushthresh: u32, @@ -5434,50 +6913,82 @@ fn bindgen_test_layout_rte_mempool_cache() { 64usize, concat!("Alignment of ", stringify!(rte_mempool_cache)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).size as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_cache), - "::", - stringify!(size) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flushthresh as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_cache), - "::", - stringify!(flushthresh) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).len as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_cache), - "::", - stringify!(len) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).objs as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_cache), - "::", - stringify!(objs) - ) - ); + fn test_field_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_cache), + "::", + stringify!(size) + ) + ); + } + test_field_size(); + fn test_field_flushthresh() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flushthresh) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_cache), + "::", + stringify!(flushthresh) + ) + ); + } + test_field_flushthresh(); + fn test_field_len() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_cache), + "::", + stringify!(len) + ) + ); + } + test_field_len(); + fn test_field_objs() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).objs) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_cache), + "::", + stringify!(objs) + ) + ); + } + test_field_objs(); } impl Default for rte_mempool_cache { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -5500,46 +7011,74 @@ fn bindgen_test_layout_rte_mempool_objsz() { 4usize, concat!("Alignment of ", stringify!(rte_mempool_objsz)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).elt_size as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_objsz), - "::", - stringify!(elt_size) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).header_size as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_objsz), - "::", - stringify!(header_size) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).trailer_size as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_objsz), - "::", - stringify!(trailer_size) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).total_size as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_objsz), - "::", - stringify!(total_size) - ) - ); + fn test_field_elt_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).elt_size) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_objsz), + "::", + stringify!(elt_size) + ) + ); + } + test_field_elt_size(); + fn test_field_header_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).header_size) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_objsz), + "::", + stringify!(header_size) + ) + ); + } + test_field_header_size(); + fn test_field_trailer_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).trailer_size) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_objsz), + "::", + stringify!(trailer_size) + ) + ); + } + test_field_trailer_size(); + fn test_field_total_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).total_size) as usize - ptr as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_objsz), + "::", + stringify!(total_size) + ) + ); + } + test_field_total_size(); } #[repr(C)] #[derive(Copy, Clone)] @@ -5568,23 +7107,31 @@ fn bindgen_test_layout_rte_mempool_objhdr__bindgen_ty_1() { stringify!(rte_mempool_objhdr__bindgen_ty_1) ) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).stqe_next as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_objhdr__bindgen_ty_1), - "::", - stringify!(stqe_next) - ) - ); + fn test_field_stqe_next() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).stqe_next) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_objhdr__bindgen_ty_1), + "::", + stringify!(stqe_next) + ) + ); + } + test_field_stqe_next(); } impl Default for rte_mempool_objhdr__bindgen_ty_1 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -5592,7 +7139,6 @@ impl Default for rte_mempool_objhdr__bindgen_ty_1 { pub union rte_mempool_objhdr__bindgen_ty_2 { pub iova: rte_iova_t, pub physaddr: phys_addr_t, - _bindgen_union_align: u64, } #[test] fn bindgen_test_layout_rte_mempool_objhdr__bindgen_ty_2() { @@ -5609,35 +7155,48 @@ fn bindgen_test_layout_rte_mempool_objhdr__bindgen_ty_2() { stringify!(rte_mempool_objhdr__bindgen_ty_2) ) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).iova as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_objhdr__bindgen_ty_2), - "::", - stringify!(iova) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).physaddr as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_objhdr__bindgen_ty_2), - "::", - stringify!(physaddr) - ) - ); + fn test_field_iova() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).iova) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_objhdr__bindgen_ty_2), + "::", + stringify!(iova) + ) + ); + } + test_field_iova(); + fn test_field_physaddr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).physaddr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_objhdr__bindgen_ty_2), + "::", + stringify!(physaddr) + ) + ); + } + test_field_physaddr(); } impl Default for rte_mempool_objhdr__bindgen_ty_2 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[test] @@ -5652,30 +7211,48 @@ fn bindgen_test_layout_rte_mempool_objhdr() { 8usize, concat!("Alignment of ", stringify!(rte_mempool_objhdr)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).next as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_objhdr), - "::", - stringify!(next) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mp as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_objhdr), - "::", - stringify!(mp) - ) - ); + fn test_field_next() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).next) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_objhdr), + "::", + stringify!(next) + ) + ); + } + test_field_next(); + fn test_field_mp() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mp) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_objhdr), + "::", + stringify!(mp) + ) + ); + } + test_field_mp(); } impl Default for rte_mempool_objhdr { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -5696,34 +7273,48 @@ fn bindgen_test_layout_rte_mempool_objhdr_list() { 8usize, concat!("Alignment of ", stringify!(rte_mempool_objhdr_list)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).stqh_first as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_objhdr_list), - "::", - stringify!(stqh_first) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).stqh_last as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_objhdr_list), - "::", - stringify!(stqh_last) - ) - ); + fn test_field_stqh_first() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).stqh_first) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_objhdr_list), + "::", + stringify!(stqh_first) + ) + ); + } + test_field_stqh_first(); + fn test_field_stqh_last() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).stqh_last) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_objhdr_list), + "::", + stringify!(stqh_last) + ) + ); + } + test_field_stqh_last(); } impl Default for rte_mempool_objhdr_list { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -5744,34 +7335,48 @@ fn bindgen_test_layout_rte_mempool_memhdr_list() { 8usize, concat!("Alignment of ", stringify!(rte_mempool_memhdr_list)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).stqh_first as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_memhdr_list), - "::", - stringify!(stqh_first) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).stqh_last as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_memhdr_list), - "::", - stringify!(stqh_last) - ) - ); + fn test_field_stqh_first() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).stqh_first) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_memhdr_list), + "::", + stringify!(stqh_first) + ) + ); + } + test_field_stqh_first(); + fn test_field_stqh_last() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).stqh_last) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_memhdr_list), + "::", + stringify!(stqh_last) + ) + ); + } + test_field_stqh_last(); } impl Default for rte_mempool_memhdr_list { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type rte_mempool_memchunk_free_cb_t = ::std::option::Option< @@ -5808,23 +7413,31 @@ fn bindgen_test_layout_rte_mempool_memhdr__bindgen_ty_1() { stringify!(rte_mempool_memhdr__bindgen_ty_1) ) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).stqe_next as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_memhdr__bindgen_ty_1), - "::", - stringify!(stqe_next) - ) - ); + fn test_field_stqe_next() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).stqe_next) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_memhdr__bindgen_ty_1), + "::", + stringify!(stqe_next) + ) + ); + } + test_field_stqe_next(); } impl Default for rte_mempool_memhdr__bindgen_ty_1 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -5832,7 +7445,6 @@ impl Default for rte_mempool_memhdr__bindgen_ty_1 { pub union rte_mempool_memhdr__bindgen_ty_2 { pub iova: rte_iova_t, pub phys_addr: phys_addr_t, - _bindgen_union_align: u64, } #[test] fn bindgen_test_layout_rte_mempool_memhdr__bindgen_ty_2() { @@ -5849,35 +7461,48 @@ fn bindgen_test_layout_rte_mempool_memhdr__bindgen_ty_2() { stringify!(rte_mempool_memhdr__bindgen_ty_2) ) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).iova as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_memhdr__bindgen_ty_2), - "::", - stringify!(iova) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).phys_addr as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_memhdr__bindgen_ty_2), - "::", - stringify!(phys_addr) - ) - ); + fn test_field_iova() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).iova) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_memhdr__bindgen_ty_2), + "::", + stringify!(iova) + ) + ); + } + test_field_iova(); + fn test_field_phys_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).phys_addr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_memhdr__bindgen_ty_2), + "::", + stringify!(phys_addr) + ) + ); + } + test_field_phys_addr(); } impl Default for rte_mempool_memhdr__bindgen_ty_2 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[test] @@ -5892,75 +7517,121 @@ fn bindgen_test_layout_rte_mempool_memhdr() { 8usize, concat!("Alignment of ", stringify!(rte_mempool_memhdr)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).next as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_memhdr), - "::", - stringify!(next) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mp as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_memhdr), - "::", - stringify!(mp) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_memhdr), - "::", - stringify!(addr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).len as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_memhdr), - "::", - stringify!(len) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).free_cb as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_memhdr), - "::", - stringify!(free_cb) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).opaque as *const _ as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_memhdr), - "::", - stringify!(opaque) - ) - ); + fn test_field_next() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).next) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_memhdr), + "::", + stringify!(next) + ) + ); + } + test_field_next(); + fn test_field_mp() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mp) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_memhdr), + "::", + stringify!(mp) + ) + ); + } + test_field_mp(); + fn test_field_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_memhdr), + "::", + stringify!(addr) + ) + ); + } + test_field_addr(); + fn test_field_len() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_memhdr), + "::", + stringify!(len) + ) + ); + } + test_field_len(); + fn test_field_free_cb() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).free_cb) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_memhdr), + "::", + stringify!(free_cb) + ) + ); + } + test_field_free_cb(); + fn test_field_opaque() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).opaque) as usize - ptr as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_memhdr), + "::", + stringify!(opaque) + ) + ); + } + test_field_opaque(); } impl Default for rte_mempool_memhdr { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] #[repr(align(64))] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct rte_mempool_info { pub contig_block_size: ::std::os::raw::c_uint, } @@ -5976,22 +7647,31 @@ fn bindgen_test_layout_rte_mempool_info() { 64usize, concat!("Alignment of ", stringify!(rte_mempool_info)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).contig_block_size as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_info), - "::", - stringify!(contig_block_size) - ) - ); + fn test_field_contig_block_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).contig_block_size) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_info), + "::", + stringify!(contig_block_size) + ) + ); + } + test_field_contig_block_size(); } impl Default for rte_mempool_info { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -6022,7 +7702,6 @@ pub struct rte_mempool { pub union rte_mempool__bindgen_ty_1 { pub pool_data: *mut ::std::os::raw::c_void, pub pool_id: u64, - _bindgen_union_align: u64, } #[test] fn bindgen_test_layout_rte_mempool__bindgen_ty_1() { @@ -6036,34 +7715,48 @@ fn bindgen_test_layout_rte_mempool__bindgen_ty_1() { 8usize, concat!("Alignment of ", stringify!(rte_mempool__bindgen_ty_1)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pool_data as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool__bindgen_ty_1), - "::", - stringify!(pool_data) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pool_id as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool__bindgen_ty_1), - "::", - stringify!(pool_id) - ) - ); + fn test_field_pool_data() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pool_data) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool__bindgen_ty_1), + "::", + stringify!(pool_data) + ) + ); + } + test_field_pool_data(); + fn test_field_pool_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pool_id) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool__bindgen_ty_1), + "::", + stringify!(pool_id) + ) + ); + } + test_field_pool_id(); } impl Default for rte_mempool__bindgen_ty_1 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[test] @@ -6078,201 +7771,324 @@ fn bindgen_test_layout_rte_mempool() { 64usize, concat!("Alignment of ", stringify!(rte_mempool)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).name as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool), - "::", - stringify!(name) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pool_config as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool), - "::", - stringify!(pool_config) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mz as *const _ as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool), - "::", - stringify!(mz) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).socket_id as *const _ as usize }, - 60usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool), - "::", - stringify!(socket_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).size as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool), - "::", - stringify!(size) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).cache_size as *const _ as usize }, - 68usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool), - "::", - stringify!(cache_size) - ) + fn test_field_name() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool), + "::", + stringify!(name) + ) + ); + } + test_field_name(); + fn test_field_pool_config() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pool_config) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool), + "::", + stringify!(pool_config) + ) + ); + } + test_field_pool_config(); + fn test_field_mz() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mz) as usize - ptr as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool), + "::", + stringify!(mz) + ) + ); + } + test_field_mz(); + fn test_field_flags() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool), + "::", + stringify!(flags) + ) + ); + } + test_field_flags(); + fn test_field_socket_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).socket_id) as usize - ptr as usize + }, + 60usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool), + "::", + stringify!(socket_id) + ) + ); + } + test_field_socket_id(); + fn test_field_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool), + "::", + stringify!(size) + ) + ); + } + test_field_size(); + fn test_field_cache_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).cache_size) as usize - ptr as usize + }, + 68usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool), + "::", + stringify!(cache_size) + ) + ); + } + test_field_cache_size(); + fn test_field_elt_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).elt_size) as usize - ptr as usize + }, + 72usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool), + "::", + stringify!(elt_size) + ) + ); + } + test_field_elt_size(); + fn test_field_header_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).header_size) as usize - ptr as usize + }, + 76usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool), + "::", + stringify!(header_size) + ) + ); + } + test_field_header_size(); + fn test_field_trailer_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).trailer_size) as usize - ptr as usize + }, + 80usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool), + "::", + stringify!(trailer_size) + ) + ); + } + test_field_trailer_size(); + fn test_field_private_data_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).private_data_size) as usize - ptr as usize + }, + 84usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool), + "::", + stringify!(private_data_size) + ) + ); + } + test_field_private_data_size(); + fn test_field_ops_index() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ops_index) as usize - ptr as usize + }, + 88usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool), + "::", + stringify!(ops_index) + ) + ); + } + test_field_ops_index(); + fn test_field_local_cache() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).local_cache) as usize - ptr as usize + }, + 96usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool), + "::", + stringify!(local_cache) + ) + ); + } + test_field_local_cache(); + fn test_field_populated_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).populated_size) as usize - ptr as usize + }, + 104usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool), + "::", + stringify!(populated_size) + ) + ); + } + test_field_populated_size(); + fn test_field_elt_list() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).elt_list) as usize - ptr as usize + }, + 112usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool), + "::", + stringify!(elt_list) + ) + ); + } + test_field_elt_list(); + fn test_field_nb_mem_chunks() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_mem_chunks) as usize - ptr as usize + }, + 128usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool), + "::", + stringify!(nb_mem_chunks) + ) + ); + } + test_field_nb_mem_chunks(); + fn test_field_mem_list() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mem_list) as usize - ptr as usize + }, + 136usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool), + "::", + stringify!(mem_list) + ) + ); + } + test_field_mem_list(); +} +impl Default for rte_mempool { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct rte_mempool_objtlr { + _unused: [u8; 0], +} +extern "C" { + pub fn rte_mempool_check_cookies( + mp: *const rte_mempool, + obj_table_const: *const *mut ::std::os::raw::c_void, + n: ::std::os::raw::c_uint, + free: ::std::os::raw::c_int, ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).elt_size as *const _ as usize }, - 72usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool), - "::", - stringify!(elt_size) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).header_size as *const _ as usize }, - 76usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool), - "::", - stringify!(header_size) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).trailer_size as *const _ as usize }, - 80usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool), - "::", - stringify!(trailer_size) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).private_data_size as *const _ as usize }, - 84usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool), - "::", - stringify!(private_data_size) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ops_index as *const _ as usize }, - 88usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool), - "::", - stringify!(ops_index) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).local_cache as *const _ as usize }, - 96usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool), - "::", - stringify!(local_cache) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).populated_size as *const _ as usize }, - 104usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool), - "::", - stringify!(populated_size) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).elt_list as *const _ as usize }, - 112usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool), - "::", - stringify!(elt_list) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).nb_mem_chunks as *const _ as usize }, - 128usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool), - "::", - stringify!(nb_mem_chunks) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mem_list as *const _ as usize }, - 136usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool), - "::", - stringify!(mem_list) - ) - ); -} -impl Default for rte_mempool { - fn default() -> Self { - unsafe { ::std::mem::zeroed() } - } -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct rte_mempool_objtlr { - _unused: [u8; 0], -} -extern "C" { - pub fn rte_mempool_check_cookies( - mp: *const rte_mempool, - obj_table_const: *const *mut ::std::os::raw::c_void, - n: ::std::os::raw::c_uint, - free: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn rte_mempool_contig_blocks_check_cookies( - mp: *const rte_mempool, - first_obj_table_const: *const *mut ::std::os::raw::c_void, - n: ::std::os::raw::c_uint, - free: ::std::os::raw::c_int, +} +extern "C" { + pub fn rte_mempool_contig_blocks_check_cookies( + mp: *const rte_mempool, + first_obj_table_const: *const *mut ::std::os::raw::c_void, + n: ::std::os::raw::c_uint, + free: ::std::os::raw::c_int, ); } pub type rte_mempool_alloc_t = @@ -6379,7 +8195,7 @@ pub type rte_mempool_get_info_t = ::std::option::Option< >; #[repr(C)] #[repr(align(64))] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct rte_mempool_ops { pub name: [::std::os::raw::c_char; 32usize], pub alloc: rte_mempool_alloc_t, @@ -6404,117 +8220,189 @@ fn bindgen_test_layout_rte_mempool_ops() { 64usize, concat!("Alignment of ", stringify!(rte_mempool_ops)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).name as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_ops), - "::", - stringify!(name) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).alloc as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_ops), - "::", - stringify!(alloc) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).free as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_ops), - "::", - stringify!(free) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).enqueue as *const _ as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_ops), - "::", - stringify!(enqueue) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dequeue as *const _ as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_ops), - "::", - stringify!(dequeue) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).get_count as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_ops), - "::", - stringify!(get_count) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).calc_mem_size as *const _ as usize }, - 72usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_ops), - "::", - stringify!(calc_mem_size) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).populate as *const _ as usize }, - 80usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_ops), - "::", - stringify!(populate) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).get_info as *const _ as usize }, - 88usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_ops), - "::", - stringify!(get_info) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).dequeue_contig_blocks as *const _ as usize - }, - 96usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_ops), - "::", - stringify!(dequeue_contig_blocks) - ) - ); + fn test_field_name() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_ops), + "::", + stringify!(name) + ) + ); + } + test_field_name(); + fn test_field_alloc() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).alloc) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_ops), + "::", + stringify!(alloc) + ) + ); + } + test_field_alloc(); + fn test_field_free() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).free) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_ops), + "::", + stringify!(free) + ) + ); + } + test_field_free(); + fn test_field_enqueue() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).enqueue) as usize - ptr as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_ops), + "::", + stringify!(enqueue) + ) + ); + } + test_field_enqueue(); + fn test_field_dequeue() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dequeue) as usize - ptr as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_ops), + "::", + stringify!(dequeue) + ) + ); + } + test_field_dequeue(); + fn test_field_get_count() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).get_count) as usize - ptr as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_ops), + "::", + stringify!(get_count) + ) + ); + } + test_field_get_count(); + fn test_field_calc_mem_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).calc_mem_size) as usize - ptr as usize + }, + 72usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_ops), + "::", + stringify!(calc_mem_size) + ) + ); + } + test_field_calc_mem_size(); + fn test_field_populate() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).populate) as usize - ptr as usize + }, + 80usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_ops), + "::", + stringify!(populate) + ) + ); + } + test_field_populate(); + fn test_field_get_info() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).get_info) as usize - ptr as usize + }, + 88usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_ops), + "::", + stringify!(get_info) + ) + ); + } + test_field_get_info(); + fn test_field_dequeue_contig_blocks() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dequeue_contig_blocks) as usize - ptr as usize + }, + 96usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_ops), + "::", + stringify!(dequeue_contig_blocks) + ) + ); + } + test_field_dequeue_contig_blocks(); } impl Default for rte_mempool_ops { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] #[repr(align(64))] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct rte_mempool_ops_table { pub sl: rte_spinlock_t, pub num_ops: u32, @@ -6533,40 +8421,65 @@ fn bindgen_test_layout_rte_mempool_ops_table() { 64usize, concat!("Alignment of ", stringify!(rte_mempool_ops_table)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).sl as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_ops_table), - "::", - stringify!(sl) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).num_ops as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_ops_table), - "::", - stringify!(num_ops) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ops as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(rte_mempool_ops_table), - "::", - stringify!(ops) - ) - ); + fn test_field_sl() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).sl) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_ops_table), + "::", + stringify!(sl) + ) + ); + } + test_field_sl(); + fn test_field_num_ops() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).num_ops) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_ops_table), + "::", + stringify!(num_ops) + ) + ); + } + test_field_num_ops(); + fn test_field_ops() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ops) as usize - ptr as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(rte_mempool_ops_table), + "::", + stringify!(ops) + ) + ); + } + test_field_ops(); } impl Default for rte_mempool_ops_table { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } extern "C" { @@ -6806,46 +8719,74 @@ fn bindgen_test_layout_rte_mbuf_sched() { 4usize, concat!("Alignment of ", stringify!(rte_mbuf_sched)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).queue_id as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf_sched), - "::", - stringify!(queue_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).traffic_class as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf_sched), - "::", - stringify!(traffic_class) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).color as *const _ as usize }, - 5usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf_sched), - "::", - stringify!(color) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved as *const _ as usize }, - 6usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf_sched), - "::", - stringify!(reserved) - ) - ); + fn test_field_queue_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).queue_id) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf_sched), + "::", + stringify!(queue_id) + ) + ); + } + test_field_queue_id(); + fn test_field_traffic_class() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).traffic_class) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf_sched), + "::", + stringify!(traffic_class) + ) + ); + } + test_field_traffic_class(); + fn test_field_color() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).color) as usize - ptr as usize + }, + 5usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf_sched), + "::", + stringify!(color) + ) + ); + } + test_field_color(); + fn test_field_reserved() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf_sched), + "::", + stringify!(reserved) + ) + ); + } + test_field_reserved(); } pub mod _bindgen_ty_14 { pub type Type = ::std::os::raw::c_uint; @@ -6901,7 +8842,6 @@ pub struct rte_mbuf { pub union rte_mbuf__bindgen_ty_1 { pub buf_iova: rte_iova_t, pub buf_physaddr: rte_iova_t, - _bindgen_union_align: u64, } #[test] fn bindgen_test_layout_rte_mbuf__bindgen_ty_1() { @@ -6915,32 +8855,48 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_1() { 8usize, concat!("Alignment of ", stringify!(rte_mbuf__bindgen_ty_1)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).buf_iova as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf__bindgen_ty_1), - "::", - stringify!(buf_iova) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).buf_physaddr as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf__bindgen_ty_1), - "::", - stringify!(buf_physaddr) - ) - ); + fn test_field_buf_iova() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).buf_iova) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf__bindgen_ty_1), + "::", + stringify!(buf_iova) + ) + ); + } + test_field_buf_iova(); + fn test_field_buf_physaddr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).buf_physaddr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf__bindgen_ty_1), + "::", + stringify!(buf_physaddr) + ) + ); + } + test_field_buf_physaddr(); } impl Default for rte_mbuf__bindgen_ty_1 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -6948,7 +8904,6 @@ impl Default for rte_mbuf__bindgen_ty_1 { pub union rte_mbuf__bindgen_ty_2 { pub refcnt_atomic: rte_atomic16_t, pub refcnt: u16, - _bindgen_union_align: u16, } #[test] fn bindgen_test_layout_rte_mbuf__bindgen_ty_2() { @@ -6962,32 +8917,48 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_2() { 2usize, concat!("Alignment of ", stringify!(rte_mbuf__bindgen_ty_2)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).refcnt_atomic as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf__bindgen_ty_2), - "::", - stringify!(refcnt_atomic) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).refcnt as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf__bindgen_ty_2), - "::", - stringify!(refcnt) - ) - ); + fn test_field_refcnt_atomic() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).refcnt_atomic) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf__bindgen_ty_2), + "::", + stringify!(refcnt_atomic) + ) + ); + } + test_field_refcnt_atomic(); + fn test_field_refcnt() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).refcnt) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf__bindgen_ty_2), + "::", + stringify!(refcnt) + ) + ); + } + test_field_refcnt(); } impl Default for rte_mbuf__bindgen_ty_2 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -6995,7 +8966,6 @@ impl Default for rte_mbuf__bindgen_ty_2 { pub union rte_mbuf__bindgen_ty_3 { pub packet_type: u32, pub __bindgen_anon_1: rte_mbuf__bindgen_ty_3__bindgen_ty_1, - _bindgen_union_align: u32, } #[repr(C)] #[repr(align(4))] @@ -7012,7 +8982,6 @@ pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_1 { pub union rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 { pub inner_esp_next_proto: u8, pub __bindgen_anon_1: rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1, - _bindgen_union_align: u8, } #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -7097,23 +9066,33 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1() { stringify!(rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1) ) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())) - .inner_esp_next_proto as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1), - "::", - stringify!(inner_esp_next_proto) - ) - ); + fn test_field_inner_esp_next_proto() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::< + rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1, + >::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).inner_esp_next_proto) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(inner_esp_next_proto) + ) + ); + } + test_field_inner_esp_next_proto(); } impl Default for rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[test] @@ -7137,7 +9116,11 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1() { } impl Default for rte_mbuf__bindgen_ty_3__bindgen_ty_1 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } impl rte_mbuf__bindgen_ty_3__bindgen_ty_1 { @@ -7244,29 +9227,37 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_3() { 4usize, concat!("Alignment of ", stringify!(rte_mbuf__bindgen_ty_3)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).packet_type as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf__bindgen_ty_3), - "::", - stringify!(packet_type) - ) - ); + fn test_field_packet_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).packet_type) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf__bindgen_ty_3), + "::", + stringify!(packet_type) + ) + ); + } + test_field_packet_type(); } impl Default for rte_mbuf__bindgen_ty_3 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] #[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_4 { pub hash: rte_mbuf__bindgen_ty_4__bindgen_ty_1, - _bindgen_union_align: [u32; 2usize], } #[repr(C)] #[derive(Copy, Clone)] @@ -7276,7 +9267,6 @@ pub union rte_mbuf__bindgen_ty_4__bindgen_ty_1 { pub sched: rte_mbuf_sched, pub txadapter: rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_2, pub usr: u32, - _bindgen_union_align: [u32; 2usize], } #[repr(C)] #[derive(Copy, Clone)] @@ -7290,7 +9280,6 @@ pub union rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 { pub __bindgen_anon_1: rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1, pub lo: u32, - _bindgen_union_align: u32, } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -7325,40 +9314,48 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1__bindg ) ) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::< - rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1, - >())) - .hash as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!( - rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 - ), - "::", - stringify!(hash) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::< - rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1, - >())) - .id as *const _ as usize - }, - 2usize, - concat!( - "Offset of field: ", - stringify!( - rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 - ), - "::", - stringify!(id) - ) - ); + fn test_field_hash() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::< + rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1, + >::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).hash) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!( + rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 + ), + "::", + stringify!(hash) + ) + ); + } + test_field_hash(); + fn test_field_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::< + rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1, + >::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!( + rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 + ), + "::", + stringify!(id) + ) + ); + } + test_field_id(); } #[test] fn bindgen_test_layout_rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1() { @@ -7378,22 +9375,33 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1__bindg stringify!(rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1) ) ); - assert_eq!( - unsafe { - & (* (:: std :: ptr :: null :: < rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 > ())) . lo as * const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), - "::", - stringify!(lo) - ) - ); + fn test_field_lo() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::< + rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1, + >::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).lo) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(lo) + ) + ); + } + test_field_lo(); } impl Default for rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[test] @@ -7414,23 +9422,33 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1() { stringify!(rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1) ) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).hi - as *const _ as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1), - "::", - stringify!(hi) - ) - ); + fn test_field_hi() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::< + rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1, + >::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).hi) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(hi) + ) + ); + } + test_field_hi(); } impl Default for rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_1 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -7458,45 +9476,63 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_2() { stringify!(rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_2) ) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved1 - as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_2), - "::", - stringify!(reserved1) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved2 - as *const _ as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_2), - "::", - stringify!(reserved2) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).txq - as *const _ as usize - }, - 6usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_2), - "::", - stringify!(txq) - ) - ); + fn test_field_reserved1() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::< + rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_2, + >::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).reserved1) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(reserved1) + ) + ); + } + test_field_reserved1(); + fn test_field_reserved2() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::< + rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_2, + >::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).reserved2) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(reserved2) + ) + ); + } + test_field_reserved2(); + fn test_field_txq() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::< + rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_2, + >::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).txq) as usize - ptr as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf__bindgen_ty_4__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(txq) + ) + ); + } + test_field_txq(); } #[test] fn bindgen_test_layout_rte_mbuf__bindgen_ty_4__bindgen_ty_1() { @@ -7516,75 +9552,104 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_4__bindgen_ty_1() { stringify!(rte_mbuf__bindgen_ty_4__bindgen_ty_1) ) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).rss as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf__bindgen_ty_4__bindgen_ty_1), - "::", - stringify!(rss) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).fdir as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf__bindgen_ty_4__bindgen_ty_1), - "::", - stringify!(fdir) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).sched as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf__bindgen_ty_4__bindgen_ty_1), - "::", - stringify!(sched) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).txadapter as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf__bindgen_ty_4__bindgen_ty_1), - "::", - stringify!(txadapter) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).usr as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf__bindgen_ty_4__bindgen_ty_1), - "::", - stringify!(usr) - ) - ); + fn test_field_rss() { + assert_eq!( + unsafe { + let uninit = + ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rss) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf__bindgen_ty_4__bindgen_ty_1), + "::", + stringify!(rss) + ) + ); + } + test_field_rss(); + fn test_field_fdir() { + assert_eq!( + unsafe { + let uninit = + ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).fdir) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf__bindgen_ty_4__bindgen_ty_1), + "::", + stringify!(fdir) + ) + ); + } + test_field_fdir(); + fn test_field_sched() { + assert_eq!( + unsafe { + let uninit = + ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).sched) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf__bindgen_ty_4__bindgen_ty_1), + "::", + stringify!(sched) + ) + ); + } + test_field_sched(); + fn test_field_txadapter() { + assert_eq!( + unsafe { + let uninit = + ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).txadapter) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf__bindgen_ty_4__bindgen_ty_1), + "::", + stringify!(txadapter) + ) + ); + } + test_field_txadapter(); + fn test_field_usr() { + assert_eq!( + unsafe { + let uninit = + ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).usr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf__bindgen_ty_4__bindgen_ty_1), + "::", + stringify!(usr) + ) + ); + } + test_field_usr(); } impl Default for rte_mbuf__bindgen_ty_4__bindgen_ty_1 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[test] @@ -7599,20 +9664,31 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_4() { 4usize, concat!("Alignment of ", stringify!(rte_mbuf__bindgen_ty_4)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).hash as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf__bindgen_ty_4), - "::", - stringify!(hash) - ) - ); + fn test_field_hash() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).hash) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf__bindgen_ty_4), + "::", + stringify!(hash) + ) + ); + } + test_field_hash(); } impl Default for rte_mbuf__bindgen_ty_4 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -7620,7 +9696,6 @@ impl Default for rte_mbuf__bindgen_ty_4 { pub union rte_mbuf__bindgen_ty_5 { pub userdata: *mut ::std::os::raw::c_void, pub udata64: u64, - _bindgen_union_align: u64, } #[test] fn bindgen_test_layout_rte_mbuf__bindgen_ty_5() { @@ -7634,30 +9709,48 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_5() { 8usize, concat!("Alignment of ", stringify!(rte_mbuf__bindgen_ty_5)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).userdata as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf__bindgen_ty_5), - "::", - stringify!(userdata) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).udata64 as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf__bindgen_ty_5), - "::", - stringify!(udata64) - ) - ); + fn test_field_userdata() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).userdata) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf__bindgen_ty_5), + "::", + stringify!(userdata) + ) + ); + } + test_field_userdata(); + fn test_field_udata64() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).udata64) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf__bindgen_ty_5), + "::", + stringify!(udata64) + ) + ); + } + test_field_udata64(); } impl Default for rte_mbuf__bindgen_ty_5 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -7665,7 +9758,6 @@ impl Default for rte_mbuf__bindgen_ty_5 { pub union rte_mbuf__bindgen_ty_6 { pub tx_offload: u64, pub __bindgen_anon_1: rte_mbuf__bindgen_ty_6__bindgen_ty_1, - _bindgen_union_align: u64, } #[repr(C)] #[repr(align(8))] @@ -7809,22 +9901,31 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_6() { 8usize, concat!("Alignment of ", stringify!(rte_mbuf__bindgen_ty_6)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).tx_offload as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf__bindgen_ty_6), - "::", - stringify!(tx_offload) - ) - ); + fn test_field_tx_offload() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tx_offload) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf__bindgen_ty_6), + "::", + stringify!(tx_offload) + ) + ); + } + test_field_tx_offload(); } impl Default for rte_mbuf__bindgen_ty_6 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[test] @@ -7839,230 +9940,388 @@ fn bindgen_test_layout_rte_mbuf() { 64usize, concat!("Alignment of ", stringify!(rte_mbuf)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).cacheline0 as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf), - "::", - stringify!(cacheline0) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).buf_addr as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf), - "::", - stringify!(buf_addr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rearm_data as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf), - "::", - stringify!(rearm_data) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).data_off as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf), - "::", - stringify!(data_off) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).nb_segs as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf), - "::", - stringify!(nb_segs) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).port as *const _ as usize }, - 22usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf), - "::", - stringify!(port) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ol_flags as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf), - "::", - stringify!(ol_flags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rx_descriptor_fields1 as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf), - "::", - stringify!(rx_descriptor_fields1) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pkt_len as *const _ as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf), - "::", - stringify!(pkt_len) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).data_len as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf), - "::", - stringify!(data_len) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).vlan_tci as *const _ as usize }, - 42usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf), - "::", - stringify!(vlan_tci) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).vlan_tci_outer as *const _ as usize }, - 52usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf), - "::", - stringify!(vlan_tci_outer) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).buf_len as *const _ as usize }, - 54usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf), - "::", - stringify!(buf_len) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).timestamp as *const _ as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf), - "::", - stringify!(timestamp) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).cacheline1 as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf), - "::", - stringify!(cacheline1) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pool as *const _ as usize }, - 72usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf), - "::", - stringify!(pool) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).next as *const _ as usize }, - 80usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf), - "::", - stringify!(next) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).priv_size as *const _ as usize }, - 96usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf), - "::", - stringify!(priv_size) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).timesync as *const _ as usize }, - 98usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf), - "::", - stringify!(timesync) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).seqn as *const _ as usize }, - 100usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf), - "::", - stringify!(seqn) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).shinfo as *const _ as usize }, - 104usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf), - "::", - stringify!(shinfo) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dynfield1 as *const _ as usize }, - 112usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf), - "::", - stringify!(dynfield1) - ) - ); + fn test_field_cacheline0() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).cacheline0) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf), + "::", + stringify!(cacheline0) + ) + ); + } + test_field_cacheline0(); + fn test_field_buf_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).buf_addr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf), + "::", + stringify!(buf_addr) + ) + ); + } + test_field_buf_addr(); + fn test_field_rearm_data() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rearm_data) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf), + "::", + stringify!(rearm_data) + ) + ); + } + test_field_rearm_data(); + fn test_field_data_off() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).data_off) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf), + "::", + stringify!(data_off) + ) + ); + } + test_field_data_off(); + fn test_field_nb_segs() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_segs) as usize - ptr as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf), + "::", + stringify!(nb_segs) + ) + ); + } + test_field_nb_segs(); + fn test_field_port() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).port) as usize - ptr as usize + }, + 22usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf), + "::", + stringify!(port) + ) + ); + } + test_field_port(); + fn test_field_ol_flags() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ol_flags) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf), + "::", + stringify!(ol_flags) + ) + ); + } + test_field_ol_flags(); + fn test_field_rx_descriptor_fields1() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_descriptor_fields1) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf), + "::", + stringify!(rx_descriptor_fields1) + ) + ); + } + test_field_rx_descriptor_fields1(); + fn test_field_pkt_len() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pkt_len) as usize - ptr as usize + }, + 36usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf), + "::", + stringify!(pkt_len) + ) + ); + } + test_field_pkt_len(); + fn test_field_data_len() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).data_len) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf), + "::", + stringify!(data_len) + ) + ); + } + test_field_data_len(); + fn test_field_vlan_tci() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vlan_tci) as usize - ptr as usize + }, + 42usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf), + "::", + stringify!(vlan_tci) + ) + ); + } + test_field_vlan_tci(); + fn test_field_vlan_tci_outer() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vlan_tci_outer) as usize - ptr as usize + }, + 52usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf), + "::", + stringify!(vlan_tci_outer) + ) + ); + } + test_field_vlan_tci_outer(); + fn test_field_buf_len() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).buf_len) as usize - ptr as usize + }, + 54usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf), + "::", + stringify!(buf_len) + ) + ); + } + test_field_buf_len(); + fn test_field_timestamp() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).timestamp) as usize - ptr as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf), + "::", + stringify!(timestamp) + ) + ); + } + test_field_timestamp(); + fn test_field_cacheline1() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).cacheline1) as usize - ptr as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf), + "::", + stringify!(cacheline1) + ) + ); + } + test_field_cacheline1(); + fn test_field_pool() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pool) as usize - ptr as usize + }, + 72usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf), + "::", + stringify!(pool) + ) + ); + } + test_field_pool(); + fn test_field_next() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).next) as usize - ptr as usize + }, + 80usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf), + "::", + stringify!(next) + ) + ); + } + test_field_next(); + fn test_field_priv_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).priv_size) as usize - ptr as usize + }, + 96usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf), + "::", + stringify!(priv_size) + ) + ); + } + test_field_priv_size(); + fn test_field_timesync() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).timesync) as usize - ptr as usize + }, + 98usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf), + "::", + stringify!(timesync) + ) + ); + } + test_field_timesync(); + fn test_field_seqn() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).seqn) as usize - ptr as usize + }, + 100usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf), + "::", + stringify!(seqn) + ) + ); + } + test_field_seqn(); + fn test_field_shinfo() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).shinfo) as usize - ptr as usize + }, + 104usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf), + "::", + stringify!(shinfo) + ) + ); + } + test_field_shinfo(); + fn test_field_dynfield1() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dynfield1) as usize - ptr as usize + }, + 112usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf), + "::", + stringify!(dynfield1) + ) + ); + } + test_field_dynfield1(); } impl Default for rte_mbuf { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type rte_mbuf_extbuf_free_callback_t = ::std::option::Option< @@ -8087,46 +10346,65 @@ fn bindgen_test_layout_rte_mbuf_ext_shared_info() { 8usize, concat!("Alignment of ", stringify!(rte_mbuf_ext_shared_info)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).free_cb as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf_ext_shared_info), - "::", - stringify!(free_cb) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).fcb_opaque as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf_ext_shared_info), - "::", - stringify!(fcb_opaque) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).refcnt_atomic as *const _ as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf_ext_shared_info), - "::", - stringify!(refcnt_atomic) - ) - ); + fn test_field_free_cb() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).free_cb) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf_ext_shared_info), + "::", + stringify!(free_cb) + ) + ); + } + test_field_free_cb(); + fn test_field_fcb_opaque() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).fcb_opaque) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf_ext_shared_info), + "::", + stringify!(fcb_opaque) + ) + ); + } + test_field_fcb_opaque(); + fn test_field_refcnt_atomic() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).refcnt_atomic) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf_ext_shared_info), + "::", + stringify!(refcnt_atomic) + ) + ); + } + test_field_refcnt_atomic(); } impl Default for rte_mbuf_ext_shared_info { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } extern "C" { @@ -8168,41 +10446,57 @@ fn bindgen_test_layout_rte_pktmbuf_pool_private() { 4usize, concat!("Alignment of ", stringify!(rte_pktmbuf_pool_private)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mbuf_data_room_size as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_pktmbuf_pool_private), - "::", - stringify!(mbuf_data_room_size) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mbuf_priv_size as *const _ as usize - }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_pktmbuf_pool_private), - "::", - stringify!(mbuf_priv_size) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_pktmbuf_pool_private), - "::", - stringify!(flags) - ) - ); + fn test_field_mbuf_data_room_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mbuf_data_room_size) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_pktmbuf_pool_private), + "::", + stringify!(mbuf_data_room_size) + ) + ); + } + test_field_mbuf_data_room_size(); + fn test_field_mbuf_priv_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mbuf_priv_size) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_pktmbuf_pool_private), + "::", + stringify!(mbuf_priv_size) + ) + ); + } + test_field_mbuf_priv_size(); + fn test_field_flags() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_pktmbuf_pool_private), + "::", + stringify!(flags) + ) + ); + } + test_field_flags(); } extern "C" { pub fn rte_mbuf_sanity_check(m: *const rte_mbuf, is_header: ::std::os::raw::c_int); @@ -8281,16 +10575,23 @@ fn bindgen_test_layout_rte_ether_addr() { 2usize, concat!("Alignment of ", stringify!(rte_ether_addr)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr_bytes as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_ether_addr), - "::", - stringify!(addr_bytes) - ) - ); + fn test_field_addr_bytes() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).addr_bytes) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_ether_addr), + "::", + stringify!(addr_bytes) + ) + ); + } + test_field_addr_bytes(); } extern "C" { pub fn rte_eth_random_addr(addr: *mut u8); @@ -8327,36 +10628,57 @@ fn bindgen_test_layout_rte_ether_hdr() { 2usize, concat!("Alignment of ", stringify!(rte_ether_hdr)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).d_addr as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_ether_hdr), - "::", - stringify!(d_addr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).s_addr as *const _ as usize }, - 6usize, - concat!( - "Offset of field: ", - stringify!(rte_ether_hdr), - "::", - stringify!(s_addr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ether_type as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(rte_ether_hdr), - "::", - stringify!(ether_type) - ) - ); + fn test_field_d_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).d_addr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_ether_hdr), + "::", + stringify!(d_addr) + ) + ); + } + test_field_d_addr(); + fn test_field_s_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).s_addr) as usize - ptr as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(rte_ether_hdr), + "::", + stringify!(s_addr) + ) + ); + } + test_field_s_addr(); + fn test_field_ether_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ether_type) as usize - ptr as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(rte_ether_hdr), + "::", + stringify!(ether_type) + ) + ); + } + test_field_ether_type(); } #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -8376,26 +10698,40 @@ fn bindgen_test_layout_rte_vlan_hdr() { 1usize, concat!("Alignment of ", stringify!(rte_vlan_hdr)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).vlan_tci as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_vlan_hdr), - "::", - stringify!(vlan_tci) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).eth_proto as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_vlan_hdr), - "::", - stringify!(eth_proto) - ) - ); + fn test_field_vlan_tci() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vlan_tci) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_vlan_hdr), + "::", + stringify!(vlan_tci) + ) + ); + } + test_field_vlan_tci(); + fn test_field_eth_proto() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).eth_proto) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_vlan_hdr), + "::", + stringify!(eth_proto) + ) + ); + } + test_field_eth_proto(); } #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq)] @@ -8418,60 +10754,99 @@ fn bindgen_test_layout_rte_dev_reg_info() { 8usize, concat!("Alignment of ", stringify!(rte_dev_reg_info)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_dev_reg_info), - "::", - stringify!(data) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).offset as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_dev_reg_info), - "::", - stringify!(offset) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).length as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(rte_dev_reg_info), - "::", - stringify!(length) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).width as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_dev_reg_info), - "::", - stringify!(width) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).version as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(rte_dev_reg_info), - "::", - stringify!(version) - ) - ); + fn test_field_data() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_dev_reg_info), + "::", + stringify!(data) + ) + ); + } + test_field_data(); + fn test_field_offset() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).offset) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_dev_reg_info), + "::", + stringify!(offset) + ) + ); + } + test_field_offset(); + fn test_field_length() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).length) as usize - ptr as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(rte_dev_reg_info), + "::", + stringify!(length) + ) + ); + } + test_field_length(); + fn test_field_width() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).width) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_dev_reg_info), + "::", + stringify!(width) + ) + ); + } + test_field_width(); + fn test_field_version() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).version) as usize - ptr as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(rte_dev_reg_info), + "::", + stringify!(version) + ) + ); + } + test_field_version(); } impl Default for rte_dev_reg_info { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -8494,50 +10869,82 @@ fn bindgen_test_layout_rte_dev_eeprom_info() { 8usize, concat!("Alignment of ", stringify!(rte_dev_eeprom_info)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_dev_eeprom_info), - "::", - stringify!(data) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).offset as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_dev_eeprom_info), - "::", - stringify!(offset) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).length as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(rte_dev_eeprom_info), - "::", - stringify!(length) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).magic as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_dev_eeprom_info), - "::", - stringify!(magic) - ) - ); + fn test_field_data() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_dev_eeprom_info), + "::", + stringify!(data) + ) + ); + } + test_field_data(); + fn test_field_offset() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).offset) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_dev_eeprom_info), + "::", + stringify!(offset) + ) + ); + } + test_field_offset(); + fn test_field_length() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).length) as usize - ptr as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(rte_dev_eeprom_info), + "::", + stringify!(length) + ) + ); + } + test_field_length(); + fn test_field_magic() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).magic) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_dev_eeprom_info), + "::", + stringify!(magic) + ) + ); + } + test_field_magic(); } impl Default for rte_dev_eeprom_info { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -8558,28 +10965,40 @@ fn bindgen_test_layout_rte_eth_dev_module_info() { 4usize, concat!("Alignment of ", stringify!(rte_eth_dev_module_info)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_module_info), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).eeprom_len as *const _ as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_module_info), - "::", - stringify!(eeprom_len) - ) - ); + fn test_field_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_module_info), + "::", + stringify!(type_) + ) + ); + } + test_field_type(); + fn test_field_eeprom_len() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).eeprom_len) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_module_info), + "::", + stringify!(eeprom_len) + ) + ); + } + test_field_eeprom_len(); } extern "C" { pub static mut rte_eth_dev_logtype: ::std::os::raw::c_int; @@ -8625,136 +11044,227 @@ fn bindgen_test_layout_rte_eth_stats() { 8usize, concat!("Alignment of ", stringify!(rte_eth_stats)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ipackets as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_stats), - "::", - stringify!(ipackets) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).opackets as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_stats), - "::", - stringify!(opackets) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ibytes as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_stats), - "::", - stringify!(ibytes) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).obytes as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_stats), - "::", - stringify!(obytes) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).imissed as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_stats), - "::", - stringify!(imissed) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ierrors as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_stats), - "::", - stringify!(ierrors) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).oerrors as *const _ as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_stats), - "::", - stringify!(oerrors) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rx_nombuf as *const _ as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_stats), - "::", - stringify!(rx_nombuf) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).q_ipackets as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_stats), - "::", - stringify!(q_ipackets) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).q_opackets as *const _ as usize }, - 192usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_stats), - "::", - stringify!(q_opackets) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).q_ibytes as *const _ as usize }, - 320usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_stats), - "::", - stringify!(q_ibytes) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).q_obytes as *const _ as usize }, - 448usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_stats), - "::", - stringify!(q_obytes) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).q_errors as *const _ as usize }, - 576usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_stats), - "::", - stringify!(q_errors) - ) - ); + fn test_field_ipackets() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ipackets) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_stats), + "::", + stringify!(ipackets) + ) + ); + } + test_field_ipackets(); + fn test_field_opackets() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).opackets) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_stats), + "::", + stringify!(opackets) + ) + ); + } + test_field_opackets(); + fn test_field_ibytes() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ibytes) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_stats), + "::", + stringify!(ibytes) + ) + ); + } + test_field_ibytes(); + fn test_field_obytes() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).obytes) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_stats), + "::", + stringify!(obytes) + ) + ); + } + test_field_obytes(); + fn test_field_imissed() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).imissed) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_stats), + "::", + stringify!(imissed) + ) + ); + } + test_field_imissed(); + fn test_field_ierrors() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ierrors) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_stats), + "::", + stringify!(ierrors) + ) + ); + } + test_field_ierrors(); + fn test_field_oerrors() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).oerrors) as usize - ptr as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_stats), + "::", + stringify!(oerrors) + ) + ); + } + test_field_oerrors(); + fn test_field_rx_nombuf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_nombuf) as usize - ptr as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_stats), + "::", + stringify!(rx_nombuf) + ) + ); + } + test_field_rx_nombuf(); + fn test_field_q_ipackets() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).q_ipackets) as usize - ptr as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_stats), + "::", + stringify!(q_ipackets) + ) + ); + } + test_field_q_ipackets(); + fn test_field_q_opackets() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).q_opackets) as usize - ptr as usize + }, + 192usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_stats), + "::", + stringify!(q_opackets) + ) + ); + } + test_field_q_opackets(); + fn test_field_q_ibytes() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).q_ibytes) as usize - ptr as usize + }, + 320usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_stats), + "::", + stringify!(q_ibytes) + ) + ); + } + test_field_q_ibytes(); + fn test_field_q_obytes() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).q_obytes) as usize - ptr as usize + }, + 448usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_stats), + "::", + stringify!(q_obytes) + ) + ); + } + test_field_q_obytes(); + fn test_field_q_errors() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).q_errors) as usize - ptr as usize + }, + 576usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_stats), + "::", + stringify!(q_errors) + ) + ); + } + test_field_q_errors(); } #[repr(C)] #[repr(align(8))] @@ -8777,16 +11287,23 @@ fn bindgen_test_layout_rte_eth_link() { 8usize, concat!("Alignment of ", stringify!(rte_eth_link)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).link_speed as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_link), - "::", - stringify!(link_speed) - ) - ); + fn test_field_link_speed() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).link_speed) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_link), + "::", + stringify!(link_speed) + ) + ); + } + test_field_link_speed(); } impl rte_eth_link { #[inline] @@ -8863,36 +11380,57 @@ fn bindgen_test_layout_rte_eth_thresh() { 1usize, concat!("Alignment of ", stringify!(rte_eth_thresh)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pthresh as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_thresh), - "::", - stringify!(pthresh) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).hthresh as *const _ as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_thresh), - "::", - stringify!(hthresh) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).wthresh as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_thresh), - "::", - stringify!(wthresh) - ) - ); + fn test_field_pthresh() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pthresh) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_thresh), + "::", + stringify!(pthresh) + ) + ); + } + test_field_pthresh(); + fn test_field_hthresh() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).hthresh) as usize - ptr as usize + }, + 1usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_thresh), + "::", + stringify!(hthresh) + ) + ); + } + test_field_hthresh(); + fn test_field_wthresh() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).wthresh) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_thresh), + "::", + stringify!(wthresh) + ) + ); + } + test_field_wthresh(); } pub mod rte_eth_rx_mq_mode { pub type Type = ::std::os::raw::c_uint; @@ -8935,80 +11473,133 @@ fn bindgen_test_layout_rte_eth_rxmode() { 8usize, concat!("Alignment of ", stringify!(rte_eth_rxmode)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mq_mode as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_rxmode), - "::", - stringify!(mq_mode) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).max_rx_pkt_len as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_rxmode), - "::", - stringify!(max_rx_pkt_len) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).max_lro_pkt_size as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_rxmode), - "::", - stringify!(max_lro_pkt_size) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).split_hdr_size as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_rxmode), - "::", - stringify!(split_hdr_size) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).offloads as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_rxmode), - "::", - stringify!(offloads) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved_64s as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_rxmode), - "::", - stringify!(reserved_64s) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved_ptrs as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_rxmode), - "::", - stringify!(reserved_ptrs) - ) - ); + fn test_field_mq_mode() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mq_mode) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_rxmode), + "::", + stringify!(mq_mode) + ) + ); + } + test_field_mq_mode(); + fn test_field_max_rx_pkt_len() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).max_rx_pkt_len) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_rxmode), + "::", + stringify!(max_rx_pkt_len) + ) + ); + } + test_field_max_rx_pkt_len(); + fn test_field_max_lro_pkt_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).max_lro_pkt_size) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_rxmode), + "::", + stringify!(max_lro_pkt_size) + ) + ); + } + test_field_max_lro_pkt_size(); + fn test_field_split_hdr_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).split_hdr_size) as usize - ptr as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_rxmode), + "::", + stringify!(split_hdr_size) + ) + ); + } + test_field_split_hdr_size(); + fn test_field_offloads() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).offloads) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_rxmode), + "::", + stringify!(offloads) + ) + ); + } + test_field_offloads(); + fn test_field_reserved_64s() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).reserved_64s) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_rxmode), + "::", + stringify!(reserved_64s) + ) + ); + } + test_field_reserved_64s(); + fn test_field_reserved_ptrs() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).reserved_ptrs) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_rxmode), + "::", + stringify!(reserved_ptrs) + ) + ); + } + test_field_reserved_ptrs(); } impl Default for rte_eth_rxmode { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub mod rte_vlan_type { @@ -9019,7 +11610,7 @@ pub mod rte_vlan_type { pub const ETH_VLAN_TYPE_MAX: Type = 3; } #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct rte_vlan_filter_conf { pub ids: [u64; 64usize], } @@ -9035,20 +11626,31 @@ fn bindgen_test_layout_rte_vlan_filter_conf() { 8usize, concat!("Alignment of ", stringify!(rte_vlan_filter_conf)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ids as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_vlan_filter_conf), - "::", - stringify!(ids) - ) - ); + fn test_field_ids() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ids) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_vlan_filter_conf), + "::", + stringify!(ids) + ) + ); + } + test_field_ids(); } impl Default for rte_vlan_filter_conf { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -9070,44 +11672,69 @@ fn bindgen_test_layout_rte_eth_rss_conf() { 8usize, concat!("Alignment of ", stringify!(rte_eth_rss_conf)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rss_key as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_rss_conf), - "::", - stringify!(rss_key) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rss_key_len as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_rss_conf), - "::", - stringify!(rss_key_len) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rss_hf as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_rss_conf), - "::", - stringify!(rss_hf) - ) - ); + fn test_field_rss_key() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rss_key) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_rss_conf), + "::", + stringify!(rss_key) + ) + ); + } + test_field_rss_key(); + fn test_field_rss_key_len() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rss_key_len) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_rss_conf), + "::", + stringify!(rss_key_len) + ) + ); + } + test_field_rss_key_len(); + fn test_field_rss_hf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rss_hf) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_rss_conf), + "::", + stringify!(rss_hf) + ) + ); + } + test_field_rss_hf(); } impl Default for rte_eth_rss_conf { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct rte_eth_vlan_mirror { pub vlan_mask: u64, pub vlan_id: [u16; 64usize], @@ -9124,34 +11751,52 @@ fn bindgen_test_layout_rte_eth_vlan_mirror() { 8usize, concat!("Alignment of ", stringify!(rte_eth_vlan_mirror)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).vlan_mask as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_vlan_mirror), - "::", - stringify!(vlan_mask) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).vlan_id as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_vlan_mirror), - "::", - stringify!(vlan_id) - ) - ); + fn test_field_vlan_mask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vlan_mask) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_vlan_mirror), + "::", + stringify!(vlan_mask) + ) + ); + } + test_field_vlan_mask(); + fn test_field_vlan_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vlan_id) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_vlan_mirror), + "::", + stringify!(vlan_id) + ) + ); + } + test_field_vlan_id(); } impl Default for rte_eth_vlan_mirror { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct rte_eth_mirror_conf { pub rule_type: u8, pub dst_pool: u8, @@ -9170,54 +11815,86 @@ fn bindgen_test_layout_rte_eth_mirror_conf() { 8usize, concat!("Alignment of ", stringify!(rte_eth_mirror_conf)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rule_type as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_mirror_conf), - "::", - stringify!(rule_type) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dst_pool as *const _ as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_mirror_conf), - "::", - stringify!(dst_pool) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pool_mask as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_mirror_conf), - "::", - stringify!(pool_mask) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).vlan as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_mirror_conf), - "::", - stringify!(vlan) - ) - ); + fn test_field_rule_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rule_type) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_mirror_conf), + "::", + stringify!(rule_type) + ) + ); + } + test_field_rule_type(); + fn test_field_dst_pool() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dst_pool) as usize - ptr as usize + }, + 1usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_mirror_conf), + "::", + stringify!(dst_pool) + ) + ); + } + test_field_dst_pool(); + fn test_field_pool_mask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pool_mask) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_mirror_conf), + "::", + stringify!(pool_mask) + ) + ); + } + test_field_pool_mask(); + fn test_field_vlan() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vlan) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_mirror_conf), + "::", + stringify!(vlan) + ) + ); + } + test_field_vlan(); } impl Default for rte_eth_mirror_conf { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct rte_eth_rss_reta_entry64 { pub mask: u64, pub reta: [u16; 64usize], @@ -9234,30 +11911,48 @@ fn bindgen_test_layout_rte_eth_rss_reta_entry64() { 8usize, concat!("Alignment of ", stringify!(rte_eth_rss_reta_entry64)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mask as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_rss_reta_entry64), - "::", - stringify!(mask) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).reta as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_rss_reta_entry64), - "::", - stringify!(reta) - ) - ); + fn test_field_mask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mask) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_rss_reta_entry64), + "::", + stringify!(mask) + ) + ); + } + test_field_mask(); + fn test_field_reta() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).reta) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_rss_reta_entry64), + "::", + stringify!(reta) + ) + ); + } + test_field_reta(); } impl Default for rte_eth_rss_reta_entry64 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub mod rte_eth_nb_tcs { @@ -9290,30 +11985,48 @@ fn bindgen_test_layout_rte_eth_dcb_rx_conf() { 4usize, concat!("Alignment of ", stringify!(rte_eth_dcb_rx_conf)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).nb_tcs as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dcb_rx_conf), - "::", - stringify!(nb_tcs) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dcb_tc as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dcb_rx_conf), - "::", - stringify!(dcb_tc) - ) - ); + fn test_field_nb_tcs() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_tcs) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dcb_rx_conf), + "::", + stringify!(nb_tcs) + ) + ); + } + test_field_nb_tcs(); + fn test_field_dcb_tc() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dcb_tc) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dcb_rx_conf), + "::", + stringify!(dcb_tc) + ) + ); + } + test_field_dcb_tc(); } impl Default for rte_eth_dcb_rx_conf { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -9334,32 +12047,48 @@ fn bindgen_test_layout_rte_eth_vmdq_dcb_tx_conf() { 4usize, concat!("Alignment of ", stringify!(rte_eth_vmdq_dcb_tx_conf)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).nb_queue_pools as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_vmdq_dcb_tx_conf), - "::", - stringify!(nb_queue_pools) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dcb_tc as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_vmdq_dcb_tx_conf), - "::", - stringify!(dcb_tc) - ) - ); + fn test_field_nb_queue_pools() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_queue_pools) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_vmdq_dcb_tx_conf), + "::", + stringify!(nb_queue_pools) + ) + ); + } + test_field_nb_queue_pools(); + fn test_field_dcb_tc() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dcb_tc) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_vmdq_dcb_tx_conf), + "::", + stringify!(dcb_tc) + ) + ); + } + test_field_dcb_tc(); } impl Default for rte_eth_vmdq_dcb_tx_conf { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -9380,30 +12109,48 @@ fn bindgen_test_layout_rte_eth_dcb_tx_conf() { 4usize, concat!("Alignment of ", stringify!(rte_eth_dcb_tx_conf)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).nb_tcs as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dcb_tx_conf), - "::", - stringify!(nb_tcs) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dcb_tc as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dcb_tx_conf), - "::", - stringify!(dcb_tc) - ) - ); + fn test_field_nb_tcs() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_tcs) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dcb_tx_conf), + "::", + stringify!(nb_tcs) + ) + ); + } + test_field_nb_tcs(); + fn test_field_dcb_tc() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dcb_tc) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dcb_tx_conf), + "::", + stringify!(dcb_tc) + ) + ); + } + test_field_dcb_tc(); } impl Default for rte_eth_dcb_tx_conf { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -9423,26 +12170,35 @@ fn bindgen_test_layout_rte_eth_vmdq_tx_conf() { 4usize, concat!("Alignment of ", stringify!(rte_eth_vmdq_tx_conf)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).nb_queue_pools as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_vmdq_tx_conf), - "::", - stringify!(nb_queue_pools) - ) - ); + fn test_field_nb_queue_pools() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_queue_pools) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_vmdq_tx_conf), + "::", + stringify!(nb_queue_pools) + ) + ); + } + test_field_nb_queue_pools(); } impl Default for rte_eth_vmdq_tx_conf { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct rte_eth_vmdq_dcb_conf { pub nb_queue_pools: rte_eth_nb_pools::Type, pub enable_default_pool: u8, @@ -9472,32 +12228,42 @@ fn bindgen_test_layout_rte_eth_vmdq_dcb_conf__bindgen_ty_1() { stringify!(rte_eth_vmdq_dcb_conf__bindgen_ty_1) ) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).vlan_id as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_vmdq_dcb_conf__bindgen_ty_1), - "::", - stringify!(vlan_id) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pools as *const _ - as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_vmdq_dcb_conf__bindgen_ty_1), - "::", - stringify!(pools) - ) - ); + fn test_field_vlan_id() { + assert_eq!( + unsafe { + let uninit = + ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vlan_id) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_vmdq_dcb_conf__bindgen_ty_1), + "::", + stringify!(vlan_id) + ) + ); + } + test_field_vlan_id(); + fn test_field_pools() { + assert_eq!( + unsafe { + let uninit = + ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pools) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_vmdq_dcb_conf__bindgen_ty_1), + "::", + stringify!(pools) + ) + ); + } + test_field_pools(); } #[test] fn bindgen_test_layout_rte_eth_vmdq_dcb_conf() { @@ -9511,83 +12277,120 @@ fn bindgen_test_layout_rte_eth_vmdq_dcb_conf() { 8usize, concat!("Alignment of ", stringify!(rte_eth_vmdq_dcb_conf)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).nb_queue_pools as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_vmdq_dcb_conf), - "::", - stringify!(nb_queue_pools) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).enable_default_pool as *const _ - as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_vmdq_dcb_conf), - "::", - stringify!(enable_default_pool) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).default_pool as *const _ as usize - }, - 5usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_vmdq_dcb_conf), - "::", - stringify!(default_pool) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).nb_pool_maps as *const _ as usize - }, - 6usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_vmdq_dcb_conf), - "::", - stringify!(nb_pool_maps) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pool_map as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_vmdq_dcb_conf), - "::", - stringify!(pool_map) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dcb_tc as *const _ as usize }, - 1032usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_vmdq_dcb_conf), - "::", - stringify!(dcb_tc) - ) - ); + fn test_field_nb_queue_pools() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_queue_pools) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_vmdq_dcb_conf), + "::", + stringify!(nb_queue_pools) + ) + ); + } + test_field_nb_queue_pools(); + fn test_field_enable_default_pool() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).enable_default_pool) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_vmdq_dcb_conf), + "::", + stringify!(enable_default_pool) + ) + ); + } + test_field_enable_default_pool(); + fn test_field_default_pool() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).default_pool) as usize - ptr as usize + }, + 5usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_vmdq_dcb_conf), + "::", + stringify!(default_pool) + ) + ); + } + test_field_default_pool(); + fn test_field_nb_pool_maps() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_pool_maps) as usize - ptr as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_vmdq_dcb_conf), + "::", + stringify!(nb_pool_maps) + ) + ); + } + test_field_nb_pool_maps(); + fn test_field_pool_map() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pool_map) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_vmdq_dcb_conf), + "::", + stringify!(pool_map) + ) + ); + } + test_field_pool_map(); + fn test_field_dcb_tc() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dcb_tc) as usize - ptr as usize + }, + 1032usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_vmdq_dcb_conf), + "::", + stringify!(dcb_tc) + ) + ); + } + test_field_dcb_tc(); } impl Default for rte_eth_vmdq_dcb_conf { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct rte_eth_vmdq_rx_conf { pub nb_queue_pools: rte_eth_nb_pools::Type, pub enable_default_pool: u8, @@ -9618,32 +12421,42 @@ fn bindgen_test_layout_rte_eth_vmdq_rx_conf__bindgen_ty_1() { stringify!(rte_eth_vmdq_rx_conf__bindgen_ty_1) ) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).vlan_id as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_vmdq_rx_conf__bindgen_ty_1), - "::", - stringify!(vlan_id) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pools as *const _ - as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_vmdq_rx_conf__bindgen_ty_1), - "::", - stringify!(pools) - ) - ); + fn test_field_vlan_id() { + assert_eq!( + unsafe { + let uninit = + ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vlan_id) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_vmdq_rx_conf__bindgen_ty_1), + "::", + stringify!(vlan_id) + ) + ); + } + test_field_vlan_id(); + fn test_field_pools() { + assert_eq!( + unsafe { + let uninit = + ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pools) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_vmdq_rx_conf__bindgen_ty_1), + "::", + stringify!(pools) + ) + ); + } + test_field_pools(); } #[test] fn bindgen_test_layout_rte_eth_vmdq_rx_conf() { @@ -9657,91 +12470,133 @@ fn bindgen_test_layout_rte_eth_vmdq_rx_conf() { 8usize, concat!("Alignment of ", stringify!(rte_eth_vmdq_rx_conf)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).nb_queue_pools as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_vmdq_rx_conf), - "::", - stringify!(nb_queue_pools) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).enable_default_pool as *const _ - as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_vmdq_rx_conf), - "::", - stringify!(enable_default_pool) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).default_pool as *const _ as usize - }, - 5usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_vmdq_rx_conf), - "::", - stringify!(default_pool) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).enable_loop_back as *const _ as usize - }, - 6usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_vmdq_rx_conf), - "::", - stringify!(enable_loop_back) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).nb_pool_maps as *const _ as usize - }, - 7usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_vmdq_rx_conf), - "::", - stringify!(nb_pool_maps) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rx_mode as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_vmdq_rx_conf), - "::", - stringify!(rx_mode) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pool_map as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_vmdq_rx_conf), - "::", - stringify!(pool_map) - ) - ); + fn test_field_nb_queue_pools() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_queue_pools) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_vmdq_rx_conf), + "::", + stringify!(nb_queue_pools) + ) + ); + } + test_field_nb_queue_pools(); + fn test_field_enable_default_pool() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).enable_default_pool) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_vmdq_rx_conf), + "::", + stringify!(enable_default_pool) + ) + ); + } + test_field_enable_default_pool(); + fn test_field_default_pool() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).default_pool) as usize - ptr as usize + }, + 5usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_vmdq_rx_conf), + "::", + stringify!(default_pool) + ) + ); + } + test_field_default_pool(); + fn test_field_enable_loop_back() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).enable_loop_back) as usize - ptr as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_vmdq_rx_conf), + "::", + stringify!(enable_loop_back) + ) + ); + } + test_field_enable_loop_back(); + fn test_field_nb_pool_maps() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_pool_maps) as usize - ptr as usize + }, + 7usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_vmdq_rx_conf), + "::", + stringify!(nb_pool_maps) + ) + ); + } + test_field_nb_pool_maps(); + fn test_field_rx_mode() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_mode) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_vmdq_rx_conf), + "::", + stringify!(rx_mode) + ) + ); + } + test_field_rx_mode(); + fn test_field_pool_map() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pool_map) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_vmdq_rx_conf), + "::", + stringify!(pool_map) + ) + ); + } + test_field_pool_map(); } impl Default for rte_eth_vmdq_rx_conf { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -9767,60 +12622,99 @@ fn bindgen_test_layout_rte_eth_txmode() { 8usize, concat!("Alignment of ", stringify!(rte_eth_txmode)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mq_mode as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_txmode), - "::", - stringify!(mq_mode) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).offloads as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_txmode), - "::", - stringify!(offloads) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pvid as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_txmode), - "::", - stringify!(pvid) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved_64s as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_txmode), - "::", - stringify!(reserved_64s) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved_ptrs as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_txmode), - "::", - stringify!(reserved_ptrs) - ) - ); + fn test_field_mq_mode() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mq_mode) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_txmode), + "::", + stringify!(mq_mode) + ) + ); + } + test_field_mq_mode(); + fn test_field_offloads() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).offloads) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_txmode), + "::", + stringify!(offloads) + ) + ); + } + test_field_offloads(); + fn test_field_pvid() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pvid) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_txmode), + "::", + stringify!(pvid) + ) + ); + } + test_field_pvid(); + fn test_field_reserved_64s() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).reserved_64s) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_txmode), + "::", + stringify!(reserved_64s) + ) + ); + } + test_field_reserved_64s(); + fn test_field_reserved_ptrs() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).reserved_ptrs) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_txmode), + "::", + stringify!(reserved_ptrs) + ) + ); + } + test_field_reserved_ptrs(); } impl Default for rte_eth_txmode { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } impl rte_eth_txmode { @@ -9903,82 +12797,133 @@ fn bindgen_test_layout_rte_eth_rxconf() { 8usize, concat!("Alignment of ", stringify!(rte_eth_rxconf)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rx_thresh as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_rxconf), - "::", - stringify!(rx_thresh) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rx_free_thresh as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_rxconf), - "::", - stringify!(rx_free_thresh) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rx_drop_en as *const _ as usize }, - 6usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_rxconf), - "::", - stringify!(rx_drop_en) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).rx_deferred_start as *const _ as usize - }, - 7usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_rxconf), - "::", - stringify!(rx_deferred_start) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).offloads as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_rxconf), - "::", - stringify!(offloads) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved_64s as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_rxconf), - "::", - stringify!(reserved_64s) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved_ptrs as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_rxconf), - "::", - stringify!(reserved_ptrs) - ) - ); + fn test_field_rx_thresh() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_thresh) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_rxconf), + "::", + stringify!(rx_thresh) + ) + ); + } + test_field_rx_thresh(); + fn test_field_rx_free_thresh() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_free_thresh) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_rxconf), + "::", + stringify!(rx_free_thresh) + ) + ); + } + test_field_rx_free_thresh(); + fn test_field_rx_drop_en() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_drop_en) as usize - ptr as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_rxconf), + "::", + stringify!(rx_drop_en) + ) + ); + } + test_field_rx_drop_en(); + fn test_field_rx_deferred_start() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_deferred_start) as usize - ptr as usize + }, + 7usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_rxconf), + "::", + stringify!(rx_deferred_start) + ) + ); + } + test_field_rx_deferred_start(); + fn test_field_offloads() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).offloads) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_rxconf), + "::", + stringify!(offloads) + ) + ); + } + test_field_offloads(); + fn test_field_reserved_64s() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).reserved_64s) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_rxconf), + "::", + stringify!(reserved_64s) + ) + ); + } + test_field_reserved_64s(); + fn test_field_reserved_ptrs() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).reserved_ptrs) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_rxconf), + "::", + stringify!(reserved_ptrs) + ) + ); + } + test_field_reserved_ptrs(); } impl Default for rte_eth_rxconf { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -10004,82 +12949,133 @@ fn bindgen_test_layout_rte_eth_txconf() { 8usize, concat!("Alignment of ", stringify!(rte_eth_txconf)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tx_thresh as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_txconf), - "::", - stringify!(tx_thresh) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tx_rs_thresh as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_txconf), - "::", - stringify!(tx_rs_thresh) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tx_free_thresh as *const _ as usize }, - 6usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_txconf), - "::", - stringify!(tx_free_thresh) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).tx_deferred_start as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_txconf), - "::", - stringify!(tx_deferred_start) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).offloads as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_txconf), - "::", - stringify!(offloads) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved_64s as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_txconf), - "::", - stringify!(reserved_64s) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved_ptrs as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_txconf), - "::", - stringify!(reserved_ptrs) - ) - ); + fn test_field_tx_thresh() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tx_thresh) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_txconf), + "::", + stringify!(tx_thresh) + ) + ); + } + test_field_tx_thresh(); + fn test_field_tx_rs_thresh() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tx_rs_thresh) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_txconf), + "::", + stringify!(tx_rs_thresh) + ) + ); + } + test_field_tx_rs_thresh(); + fn test_field_tx_free_thresh() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tx_free_thresh) as usize - ptr as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_txconf), + "::", + stringify!(tx_free_thresh) + ) + ); + } + test_field_tx_free_thresh(); + fn test_field_tx_deferred_start() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tx_deferred_start) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_txconf), + "::", + stringify!(tx_deferred_start) + ) + ); + } + test_field_tx_deferred_start(); + fn test_field_offloads() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).offloads) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_txconf), + "::", + stringify!(offloads) + ) + ); + } + test_field_offloads(); + fn test_field_reserved_64s() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).reserved_64s) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_txconf), + "::", + stringify!(reserved_64s) + ) + ); + } + test_field_reserved_64s(); + fn test_field_reserved_ptrs() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).reserved_ptrs) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_txconf), + "::", + stringify!(reserved_ptrs) + ) + ); + } + test_field_reserved_ptrs(); } impl Default for rte_eth_txconf { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -10102,48 +13098,74 @@ fn bindgen_test_layout_rte_eth_hairpin_cap() { 2usize, concat!("Alignment of ", stringify!(rte_eth_hairpin_cap)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).max_nb_queues as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_hairpin_cap), - "::", - stringify!(max_nb_queues) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).max_rx_2_tx as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_hairpin_cap), - "::", - stringify!(max_rx_2_tx) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).max_tx_2_rx as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_hairpin_cap), - "::", - stringify!(max_tx_2_rx) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).max_nb_desc as *const _ as usize }, - 6usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_hairpin_cap), - "::", - stringify!(max_nb_desc) - ) - ); + fn test_field_max_nb_queues() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).max_nb_queues) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_hairpin_cap), + "::", + stringify!(max_nb_queues) + ) + ); + } + test_field_max_nb_queues(); + fn test_field_max_rx_2_tx() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).max_rx_2_tx) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_hairpin_cap), + "::", + stringify!(max_rx_2_tx) + ) + ); + } + test_field_max_rx_2_tx(); + fn test_field_max_tx_2_rx() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).max_tx_2_rx) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_hairpin_cap), + "::", + stringify!(max_tx_2_rx) + ) + ); + } + test_field_max_tx_2_rx(); + fn test_field_max_nb_desc() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).max_nb_desc) as usize - ptr as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_hairpin_cap), + "::", + stringify!(max_nb_desc) + ) + ); + } + test_field_max_nb_desc(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -10163,26 +13185,40 @@ fn bindgen_test_layout_rte_eth_hairpin_peer() { 2usize, concat!("Alignment of ", stringify!(rte_eth_hairpin_peer)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).port as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_hairpin_peer), - "::", - stringify!(port) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).queue as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_hairpin_peer), - "::", - stringify!(queue) - ) - ); + fn test_field_port() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).port) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_hairpin_peer), + "::", + stringify!(port) + ) + ); + } + test_field_port(); + fn test_field_queue() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).queue) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_hairpin_peer), + "::", + stringify!(queue) + ) + ); + } + test_field_queue(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -10202,26 +13238,40 @@ fn bindgen_test_layout_rte_eth_hairpin_conf() { 2usize, concat!("Alignment of ", stringify!(rte_eth_hairpin_conf)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).peer_count as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_hairpin_conf), - "::", - stringify!(peer_count) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).peers as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_hairpin_conf), - "::", - stringify!(peers) - ) - ); + fn test_field_peer_count() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).peer_count) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_hairpin_conf), + "::", + stringify!(peer_count) + ) + ); + } + test_field_peer_count(); + fn test_field_peers() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).peers) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_hairpin_conf), + "::", + stringify!(peers) + ) + ); + } + test_field_peers(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -10244,56 +13294,91 @@ fn bindgen_test_layout_rte_eth_desc_lim() { 2usize, concat!("Alignment of ", stringify!(rte_eth_desc_lim)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).nb_max as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_desc_lim), - "::", - stringify!(nb_max) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).nb_min as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_desc_lim), - "::", - stringify!(nb_min) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).nb_align as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_desc_lim), - "::", - stringify!(nb_align) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).nb_seg_max as *const _ as usize }, - 6usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_desc_lim), - "::", - stringify!(nb_seg_max) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).nb_mtu_seg_max as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_desc_lim), - "::", - stringify!(nb_mtu_seg_max) - ) - ); + fn test_field_nb_max() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_max) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_desc_lim), + "::", + stringify!(nb_max) + ) + ); + } + test_field_nb_max(); + fn test_field_nb_min() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_min) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_desc_lim), + "::", + stringify!(nb_min) + ) + ); + } + test_field_nb_min(); + fn test_field_nb_align() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_align) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_desc_lim), + "::", + stringify!(nb_align) + ) + ); + } + test_field_nb_align(); + fn test_field_nb_seg_max() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_seg_max) as usize - ptr as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_desc_lim), + "::", + stringify!(nb_seg_max) + ) + ); + } + test_field_nb_seg_max(); + fn test_field_nb_mtu_seg_max() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_mtu_seg_max) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_desc_lim), + "::", + stringify!(nb_mtu_seg_max) + ) + ); + } + test_field_nb_mtu_seg_max(); } pub mod rte_eth_fc_mode { pub type Type = ::std::os::raw::c_uint; @@ -10325,82 +13410,133 @@ fn bindgen_test_layout_rte_eth_fc_conf() { 4usize, concat!("Alignment of ", stringify!(rte_eth_fc_conf)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).high_water as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fc_conf), - "::", - stringify!(high_water) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).low_water as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fc_conf), - "::", - stringify!(low_water) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pause_time as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fc_conf), - "::", - stringify!(pause_time) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).send_xon as *const _ as usize }, - 10usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fc_conf), - "::", - stringify!(send_xon) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mode as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fc_conf), - "::", - stringify!(mode) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mac_ctrl_frame_fwd as *const _ as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fc_conf), - "::", - stringify!(mac_ctrl_frame_fwd) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).autoneg as *const _ as usize }, - 17usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fc_conf), - "::", - stringify!(autoneg) - ) - ); + fn test_field_high_water() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).high_water) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fc_conf), + "::", + stringify!(high_water) + ) + ); + } + test_field_high_water(); + fn test_field_low_water() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).low_water) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fc_conf), + "::", + stringify!(low_water) + ) + ); + } + test_field_low_water(); + fn test_field_pause_time() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pause_time) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fc_conf), + "::", + stringify!(pause_time) + ) + ); + } + test_field_pause_time(); + fn test_field_send_xon() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).send_xon) as usize - ptr as usize + }, + 10usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fc_conf), + "::", + stringify!(send_xon) + ) + ); + } + test_field_send_xon(); + fn test_field_mode() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mode) as usize - ptr as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fc_conf), + "::", + stringify!(mode) + ) + ); + } + test_field_mode(); + fn test_field_mac_ctrl_frame_fwd() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mac_ctrl_frame_fwd) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fc_conf), + "::", + stringify!(mac_ctrl_frame_fwd) + ) + ); + } + test_field_mac_ctrl_frame_fwd(); + fn test_field_autoneg() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).autoneg) as usize - ptr as usize + }, + 17usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fc_conf), + "::", + stringify!(autoneg) + ) + ); + } + test_field_autoneg(); } impl Default for rte_eth_fc_conf { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -10421,30 +13557,48 @@ fn bindgen_test_layout_rte_eth_pfc_conf() { 4usize, concat!("Alignment of ", stringify!(rte_eth_pfc_conf)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).fc as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_pfc_conf), - "::", - stringify!(fc) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).priority as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_pfc_conf), - "::", - stringify!(priority) - ) - ); + fn test_field_fc() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).fc) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_pfc_conf), + "::", + stringify!(fc) + ) + ); + } + test_field_fc(); + fn test_field_priority() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).priority) as usize - ptr as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_pfc_conf), + "::", + stringify!(priority) + ) + ); + } + test_field_priority(); } impl Default for rte_eth_pfc_conf { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub mod rte_eth_tunnel_type { @@ -10524,56 +13678,91 @@ fn bindgen_test_layout_rte_icmp_hdr() { 1usize, concat!("Alignment of ", stringify!(rte_icmp_hdr)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).icmp_type as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_icmp_hdr), - "::", - stringify!(icmp_type) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).icmp_code as *const _ as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(rte_icmp_hdr), - "::", - stringify!(icmp_code) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).icmp_cksum as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_icmp_hdr), - "::", - stringify!(icmp_cksum) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).icmp_ident as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_icmp_hdr), - "::", - stringify!(icmp_ident) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).icmp_seq_nb as *const _ as usize }, - 6usize, - concat!( - "Offset of field: ", - stringify!(rte_icmp_hdr), - "::", - stringify!(icmp_seq_nb) - ) - ); + fn test_field_icmp_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).icmp_type) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_icmp_hdr), + "::", + stringify!(icmp_type) + ) + ); + } + test_field_icmp_type(); + fn test_field_icmp_code() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).icmp_code) as usize - ptr as usize + }, + 1usize, + concat!( + "Offset of field: ", + stringify!(rte_icmp_hdr), + "::", + stringify!(icmp_code) + ) + ); + } + test_field_icmp_code(); + fn test_field_icmp_cksum() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).icmp_cksum) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_icmp_hdr), + "::", + stringify!(icmp_cksum) + ) + ); + } + test_field_icmp_cksum(); + fn test_field_icmp_ident() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).icmp_ident) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_icmp_hdr), + "::", + stringify!(icmp_ident) + ) + ); + } + test_field_icmp_ident(); + fn test_field_icmp_seq_nb() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).icmp_seq_nb) as usize - ptr as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(rte_icmp_hdr), + "::", + stringify!(icmp_seq_nb) + ) + ); + } + test_field_icmp_seq_nb(); } pub type sa_family_t = ::std::os::raw::c_ushort; #[repr(C)] @@ -10594,26 +13783,40 @@ fn bindgen_test_layout_sockaddr() { 2usize, concat!("Alignment of ", stringify!(sockaddr)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).sa_family as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(sockaddr), - "::", - stringify!(sa_family) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).sa_data as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(sockaddr), - "::", - stringify!(sa_data) - ) - ); + fn test_field_sa_family() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).sa_family) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(sockaddr), + "::", + stringify!(sa_family) + ) + ); + } + test_field_sa_family(); + fn test_field_sa_data() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).sa_data) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(sockaddr), + "::", + stringify!(sa_data) + ) + ); + } + test_field_sa_data(); } #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -10641,106 +13844,176 @@ fn bindgen_test_layout_rte_ipv4_hdr() { 1usize, concat!("Alignment of ", stringify!(rte_ipv4_hdr)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).version_ihl as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_ipv4_hdr), - "::", - stringify!(version_ihl) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_of_service as *const _ as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(rte_ipv4_hdr), - "::", - stringify!(type_of_service) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).total_length as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_ipv4_hdr), - "::", - stringify!(total_length) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).packet_id as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_ipv4_hdr), - "::", - stringify!(packet_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).fragment_offset as *const _ as usize }, - 6usize, - concat!( - "Offset of field: ", - stringify!(rte_ipv4_hdr), - "::", - stringify!(fragment_offset) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).time_to_live as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_ipv4_hdr), - "::", - stringify!(time_to_live) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).next_proto_id as *const _ as usize }, - 9usize, - concat!( - "Offset of field: ", - stringify!(rte_ipv4_hdr), - "::", - stringify!(next_proto_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).hdr_checksum as *const _ as usize }, - 10usize, - concat!( - "Offset of field: ", - stringify!(rte_ipv4_hdr), - "::", - stringify!(hdr_checksum) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).src_addr as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(rte_ipv4_hdr), - "::", - stringify!(src_addr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dst_addr as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_ipv4_hdr), - "::", - stringify!(dst_addr) - ) - ); + fn test_field_version_ihl() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).version_ihl) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_ipv4_hdr), + "::", + stringify!(version_ihl) + ) + ); + } + test_field_version_ihl(); + fn test_field_type_of_service() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).type_of_service) as usize - ptr as usize + }, + 1usize, + concat!( + "Offset of field: ", + stringify!(rte_ipv4_hdr), + "::", + stringify!(type_of_service) + ) + ); + } + test_field_type_of_service(); + fn test_field_total_length() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).total_length) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_ipv4_hdr), + "::", + stringify!(total_length) + ) + ); + } + test_field_total_length(); + fn test_field_packet_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).packet_id) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_ipv4_hdr), + "::", + stringify!(packet_id) + ) + ); + } + test_field_packet_id(); + fn test_field_fragment_offset() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).fragment_offset) as usize - ptr as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(rte_ipv4_hdr), + "::", + stringify!(fragment_offset) + ) + ); + } + test_field_fragment_offset(); + fn test_field_time_to_live() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).time_to_live) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_ipv4_hdr), + "::", + stringify!(time_to_live) + ) + ); + } + test_field_time_to_live(); + fn test_field_next_proto_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).next_proto_id) as usize - ptr as usize + }, + 9usize, + concat!( + "Offset of field: ", + stringify!(rte_ipv4_hdr), + "::", + stringify!(next_proto_id) + ) + ); + } + test_field_next_proto_id(); + fn test_field_hdr_checksum() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).hdr_checksum) as usize - ptr as usize + }, + 10usize, + concat!( + "Offset of field: ", + stringify!(rte_ipv4_hdr), + "::", + stringify!(hdr_checksum) + ) + ); + } + test_field_hdr_checksum(); + fn test_field_src_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).src_addr) as usize - ptr as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(rte_ipv4_hdr), + "::", + stringify!(src_addr) + ) + ); + } + test_field_src_addr(); + fn test_field_dst_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dst_addr) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_ipv4_hdr), + "::", + stringify!(dst_addr) + ) + ); + } + test_field_dst_addr(); } #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -10764,66 +14037,108 @@ fn bindgen_test_layout_rte_ipv6_hdr() { 1usize, concat!("Alignment of ", stringify!(rte_ipv6_hdr)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).vtc_flow as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_ipv6_hdr), - "::", - stringify!(vtc_flow) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).payload_len as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_ipv6_hdr), - "::", - stringify!(payload_len) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).proto as *const _ as usize }, - 6usize, - concat!( - "Offset of field: ", - stringify!(rte_ipv6_hdr), - "::", - stringify!(proto) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).hop_limits as *const _ as usize }, - 7usize, - concat!( - "Offset of field: ", - stringify!(rte_ipv6_hdr), - "::", - stringify!(hop_limits) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).src_addr as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_ipv6_hdr), - "::", - stringify!(src_addr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dst_addr as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(rte_ipv6_hdr), - "::", - stringify!(dst_addr) - ) - ); + fn test_field_vtc_flow() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vtc_flow) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_ipv6_hdr), + "::", + stringify!(vtc_flow) + ) + ); + } + test_field_vtc_flow(); + fn test_field_payload_len() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).payload_len) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_ipv6_hdr), + "::", + stringify!(payload_len) + ) + ); + } + test_field_payload_len(); + fn test_field_proto() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).proto) as usize - ptr as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(rte_ipv6_hdr), + "::", + stringify!(proto) + ) + ); + } + test_field_proto(); + fn test_field_hop_limits() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).hop_limits) as usize - ptr as usize + }, + 7usize, + concat!( + "Offset of field: ", + stringify!(rte_ipv6_hdr), + "::", + stringify!(hop_limits) + ) + ); + } + test_field_hop_limits(); + fn test_field_src_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).src_addr) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_ipv6_hdr), + "::", + stringify!(src_addr) + ) + ); + } + test_field_src_addr(); + fn test_field_dst_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dst_addr) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rte_ipv6_hdr), + "::", + stringify!(dst_addr) + ) + ); + } + test_field_dst_addr(); } #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -10845,46 +14160,74 @@ fn bindgen_test_layout_rte_sctp_hdr() { 1usize, concat!("Alignment of ", stringify!(rte_sctp_hdr)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).src_port as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_sctp_hdr), - "::", - stringify!(src_port) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dst_port as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_sctp_hdr), - "::", - stringify!(dst_port) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tag as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_sctp_hdr), - "::", - stringify!(tag) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).cksum as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_sctp_hdr), - "::", - stringify!(cksum) - ) - ); + fn test_field_src_port() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).src_port) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_sctp_hdr), + "::", + stringify!(src_port) + ) + ); + } + test_field_src_port(); + fn test_field_dst_port() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dst_port) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_sctp_hdr), + "::", + stringify!(dst_port) + ) + ); + } + test_field_dst_port(); + fn test_field_tag() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tag) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_sctp_hdr), + "::", + stringify!(tag) + ) + ); + } + test_field_tag(); + fn test_field_cksum() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).cksum) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_sctp_hdr), + "::", + stringify!(cksum) + ) + ); + } + test_field_cksum(); } #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -10911,96 +14254,159 @@ fn bindgen_test_layout_rte_tcp_hdr() { 1usize, concat!("Alignment of ", stringify!(rte_tcp_hdr)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).src_port as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_tcp_hdr), - "::", - stringify!(src_port) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dst_port as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_tcp_hdr), - "::", - stringify!(dst_port) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).sent_seq as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_tcp_hdr), - "::", - stringify!(sent_seq) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).recv_ack as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_tcp_hdr), - "::", - stringify!(recv_ack) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).data_off as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(rte_tcp_hdr), - "::", - stringify!(data_off) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tcp_flags as *const _ as usize }, - 13usize, - concat!( - "Offset of field: ", - stringify!(rte_tcp_hdr), - "::", - stringify!(tcp_flags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rx_win as *const _ as usize }, - 14usize, - concat!( - "Offset of field: ", - stringify!(rte_tcp_hdr), - "::", - stringify!(rx_win) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).cksum as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_tcp_hdr), - "::", - stringify!(cksum) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tcp_urp as *const _ as usize }, - 18usize, - concat!( - "Offset of field: ", - stringify!(rte_tcp_hdr), - "::", - stringify!(tcp_urp) - ) - ); + fn test_field_src_port() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).src_port) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_tcp_hdr), + "::", + stringify!(src_port) + ) + ); + } + test_field_src_port(); + fn test_field_dst_port() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dst_port) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_tcp_hdr), + "::", + stringify!(dst_port) + ) + ); + } + test_field_dst_port(); + fn test_field_sent_seq() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).sent_seq) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_tcp_hdr), + "::", + stringify!(sent_seq) + ) + ); + } + test_field_sent_seq(); + fn test_field_recv_ack() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).recv_ack) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_tcp_hdr), + "::", + stringify!(recv_ack) + ) + ); + } + test_field_recv_ack(); + fn test_field_data_off() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).data_off) as usize - ptr as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(rte_tcp_hdr), + "::", + stringify!(data_off) + ) + ); + } + test_field_data_off(); + fn test_field_tcp_flags() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tcp_flags) as usize - ptr as usize + }, + 13usize, + concat!( + "Offset of field: ", + stringify!(rte_tcp_hdr), + "::", + stringify!(tcp_flags) + ) + ); + } + test_field_tcp_flags(); + fn test_field_rx_win() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_win) as usize - ptr as usize + }, + 14usize, + concat!( + "Offset of field: ", + stringify!(rte_tcp_hdr), + "::", + stringify!(rx_win) + ) + ); + } + test_field_rx_win(); + fn test_field_cksum() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).cksum) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_tcp_hdr), + "::", + stringify!(cksum) + ) + ); + } + test_field_cksum(); + fn test_field_tcp_urp() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tcp_urp) as usize - ptr as usize + }, + 18usize, + concat!( + "Offset of field: ", + stringify!(rte_tcp_hdr), + "::", + stringify!(tcp_urp) + ) + ); + } + test_field_tcp_urp(); } #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -11022,46 +14428,74 @@ fn bindgen_test_layout_rte_udp_hdr() { 1usize, concat!("Alignment of ", stringify!(rte_udp_hdr)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).src_port as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_udp_hdr), - "::", - stringify!(src_port) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dst_port as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_udp_hdr), - "::", - stringify!(dst_port) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dgram_len as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_udp_hdr), - "::", - stringify!(dgram_len) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dgram_cksum as *const _ as usize }, - 6usize, - concat!( - "Offset of field: ", - stringify!(rte_udp_hdr), - "::", - stringify!(dgram_cksum) - ) - ); + fn test_field_src_port() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).src_port) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_udp_hdr), + "::", + stringify!(src_port) + ) + ); + } + test_field_src_port(); + fn test_field_dst_port() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dst_port) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_udp_hdr), + "::", + stringify!(dst_port) + ) + ); + } + test_field_dst_port(); + fn test_field_dgram_len() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dgram_len) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_udp_hdr), + "::", + stringify!(dgram_len) + ) + ); + } + test_field_dgram_len(); + fn test_field_dgram_cksum() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dgram_cksum) as usize - ptr as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(rte_udp_hdr), + "::", + stringify!(dgram_cksum) + ) + ); + } + test_field_dgram_cksum(); } #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -11081,26 +14515,40 @@ fn bindgen_test_layout_rte_esp_hdr() { 1usize, concat!("Alignment of ", stringify!(rte_esp_hdr)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).spi as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_esp_hdr), - "::", - stringify!(spi) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).seq as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_esp_hdr), - "::", - stringify!(seq) - ) - ); + fn test_field_spi() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).spi) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_esp_hdr), + "::", + stringify!(spi) + ) + ); + } + test_field_spi(); + fn test_field_seq() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).seq) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_esp_hdr), + "::", + stringify!(seq) + ) + ); + } + test_field_seq(); } #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -11120,26 +14568,40 @@ fn bindgen_test_layout_rte_esp_tail() { 1usize, concat!("Alignment of ", stringify!(rte_esp_tail)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad_len as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_esp_tail), - "::", - stringify!(pad_len) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).next_proto as *const _ as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(rte_esp_tail), - "::", - stringify!(next_proto) - ) - ); + fn test_field_pad_len() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pad_len) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_esp_tail), + "::", + stringify!(pad_len) + ) + ); + } + test_field_pad_len(); + fn test_field_next_proto() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).next_proto) as usize - ptr as usize + }, + 1usize, + concat!( + "Offset of field: ", + stringify!(rte_esp_tail), + "::", + stringify!(next_proto) + ) + ); + } + test_field_next_proto(); } #[repr(C)] #[repr(align(4))] @@ -11730,38 +15192,57 @@ fn bindgen_test_layout_rte_higig2_ppt_type1() { 2usize, concat!("Alignment of ", stringify!(rte_higig2_ppt_type1)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).classification as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_higig2_ppt_type1), - "::", - stringify!(classification) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).resv as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_higig2_ppt_type1), - "::", - stringify!(resv) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).vid as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_higig2_ppt_type1), - "::", - stringify!(vid) - ) - ); + fn test_field_classification() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).classification) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_higig2_ppt_type1), + "::", + stringify!(classification) + ) + ); + } + test_field_classification(); + fn test_field_resv() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).resv) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_higig2_ppt_type1), + "::", + stringify!(resv) + ) + ); + } + test_field_resv(); + fn test_field_vid() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vid) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_higig2_ppt_type1), + "::", + stringify!(vid) + ) + ); + } + test_field_vid(); } impl rte_higig2_ppt_type1 { #[inline] @@ -11878,7 +15359,6 @@ pub struct rte_higig2_hdr { pub union rte_higig2_hdr__bindgen_ty_1 { pub ppt0: rte_higig2_ppt_type0, pub ppt1: rte_higig2_ppt_type1, - _bindgen_union_align: [u32; 2usize], } #[test] fn bindgen_test_layout_rte_higig2_hdr__bindgen_ty_1() { @@ -11892,34 +15372,48 @@ fn bindgen_test_layout_rte_higig2_hdr__bindgen_ty_1() { 4usize, concat!("Alignment of ", stringify!(rte_higig2_hdr__bindgen_ty_1)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ppt0 as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_higig2_hdr__bindgen_ty_1), - "::", - stringify!(ppt0) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ppt1 as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_higig2_hdr__bindgen_ty_1), - "::", - stringify!(ppt1) - ) - ); + fn test_field_ppt0() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ppt0) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_higig2_hdr__bindgen_ty_1), + "::", + stringify!(ppt0) + ) + ); + } + test_field_ppt0(); + fn test_field_ppt1() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ppt1) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_higig2_hdr__bindgen_ty_1), + "::", + stringify!(ppt1) + ) + ); + } + test_field_ppt1(); } impl Default for rte_higig2_hdr__bindgen_ty_1 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[test] @@ -11934,24 +15428,35 @@ fn bindgen_test_layout_rte_higig2_hdr() { 4usize, concat!("Alignment of ", stringify!(rte_higig2_hdr)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).fcr as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_higig2_hdr), - "::", - stringify!(fcr) - ) - ); + fn test_field_fcr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).fcr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_higig2_hdr), + "::", + stringify!(fcr) + ) + ); + } + test_field_fcr(); } impl Default for rte_higig2_hdr { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct rte_mbuf_dynfield { pub name: [::std::os::raw::c_char; 64usize], pub size: size_t, @@ -11970,54 +15475,86 @@ fn bindgen_test_layout_rte_mbuf_dynfield() { 8usize, concat!("Alignment of ", stringify!(rte_mbuf_dynfield)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).name as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf_dynfield), - "::", - stringify!(name) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).size as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf_dynfield), - "::", - stringify!(size) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).align as *const _ as usize }, - 72usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf_dynfield), - "::", - stringify!(align) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 80usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf_dynfield), - "::", - stringify!(flags) - ) - ); + fn test_field_name() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf_dynfield), + "::", + stringify!(name) + ) + ); + } + test_field_name(); + fn test_field_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf_dynfield), + "::", + stringify!(size) + ) + ); + } + test_field_size(); + fn test_field_align() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).align) as usize - ptr as usize + }, + 72usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf_dynfield), + "::", + stringify!(align) + ) + ); + } + test_field_align(); + fn test_field_flags() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize + }, + 80usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf_dynfield), + "::", + stringify!(flags) + ) + ); + } + test_field_flags(); } impl Default for rte_mbuf_dynfield { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct rte_mbuf_dynflag { pub name: [::std::os::raw::c_char; 64usize], pub flags: ::std::os::raw::c_uint, @@ -12034,30 +15571,48 @@ fn bindgen_test_layout_rte_mbuf_dynflag() { 4usize, concat!("Alignment of ", stringify!(rte_mbuf_dynflag)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).name as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf_dynflag), - "::", - stringify!(name) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(rte_mbuf_dynflag), - "::", - stringify!(flags) - ) - ); + fn test_field_name() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf_dynflag), + "::", + stringify!(name) + ) + ); + } + test_field_name(); + fn test_field_flags() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(rte_mbuf_dynflag), + "::", + stringify!(flags) + ) + ); + } + test_field_flags(); } impl Default for rte_mbuf_dynflag { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } extern "C" { @@ -12113,26 +15668,40 @@ fn bindgen_test_layout_rte_flow_attr() { 4usize, concat!("Alignment of ", stringify!(rte_flow_attr)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).group as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_attr), - "::", - stringify!(group) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).priority as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_attr), - "::", - stringify!(priority) - ) - ); + fn test_field_group() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).group) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_attr), + "::", + stringify!(group) + ) + ); + } + test_field_group(); + fn test_field_priority() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).priority) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_attr), + "::", + stringify!(priority) + ) + ); + } + test_field_priority(); } impl rte_flow_attr { #[inline] @@ -12275,20 +15844,31 @@ fn bindgen_test_layout_rte_flow_item_higig2_hdr() { 4usize, concat!("Alignment of ", stringify!(rte_flow_item_higig2_hdr)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).hdr as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_higig2_hdr), - "::", - stringify!(hdr) - ) - ); + fn test_field_hdr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_higig2_hdr), + "::", + stringify!(hdr) + ) + ); + } + test_field_hdr(); } impl Default for rte_flow_item_higig2_hdr { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } extern "C" { @@ -12311,16 +15891,23 @@ fn bindgen_test_layout_rte_flow_item_any() { 4usize, concat!("Alignment of ", stringify!(rte_flow_item_any)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).num as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_any), - "::", - stringify!(num) - ) - ); + fn test_field_num() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).num) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_any), + "::", + stringify!(num) + ) + ); + } + test_field_num(); } extern "C" { pub static rte_flow_item_any_mask: rte_flow_item_any; @@ -12342,16 +15929,23 @@ fn bindgen_test_layout_rte_flow_item_vf() { 4usize, concat!("Alignment of ", stringify!(rte_flow_item_vf)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).id as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_vf), - "::", - stringify!(id) - ) - ); + fn test_field_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_vf), + "::", + stringify!(id) + ) + ); + } + test_field_id(); } extern "C" { pub static rte_flow_item_vf_mask: rte_flow_item_vf; @@ -12373,16 +15967,23 @@ fn bindgen_test_layout_rte_flow_item_phy_port() { 4usize, concat!("Alignment of ", stringify!(rte_flow_item_phy_port)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).index as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_phy_port), - "::", - stringify!(index) - ) - ); + fn test_field_index() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).index) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_phy_port), + "::", + stringify!(index) + ) + ); + } + test_field_index(); } extern "C" { pub static rte_flow_item_phy_port_mask: rte_flow_item_phy_port; @@ -12404,16 +16005,23 @@ fn bindgen_test_layout_rte_flow_item_port_id() { 4usize, concat!("Alignment of ", stringify!(rte_flow_item_port_id)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).id as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_port_id), - "::", - stringify!(id) - ) - ); + fn test_field_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_port_id), + "::", + stringify!(id) + ) + ); + } + test_field_id(); } extern "C" { pub static rte_flow_item_port_id_mask: rte_flow_item_port_id; @@ -12440,50 +16048,82 @@ fn bindgen_test_layout_rte_flow_item_raw() { 8usize, concat!("Alignment of ", stringify!(rte_flow_item_raw)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).offset as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_raw), - "::", - stringify!(offset) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).limit as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_raw), - "::", - stringify!(limit) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).length as *const _ as usize }, - 10usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_raw), - "::", - stringify!(length) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pattern as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_raw), - "::", - stringify!(pattern) - ) - ); + fn test_field_offset() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).offset) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_raw), + "::", + stringify!(offset) + ) + ); + } + test_field_offset(); + fn test_field_limit() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).limit) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_raw), + "::", + stringify!(limit) + ) + ); + } + test_field_limit(); + fn test_field_length() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).length) as usize - ptr as usize + }, + 10usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_raw), + "::", + stringify!(length) + ) + ); + } + test_field_length(); + fn test_field_pattern() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pattern) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_raw), + "::", + stringify!(pattern) + ) + ); + } + test_field_pattern(); } impl Default for rte_flow_item_raw { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } impl rte_flow_item_raw { @@ -12564,36 +16204,57 @@ fn bindgen_test_layout_rte_flow_item_eth() { 2usize, concat!("Alignment of ", stringify!(rte_flow_item_eth)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dst as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_eth), - "::", - stringify!(dst) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).src as *const _ as usize }, - 6usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_eth), - "::", - stringify!(src) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_eth), - "::", - stringify!(type_) - ) - ); + fn test_field_dst() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dst) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_eth), + "::", + stringify!(dst) + ) + ); + } + test_field_dst(); + fn test_field_src() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).src) as usize - ptr as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_eth), + "::", + stringify!(src) + ) + ); + } + test_field_src(); + fn test_field_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_eth), + "::", + stringify!(type_) + ) + ); + } + test_field_type(); } extern "C" { pub static rte_flow_item_eth_mask: rte_flow_item_eth; @@ -12616,26 +16277,40 @@ fn bindgen_test_layout_rte_flow_item_vlan() { 2usize, concat!("Alignment of ", stringify!(rte_flow_item_vlan)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tci as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_vlan), - "::", - stringify!(tci) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).inner_type as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_vlan), - "::", - stringify!(inner_type) - ) - ); + fn test_field_tci() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tci) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_vlan), + "::", + stringify!(tci) + ) + ); + } + test_field_tci(); + fn test_field_inner_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).inner_type) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_vlan), + "::", + stringify!(inner_type) + ) + ); + } + test_field_inner_type(); } extern "C" { pub static rte_flow_item_vlan_mask: rte_flow_item_vlan; @@ -12657,16 +16332,23 @@ fn bindgen_test_layout_rte_flow_item_ipv4() { 1usize, concat!("Alignment of ", stringify!(rte_flow_item_ipv4)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).hdr as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_ipv4), - "::", - stringify!(hdr) - ) - ); + fn test_field_hdr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_ipv4), + "::", + stringify!(hdr) + ) + ); + } + test_field_hdr(); } extern "C" { pub static rte_flow_item_ipv4_mask: rte_flow_item_ipv4; @@ -12688,16 +16370,23 @@ fn bindgen_test_layout_rte_flow_item_ipv6() { 1usize, concat!("Alignment of ", stringify!(rte_flow_item_ipv6)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).hdr as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_ipv6), - "::", - stringify!(hdr) - ) - ); + fn test_field_hdr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_ipv6), + "::", + stringify!(hdr) + ) + ); + } + test_field_hdr(); } extern "C" { pub static rte_flow_item_ipv6_mask: rte_flow_item_ipv6; @@ -12719,16 +16408,23 @@ fn bindgen_test_layout_rte_flow_item_icmp() { 1usize, concat!("Alignment of ", stringify!(rte_flow_item_icmp)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).hdr as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_icmp), - "::", - stringify!(hdr) - ) - ); + fn test_field_hdr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_icmp), + "::", + stringify!(hdr) + ) + ); + } + test_field_hdr(); } extern "C" { pub static rte_flow_item_icmp_mask: rte_flow_item_icmp; @@ -12750,16 +16446,23 @@ fn bindgen_test_layout_rte_flow_item_udp() { 1usize, concat!("Alignment of ", stringify!(rte_flow_item_udp)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).hdr as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_udp), - "::", - stringify!(hdr) - ) - ); + fn test_field_hdr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_udp), + "::", + stringify!(hdr) + ) + ); + } + test_field_hdr(); } extern "C" { pub static rte_flow_item_udp_mask: rte_flow_item_udp; @@ -12781,16 +16484,23 @@ fn bindgen_test_layout_rte_flow_item_tcp() { 1usize, concat!("Alignment of ", stringify!(rte_flow_item_tcp)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).hdr as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_tcp), - "::", - stringify!(hdr) - ) - ); + fn test_field_hdr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_tcp), + "::", + stringify!(hdr) + ) + ); + } + test_field_hdr(); } extern "C" { pub static rte_flow_item_tcp_mask: rte_flow_item_tcp; @@ -12812,16 +16522,23 @@ fn bindgen_test_layout_rte_flow_item_sctp() { 1usize, concat!("Alignment of ", stringify!(rte_flow_item_sctp)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).hdr as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_sctp), - "::", - stringify!(hdr) - ) - ); + fn test_field_hdr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_sctp), + "::", + stringify!(hdr) + ) + ); + } + test_field_hdr(); } extern "C" { pub static rte_flow_item_sctp_mask: rte_flow_item_sctp; @@ -12846,46 +16563,74 @@ fn bindgen_test_layout_rte_flow_item_vxlan() { 1usize, concat!("Alignment of ", stringify!(rte_flow_item_vxlan)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_vxlan), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rsvd0 as *const _ as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_vxlan), - "::", - stringify!(rsvd0) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).vni as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_vxlan), - "::", - stringify!(vni) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rsvd1 as *const _ as usize }, - 7usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_vxlan), - "::", - stringify!(rsvd1) - ) - ); + fn test_field_flags() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_vxlan), + "::", + stringify!(flags) + ) + ); + } + test_field_flags(); + fn test_field_rsvd0() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rsvd0) as usize - ptr as usize + }, + 1usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_vxlan), + "::", + stringify!(rsvd0) + ) + ); + } + test_field_rsvd0(); + fn test_field_vni() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vni) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_vxlan), + "::", + stringify!(vni) + ) + ); + } + test_field_vni(); + fn test_field_rsvd1() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rsvd1) as usize - ptr as usize + }, + 7usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_vxlan), + "::", + stringify!(rsvd1) + ) + ); + } + test_field_rsvd1(); } extern "C" { pub static rte_flow_item_vxlan_mask: rte_flow_item_vxlan; @@ -12911,60 +16656,91 @@ fn bindgen_test_layout_rte_flow_item_e_tag() { 2usize, concat!("Alignment of ", stringify!(rte_flow_item_e_tag)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).epcp_edei_in_ecid_b as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_e_tag), - "::", - stringify!(epcp_edei_in_ecid_b) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).rsvd_grp_ecid_b as *const _ as usize - }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_e_tag), - "::", - stringify!(rsvd_grp_ecid_b) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).in_ecid_e as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_e_tag), - "::", - stringify!(in_ecid_e) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ecid_e as *const _ as usize }, - 5usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_e_tag), - "::", - stringify!(ecid_e) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).inner_type as *const _ as usize }, - 6usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_e_tag), - "::", - stringify!(inner_type) - ) - ); + fn test_field_epcp_edei_in_ecid_b() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).epcp_edei_in_ecid_b) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_e_tag), + "::", + stringify!(epcp_edei_in_ecid_b) + ) + ); + } + test_field_epcp_edei_in_ecid_b(); + fn test_field_rsvd_grp_ecid_b() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rsvd_grp_ecid_b) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_e_tag), + "::", + stringify!(rsvd_grp_ecid_b) + ) + ); + } + test_field_rsvd_grp_ecid_b(); + fn test_field_in_ecid_e() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).in_ecid_e) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_e_tag), + "::", + stringify!(in_ecid_e) + ) + ); + } + test_field_in_ecid_e(); + fn test_field_ecid_e() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ecid_e) as usize - ptr as usize + }, + 5usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_e_tag), + "::", + stringify!(ecid_e) + ) + ); + } + test_field_ecid_e(); + fn test_field_inner_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).inner_type) as usize - ptr as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_e_tag), + "::", + stringify!(inner_type) + ) + ); + } + test_field_inner_type(); } extern "C" { pub static rte_flow_item_e_tag_mask: rte_flow_item_e_tag; @@ -12989,48 +16765,74 @@ fn bindgen_test_layout_rte_flow_item_nvgre() { 2usize, concat!("Alignment of ", stringify!(rte_flow_item_nvgre)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).c_k_s_rsvd0_ver as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_nvgre), - "::", - stringify!(c_k_s_rsvd0_ver) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).protocol as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_nvgre), - "::", - stringify!(protocol) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tni as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_nvgre), - "::", - stringify!(tni) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flow_id as *const _ as usize }, - 7usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_nvgre), - "::", - stringify!(flow_id) - ) - ); + fn test_field_c_k_s_rsvd0_ver() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).c_k_s_rsvd0_ver) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_nvgre), + "::", + stringify!(c_k_s_rsvd0_ver) + ) + ); + } + test_field_c_k_s_rsvd0_ver(); + fn test_field_protocol() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).protocol) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_nvgre), + "::", + stringify!(protocol) + ) + ); + } + test_field_protocol(); + fn test_field_tni() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tni) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_nvgre), + "::", + stringify!(tni) + ) + ); + } + test_field_tni(); + fn test_field_flow_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flow_id) as usize - ptr as usize + }, + 7usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_nvgre), + "::", + stringify!(flow_id) + ) + ); + } + test_field_flow_id(); } extern "C" { pub static rte_flow_item_nvgre_mask: rte_flow_item_nvgre; @@ -13053,26 +16855,40 @@ fn bindgen_test_layout_rte_flow_item_mpls() { 1usize, concat!("Alignment of ", stringify!(rte_flow_item_mpls)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).label_tc_s as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_mpls), - "::", - stringify!(label_tc_s) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ttl as *const _ as usize }, - 3usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_mpls), - "::", - stringify!(ttl) - ) - ); + fn test_field_label_tc_s() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).label_tc_s) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_mpls), + "::", + stringify!(label_tc_s) + ) + ); + } + test_field_label_tc_s(); + fn test_field_ttl() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ttl) as usize - ptr as usize + }, + 3usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_mpls), + "::", + stringify!(ttl) + ) + ); + } + test_field_ttl(); } extern "C" { pub static rte_flow_item_mpls_mask: rte_flow_item_mpls; @@ -13095,26 +16911,40 @@ fn bindgen_test_layout_rte_flow_item_gre() { 2usize, concat!("Alignment of ", stringify!(rte_flow_item_gre)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).c_rsvd0_ver as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_gre), - "::", - stringify!(c_rsvd0_ver) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).protocol as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_gre), - "::", - stringify!(protocol) - ) - ); + fn test_field_c_rsvd0_ver() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).c_rsvd0_ver) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_gre), + "::", + stringify!(c_rsvd0_ver) + ) + ); + } + test_field_c_rsvd0_ver(); + fn test_field_protocol() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).protocol) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_gre), + "::", + stringify!(protocol) + ) + ); + } + test_field_protocol(); } extern "C" { pub static rte_flow_item_gre_mask: rte_flow_item_gre; @@ -13136,16 +16966,23 @@ fn bindgen_test_layout_rte_flow_item_fuzzy() { 4usize, concat!("Alignment of ", stringify!(rte_flow_item_fuzzy)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).thresh as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_fuzzy), - "::", - stringify!(thresh) - ) - ); + fn test_field_thresh() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).thresh) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_fuzzy), + "::", + stringify!(thresh) + ) + ); + } + test_field_thresh(); } extern "C" { pub static rte_flow_item_fuzzy_mask: rte_flow_item_fuzzy; @@ -13170,48 +17007,74 @@ fn bindgen_test_layout_rte_flow_item_gtp() { 4usize, concat!("Alignment of ", stringify!(rte_flow_item_gtp)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).v_pt_rsv_flags as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_gtp), - "::", - stringify!(v_pt_rsv_flags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).msg_type as *const _ as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_gtp), - "::", - stringify!(msg_type) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).msg_len as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_gtp), - "::", - stringify!(msg_len) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).teid as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_gtp), - "::", - stringify!(teid) - ) - ); + fn test_field_v_pt_rsv_flags() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).v_pt_rsv_flags) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_gtp), + "::", + stringify!(v_pt_rsv_flags) + ) + ); + } + test_field_v_pt_rsv_flags(); + fn test_field_msg_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).msg_type) as usize - ptr as usize + }, + 1usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_gtp), + "::", + stringify!(msg_type) + ) + ); + } + test_field_msg_type(); + fn test_field_msg_len() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).msg_len) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_gtp), + "::", + stringify!(msg_len) + ) + ); + } + test_field_msg_len(); + fn test_field_teid() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).teid) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_gtp), + "::", + stringify!(teid) + ) + ); + } + test_field_teid(); } extern "C" { pub static rte_flow_item_gtp_mask: rte_flow_item_gtp; @@ -13233,16 +17096,23 @@ fn bindgen_test_layout_rte_flow_item_esp() { 1usize, concat!("Alignment of ", stringify!(rte_flow_item_esp)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).hdr as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_esp), - "::", - stringify!(hdr) - ) - ); + fn test_field_hdr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_esp), + "::", + stringify!(hdr) + ) + ); + } + test_field_hdr(); } extern "C" { pub static rte_flow_item_esp_mask: rte_flow_item_esp; @@ -13267,49 +17137,74 @@ fn bindgen_test_layout_rte_flow_item_geneve() { 2usize, concat!("Alignment of ", stringify!(rte_flow_item_geneve)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ver_opt_len_o_c_rsvd0 as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_geneve), - "::", - stringify!(ver_opt_len_o_c_rsvd0) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).protocol as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_geneve), - "::", - stringify!(protocol) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).vni as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_geneve), - "::", - stringify!(vni) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rsvd1 as *const _ as usize }, - 7usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_geneve), - "::", - stringify!(rsvd1) - ) - ); + fn test_field_ver_opt_len_o_c_rsvd0() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ver_opt_len_o_c_rsvd0) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_geneve), + "::", + stringify!(ver_opt_len_o_c_rsvd0) + ) + ); + } + test_field_ver_opt_len_o_c_rsvd0(); + fn test_field_protocol() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).protocol) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_geneve), + "::", + stringify!(protocol) + ) + ); + } + test_field_protocol(); + fn test_field_vni() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vni) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_geneve), + "::", + stringify!(vni) + ) + ); + } + test_field_vni(); + fn test_field_rsvd1() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rsvd1) as usize - ptr as usize + }, + 7usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_geneve), + "::", + stringify!(rsvd1) + ) + ); + } + test_field_rsvd1(); } extern "C" { pub static rte_flow_item_geneve_mask: rte_flow_item_geneve; @@ -13335,58 +17230,91 @@ fn bindgen_test_layout_rte_flow_item_vxlan_gpe() { 1usize, concat!("Alignment of ", stringify!(rte_flow_item_vxlan_gpe)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_vxlan_gpe), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rsvd0 as *const _ as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_vxlan_gpe), - "::", - stringify!(rsvd0) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).protocol as *const _ as usize - }, - 3usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_vxlan_gpe), - "::", - stringify!(protocol) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).vni as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_vxlan_gpe), - "::", - stringify!(vni) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rsvd1 as *const _ as usize }, - 7usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_vxlan_gpe), - "::", - stringify!(rsvd1) - ) - ); + fn test_field_flags() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_vxlan_gpe), + "::", + stringify!(flags) + ) + ); + } + test_field_flags(); + fn test_field_rsvd0() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rsvd0) as usize - ptr as usize + }, + 1usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_vxlan_gpe), + "::", + stringify!(rsvd0) + ) + ); + } + test_field_rsvd0(); + fn test_field_protocol() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).protocol) as usize - ptr as usize + }, + 3usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_vxlan_gpe), + "::", + stringify!(protocol) + ) + ); + } + test_field_protocol(); + fn test_field_vni() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vni) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_vxlan_gpe), + "::", + stringify!(vni) + ) + ); + } + test_field_vni(); + fn test_field_rsvd1() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rsvd1) as usize - ptr as usize + }, + 7usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_vxlan_gpe), + "::", + stringify!(rsvd1) + ) + ); + } + test_field_rsvd1(); } extern "C" { pub static rte_flow_item_vxlan_gpe_mask: rte_flow_item_vxlan_gpe; @@ -13416,96 +17344,159 @@ fn bindgen_test_layout_rte_flow_item_arp_eth_ipv4() { 4usize, concat!("Alignment of ", stringify!(rte_flow_item_arp_eth_ipv4)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).hrd as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_arp_eth_ipv4), - "::", - stringify!(hrd) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pro as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_arp_eth_ipv4), - "::", - stringify!(pro) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).hln as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_arp_eth_ipv4), - "::", - stringify!(hln) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pln as *const _ as usize }, - 5usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_arp_eth_ipv4), - "::", - stringify!(pln) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).op as *const _ as usize }, - 6usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_arp_eth_ipv4), - "::", - stringify!(op) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).sha as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_arp_eth_ipv4), - "::", - stringify!(sha) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).spa as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_arp_eth_ipv4), - "::", - stringify!(spa) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tha as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_arp_eth_ipv4), - "::", - stringify!(tha) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tpa as *const _ as usize }, - 28usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_arp_eth_ipv4), - "::", - stringify!(tpa) - ) - ); + fn test_field_hrd() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).hrd) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_arp_eth_ipv4), + "::", + stringify!(hrd) + ) + ); + } + test_field_hrd(); + fn test_field_pro() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pro) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_arp_eth_ipv4), + "::", + stringify!(pro) + ) + ); + } + test_field_pro(); + fn test_field_hln() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).hln) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_arp_eth_ipv4), + "::", + stringify!(hln) + ) + ); + } + test_field_hln(); + fn test_field_pln() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pln) as usize - ptr as usize + }, + 5usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_arp_eth_ipv4), + "::", + stringify!(pln) + ) + ); + } + test_field_pln(); + fn test_field_op() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).op) as usize - ptr as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_arp_eth_ipv4), + "::", + stringify!(op) + ) + ); + } + test_field_op(); + fn test_field_sha() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).sha) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_arp_eth_ipv4), + "::", + stringify!(sha) + ) + ); + } + test_field_sha(); + fn test_field_spa() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).spa) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_arp_eth_ipv4), + "::", + stringify!(spa) + ) + ); + } + test_field_spa(); + fn test_field_tha() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tha) as usize - ptr as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_arp_eth_ipv4), + "::", + stringify!(tha) + ) + ); + } + test_field_tha(); + fn test_field_tpa() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tpa) as usize - ptr as usize + }, + 28usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_arp_eth_ipv4), + "::", + stringify!(tpa) + ) + ); + } + test_field_tpa(); } extern "C" { pub static rte_flow_item_arp_eth_ipv4_mask: rte_flow_item_arp_eth_ipv4; @@ -13527,16 +17518,23 @@ fn bindgen_test_layout_rte_flow_item_ipv6_ext() { 1usize, concat!("Alignment of ", stringify!(rte_flow_item_ipv6_ext)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).next_hdr as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_ipv6_ext), - "::", - stringify!(next_hdr) - ) - ); + fn test_field_next_hdr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).next_hdr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_ipv6_ext), + "::", + stringify!(next_hdr) + ) + ); + } + test_field_next_hdr(); } extern "C" { pub static rte_flow_item_ipv6_ext_mask: rte_flow_item_ipv6_ext; @@ -13560,36 +17558,57 @@ fn bindgen_test_layout_rte_flow_item_icmp6() { 2usize, concat!("Alignment of ", stringify!(rte_flow_item_icmp6)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_icmp6), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).code as *const _ as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_icmp6), - "::", - stringify!(code) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).checksum as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_icmp6), - "::", - stringify!(checksum) - ) - ); + fn test_field_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_icmp6), + "::", + stringify!(type_) + ) + ); + } + test_field_type(); + fn test_field_code() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).code) as usize - ptr as usize + }, + 1usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_icmp6), + "::", + stringify!(code) + ) + ); + } + test_field_code(); + fn test_field_checksum() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).checksum) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_icmp6), + "::", + stringify!(checksum) + ) + ); + } + test_field_checksum(); } extern "C" { pub static rte_flow_item_icmp6_mask: rte_flow_item_icmp6; @@ -13615,62 +17634,91 @@ fn bindgen_test_layout_rte_flow_item_icmp6_nd_ns() { 4usize, concat!("Alignment of ", stringify!(rte_flow_item_icmp6_nd_ns)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_icmp6_nd_ns), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).code as *const _ as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_icmp6_nd_ns), - "::", - stringify!(code) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).checksum as *const _ as usize - }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_icmp6_nd_ns), - "::", - stringify!(checksum) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved as *const _ as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_icmp6_nd_ns), - "::", - stringify!(reserved) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).target_addr as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_icmp6_nd_ns), - "::", - stringify!(target_addr) - ) - ); + fn test_field_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_icmp6_nd_ns), + "::", + stringify!(type_) + ) + ); + } + test_field_type(); + fn test_field_code() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).code) as usize - ptr as usize + }, + 1usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_icmp6_nd_ns), + "::", + stringify!(code) + ) + ); + } + test_field_code(); + fn test_field_checksum() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).checksum) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_icmp6_nd_ns), + "::", + stringify!(checksum) + ) + ); + } + test_field_checksum(); + fn test_field_reserved() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_icmp6_nd_ns), + "::", + stringify!(reserved) + ) + ); + } + test_field_reserved(); + fn test_field_target_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).target_addr) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_icmp6_nd_ns), + "::", + stringify!(target_addr) + ) + ); + } + test_field_target_addr(); } extern "C" { pub static rte_flow_item_icmp6_nd_ns_mask: rte_flow_item_icmp6_nd_ns; @@ -13696,62 +17744,91 @@ fn bindgen_test_layout_rte_flow_item_icmp6_nd_na() { 4usize, concat!("Alignment of ", stringify!(rte_flow_item_icmp6_nd_na)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_icmp6_nd_na), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).code as *const _ as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_icmp6_nd_na), - "::", - stringify!(code) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).checksum as *const _ as usize - }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_icmp6_nd_na), - "::", - stringify!(checksum) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).rso_reserved as *const _ as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_icmp6_nd_na), - "::", - stringify!(rso_reserved) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).target_addr as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_icmp6_nd_na), - "::", - stringify!(target_addr) - ) - ); + fn test_field_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_icmp6_nd_na), + "::", + stringify!(type_) + ) + ); + } + test_field_type(); + fn test_field_code() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).code) as usize - ptr as usize + }, + 1usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_icmp6_nd_na), + "::", + stringify!(code) + ) + ); + } + test_field_code(); + fn test_field_checksum() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).checksum) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_icmp6_nd_na), + "::", + stringify!(checksum) + ) + ); + } + test_field_checksum(); + fn test_field_rso_reserved() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rso_reserved) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_icmp6_nd_na), + "::", + stringify!(rso_reserved) + ) + ); + } + test_field_rso_reserved(); + fn test_field_target_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).target_addr) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_icmp6_nd_na), + "::", + stringify!(target_addr) + ) + ); + } + test_field_target_addr(); } extern "C" { pub static rte_flow_item_icmp6_nd_na_mask: rte_flow_item_icmp6_nd_na; @@ -13774,30 +17851,40 @@ fn bindgen_test_layout_rte_flow_item_icmp6_nd_opt() { 1usize, concat!("Alignment of ", stringify!(rte_flow_item_icmp6_nd_opt)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).type_ as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_icmp6_nd_opt), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).length as *const _ as usize - }, - 1usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_icmp6_nd_opt), - "::", - stringify!(length) - ) - ); + fn test_field_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_icmp6_nd_opt), + "::", + stringify!(type_) + ) + ); + } + test_field_type(); + fn test_field_length() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).length) as usize - ptr as usize + }, + 1usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_icmp6_nd_opt), + "::", + stringify!(length) + ) + ); + } + test_field_length(); } extern "C" { pub static rte_flow_item_icmp6_nd_opt_mask: rte_flow_item_icmp6_nd_opt; @@ -13824,44 +17911,60 @@ fn bindgen_test_layout_rte_flow_item_icmp6_nd_opt_sla_eth() { stringify!(rte_flow_item_icmp6_nd_opt_sla_eth) ) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).type_ as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_icmp6_nd_opt_sla_eth), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).length as *const _ - as usize - }, - 1usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_icmp6_nd_opt_sla_eth), - "::", - stringify!(length) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).sla as *const _ as usize - }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_icmp6_nd_opt_sla_eth), - "::", - stringify!(sla) - ) - ); + fn test_field_type() { + assert_eq!( + unsafe { + let uninit = + ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_icmp6_nd_opt_sla_eth), + "::", + stringify!(type_) + ) + ); + } + test_field_type(); + fn test_field_length() { + assert_eq!( + unsafe { + let uninit = + ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).length) as usize - ptr as usize + }, + 1usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_icmp6_nd_opt_sla_eth), + "::", + stringify!(length) + ) + ); + } + test_field_length(); + fn test_field_sla() { + assert_eq!( + unsafe { + let uninit = + ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).sla) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_icmp6_nd_opt_sla_eth), + "::", + stringify!(sla) + ) + ); + } + test_field_sla(); } extern "C" { pub static rte_flow_item_icmp6_nd_opt_sla_eth_mask: rte_flow_item_icmp6_nd_opt_sla_eth; @@ -13888,44 +17991,60 @@ fn bindgen_test_layout_rte_flow_item_icmp6_nd_opt_tla_eth() { stringify!(rte_flow_item_icmp6_nd_opt_tla_eth) ) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).type_ as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_icmp6_nd_opt_tla_eth), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).length as *const _ - as usize - }, - 1usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_icmp6_nd_opt_tla_eth), - "::", - stringify!(length) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).tla as *const _ as usize - }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_icmp6_nd_opt_tla_eth), - "::", - stringify!(tla) - ) - ); + fn test_field_type() { + assert_eq!( + unsafe { + let uninit = + ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_icmp6_nd_opt_tla_eth), + "::", + stringify!(type_) + ) + ); + } + test_field_type(); + fn test_field_length() { + assert_eq!( + unsafe { + let uninit = + ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).length) as usize - ptr as usize + }, + 1usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_icmp6_nd_opt_tla_eth), + "::", + stringify!(length) + ) + ); + } + test_field_length(); + fn test_field_tla() { + assert_eq!( + unsafe { + let uninit = + ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tla) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_icmp6_nd_opt_tla_eth), + "::", + stringify!(tla) + ) + ); + } + test_field_tla(); } extern "C" { pub static rte_flow_item_icmp6_nd_opt_tla_eth_mask: rte_flow_item_icmp6_nd_opt_tla_eth; @@ -13947,16 +18066,23 @@ fn bindgen_test_layout_rte_flow_item_meta() { 4usize, concat!("Alignment of ", stringify!(rte_flow_item_meta)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_meta), - "::", - stringify!(data) - ) - ); + fn test_field_data() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_meta), + "::", + stringify!(data) + ) + ); + } + test_field_data(); } extern "C" { pub static rte_flow_item_meta_mask: rte_flow_item_meta; @@ -13979,26 +18105,40 @@ fn bindgen_test_layout_rte_flow_item_gtp_psc() { 1usize, concat!("Alignment of ", stringify!(rte_flow_item_gtp_psc)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pdu_type as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_gtp_psc), - "::", - stringify!(pdu_type) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).qfi as *const _ as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_gtp_psc), - "::", - stringify!(qfi) - ) - ); + fn test_field_pdu_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pdu_type) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_gtp_psc), + "::", + stringify!(pdu_type) + ) + ); + } + test_field_pdu_type(); + fn test_field_qfi() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).qfi) as usize - ptr as usize + }, + 1usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_gtp_psc), + "::", + stringify!(qfi) + ) + ); + } + test_field_qfi(); } extern "C" { pub static rte_flow_item_gtp_psc_mask: rte_flow_item_gtp_psc; @@ -14023,48 +18163,74 @@ fn bindgen_test_layout_rte_flow_item_pppoe() { 2usize, concat!("Alignment of ", stringify!(rte_flow_item_pppoe)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).version_type as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_pppoe), - "::", - stringify!(version_type) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).code as *const _ as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_pppoe), - "::", - stringify!(code) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).session_id as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_pppoe), - "::", - stringify!(session_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).length as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_pppoe), - "::", - stringify!(length) - ) - ); + fn test_field_version_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).version_type) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_pppoe), + "::", + stringify!(version_type) + ) + ); + } + test_field_version_type(); + fn test_field_code() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).code) as usize - ptr as usize + }, + 1usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_pppoe), + "::", + stringify!(code) + ) + ); + } + test_field_code(); + fn test_field_session_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).session_id) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_pppoe), + "::", + stringify!(session_id) + ) + ); + } + test_field_session_id(); + fn test_field_length() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).length) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_pppoe), + "::", + stringify!(length) + ) + ); + } + test_field_length(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -14083,18 +18249,23 @@ fn bindgen_test_layout_rte_flow_item_pppoe_proto_id() { 2usize, concat!("Alignment of ", stringify!(rte_flow_item_pppoe_proto_id)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).proto_id as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_pppoe_proto_id), - "::", - stringify!(proto_id) - ) - ); + fn test_field_proto_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).proto_id) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_pppoe_proto_id), + "::", + stringify!(proto_id) + ) + ); + } + test_field_proto_id(); } extern "C" { pub static rte_flow_item_pppoe_proto_id_mask: rte_flow_item_pppoe_proto_id; @@ -14117,26 +18288,40 @@ fn bindgen_test_layout_rte_flow_item_tag() { 4usize, concat!("Alignment of ", stringify!(rte_flow_item_tag)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_tag), - "::", - stringify!(data) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).index as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_tag), - "::", - stringify!(index) - ) - ); + fn test_field_data() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_tag), + "::", + stringify!(data) + ) + ); + } + test_field_data(); + fn test_field_index() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).index) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_tag), + "::", + stringify!(index) + ) + ); + } + test_field_index(); } extern "C" { pub static rte_flow_item_tag_mask: rte_flow_item_tag; @@ -14158,16 +18343,23 @@ fn bindgen_test_layout_rte_flow_item_mark() { 4usize, concat!("Alignment of ", stringify!(rte_flow_item_mark)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).id as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_mark), - "::", - stringify!(id) - ) - ); + fn test_field_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_mark), + "::", + stringify!(id) + ) + ); + } + test_field_id(); } extern "C" { pub static rte_flow_item_mark_mask: rte_flow_item_mark; @@ -14382,16 +18574,23 @@ fn bindgen_test_layout_rte_flow_item_igmp() { 4usize, concat!("Alignment of ", stringify!(rte_flow_item_igmp)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).group_addr as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_igmp), - "::", - stringify!(group_addr) - ) - ); + fn test_field_group_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).group_addr) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_igmp), + "::", + stringify!(group_addr) + ) + ); + } + test_field_group_addr(); } impl rte_flow_item_igmp { #[inline] @@ -14472,26 +18671,40 @@ fn bindgen_test_layout_rte_flow_item_ah() { 4usize, concat!("Alignment of ", stringify!(rte_flow_item_ah)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).spi as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_ah), - "::", - stringify!(spi) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).seq_num as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item_ah), - "::", - stringify!(seq_num) - ) - ); + fn test_field_spi() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).spi) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_ah), + "::", + stringify!(spi) + ) + ); + } + test_field_spi(); + fn test_field_seq_num() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).seq_num) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item_ah), + "::", + stringify!(seq_num) + ) + ); + } + test_field_seq_num(); } impl rte_flow_item_ah { #[inline] @@ -14572,50 +18785,82 @@ fn bindgen_test_layout_rte_flow_item() { 8usize, concat!("Alignment of ", stringify!(rte_flow_item)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).spec as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item), - "::", - stringify!(spec) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).last as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item), - "::", - stringify!(last) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mask as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_item), - "::", - stringify!(mask) - ) - ); + fn test_field_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item), + "::", + stringify!(type_) + ) + ); + } + test_field_type(); + fn test_field_spec() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).spec) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item), + "::", + stringify!(spec) + ) + ); + } + test_field_spec(); + fn test_field_last() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).last) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item), + "::", + stringify!(last) + ) + ); + } + test_field_last(); + fn test_field_mask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mask) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_item), + "::", + stringify!(mask) + ) + ); + } + test_field_mask(); } impl Default for rte_flow_item { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub mod rte_flow_action_type { @@ -14689,16 +18934,23 @@ fn bindgen_test_layout_rte_flow_action_mark() { 4usize, concat!("Alignment of ", stringify!(rte_flow_action_mark)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).id as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_mark), - "::", - stringify!(id) - ) - ); + fn test_field_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_mark), + "::", + stringify!(id) + ) + ); + } + test_field_id(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -14717,16 +18969,23 @@ fn bindgen_test_layout_rte_flow_action_jump() { 4usize, concat!("Alignment of ", stringify!(rte_flow_action_jump)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).group as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_jump), - "::", - stringify!(group) - ) - ); + fn test_field_group() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).group) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_jump), + "::", + stringify!(group) + ) + ); + } + test_field_group(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -14745,16 +19004,23 @@ fn bindgen_test_layout_rte_flow_action_queue() { 2usize, concat!("Alignment of ", stringify!(rte_flow_action_queue)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).index as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_queue), - "::", - stringify!(index) - ) - ); + fn test_field_index() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).index) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_queue), + "::", + stringify!(index) + ) + ); + } + test_field_index(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -14775,16 +19041,23 @@ fn bindgen_test_layout_rte_flow_action_count() { 4usize, concat!("Alignment of ", stringify!(rte_flow_action_count)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).id as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_count), - "::", - stringify!(id) - ) - ); + fn test_field_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_count), + "::", + stringify!(id) + ) + ); + } + test_field_id(); } impl rte_flow_action_count { #[inline] @@ -14843,26 +19116,40 @@ fn bindgen_test_layout_rte_flow_query_count() { 8usize, concat!("Alignment of ", stringify!(rte_flow_query_count)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).hits as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_query_count), - "::", - stringify!(hits) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).bytes as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_query_count), - "::", - stringify!(bytes) - ) - ); + fn test_field_hits() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).hits) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_query_count), + "::", + stringify!(hits) + ) + ); + } + test_field_hits(); + fn test_field_bytes() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).bytes) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_query_count), + "::", + stringify!(bytes) + ) + ); + } + test_field_bytes(); } impl rte_flow_query_count { #[inline] @@ -14967,80 +19254,133 @@ fn bindgen_test_layout_rte_flow_action_rss() { 8usize, concat!("Alignment of ", stringify!(rte_flow_action_rss)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).func as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_rss), - "::", - stringify!(func) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).level as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_rss), - "::", - stringify!(level) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).types as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_rss), - "::", - stringify!(types) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).key_len as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_rss), - "::", - stringify!(key_len) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).queue_num as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_rss), - "::", - stringify!(queue_num) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).key as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_rss), - "::", - stringify!(key) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).queue as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_rss), - "::", - stringify!(queue) - ) - ); + fn test_field_func() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).func) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_rss), + "::", + stringify!(func) + ) + ); + } + test_field_func(); + fn test_field_level() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).level) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_rss), + "::", + stringify!(level) + ) + ); + } + test_field_level(); + fn test_field_types() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).types) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_rss), + "::", + stringify!(types) + ) + ); + } + test_field_types(); + fn test_field_key_len() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).key_len) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_rss), + "::", + stringify!(key_len) + ) + ); + } + test_field_key_len(); + fn test_field_queue_num() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).queue_num) as usize - ptr as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_rss), + "::", + stringify!(queue_num) + ) + ); + } + test_field_queue_num(); + fn test_field_key() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).key) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_rss), + "::", + stringify!(key) + ) + ); + } + test_field_key(); + fn test_field_queue() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).queue) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_rss), + "::", + stringify!(queue) + ) + ); + } + test_field_queue(); } impl Default for rte_flow_action_rss { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -15062,16 +19402,23 @@ fn bindgen_test_layout_rte_flow_action_vf() { 4usize, concat!("Alignment of ", stringify!(rte_flow_action_vf)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).id as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_vf), - "::", - stringify!(id) - ) - ); + fn test_field_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_vf), + "::", + stringify!(id) + ) + ); + } + test_field_id(); } impl rte_flow_action_vf { #[inline] @@ -15129,16 +19476,23 @@ fn bindgen_test_layout_rte_flow_action_phy_port() { 4usize, concat!("Alignment of ", stringify!(rte_flow_action_phy_port)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).index as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_phy_port), - "::", - stringify!(index) - ) - ); + fn test_field_index() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).index) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_phy_port), + "::", + stringify!(index) + ) + ); + } + test_field_index(); } impl rte_flow_action_phy_port { #[inline] @@ -15196,16 +19550,23 @@ fn bindgen_test_layout_rte_flow_action_port_id() { 4usize, concat!("Alignment of ", stringify!(rte_flow_action_port_id)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).id as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_port_id), - "::", - stringify!(id) - ) - ); + fn test_field_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_port_id), + "::", + stringify!(id) + ) + ); + } + test_field_id(); } impl rte_flow_action_port_id { #[inline] @@ -15261,16 +19622,23 @@ fn bindgen_test_layout_rte_flow_action_meter() { 4usize, concat!("Alignment of ", stringify!(rte_flow_action_meter)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mtr_id as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_meter), - "::", - stringify!(mtr_id) - ) - ); + fn test_field_mtr_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mtr_id) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_meter), + "::", + stringify!(mtr_id) + ) + ); + } + test_field_mtr_id(); } #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq)] @@ -15289,23 +19657,31 @@ fn bindgen_test_layout_rte_flow_action_security() { 8usize, concat!("Alignment of ", stringify!(rte_flow_action_security)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).security_session as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_security), - "::", - stringify!(security_session) - ) - ); + fn test_field_security_session() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).security_session) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_security), + "::", + stringify!(security_session) + ) + ); + } + test_field_security_session(); } impl Default for rte_flow_action_security { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -15325,19 +19701,23 @@ fn bindgen_test_layout_rte_flow_action_of_set_mpls_ttl() { 1usize, concat!("Alignment of ", stringify!(rte_flow_action_of_set_mpls_ttl)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mpls_ttl as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_of_set_mpls_ttl), - "::", - stringify!(mpls_ttl) - ) - ); + fn test_field_mpls_ttl() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mpls_ttl) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_of_set_mpls_ttl), + "::", + stringify!(mpls_ttl) + ) + ); + } + test_field_mpls_ttl(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -15356,18 +19736,23 @@ fn bindgen_test_layout_rte_flow_action_of_set_nw_ttl() { 1usize, concat!("Alignment of ", stringify!(rte_flow_action_of_set_nw_ttl)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).nw_ttl as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_of_set_nw_ttl), - "::", - stringify!(nw_ttl) - ) - ); + fn test_field_nw_ttl() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nw_ttl) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_of_set_nw_ttl), + "::", + stringify!(nw_ttl) + ) + ); + } + test_field_nw_ttl(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -15386,18 +19771,23 @@ fn bindgen_test_layout_rte_flow_action_of_push_vlan() { 2usize, concat!("Alignment of ", stringify!(rte_flow_action_of_push_vlan)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ethertype as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_of_push_vlan), - "::", - stringify!(ethertype) - ) - ); + fn test_field_ethertype() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ethertype) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_of_push_vlan), + "::", + stringify!(ethertype) + ) + ); + } + test_field_ethertype(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -15416,19 +19806,23 @@ fn bindgen_test_layout_rte_flow_action_of_set_vlan_vid() { 2usize, concat!("Alignment of ", stringify!(rte_flow_action_of_set_vlan_vid)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).vlan_vid as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_of_set_vlan_vid), - "::", - stringify!(vlan_vid) - ) - ); + fn test_field_vlan_vid() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vlan_vid) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_of_set_vlan_vid), + "::", + stringify!(vlan_vid) + ) + ); + } + test_field_vlan_vid(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -15447,19 +19841,23 @@ fn bindgen_test_layout_rte_flow_action_of_set_vlan_pcp() { 1usize, concat!("Alignment of ", stringify!(rte_flow_action_of_set_vlan_pcp)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).vlan_pcp as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_of_set_vlan_pcp), - "::", - stringify!(vlan_pcp) - ) - ); + fn test_field_vlan_pcp() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vlan_pcp) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_of_set_vlan_pcp), + "::", + stringify!(vlan_pcp) + ) + ); + } + test_field_vlan_pcp(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -15478,18 +19876,23 @@ fn bindgen_test_layout_rte_flow_action_of_pop_mpls() { 2usize, concat!("Alignment of ", stringify!(rte_flow_action_of_pop_mpls)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ethertype as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_of_pop_mpls), - "::", - stringify!(ethertype) - ) - ); + fn test_field_ethertype() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ethertype) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_of_pop_mpls), + "::", + stringify!(ethertype) + ) + ); + } + test_field_ethertype(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -15508,18 +19911,23 @@ fn bindgen_test_layout_rte_flow_action_of_push_mpls() { 2usize, concat!("Alignment of ", stringify!(rte_flow_action_of_push_mpls)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ethertype as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_of_push_mpls), - "::", - stringify!(ethertype) - ) - ); + fn test_field_ethertype() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ethertype) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_of_push_mpls), + "::", + stringify!(ethertype) + ) + ); + } + test_field_ethertype(); } #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq)] @@ -15538,22 +19946,31 @@ fn bindgen_test_layout_rte_flow_action_vxlan_encap() { 8usize, concat!("Alignment of ", stringify!(rte_flow_action_vxlan_encap)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).definition as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_vxlan_encap), - "::", - stringify!(definition) - ) - ); + fn test_field_definition() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).definition) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_vxlan_encap), + "::", + stringify!(definition) + ) + ); + } + test_field_definition(); } impl Default for rte_flow_action_vxlan_encap { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -15573,22 +19990,31 @@ fn bindgen_test_layout_rte_flow_action_nvgre_encap() { 8usize, concat!("Alignment of ", stringify!(rte_flow_action_nvgre_encap)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).definition as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_nvgre_encap), - "::", - stringify!(definition) - ) - ); + fn test_field_definition() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).definition) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_nvgre_encap), + "::", + stringify!(definition) + ) + ); + } + test_field_definition(); } impl Default for rte_flow_action_nvgre_encap { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -15610,42 +20036,65 @@ fn bindgen_test_layout_rte_flow_action_raw_encap() { 8usize, concat!("Alignment of ", stringify!(rte_flow_action_raw_encap)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_raw_encap), - "::", - stringify!(data) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).preserve as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_raw_encap), - "::", - stringify!(preserve) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).size as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_raw_encap), - "::", - stringify!(size) - ) - ); + fn test_field_data() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_raw_encap), + "::", + stringify!(data) + ) + ); + } + test_field_data(); + fn test_field_preserve() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).preserve) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_raw_encap), + "::", + stringify!(preserve) + ) + ); + } + test_field_preserve(); + fn test_field_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_raw_encap), + "::", + stringify!(size) + ) + ); + } + test_field_size(); } impl Default for rte_flow_action_raw_encap { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -15666,30 +20115,48 @@ fn bindgen_test_layout_rte_flow_action_raw_decap() { 8usize, concat!("Alignment of ", stringify!(rte_flow_action_raw_decap)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_raw_decap), - "::", - stringify!(data) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).size as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_raw_decap), - "::", - stringify!(size) - ) - ); + fn test_field_data() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_raw_decap), + "::", + stringify!(data) + ) + ); + } + test_field_data(); + fn test_field_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_raw_decap), + "::", + stringify!(size) + ) + ); + } + test_field_size(); } impl Default for rte_flow_action_raw_decap { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -15709,18 +20176,23 @@ fn bindgen_test_layout_rte_flow_action_set_ipv4() { 4usize, concat!("Alignment of ", stringify!(rte_flow_action_set_ipv4)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ipv4_addr as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_set_ipv4), - "::", - stringify!(ipv4_addr) - ) - ); + fn test_field_ipv4_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ipv4_addr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_set_ipv4), + "::", + stringify!(ipv4_addr) + ) + ); + } + test_field_ipv4_addr(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -15739,18 +20211,23 @@ fn bindgen_test_layout_rte_flow_action_set_ipv6() { 1usize, concat!("Alignment of ", stringify!(rte_flow_action_set_ipv6)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ipv6_addr as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_set_ipv6), - "::", - stringify!(ipv6_addr) - ) - ); + fn test_field_ipv6_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ipv6_addr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_set_ipv6), + "::", + stringify!(ipv6_addr) + ) + ); + } + test_field_ipv6_addr(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -15769,16 +20246,23 @@ fn bindgen_test_layout_rte_flow_action_set_tp() { 2usize, concat!("Alignment of ", stringify!(rte_flow_action_set_tp)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).port as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_set_tp), - "::", - stringify!(port) - ) - ); + fn test_field_port() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).port) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_set_tp), + "::", + stringify!(port) + ) + ); + } + test_field_port(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -15797,18 +20281,23 @@ fn bindgen_test_layout_rte_flow_action_set_ttl() { 1usize, concat!("Alignment of ", stringify!(rte_flow_action_set_ttl)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ttl_value as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_set_ttl), - "::", - stringify!(ttl_value) - ) - ); + fn test_field_ttl_value() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ttl_value) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_set_ttl), + "::", + stringify!(ttl_value) + ) + ); + } + test_field_ttl_value(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -15827,18 +20316,23 @@ fn bindgen_test_layout_rte_flow_action_set_mac() { 1usize, concat!("Alignment of ", stringify!(rte_flow_action_set_mac)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mac_addr as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_set_mac), - "::", - stringify!(mac_addr) - ) - ); + fn test_field_mac_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mac_addr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_set_mac), + "::", + stringify!(mac_addr) + ) + ); + } + test_field_mac_addr(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -15859,36 +20353,57 @@ fn bindgen_test_layout_rte_flow_action_set_tag() { 4usize, concat!("Alignment of ", stringify!(rte_flow_action_set_tag)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_set_tag), - "::", - stringify!(data) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mask as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_set_tag), - "::", - stringify!(mask) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).index as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_set_tag), - "::", - stringify!(index) - ) - ); + fn test_field_data() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_set_tag), + "::", + stringify!(data) + ) + ); + } + test_field_data(); + fn test_field_mask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mask) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_set_tag), + "::", + stringify!(mask) + ) + ); + } + test_field_mask(); + fn test_field_index() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).index) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_set_tag), + "::", + stringify!(index) + ) + ); + } + test_field_index(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -15908,26 +20423,40 @@ fn bindgen_test_layout_rte_flow_action_set_meta() { 4usize, concat!("Alignment of ", stringify!(rte_flow_action_set_meta)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_set_meta), - "::", - stringify!(data) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mask as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action_set_meta), - "::", - stringify!(mask) - ) - ); + fn test_field_data() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_set_meta), + "::", + stringify!(data) + ) + ); + } + test_field_data(); + fn test_field_mask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mask) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action_set_meta), + "::", + stringify!(mask) + ) + ); + } + test_field_mask(); } extern "C" { pub static mut rte_flow_dynf_metadata_offs: i32; @@ -15953,30 +20482,48 @@ fn bindgen_test_layout_rte_flow_action() { 8usize, concat!("Alignment of ", stringify!(rte_flow_action)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).conf as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_action), - "::", - stringify!(conf) - ) - ); + fn test_field_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action), + "::", + stringify!(type_) + ) + ); + } + test_field_type(); + fn test_field_conf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).conf) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_action), + "::", + stringify!(conf) + ) + ); + } + test_field_conf(); } impl Default for rte_flow_action { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -16023,40 +20570,65 @@ fn bindgen_test_layout_rte_flow_error() { 8usize, concat!("Alignment of ", stringify!(rte_flow_error)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_error), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).cause as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_error), - "::", - stringify!(cause) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).message as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_error), - "::", - stringify!(message) - ) - ); + fn test_field_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_error), + "::", + stringify!(type_) + ) + ); + } + test_field_type(); + fn test_field_cause() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).cause) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_error), + "::", + stringify!(cause) + ) + ); + } + test_field_cause(); + fn test_field_message() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).message) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_error), + "::", + stringify!(message) + ) + ); + } + test_field_message(); } impl Default for rte_flow_error { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -16071,7 +20643,6 @@ pub struct rte_flow_conv_rule { pub union rte_flow_conv_rule__bindgen_ty_1 { pub attr_ro: *const rte_flow_attr, pub attr: *mut rte_flow_attr, - _bindgen_union_align: u64, } #[test] fn bindgen_test_layout_rte_flow_conv_rule__bindgen_ty_1() { @@ -16088,35 +20659,48 @@ fn bindgen_test_layout_rte_flow_conv_rule__bindgen_ty_1() { stringify!(rte_flow_conv_rule__bindgen_ty_1) ) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).attr_ro as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_conv_rule__bindgen_ty_1), - "::", - stringify!(attr_ro) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).attr as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_conv_rule__bindgen_ty_1), - "::", - stringify!(attr) - ) - ); + fn test_field_attr_ro() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).attr_ro) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_conv_rule__bindgen_ty_1), + "::", + stringify!(attr_ro) + ) + ); + } + test_field_attr_ro(); + fn test_field_attr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).attr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_conv_rule__bindgen_ty_1), + "::", + stringify!(attr) + ) + ); + } + test_field_attr(); } impl Default for rte_flow_conv_rule__bindgen_ty_1 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -16124,7 +20708,6 @@ impl Default for rte_flow_conv_rule__bindgen_ty_1 { pub union rte_flow_conv_rule__bindgen_ty_2 { pub pattern_ro: *const rte_flow_item, pub pattern: *mut rte_flow_item, - _bindgen_union_align: u64, } #[test] fn bindgen_test_layout_rte_flow_conv_rule__bindgen_ty_2() { @@ -16141,36 +20724,48 @@ fn bindgen_test_layout_rte_flow_conv_rule__bindgen_ty_2() { stringify!(rte_flow_conv_rule__bindgen_ty_2) ) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pattern_ro as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_conv_rule__bindgen_ty_2), - "::", - stringify!(pattern_ro) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pattern as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_conv_rule__bindgen_ty_2), - "::", - stringify!(pattern) - ) - ); + fn test_field_pattern_ro() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pattern_ro) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_conv_rule__bindgen_ty_2), + "::", + stringify!(pattern_ro) + ) + ); + } + test_field_pattern_ro(); + fn test_field_pattern() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pattern) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_conv_rule__bindgen_ty_2), + "::", + stringify!(pattern) + ) + ); + } + test_field_pattern(); } impl Default for rte_flow_conv_rule__bindgen_ty_2 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -16178,7 +20773,6 @@ impl Default for rte_flow_conv_rule__bindgen_ty_2 { pub union rte_flow_conv_rule__bindgen_ty_3 { pub actions_ro: *const rte_flow_action, pub actions: *mut rte_flow_action, - _bindgen_union_align: u64, } #[test] fn bindgen_test_layout_rte_flow_conv_rule__bindgen_ty_3() { @@ -16195,36 +20789,48 @@ fn bindgen_test_layout_rte_flow_conv_rule__bindgen_ty_3() { stringify!(rte_flow_conv_rule__bindgen_ty_3) ) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).actions_ro as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_conv_rule__bindgen_ty_3), - "::", - stringify!(actions_ro) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).actions as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_flow_conv_rule__bindgen_ty_3), - "::", - stringify!(actions) - ) - ); + fn test_field_actions_ro() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).actions_ro) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_conv_rule__bindgen_ty_3), + "::", + stringify!(actions_ro) + ) + ); + } + test_field_actions_ro(); + fn test_field_actions() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).actions) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_flow_conv_rule__bindgen_ty_3), + "::", + stringify!(actions) + ) + ); + } + test_field_actions(); } impl Default for rte_flow_conv_rule__bindgen_ty_3 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[test] @@ -16242,7 +20848,11 @@ fn bindgen_test_layout_rte_flow_conv_rule() { } impl Default for rte_flow_conv_rule { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub mod rte_flow_conv_op { @@ -16339,7 +20949,11 @@ fn bindgen_test_layout_rte_flow_desc() { } impl Default for rte_flow_desc { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } extern "C" { @@ -16415,50 +21029,82 @@ fn bindgen_test_layout_rte_eth_mac_filter() { 4usize, concat!("Alignment of ", stringify!(rte_eth_mac_filter)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).is_vf as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_mac_filter), - "::", - stringify!(is_vf) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dst_id as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_mac_filter), - "::", - stringify!(dst_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).filter_type as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_mac_filter), - "::", - stringify!(filter_type) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mac_addr as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_mac_filter), - "::", - stringify!(mac_addr) - ) - ); + fn test_field_is_vf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).is_vf) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_mac_filter), + "::", + stringify!(is_vf) + ) + ); + } + test_field_is_vf(); + fn test_field_dst_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dst_id) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_mac_filter), + "::", + stringify!(dst_id) + ) + ); + } + test_field_dst_id(); + fn test_field_filter_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).filter_type) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_mac_filter), + "::", + stringify!(filter_type) + ) + ); + } + test_field_filter_type(); + fn test_field_mac_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mac_addr) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_mac_filter), + "::", + stringify!(mac_addr) + ) + ); + } + test_field_mac_addr(); } impl Default for rte_eth_mac_filter { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -16481,53 +21127,77 @@ fn bindgen_test_layout_rte_eth_ethertype_filter() { 2usize, concat!("Alignment of ", stringify!(rte_eth_ethertype_filter)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mac_addr as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_ethertype_filter), - "::", - stringify!(mac_addr) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ether_type as *const _ as usize - }, - 6usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_ethertype_filter), - "::", - stringify!(ether_type) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_ethertype_filter), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).queue as *const _ as usize }, - 10usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_ethertype_filter), - "::", - stringify!(queue) - ) - ); + fn test_field_mac_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mac_addr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_ethertype_filter), + "::", + stringify!(mac_addr) + ) + ); + } + test_field_mac_addr(); + fn test_field_ether_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ether_type) as usize - ptr as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_ethertype_filter), + "::", + stringify!(ether_type) + ) + ); + } + test_field_ether_type(); + fn test_field_flags() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_ethertype_filter), + "::", + stringify!(flags) + ) + ); + } + test_field_flags(); + fn test_field_queue() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).queue) as usize - ptr as usize + }, + 10usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_ethertype_filter), + "::", + stringify!(queue) + ) + ); + } + test_field_queue(); } #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct rte_eth_flex_filter { pub len: u16, pub bytes: [u8; 128usize], @@ -16547,60 +21217,99 @@ fn bindgen_test_layout_rte_eth_flex_filter() { 2usize, concat!("Alignment of ", stringify!(rte_eth_flex_filter)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).len as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_flex_filter), - "::", - stringify!(len) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).bytes as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_flex_filter), - "::", - stringify!(bytes) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mask as *const _ as usize }, - 130usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_flex_filter), - "::", - stringify!(mask) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).priority as *const _ as usize }, - 146usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_flex_filter), - "::", - stringify!(priority) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).queue as *const _ as usize }, - 148usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_flex_filter), - "::", - stringify!(queue) - ) - ); + fn test_field_len() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_flex_filter), + "::", + stringify!(len) + ) + ); + } + test_field_len(); + fn test_field_bytes() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).bytes) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_flex_filter), + "::", + stringify!(bytes) + ) + ); + } + test_field_bytes(); + fn test_field_mask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mask) as usize - ptr as usize + }, + 130usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_flex_filter), + "::", + stringify!(mask) + ) + ); + } + test_field_mask(); + fn test_field_priority() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).priority) as usize - ptr as usize + }, + 146usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_flex_filter), + "::", + stringify!(priority) + ) + ); + } + test_field_priority(); + fn test_field_queue() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).queue) as usize - ptr as usize + }, + 148usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_flex_filter), + "::", + stringify!(queue) + ) + ); + } + test_field_queue(); } impl Default for rte_eth_flex_filter { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -16621,26 +21330,40 @@ fn bindgen_test_layout_rte_eth_syn_filter() { 2usize, concat!("Alignment of ", stringify!(rte_eth_syn_filter)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).hig_pri as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_syn_filter), - "::", - stringify!(hig_pri) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).queue as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_syn_filter), - "::", - stringify!(queue) - ) - ); + fn test_field_hig_pri() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).hig_pri) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_syn_filter), + "::", + stringify!(hig_pri) + ) + ); + } + test_field_hig_pri(); + fn test_field_queue() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).queue) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_syn_filter), + "::", + stringify!(queue) + ) + ); + } + test_field_queue(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -16672,356 +21395,506 @@ fn bindgen_test_layout_rte_eth_ntuple_filter() { 4usize, concat!("Alignment of ", stringify!(rte_eth_ntuple_filter)) ); + fn test_field_flags() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_ntuple_filter), + "::", + stringify!(flags) + ) + ); + } + test_field_flags(); + fn test_field_dst_ip() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dst_ip) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_ntuple_filter), + "::", + stringify!(dst_ip) + ) + ); + } + test_field_dst_ip(); + fn test_field_dst_ip_mask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dst_ip_mask) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_ntuple_filter), + "::", + stringify!(dst_ip_mask) + ) + ); + } + test_field_dst_ip_mask(); + fn test_field_src_ip() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).src_ip) as usize - ptr as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_ntuple_filter), + "::", + stringify!(src_ip) + ) + ); + } + test_field_src_ip(); + fn test_field_src_ip_mask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).src_ip_mask) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_ntuple_filter), + "::", + stringify!(src_ip_mask) + ) + ); + } + test_field_src_ip_mask(); + fn test_field_dst_port() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dst_port) as usize - ptr as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_ntuple_filter), + "::", + stringify!(dst_port) + ) + ); + } + test_field_dst_port(); + fn test_field_dst_port_mask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dst_port_mask) as usize - ptr as usize + }, + 22usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_ntuple_filter), + "::", + stringify!(dst_port_mask) + ) + ); + } + test_field_dst_port_mask(); + fn test_field_src_port() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).src_port) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_ntuple_filter), + "::", + stringify!(src_port) + ) + ); + } + test_field_src_port(); + fn test_field_src_port_mask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).src_port_mask) as usize - ptr as usize + }, + 26usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_ntuple_filter), + "::", + stringify!(src_port_mask) + ) + ); + } + test_field_src_port_mask(); + fn test_field_proto() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).proto) as usize - ptr as usize + }, + 28usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_ntuple_filter), + "::", + stringify!(proto) + ) + ); + } + test_field_proto(); + fn test_field_proto_mask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).proto_mask) as usize - ptr as usize + }, + 29usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_ntuple_filter), + "::", + stringify!(proto_mask) + ) + ); + } + test_field_proto_mask(); + fn test_field_tcp_flags() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tcp_flags) as usize - ptr as usize + }, + 30usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_ntuple_filter), + "::", + stringify!(tcp_flags) + ) + ); + } + test_field_tcp_flags(); + fn test_field_priority() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).priority) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_ntuple_filter), + "::", + stringify!(priority) + ) + ); + } + test_field_priority(); + fn test_field_queue() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).queue) as usize - ptr as usize + }, + 34usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_ntuple_filter), + "::", + stringify!(queue) + ) + ); + } + test_field_queue(); +} +pub mod rte_tunnel_iptype { + pub type Type = ::std::os::raw::c_uint; + pub const RTE_TUNNEL_IPTYPE_IPV4: Type = 0; + pub const RTE_TUNNEL_IPTYPE_IPV6: Type = 1; +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct rte_eth_tunnel_filter_conf { + pub outer_mac: rte_ether_addr, + pub inner_mac: rte_ether_addr, + pub inner_vlan: u16, + pub ip_type: rte_tunnel_iptype::Type, + pub ip_addr: rte_eth_tunnel_filter_conf__bindgen_ty_1, + pub filter_type: u16, + pub tunnel_type: rte_eth_tunnel_type::Type, + pub tenant_id: u32, + pub queue_id: u16, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union rte_eth_tunnel_filter_conf__bindgen_ty_1 { + pub ipv4_addr: u32, + pub ipv6_addr: [u32; 4usize], +} +#[test] +fn bindgen_test_layout_rte_eth_tunnel_filter_conf__bindgen_ty_1() { assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 0usize, + ::std::mem::size_of::(), + 16usize, concat!( - "Offset of field: ", - stringify!(rte_eth_ntuple_filter), - "::", - stringify!(flags) + "Size of: ", + stringify!(rte_eth_tunnel_filter_conf__bindgen_ty_1) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dst_ip as *const _ as usize }, + ::std::mem::align_of::(), 4usize, concat!( - "Offset of field: ", - stringify!(rte_eth_ntuple_filter), - "::", - stringify!(dst_ip) + "Alignment of ", + stringify!(rte_eth_tunnel_filter_conf__bindgen_ty_1) ) ); - assert_eq!( + fn test_field_ipv4_addr() { + assert_eq!( + unsafe { + let uninit = + ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ipv4_addr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_tunnel_filter_conf__bindgen_ty_1), + "::", + stringify!(ipv4_addr) + ) + ); + } + test_field_ipv4_addr(); + fn test_field_ipv6_addr() { + assert_eq!( + unsafe { + let uninit = + ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ipv6_addr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_tunnel_filter_conf__bindgen_ty_1), + "::", + stringify!(ipv6_addr) + ) + ); + } + test_field_ipv6_addr(); +} +impl Default for rte_eth_tunnel_filter_conf__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { - &(*(::std::ptr::null::())).dst_ip_mask as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_ntuple_filter), - "::", - stringify!(dst_ip_mask) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).src_ip as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_ntuple_filter), - "::", - stringify!(src_ip) - ) - ); + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[test] +fn bindgen_test_layout_rte_eth_tunnel_filter_conf() { assert_eq!( - unsafe { - &(*(::std::ptr::null::())).src_ip_mask as *const _ as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_ntuple_filter), - "::", - stringify!(src_ip_mask) - ) + ::std::mem::size_of::(), + 52usize, + concat!("Size of: ", stringify!(rte_eth_tunnel_filter_conf)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dst_port as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_ntuple_filter), - "::", - stringify!(dst_port) - ) + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(rte_eth_tunnel_filter_conf)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).dst_port_mask as *const _ as usize - }, - 22usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_ntuple_filter), - "::", - stringify!(dst_port_mask) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).src_port as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_ntuple_filter), - "::", - stringify!(src_port) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).src_port_mask as *const _ as usize - }, - 26usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_ntuple_filter), - "::", - stringify!(src_port_mask) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).proto as *const _ as usize }, - 28usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_ntuple_filter), - "::", - stringify!(proto) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).proto_mask as *const _ as usize - }, - 29usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_ntuple_filter), - "::", - stringify!(proto_mask) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tcp_flags as *const _ as usize }, - 30usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_ntuple_filter), - "::", - stringify!(tcp_flags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).priority as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_ntuple_filter), - "::", - stringify!(priority) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).queue as *const _ as usize }, - 34usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_ntuple_filter), - "::", - stringify!(queue) - ) - ); -} -pub mod rte_tunnel_iptype { - pub type Type = ::std::os::raw::c_uint; - pub const RTE_TUNNEL_IPTYPE_IPV4: Type = 0; - pub const RTE_TUNNEL_IPTYPE_IPV6: Type = 1; -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct rte_eth_tunnel_filter_conf { - pub outer_mac: rte_ether_addr, - pub inner_mac: rte_ether_addr, - pub inner_vlan: u16, - pub ip_type: rte_tunnel_iptype::Type, - pub ip_addr: rte_eth_tunnel_filter_conf__bindgen_ty_1, - pub filter_type: u16, - pub tunnel_type: rte_eth_tunnel_type::Type, - pub tenant_id: u32, - pub queue_id: u16, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union rte_eth_tunnel_filter_conf__bindgen_ty_1 { - pub ipv4_addr: u32, - pub ipv6_addr: [u32; 4usize], - _bindgen_union_align: [u32; 4usize], -} -#[test] -fn bindgen_test_layout_rte_eth_tunnel_filter_conf__bindgen_ty_1() { - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!( - "Size of: ", - stringify!(rte_eth_tunnel_filter_conf__bindgen_ty_1) - ) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!( - "Alignment of ", - stringify!(rte_eth_tunnel_filter_conf__bindgen_ty_1) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ipv4_addr - as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_tunnel_filter_conf__bindgen_ty_1), - "::", - stringify!(ipv4_addr) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ipv6_addr - as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_tunnel_filter_conf__bindgen_ty_1), - "::", - stringify!(ipv6_addr) - ) - ); -} -impl Default for rte_eth_tunnel_filter_conf__bindgen_ty_1 { - fn default() -> Self { - unsafe { ::std::mem::zeroed() } + fn test_field_outer_mac() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).outer_mac) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_tunnel_filter_conf), + "::", + stringify!(outer_mac) + ) + ); + } + test_field_outer_mac(); + fn test_field_inner_mac() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).inner_mac) as usize - ptr as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_tunnel_filter_conf), + "::", + stringify!(inner_mac) + ) + ); + } + test_field_inner_mac(); + fn test_field_inner_vlan() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).inner_vlan) as usize - ptr as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_tunnel_filter_conf), + "::", + stringify!(inner_vlan) + ) + ); + } + test_field_inner_vlan(); + fn test_field_ip_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ip_type) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_tunnel_filter_conf), + "::", + stringify!(ip_type) + ) + ); + } + test_field_ip_type(); + fn test_field_ip_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ip_addr) as usize - ptr as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_tunnel_filter_conf), + "::", + stringify!(ip_addr) + ) + ); + } + test_field_ip_addr(); + fn test_field_filter_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).filter_type) as usize - ptr as usize + }, + 36usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_tunnel_filter_conf), + "::", + stringify!(filter_type) + ) + ); + } + test_field_filter_type(); + fn test_field_tunnel_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tunnel_type) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_tunnel_filter_conf), + "::", + stringify!(tunnel_type) + ) + ); + } + test_field_tunnel_type(); + fn test_field_tenant_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tenant_id) as usize - ptr as usize + }, + 44usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_tunnel_filter_conf), + "::", + stringify!(tenant_id) + ) + ); + } + test_field_tenant_id(); + fn test_field_queue_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).queue_id) as usize - ptr as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_tunnel_filter_conf), + "::", + stringify!(queue_id) + ) + ); } -} -#[test] -fn bindgen_test_layout_rte_eth_tunnel_filter_conf() { - assert_eq!( - ::std::mem::size_of::(), - 52usize, - concat!("Size of: ", stringify!(rte_eth_tunnel_filter_conf)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(rte_eth_tunnel_filter_conf)) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).outer_mac as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_tunnel_filter_conf), - "::", - stringify!(outer_mac) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).inner_mac as *const _ as usize - }, - 6usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_tunnel_filter_conf), - "::", - stringify!(inner_mac) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).inner_vlan as *const _ as usize - }, - 12usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_tunnel_filter_conf), - "::", - stringify!(inner_vlan) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ip_type as *const _ as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_tunnel_filter_conf), - "::", - stringify!(ip_type) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ip_addr as *const _ as usize - }, - 20usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_tunnel_filter_conf), - "::", - stringify!(ip_addr) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).filter_type as *const _ as usize - }, - 36usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_tunnel_filter_conf), - "::", - stringify!(filter_type) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).tunnel_type as *const _ as usize - }, - 40usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_tunnel_filter_conf), - "::", - stringify!(tunnel_type) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).tenant_id as *const _ as usize - }, - 44usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_tunnel_filter_conf), - "::", - stringify!(tenant_id) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).queue_id as *const _ as usize - }, - 48usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_tunnel_filter_conf), - "::", - stringify!(queue_id) - ) - ); + test_field_queue_id(); } impl Default for rte_eth_tunnel_filter_conf { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub mod rte_eth_global_cfg_type { @@ -17041,7 +21914,6 @@ pub struct rte_eth_global_cfg { pub union rte_eth_global_cfg__bindgen_ty_1 { pub gre_key_len: u8, pub reserved: u64, - _bindgen_union_align: u64, } #[test] fn bindgen_test_layout_rte_eth_global_cfg__bindgen_ty_1() { @@ -17058,36 +21930,48 @@ fn bindgen_test_layout_rte_eth_global_cfg__bindgen_ty_1() { stringify!(rte_eth_global_cfg__bindgen_ty_1) ) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).gre_key_len as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_global_cfg__bindgen_ty_1), - "::", - stringify!(gre_key_len) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_global_cfg__bindgen_ty_1), - "::", - stringify!(reserved) - ) - ); + fn test_field_gre_key_len() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).gre_key_len) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_global_cfg__bindgen_ty_1), + "::", + stringify!(gre_key_len) + ) + ); + } + test_field_gre_key_len(); + fn test_field_reserved() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_global_cfg__bindgen_ty_1), + "::", + stringify!(reserved) + ) + ); + } + test_field_reserved(); } impl Default for rte_eth_global_cfg__bindgen_ty_1 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[test] @@ -17102,30 +21986,48 @@ fn bindgen_test_layout_rte_eth_global_cfg() { 8usize, concat!("Alignment of ", stringify!(rte_eth_global_cfg)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).cfg_type as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_global_cfg), - "::", - stringify!(cfg_type) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).cfg as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_global_cfg), - "::", - stringify!(cfg) - ) - ); + fn test_field_cfg_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).cfg_type) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_global_cfg), + "::", + stringify!(cfg_type) + ) + ); + } + test_field_cfg_type(); + fn test_field_cfg() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).cfg) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_global_cfg), + "::", + stringify!(cfg) + ) + ); + } + test_field_cfg(); } impl Default for rte_eth_global_cfg { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub mod rte_eth_input_set_field { @@ -17178,7 +22080,7 @@ pub mod rte_filter_input_set_op { pub const RTE_ETH_INPUT_SET_OP_MAX: Type = 3; } #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct rte_eth_input_set_conf { pub flow_type: u16, pub inset_size: u16, @@ -17197,54 +22099,82 @@ fn bindgen_test_layout_rte_eth_input_set_conf() { 4usize, concat!("Alignment of ", stringify!(rte_eth_input_set_conf)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).flow_type as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_input_set_conf), - "::", - stringify!(flow_type) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).inset_size as *const _ as usize - }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_input_set_conf), - "::", - stringify!(inset_size) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).field as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_input_set_conf), - "::", - stringify!(field) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).op as *const _ as usize }, - 516usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_input_set_conf), - "::", - stringify!(op) - ) - ); + fn test_field_flow_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flow_type) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_input_set_conf), + "::", + stringify!(flow_type) + ) + ); + } + test_field_flow_type(); + fn test_field_inset_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).inset_size) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_input_set_conf), + "::", + stringify!(inset_size) + ) + ); + } + test_field_inset_size(); + fn test_field_field() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).field) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_input_set_conf), + "::", + stringify!(field) + ) + ); + } + test_field_field(); + fn test_field_op() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).op) as usize - ptr as usize + }, + 516usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_input_set_conf), + "::", + stringify!(op) + ) + ); + } + test_field_op(); } impl Default for rte_eth_input_set_conf { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -17264,16 +22194,23 @@ fn bindgen_test_layout_rte_eth_l2_flow() { 2usize, concat!("Alignment of ", stringify!(rte_eth_l2_flow)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ether_type as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_l2_flow), - "::", - stringify!(ether_type) - ) - ); + fn test_field_ether_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ether_type) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_l2_flow), + "::", + stringify!(ether_type) + ) + ); + } + test_field_ether_type(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -17296,106 +22233,162 @@ fn bindgen_test_layout_rte_eth_ipv4_flow() { 4usize, concat!("Alignment of ", stringify!(rte_eth_ipv4_flow)) ); + fn test_field_src_ip() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).src_ip) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_ipv4_flow), + "::", + stringify!(src_ip) + ) + ); + } + test_field_src_ip(); + fn test_field_dst_ip() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dst_ip) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_ipv4_flow), + "::", + stringify!(dst_ip) + ) + ); + } + test_field_dst_ip(); + fn test_field_tos() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tos) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_ipv4_flow), + "::", + stringify!(tos) + ) + ); + } + test_field_tos(); + fn test_field_ttl() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ttl) as usize - ptr as usize + }, + 9usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_ipv4_flow), + "::", + stringify!(ttl) + ) + ); + } + test_field_ttl(); + fn test_field_proto() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).proto) as usize - ptr as usize + }, + 10usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_ipv4_flow), + "::", + stringify!(proto) + ) + ); + } + test_field_proto(); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct rte_eth_udpv4_flow { + pub ip: rte_eth_ipv4_flow, + pub src_port: u16, + pub dst_port: u16, +} +#[test] +fn bindgen_test_layout_rte_eth_udpv4_flow() { assert_eq!( - unsafe { &(*(::std::ptr::null::())).src_ip as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_ipv4_flow), - "::", - stringify!(src_ip) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dst_ip as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_ipv4_flow), - "::", - stringify!(dst_ip) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tos as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_ipv4_flow), - "::", - stringify!(tos) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ttl as *const _ as usize }, - 9usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_ipv4_flow), - "::", - stringify!(ttl) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).proto as *const _ as usize }, - 10usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_ipv4_flow), - "::", - stringify!(proto) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct rte_eth_udpv4_flow { - pub ip: rte_eth_ipv4_flow, - pub src_port: u16, - pub dst_port: u16, -} -#[test] -fn bindgen_test_layout_rte_eth_udpv4_flow() { - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(rte_eth_udpv4_flow)) + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(rte_eth_udpv4_flow)) ); assert_eq!( ::std::mem::align_of::(), 4usize, concat!("Alignment of ", stringify!(rte_eth_udpv4_flow)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ip as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_udpv4_flow), - "::", - stringify!(ip) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).src_port as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_udpv4_flow), - "::", - stringify!(src_port) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dst_port as *const _ as usize }, - 14usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_udpv4_flow), - "::", - stringify!(dst_port) - ) - ); + fn test_field_ip() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ip) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_udpv4_flow), + "::", + stringify!(ip) + ) + ); + } + test_field_ip(); + fn test_field_src_port() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).src_port) as usize - ptr as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_udpv4_flow), + "::", + stringify!(src_port) + ) + ); + } + test_field_src_port(); + fn test_field_dst_port() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dst_port) as usize - ptr as usize + }, + 14usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_udpv4_flow), + "::", + stringify!(dst_port) + ) + ); + } + test_field_dst_port(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -17416,36 +22409,57 @@ fn bindgen_test_layout_rte_eth_tcpv4_flow() { 4usize, concat!("Alignment of ", stringify!(rte_eth_tcpv4_flow)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ip as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_tcpv4_flow), - "::", - stringify!(ip) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).src_port as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_tcpv4_flow), - "::", - stringify!(src_port) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dst_port as *const _ as usize }, - 14usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_tcpv4_flow), - "::", - stringify!(dst_port) - ) - ); + fn test_field_ip() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ip) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_tcpv4_flow), + "::", + stringify!(ip) + ) + ); + } + test_field_ip(); + fn test_field_src_port() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).src_port) as usize - ptr as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_tcpv4_flow), + "::", + stringify!(src_port) + ) + ); + } + test_field_src_port(); + fn test_field_dst_port() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dst_port) as usize - ptr as usize + }, + 14usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_tcpv4_flow), + "::", + stringify!(dst_port) + ) + ); + } + test_field_dst_port(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -17467,46 +22481,74 @@ fn bindgen_test_layout_rte_eth_sctpv4_flow() { 4usize, concat!("Alignment of ", stringify!(rte_eth_sctpv4_flow)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ip as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_sctpv4_flow), - "::", - stringify!(ip) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).src_port as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_sctpv4_flow), - "::", - stringify!(src_port) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dst_port as *const _ as usize }, - 14usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_sctpv4_flow), - "::", - stringify!(dst_port) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).verify_tag as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_sctpv4_flow), - "::", - stringify!(verify_tag) - ) - ); + fn test_field_ip() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ip) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_sctpv4_flow), + "::", + stringify!(ip) + ) + ); + } + test_field_ip(); + fn test_field_src_port() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).src_port) as usize - ptr as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_sctpv4_flow), + "::", + stringify!(src_port) + ) + ); + } + test_field_src_port(); + fn test_field_dst_port() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dst_port) as usize - ptr as usize + }, + 14usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_sctpv4_flow), + "::", + stringify!(dst_port) + ) + ); + } + test_field_dst_port(); + fn test_field_verify_tag() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).verify_tag) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_sctpv4_flow), + "::", + stringify!(verify_tag) + ) + ); + } + test_field_verify_tag(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -17529,56 +22571,91 @@ fn bindgen_test_layout_rte_eth_ipv6_flow() { 4usize, concat!("Alignment of ", stringify!(rte_eth_ipv6_flow)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).src_ip as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_ipv6_flow), - "::", - stringify!(src_ip) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dst_ip as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_ipv6_flow), - "::", - stringify!(dst_ip) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tc as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_ipv6_flow), - "::", - stringify!(tc) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).proto as *const _ as usize }, - 33usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_ipv6_flow), - "::", - stringify!(proto) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).hop_limits as *const _ as usize }, - 34usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_ipv6_flow), - "::", - stringify!(hop_limits) - ) - ); + fn test_field_src_ip() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).src_ip) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_ipv6_flow), + "::", + stringify!(src_ip) + ) + ); + } + test_field_src_ip(); + fn test_field_dst_ip() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dst_ip) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_ipv6_flow), + "::", + stringify!(dst_ip) + ) + ); + } + test_field_dst_ip(); + fn test_field_tc() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tc) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_ipv6_flow), + "::", + stringify!(tc) + ) + ); + } + test_field_tc(); + fn test_field_proto() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).proto) as usize - ptr as usize + }, + 33usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_ipv6_flow), + "::", + stringify!(proto) + ) + ); + } + test_field_proto(); + fn test_field_hop_limits() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).hop_limits) as usize - ptr as usize + }, + 34usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_ipv6_flow), + "::", + stringify!(hop_limits) + ) + ); + } + test_field_hop_limits(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -17599,36 +22676,57 @@ fn bindgen_test_layout_rte_eth_udpv6_flow() { 4usize, concat!("Alignment of ", stringify!(rte_eth_udpv6_flow)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ip as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_udpv6_flow), - "::", - stringify!(ip) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).src_port as *const _ as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_udpv6_flow), - "::", - stringify!(src_port) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dst_port as *const _ as usize }, - 38usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_udpv6_flow), - "::", - stringify!(dst_port) - ) - ); + fn test_field_ip() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ip) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_udpv6_flow), + "::", + stringify!(ip) + ) + ); + } + test_field_ip(); + fn test_field_src_port() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).src_port) as usize - ptr as usize + }, + 36usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_udpv6_flow), + "::", + stringify!(src_port) + ) + ); + } + test_field_src_port(); + fn test_field_dst_port() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dst_port) as usize - ptr as usize + }, + 38usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_udpv6_flow), + "::", + stringify!(dst_port) + ) + ); + } + test_field_dst_port(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -17649,36 +22747,57 @@ fn bindgen_test_layout_rte_eth_tcpv6_flow() { 4usize, concat!("Alignment of ", stringify!(rte_eth_tcpv6_flow)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ip as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_tcpv6_flow), - "::", - stringify!(ip) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).src_port as *const _ as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_tcpv6_flow), - "::", - stringify!(src_port) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dst_port as *const _ as usize }, - 38usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_tcpv6_flow), - "::", - stringify!(dst_port) - ) - ); + fn test_field_ip() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ip) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_tcpv6_flow), + "::", + stringify!(ip) + ) + ); + } + test_field_ip(); + fn test_field_src_port() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).src_port) as usize - ptr as usize + }, + 36usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_tcpv6_flow), + "::", + stringify!(src_port) + ) + ); + } + test_field_src_port(); + fn test_field_dst_port() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dst_port) as usize - ptr as usize + }, + 38usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_tcpv6_flow), + "::", + stringify!(dst_port) + ) + ); + } + test_field_dst_port(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -17700,46 +22819,74 @@ fn bindgen_test_layout_rte_eth_sctpv6_flow() { 4usize, concat!("Alignment of ", stringify!(rte_eth_sctpv6_flow)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ip as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_sctpv6_flow), - "::", - stringify!(ip) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).src_port as *const _ as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_sctpv6_flow), - "::", - stringify!(src_port) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dst_port as *const _ as usize }, - 38usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_sctpv6_flow), - "::", - stringify!(dst_port) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).verify_tag as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_sctpv6_flow), - "::", - stringify!(verify_tag) - ) - ); + fn test_field_ip() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ip) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_sctpv6_flow), + "::", + stringify!(ip) + ) + ); + } + test_field_ip(); + fn test_field_src_port() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).src_port) as usize - ptr as usize + }, + 36usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_sctpv6_flow), + "::", + stringify!(src_port) + ) + ); + } + test_field_src_port(); + fn test_field_dst_port() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dst_port) as usize - ptr as usize + }, + 38usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_sctpv6_flow), + "::", + stringify!(dst_port) + ) + ); + } + test_field_dst_port(); + fn test_field_verify_tag() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).verify_tag) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_sctpv6_flow), + "::", + stringify!(verify_tag) + ) + ); + } + test_field_verify_tag(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -17758,16 +22905,23 @@ fn bindgen_test_layout_rte_eth_mac_vlan_flow() { 2usize, concat!("Alignment of ", stringify!(rte_eth_mac_vlan_flow)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mac_addr as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_mac_vlan_flow), - "::", - stringify!(mac_addr) - ) - ); + fn test_field_mac_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mac_addr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_mac_vlan_flow), + "::", + stringify!(mac_addr) + ) + ); + } + test_field_mac_addr(); } pub mod rte_eth_fdir_tunnel_type { pub type Type = ::std::os::raw::c_uint; @@ -17794,40 +22948,65 @@ fn bindgen_test_layout_rte_eth_tunnel_flow() { 4usize, concat!("Alignment of ", stringify!(rte_eth_tunnel_flow)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tunnel_type as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_tunnel_flow), - "::", - stringify!(tunnel_type) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tunnel_id as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_tunnel_flow), - "::", - stringify!(tunnel_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mac_addr as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_tunnel_flow), - "::", - stringify!(mac_addr) - ) - ); + fn test_field_tunnel_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tunnel_type) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_tunnel_flow), + "::", + stringify!(tunnel_type) + ) + ); + } + test_field_tunnel_type(); + fn test_field_tunnel_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tunnel_id) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_tunnel_flow), + "::", + stringify!(tunnel_id) + ) + ); + } + test_field_tunnel_id(); + fn test_field_mac_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mac_addr) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_tunnel_flow), + "::", + stringify!(mac_addr) + ) + ); + } + test_field_mac_addr(); } impl Default for rte_eth_tunnel_flow { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -17844,7 +23023,6 @@ pub union rte_eth_fdir_flow { pub ipv6_flow: rte_eth_ipv6_flow, pub mac_vlan_flow: rte_eth_mac_vlan_flow, pub tunnel_flow: rte_eth_tunnel_flow, - _bindgen_union_align: [u32; 11usize], } #[test] fn bindgen_test_layout_rte_eth_fdir_flow() { @@ -17858,182 +23036,291 @@ fn bindgen_test_layout_rte_eth_fdir_flow() { 4usize, concat!("Alignment of ", stringify!(rte_eth_fdir_flow)) ); + fn test_field_l2_flow() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).l2_flow) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_flow), + "::", + stringify!(l2_flow) + ) + ); + } + test_field_l2_flow(); + fn test_field_udp4_flow() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).udp4_flow) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_flow), + "::", + stringify!(udp4_flow) + ) + ); + } + test_field_udp4_flow(); + fn test_field_tcp4_flow() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tcp4_flow) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_flow), + "::", + stringify!(tcp4_flow) + ) + ); + } + test_field_tcp4_flow(); + fn test_field_sctp4_flow() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).sctp4_flow) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_flow), + "::", + stringify!(sctp4_flow) + ) + ); + } + test_field_sctp4_flow(); + fn test_field_ip4_flow() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ip4_flow) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_flow), + "::", + stringify!(ip4_flow) + ) + ); + } + test_field_ip4_flow(); + fn test_field_udp6_flow() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).udp6_flow) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_flow), + "::", + stringify!(udp6_flow) + ) + ); + } + test_field_udp6_flow(); + fn test_field_tcp6_flow() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tcp6_flow) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_flow), + "::", + stringify!(tcp6_flow) + ) + ); + } + test_field_tcp6_flow(); + fn test_field_sctp6_flow() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).sctp6_flow) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_flow), + "::", + stringify!(sctp6_flow) + ) + ); + } + test_field_sctp6_flow(); + fn test_field_ipv6_flow() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ipv6_flow) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_flow), + "::", + stringify!(ipv6_flow) + ) + ); + } + test_field_ipv6_flow(); + fn test_field_mac_vlan_flow() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mac_vlan_flow) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_flow), + "::", + stringify!(mac_vlan_flow) + ) + ); + } + test_field_mac_vlan_flow(); + fn test_field_tunnel_flow() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tunnel_flow) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_flow), + "::", + stringify!(tunnel_flow) + ) + ); + } + test_field_tunnel_flow(); +} +impl Default for rte_eth_fdir_flow { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct rte_eth_fdir_flow_ext { + pub vlan_tci: u16, + pub flexbytes: [u8; 16usize], + pub is_vf: u8, + pub dst_id: u16, +} +#[test] +fn bindgen_test_layout_rte_eth_fdir_flow_ext() { assert_eq!( - unsafe { &(*(::std::ptr::null::())).l2_flow as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_flow), - "::", - stringify!(l2_flow) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).udp4_flow as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_flow), - "::", - stringify!(udp4_flow) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tcp4_flow as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_flow), - "::", - stringify!(tcp4_flow) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).sctp4_flow as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_flow), - "::", - stringify!(sctp4_flow) - ) + ::std::mem::size_of::(), + 22usize, + concat!("Size of: ", stringify!(rte_eth_fdir_flow_ext)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ip4_flow as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_flow), - "::", - stringify!(ip4_flow) - ) + ::std::mem::align_of::(), + 2usize, + concat!("Alignment of ", stringify!(rte_eth_fdir_flow_ext)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).udp6_flow as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_flow), - "::", - stringify!(udp6_flow) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tcp6_flow as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_flow), - "::", - stringify!(tcp6_flow) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).sctp6_flow as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_flow), - "::", - stringify!(sctp6_flow) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ipv6_flow as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_flow), - "::", - stringify!(ipv6_flow) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mac_vlan_flow as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_flow), - "::", - stringify!(mac_vlan_flow) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tunnel_flow as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_flow), - "::", - stringify!(tunnel_flow) - ) - ); -} -impl Default for rte_eth_fdir_flow { - fn default() -> Self { - unsafe { ::std::mem::zeroed() } + fn test_field_vlan_tci() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vlan_tci) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_flow_ext), + "::", + stringify!(vlan_tci) + ) + ); + } + test_field_vlan_tci(); + fn test_field_flexbytes() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flexbytes) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_flow_ext), + "::", + stringify!(flexbytes) + ) + ); + } + test_field_flexbytes(); + fn test_field_is_vf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).is_vf) as usize - ptr as usize + }, + 18usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_flow_ext), + "::", + stringify!(is_vf) + ) + ); + } + test_field_is_vf(); + fn test_field_dst_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dst_id) as usize - ptr as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_flow_ext), + "::", + stringify!(dst_id) + ) + ); } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct rte_eth_fdir_flow_ext { - pub vlan_tci: u16, - pub flexbytes: [u8; 16usize], - pub is_vf: u8, - pub dst_id: u16, -} -#[test] -fn bindgen_test_layout_rte_eth_fdir_flow_ext() { - assert_eq!( - ::std::mem::size_of::(), - 22usize, - concat!("Size of: ", stringify!(rte_eth_fdir_flow_ext)) - ); - assert_eq!( - ::std::mem::align_of::(), - 2usize, - concat!("Alignment of ", stringify!(rte_eth_fdir_flow_ext)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).vlan_tci as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_flow_ext), - "::", - stringify!(vlan_tci) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flexbytes as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_flow_ext), - "::", - stringify!(flexbytes) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).is_vf as *const _ as usize }, - 18usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_flow_ext), - "::", - stringify!(is_vf) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dst_id as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_flow_ext), - "::", - stringify!(dst_id) - ) - ); + test_field_dst_id(); } #[repr(C)] #[derive(Copy, Clone)] @@ -18054,40 +23341,65 @@ fn bindgen_test_layout_rte_eth_fdir_input() { 4usize, concat!("Alignment of ", stringify!(rte_eth_fdir_input)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flow_type as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_input), - "::", - stringify!(flow_type) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flow as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_input), - "::", - stringify!(flow) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flow_ext as *const _ as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_input), - "::", - stringify!(flow_ext) - ) - ); + fn test_field_flow_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flow_type) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_input), + "::", + stringify!(flow_type) + ) + ); + } + test_field_flow_type(); + fn test_field_flow() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flow) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_input), + "::", + stringify!(flow) + ) + ); + } + test_field_flow(); + fn test_field_flow_ext() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flow_ext) as usize - ptr as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_input), + "::", + stringify!(flow_ext) + ) + ); + } + test_field_flow_ext(); } impl Default for rte_eth_fdir_input { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub mod rte_eth_fdir_behavior { @@ -18123,52 +23435,82 @@ fn bindgen_test_layout_rte_eth_fdir_action() { 4usize, concat!("Alignment of ", stringify!(rte_eth_fdir_action)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rx_queue as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_action), - "::", - stringify!(rx_queue) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).behavior as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_action), - "::", - stringify!(behavior) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).report_status as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_action), - "::", - stringify!(report_status) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flex_off as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_action), - "::", - stringify!(flex_off) - ) - ); + fn test_field_rx_queue() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_queue) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_action), + "::", + stringify!(rx_queue) + ) + ); + } + test_field_rx_queue(); + fn test_field_behavior() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).behavior) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_action), + "::", + stringify!(behavior) + ) + ); + } + test_field_behavior(); + fn test_field_report_status() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).report_status) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_action), + "::", + stringify!(report_status) + ) + ); + } + test_field_report_status(); + fn test_field_flex_off() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flex_off) as usize - ptr as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_action), + "::", + stringify!(flex_off) + ) + ); + } + test_field_flex_off(); } impl Default for rte_eth_fdir_action { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -18190,40 +23532,65 @@ fn bindgen_test_layout_rte_eth_fdir_filter() { 4usize, concat!("Alignment of ", stringify!(rte_eth_fdir_filter)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).soft_id as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_filter), - "::", - stringify!(soft_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).input as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_filter), - "::", - stringify!(input) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).action as *const _ as usize }, - 76usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_filter), - "::", - stringify!(action) - ) - ); + fn test_field_soft_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).soft_id) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_filter), + "::", + stringify!(soft_id) + ) + ); + } + test_field_soft_id(); + fn test_field_input() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).input) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_filter), + "::", + stringify!(input) + ) + ); + } + test_field_input(); + fn test_field_action() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).action) as usize - ptr as usize + }, + 76usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_filter), + "::", + stringify!(action) + ) + ); + } + test_field_action(); } impl Default for rte_eth_fdir_filter { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -18250,98 +23617,142 @@ fn bindgen_test_layout_rte_eth_fdir_masks() { 4usize, concat!("Alignment of ", stringify!(rte_eth_fdir_masks)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).vlan_tci_mask as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_masks), - "::", - stringify!(vlan_tci_mask) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ipv4_mask as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_masks), - "::", - stringify!(ipv4_mask) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ipv6_mask as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_masks), - "::", - stringify!(ipv6_mask) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).src_port_mask as *const _ as usize - }, - 52usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_masks), - "::", - stringify!(src_port_mask) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).dst_port_mask as *const _ as usize - }, - 54usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_masks), - "::", - stringify!(dst_port_mask) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mac_addr_byte_mask as *const _ as usize - }, - 56usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_masks), - "::", - stringify!(mac_addr_byte_mask) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).tunnel_id_mask as *const _ as usize - }, - 60usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_masks), - "::", - stringify!(tunnel_id_mask) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).tunnel_type_mask as *const _ as usize - }, - 64usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_masks), - "::", - stringify!(tunnel_type_mask) - ) - ); + fn test_field_vlan_tci_mask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vlan_tci_mask) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_masks), + "::", + stringify!(vlan_tci_mask) + ) + ); + } + test_field_vlan_tci_mask(); + fn test_field_ipv4_mask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ipv4_mask) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_masks), + "::", + stringify!(ipv4_mask) + ) + ); + } + test_field_ipv4_mask(); + fn test_field_ipv6_mask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ipv6_mask) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_masks), + "::", + stringify!(ipv6_mask) + ) + ); + } + test_field_ipv6_mask(); + fn test_field_src_port_mask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).src_port_mask) as usize - ptr as usize + }, + 52usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_masks), + "::", + stringify!(src_port_mask) + ) + ); + } + test_field_src_port_mask(); + fn test_field_dst_port_mask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dst_port_mask) as usize - ptr as usize + }, + 54usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_masks), + "::", + stringify!(dst_port_mask) + ) + ); + } + test_field_dst_port_mask(); + fn test_field_mac_addr_byte_mask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mac_addr_byte_mask) as usize - ptr as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_masks), + "::", + stringify!(mac_addr_byte_mask) + ) + ); + } + test_field_mac_addr_byte_mask(); + fn test_field_tunnel_id_mask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tunnel_id_mask) as usize - ptr as usize + }, + 60usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_masks), + "::", + stringify!(tunnel_id_mask) + ) + ); + } + test_field_tunnel_id_mask(); + fn test_field_tunnel_type_mask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tunnel_type_mask) as usize - ptr as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_masks), + "::", + stringify!(tunnel_type_mask) + ) + ); + } + test_field_tunnel_type_mask(); } pub mod rte_eth_payload_type { pub type Type = ::std::os::raw::c_uint; @@ -18370,32 +23781,48 @@ fn bindgen_test_layout_rte_eth_flex_payload_cfg() { 4usize, concat!("Alignment of ", stringify!(rte_eth_flex_payload_cfg)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_flex_payload_cfg), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).src_offset as *const _ as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_flex_payload_cfg), - "::", - stringify!(src_offset) - ) - ); + fn test_field_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_flex_payload_cfg), + "::", + stringify!(type_) + ) + ); + } + test_field_type(); + fn test_field_src_offset() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).src_offset) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_flex_payload_cfg), + "::", + stringify!(src_offset) + ) + ); + } + test_field_src_offset(); } impl Default for rte_eth_flex_payload_cfg { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -18416,28 +23843,40 @@ fn bindgen_test_layout_rte_eth_fdir_flex_mask() { 2usize, concat!("Alignment of ", stringify!(rte_eth_fdir_flex_mask)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).flow_type as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_flex_mask), - "::", - stringify!(flow_type) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mask as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_flex_mask), - "::", - stringify!(mask) - ) - ); + fn test_field_flow_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flow_type) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_flex_mask), + "::", + stringify!(flow_type) + ) + ); + } + test_field_flow_type(); + fn test_field_mask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mask) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_flex_mask), + "::", + stringify!(mask) + ) + ); + } + test_field_mask(); } #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq)] @@ -18459,56 +23898,82 @@ fn bindgen_test_layout_rte_eth_fdir_flex_conf() { 4usize, concat!("Alignment of ", stringify!(rte_eth_fdir_flex_conf)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).nb_payloads as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_flex_conf), - "::", - stringify!(nb_payloads) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).nb_flexmasks as *const _ as usize - }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_flex_conf), - "::", - stringify!(nb_flexmasks) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flex_set as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_flex_conf), - "::", - stringify!(flex_set) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).flex_mask as *const _ as usize - }, - 292usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_flex_conf), - "::", - stringify!(flex_mask) - ) - ); + fn test_field_nb_payloads() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_payloads) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_flex_conf), + "::", + stringify!(nb_payloads) + ) + ); + } + test_field_nb_payloads(); + fn test_field_nb_flexmasks() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_flexmasks) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_flex_conf), + "::", + stringify!(nb_flexmasks) + ) + ); + } + test_field_nb_flexmasks(); + fn test_field_flex_set() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flex_set) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_flex_conf), + "::", + stringify!(flex_set) + ) + ); + } + test_field_flex_set(); + fn test_field_flex_mask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flex_mask) as usize - ptr as usize + }, + 292usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_flex_conf), + "::", + stringify!(flex_mask) + ) + ); + } + test_field_flex_mask(); } impl Default for rte_eth_fdir_flex_conf { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub mod rte_fdir_mode { @@ -18547,145 +24012,218 @@ fn bindgen_test_layout_rte_eth_fdir_info() { 8usize, concat!("Alignment of ", stringify!(rte_eth_fdir_info)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mode as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_info), - "::", - stringify!(mode) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mask as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_info), - "::", - stringify!(mask) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flex_conf as *const _ as usize }, - 72usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_info), - "::", - stringify!(flex_conf) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).guarant_spc as *const _ as usize }, - 796usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_info), - "::", - stringify!(guarant_spc) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).best_spc as *const _ as usize }, - 800usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_info), - "::", - stringify!(best_spc) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).flow_types_mask as *const _ as usize - }, - 808usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_info), - "::", - stringify!(flow_types_mask) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).max_flexpayload as *const _ as usize - }, - 816usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_info), - "::", - stringify!(max_flexpayload) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).flex_payload_unit as *const _ as usize - }, - 820usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_info), - "::", - stringify!(flex_payload_unit) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).max_flex_payload_segment_num as *const _ - as usize - }, - 824usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_info), - "::", - stringify!(max_flex_payload_segment_num) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).flex_payload_limit as *const _ as usize - }, - 828usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_info), - "::", - stringify!(flex_payload_limit) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).flex_bitmask_unit as *const _ as usize - }, - 832usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_info), - "::", - stringify!(flex_bitmask_unit) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).max_flex_bitmask_num as *const _ as usize - }, - 836usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_info), - "::", - stringify!(max_flex_bitmask_num) - ) - ); + fn test_field_mode() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mode) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_info), + "::", + stringify!(mode) + ) + ); + } + test_field_mode(); + fn test_field_mask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mask) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_info), + "::", + stringify!(mask) + ) + ); + } + test_field_mask(); + fn test_field_flex_conf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flex_conf) as usize - ptr as usize + }, + 72usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_info), + "::", + stringify!(flex_conf) + ) + ); + } + test_field_flex_conf(); + fn test_field_guarant_spc() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).guarant_spc) as usize - ptr as usize + }, + 796usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_info), + "::", + stringify!(guarant_spc) + ) + ); + } + test_field_guarant_spc(); + fn test_field_best_spc() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).best_spc) as usize - ptr as usize + }, + 800usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_info), + "::", + stringify!(best_spc) + ) + ); + } + test_field_best_spc(); + fn test_field_flow_types_mask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flow_types_mask) as usize - ptr as usize + }, + 808usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_info), + "::", + stringify!(flow_types_mask) + ) + ); + } + test_field_flow_types_mask(); + fn test_field_max_flexpayload() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).max_flexpayload) as usize - ptr as usize + }, + 816usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_info), + "::", + stringify!(max_flexpayload) + ) + ); + } + test_field_max_flexpayload(); + fn test_field_flex_payload_unit() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flex_payload_unit) as usize - ptr as usize + }, + 820usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_info), + "::", + stringify!(flex_payload_unit) + ) + ); + } + test_field_flex_payload_unit(); + fn test_field_max_flex_payload_segment_num() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).max_flex_payload_segment_num) as usize - ptr as usize + }, + 824usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_info), + "::", + stringify!(max_flex_payload_segment_num) + ) + ); + } + test_field_max_flex_payload_segment_num(); + fn test_field_flex_payload_limit() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flex_payload_limit) as usize - ptr as usize + }, + 828usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_info), + "::", + stringify!(flex_payload_limit) + ) + ); + } + test_field_flex_payload_limit(); + fn test_field_flex_bitmask_unit() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flex_bitmask_unit) as usize - ptr as usize + }, + 832usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_info), + "::", + stringify!(flex_bitmask_unit) + ) + ); + } + test_field_flex_bitmask_unit(); + fn test_field_max_flex_bitmask_num() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).max_flex_bitmask_num) as usize - ptr as usize + }, + 836usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_info), + "::", + stringify!(max_flex_bitmask_num) + ) + ); + } + test_field_max_flex_bitmask_num(); } impl Default for rte_eth_fdir_info { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -18714,106 +24252,176 @@ fn bindgen_test_layout_rte_eth_fdir_stats() { 8usize, concat!("Alignment of ", stringify!(rte_eth_fdir_stats)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).collision as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_stats), - "::", - stringify!(collision) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).free as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_stats), - "::", - stringify!(free) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).maxhash as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_stats), - "::", - stringify!(maxhash) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).maxlen as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_stats), - "::", - stringify!(maxlen) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).add as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_stats), - "::", - stringify!(add) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).remove as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_stats), - "::", - stringify!(remove) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).f_add as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_stats), - "::", - stringify!(f_add) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).f_remove as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_stats), - "::", - stringify!(f_remove) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).guarant_cnt as *const _ as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_stats), - "::", - stringify!(guarant_cnt) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).best_cnt as *const _ as usize }, - 52usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_stats), - "::", - stringify!(best_cnt) - ) - ); + fn test_field_collision() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).collision) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_stats), + "::", + stringify!(collision) + ) + ); + } + test_field_collision(); + fn test_field_free() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).free) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_stats), + "::", + stringify!(free) + ) + ); + } + test_field_free(); + fn test_field_maxhash() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).maxhash) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_stats), + "::", + stringify!(maxhash) + ) + ); + } + test_field_maxhash(); + fn test_field_maxlen() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).maxlen) as usize - ptr as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_stats), + "::", + stringify!(maxlen) + ) + ); + } + test_field_maxlen(); + fn test_field_add() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).add) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_stats), + "::", + stringify!(add) + ) + ); + } + test_field_add(); + fn test_field_remove() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).remove) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_stats), + "::", + stringify!(remove) + ) + ); + } + test_field_remove(); + fn test_field_f_add() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).f_add) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_stats), + "::", + stringify!(f_add) + ) + ); + } + test_field_f_add(); + fn test_field_f_remove() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).f_remove) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_stats), + "::", + stringify!(f_remove) + ) + ); + } + test_field_f_remove(); + fn test_field_guarant_cnt() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).guarant_cnt) as usize - ptr as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_stats), + "::", + stringify!(guarant_cnt) + ) + ); + } + test_field_guarant_cnt(); + fn test_field_best_cnt() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).best_cnt) as usize - ptr as usize + }, + 52usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_stats), + "::", + stringify!(best_cnt) + ) + ); + } + test_field_best_cnt(); } pub mod rte_eth_fdir_filter_info_type { pub type Type = ::std::os::raw::c_uint; @@ -18831,7 +24439,6 @@ pub struct rte_eth_fdir_filter_info { #[derive(Copy, Clone)] pub union rte_eth_fdir_filter_info__bindgen_ty_1 { pub input_set_conf: rte_eth_input_set_conf, - _bindgen_union_align: [u32; 130usize], } #[test] fn bindgen_test_layout_rte_eth_fdir_filter_info__bindgen_ty_1() { @@ -18851,23 +24458,32 @@ fn bindgen_test_layout_rte_eth_fdir_filter_info__bindgen_ty_1() { stringify!(rte_eth_fdir_filter_info__bindgen_ty_1) ) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).input_set_conf - as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_filter_info__bindgen_ty_1), - "::", - stringify!(input_set_conf) - ) - ); + fn test_field_input_set_conf() { + assert_eq!( + unsafe { + let uninit = + ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).input_set_conf) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_filter_info__bindgen_ty_1), + "::", + stringify!(input_set_conf) + ) + ); + } + test_field_input_set_conf(); } impl Default for rte_eth_fdir_filter_info__bindgen_ty_1 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[test] @@ -18882,32 +24498,48 @@ fn bindgen_test_layout_rte_eth_fdir_filter_info() { 4usize, concat!("Alignment of ", stringify!(rte_eth_fdir_filter_info)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).info_type as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_filter_info), - "::", - stringify!(info_type) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).info as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_fdir_filter_info), - "::", - stringify!(info) - ) - ); + fn test_field_info_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).info_type) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_filter_info), + "::", + stringify!(info_type) + ) + ); + } + test_field_info_type(); + fn test_field_info() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).info) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_fdir_filter_info), + "::", + stringify!(info) + ) + ); + } + test_field_info(); } impl Default for rte_eth_fdir_filter_info { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub mod rte_eth_hash_filter_info_type { @@ -18937,47 +24569,65 @@ fn bindgen_test_layout_rte_eth_hash_global_conf() { 8usize, concat!("Alignment of ", stringify!(rte_eth_hash_global_conf)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).hash_func as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_hash_global_conf), - "::", - stringify!(hash_func) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).sym_hash_enable_mask as *const _ - as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_hash_global_conf), - "::", - stringify!(sym_hash_enable_mask) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).valid_bit_mask as *const _ as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_hash_global_conf), - "::", - stringify!(valid_bit_mask) - ) - ); + fn test_field_hash_func() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).hash_func) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_hash_global_conf), + "::", + stringify!(hash_func) + ) + ); + } + test_field_hash_func(); + fn test_field_sym_hash_enable_mask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).sym_hash_enable_mask) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_hash_global_conf), + "::", + stringify!(sym_hash_enable_mask) + ) + ); + } + test_field_sym_hash_enable_mask(); + fn test_field_valid_bit_mask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).valid_bit_mask) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_hash_global_conf), + "::", + stringify!(valid_bit_mask) + ) + ); + } + test_field_valid_bit_mask(); } impl Default for rte_eth_hash_global_conf { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -18992,7 +24642,6 @@ pub union rte_eth_hash_filter_info__bindgen_ty_1 { pub enable: u8, pub global_conf: rte_eth_hash_global_conf, pub input_set_conf: rte_eth_input_set_conf, - _bindgen_union_align: [u64; 65usize], } #[test] fn bindgen_test_layout_rte_eth_hash_filter_info__bindgen_ty_1() { @@ -19012,49 +24661,68 @@ fn bindgen_test_layout_rte_eth_hash_filter_info__bindgen_ty_1() { stringify!(rte_eth_hash_filter_info__bindgen_ty_1) ) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).enable as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_hash_filter_info__bindgen_ty_1), - "::", - stringify!(enable) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).global_conf - as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_hash_filter_info__bindgen_ty_1), - "::", - stringify!(global_conf) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).input_set_conf - as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_hash_filter_info__bindgen_ty_1), - "::", - stringify!(input_set_conf) - ) - ); + fn test_field_enable() { + assert_eq!( + unsafe { + let uninit = + ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).enable) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_hash_filter_info__bindgen_ty_1), + "::", + stringify!(enable) + ) + ); + } + test_field_enable(); + fn test_field_global_conf() { + assert_eq!( + unsafe { + let uninit = + ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).global_conf) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_hash_filter_info__bindgen_ty_1), + "::", + stringify!(global_conf) + ) + ); + } + test_field_global_conf(); + fn test_field_input_set_conf() { + assert_eq!( + unsafe { + let uninit = + ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).input_set_conf) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_hash_filter_info__bindgen_ty_1), + "::", + stringify!(input_set_conf) + ) + ); + } + test_field_input_set_conf(); } impl Default for rte_eth_hash_filter_info__bindgen_ty_1 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[test] @@ -19069,32 +24737,48 @@ fn bindgen_test_layout_rte_eth_hash_filter_info() { 8usize, concat!("Alignment of ", stringify!(rte_eth_hash_filter_info)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).info_type as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_hash_filter_info), - "::", - stringify!(info_type) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).info as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_hash_filter_info), - "::", - stringify!(info) - ) - ); + fn test_field_info_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).info_type) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_hash_filter_info), + "::", + stringify!(info_type) + ) + ); + } + test_field_info_type(); + fn test_field_info() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).info) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_hash_filter_info), + "::", + stringify!(info) + ) + ); + } + test_field_info(); } impl Default for rte_eth_hash_filter_info { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -19118,66 +24802,99 @@ fn bindgen_test_layout_rte_eth_l2_tunnel_conf() { 4usize, concat!("Alignment of ", stringify!(rte_eth_l2_tunnel_conf)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).l2_tunnel_type as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_l2_tunnel_conf), - "::", - stringify!(l2_tunnel_type) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ether_type as *const _ as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_l2_tunnel_conf), - "::", - stringify!(ether_type) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).tunnel_id as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_l2_tunnel_conf), - "::", - stringify!(tunnel_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).vf_id as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_l2_tunnel_conf), - "::", - stringify!(vf_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pool as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_l2_tunnel_conf), - "::", - stringify!(pool) - ) - ); + fn test_field_l2_tunnel_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).l2_tunnel_type) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_l2_tunnel_conf), + "::", + stringify!(l2_tunnel_type) + ) + ); + } + test_field_l2_tunnel_type(); + fn test_field_ether_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ether_type) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_l2_tunnel_conf), + "::", + stringify!(ether_type) + ) + ); + } + test_field_ether_type(); + fn test_field_tunnel_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tunnel_id) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_l2_tunnel_conf), + "::", + stringify!(tunnel_id) + ) + ); + } + test_field_tunnel_id(); + fn test_field_vf_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vf_id) as usize - ptr as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_l2_tunnel_conf), + "::", + stringify!(vf_id) + ) + ); + } + test_field_vf_id(); + fn test_field_pool() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pool) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_l2_tunnel_conf), + "::", + stringify!(pool) + ) + ); + } + test_field_pool(); } impl Default for rte_eth_l2_tunnel_conf { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub mod rte_fdir_pballoc_type { @@ -19214,70 +24931,116 @@ fn bindgen_test_layout_rte_fdir_conf() { 4usize, concat!("Alignment of ", stringify!(rte_fdir_conf)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mode as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_fdir_conf), - "::", - stringify!(mode) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pballoc as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_fdir_conf), - "::", - stringify!(pballoc) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).status as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_fdir_conf), - "::", - stringify!(status) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).drop_queue as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(rte_fdir_conf), - "::", - stringify!(drop_queue) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mask as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_fdir_conf), - "::", - stringify!(mask) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flex_conf as *const _ as usize }, - 84usize, - concat!( - "Offset of field: ", - stringify!(rte_fdir_conf), - "::", - stringify!(flex_conf) - ) - ); + fn test_field_mode() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mode) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_fdir_conf), + "::", + stringify!(mode) + ) + ); + } + test_field_mode(); + fn test_field_pballoc() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pballoc) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_fdir_conf), + "::", + stringify!(pballoc) + ) + ); + } + test_field_pballoc(); + fn test_field_status() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).status) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_fdir_conf), + "::", + stringify!(status) + ) + ); + } + test_field_status(); + fn test_field_drop_queue() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).drop_queue) as usize - ptr as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(rte_fdir_conf), + "::", + stringify!(drop_queue) + ) + ); + } + test_field_drop_queue(); + fn test_field_mask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mask) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_fdir_conf), + "::", + stringify!(mask) + ) + ); + } + test_field_mask(); + fn test_field_flex_conf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flex_conf) as usize - ptr as usize + }, + 84usize, + concat!( + "Offset of field: ", + stringify!(rte_fdir_conf), + "::", + stringify!(flex_conf) + ) + ); + } + test_field_flex_conf(); } impl Default for rte_fdir_conf { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -19298,26 +25061,40 @@ fn bindgen_test_layout_rte_eth_udp_tunnel() { 2usize, concat!("Alignment of ", stringify!(rte_eth_udp_tunnel)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).udp_port as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_udp_tunnel), - "::", - stringify!(udp_port) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).prot_type as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_udp_tunnel), - "::", - stringify!(prot_type) - ) - ); + fn test_field_udp_port() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).udp_port) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_udp_tunnel), + "::", + stringify!(udp_port) + ) + ); + } + test_field_udp_port(); + fn test_field_prot_type() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).prot_type) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_udp_tunnel), + "::", + stringify!(prot_type) + ) + ); + } + test_field_prot_type(); } #[repr(C)] #[repr(align(4))] @@ -19406,7 +25183,7 @@ pub struct rte_eth_conf { pub intr_conf: rte_intr_conf, } #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct rte_eth_conf__bindgen_ty_1 { pub rss_conf: rte_eth_rss_conf, pub vmdq_dcb_conf: rte_eth_vmdq_dcb_conf, @@ -19425,59 +25202,82 @@ fn bindgen_test_layout_rte_eth_conf__bindgen_ty_1() { 8usize, concat!("Alignment of ", stringify!(rte_eth_conf__bindgen_ty_1)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).rss_conf as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_conf__bindgen_ty_1), - "::", - stringify!(rss_conf) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).vmdq_dcb_conf as *const _ - as usize - }, - 24usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_conf__bindgen_ty_1), - "::", - stringify!(vmdq_dcb_conf) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).dcb_rx_conf as *const _ as usize - }, - 1064usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_conf__bindgen_ty_1), - "::", - stringify!(dcb_rx_conf) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).vmdq_rx_conf as *const _ as usize - }, - 1080usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_conf__bindgen_ty_1), - "::", - stringify!(vmdq_rx_conf) - ) - ); + fn test_field_rss_conf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rss_conf) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_conf__bindgen_ty_1), + "::", + stringify!(rss_conf) + ) + ); + } + test_field_rss_conf(); + fn test_field_vmdq_dcb_conf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vmdq_dcb_conf) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_conf__bindgen_ty_1), + "::", + stringify!(vmdq_dcb_conf) + ) + ); + } + test_field_vmdq_dcb_conf(); + fn test_field_dcb_rx_conf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dcb_rx_conf) as usize - ptr as usize + }, + 1064usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_conf__bindgen_ty_1), + "::", + stringify!(dcb_rx_conf) + ) + ); + } + test_field_dcb_rx_conf(); + fn test_field_vmdq_rx_conf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vmdq_rx_conf) as usize - ptr as usize + }, + 1080usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_conf__bindgen_ty_1), + "::", + stringify!(vmdq_rx_conf) + ) + ); + } + test_field_vmdq_rx_conf(); } impl Default for rte_eth_conf__bindgen_ty_1 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -19486,7 +25286,6 @@ pub union rte_eth_conf__bindgen_ty_2 { pub vmdq_dcb_tx_conf: rte_eth_vmdq_dcb_tx_conf, pub dcb_tx_conf: rte_eth_dcb_tx_conf, pub vmdq_tx_conf: rte_eth_vmdq_tx_conf, - _bindgen_union_align: [u32; 3usize], } #[test] fn bindgen_test_layout_rte_eth_conf__bindgen_ty_2() { @@ -19500,47 +25299,65 @@ fn bindgen_test_layout_rte_eth_conf__bindgen_ty_2() { 4usize, concat!("Alignment of ", stringify!(rte_eth_conf__bindgen_ty_2)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).vmdq_dcb_tx_conf as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_conf__bindgen_ty_2), - "::", - stringify!(vmdq_dcb_tx_conf) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).dcb_tx_conf as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_conf__bindgen_ty_2), - "::", - stringify!(dcb_tx_conf) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).vmdq_tx_conf as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_conf__bindgen_ty_2), - "::", - stringify!(vmdq_tx_conf) - ) - ); + fn test_field_vmdq_dcb_tx_conf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vmdq_dcb_tx_conf) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_conf__bindgen_ty_2), + "::", + stringify!(vmdq_dcb_tx_conf) + ) + ); + } + test_field_vmdq_dcb_tx_conf(); + fn test_field_dcb_tx_conf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dcb_tx_conf) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_conf__bindgen_ty_2), + "::", + stringify!(dcb_tx_conf) + ) + ); + } + test_field_dcb_tx_conf(); + fn test_field_vmdq_tx_conf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vmdq_tx_conf) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_conf__bindgen_ty_2), + "::", + stringify!(vmdq_tx_conf) + ) + ); + } + test_field_vmdq_tx_conf(); } impl Default for rte_eth_conf__bindgen_ty_2 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[test] @@ -19555,100 +25372,167 @@ fn bindgen_test_layout_rte_eth_conf() { 8usize, concat!("Alignment of ", stringify!(rte_eth_conf)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).link_speeds as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_conf), - "::", - stringify!(link_speeds) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rxmode as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_conf), - "::", - stringify!(rxmode) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).txmode as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_conf), - "::", - stringify!(txmode) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).lpbk_mode as *const _ as usize }, - 120usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_conf), - "::", - stringify!(lpbk_mode) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rx_adv_conf as *const _ as usize }, - 128usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_conf), - "::", - stringify!(rx_adv_conf) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tx_adv_conf as *const _ as usize }, - 2248usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_conf), - "::", - stringify!(tx_adv_conf) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dcb_capability_en as *const _ as usize }, - 2260usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_conf), - "::", - stringify!(dcb_capability_en) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).fdir_conf as *const _ as usize }, - 2264usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_conf), - "::", - stringify!(fdir_conf) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).intr_conf as *const _ as usize }, - 3072usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_conf), - "::", - stringify!(intr_conf) - ) - ); + fn test_field_link_speeds() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).link_speeds) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_conf), + "::", + stringify!(link_speeds) + ) + ); + } + test_field_link_speeds(); + fn test_field_rxmode() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rxmode) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_conf), + "::", + stringify!(rxmode) + ) + ); + } + test_field_rxmode(); + fn test_field_txmode() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).txmode) as usize - ptr as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_conf), + "::", + stringify!(txmode) + ) + ); + } + test_field_txmode(); + fn test_field_lpbk_mode() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).lpbk_mode) as usize - ptr as usize + }, + 120usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_conf), + "::", + stringify!(lpbk_mode) + ) + ); + } + test_field_lpbk_mode(); + fn test_field_rx_adv_conf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_adv_conf) as usize - ptr as usize + }, + 128usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_conf), + "::", + stringify!(rx_adv_conf) + ) + ); + } + test_field_rx_adv_conf(); + fn test_field_tx_adv_conf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tx_adv_conf) as usize - ptr as usize + }, + 2248usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_conf), + "::", + stringify!(tx_adv_conf) + ) + ); + } + test_field_tx_adv_conf(); + fn test_field_dcb_capability_en() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dcb_capability_en) as usize - ptr as usize + }, + 2260usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_conf), + "::", + stringify!(dcb_capability_en) + ) + ); + } + test_field_dcb_capability_en(); + fn test_field_fdir_conf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).fdir_conf) as usize - ptr as usize + }, + 2264usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_conf), + "::", + stringify!(fdir_conf) + ) + ); + } + test_field_fdir_conf(); + fn test_field_intr_conf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).intr_conf) as usize - ptr as usize + }, + 3072usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_conf), + "::", + stringify!(intr_conf) + ) + ); + } + test_field_intr_conf(); } impl Default for rte_eth_conf { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -19670,36 +25554,57 @@ fn bindgen_test_layout_rte_eth_dev_portconf() { 2usize, concat!("Alignment of ", stringify!(rte_eth_dev_portconf)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).burst_size as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_portconf), - "::", - stringify!(burst_size) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ring_size as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_portconf), - "::", - stringify!(ring_size) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).nb_queues as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_portconf), - "::", - stringify!(nb_queues) - ) - ); + fn test_field_burst_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).burst_size) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_portconf), + "::", + stringify!(burst_size) + ) + ); + } + test_field_burst_size(); + fn test_field_ring_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ring_size) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_portconf), + "::", + stringify!(ring_size) + ) + ); + } + test_field_ring_size(); + fn test_field_nb_queues() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_queues) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_portconf), + "::", + stringify!(nb_queues) + ) + ); + } + test_field_nb_queues(); } #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq)] @@ -19720,40 +25625,65 @@ fn bindgen_test_layout_rte_eth_switch_info() { 8usize, concat!("Alignment of ", stringify!(rte_eth_switch_info)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).name as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_switch_info), - "::", - stringify!(name) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).domain_id as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_switch_info), - "::", - stringify!(domain_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).port_id as *const _ as usize }, - 10usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_switch_info), - "::", - stringify!(port_id) - ) - ); + fn test_field_name() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_switch_info), + "::", + stringify!(name) + ) + ); + } + test_field_name(); + fn test_field_domain_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).domain_id) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_switch_info), + "::", + stringify!(domain_id) + ) + ); + } + test_field_domain_id(); + fn test_field_port_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).port_id) as usize - ptr as usize + }, + 10usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_switch_info), + "::", + stringify!(port_id) + ) + ); + } + test_field_port_id(); } impl Default for rte_eth_switch_info { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -19810,482 +25740,764 @@ fn bindgen_test_layout_rte_eth_dev_info() { 8usize, concat!("Alignment of ", stringify!(rte_eth_dev_info)) ); + fn test_field_device() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).device) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(device) + ) + ); + } + test_field_device(); + fn test_field_driver_name() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).driver_name) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(driver_name) + ) + ); + } + test_field_driver_name(); + fn test_field_if_index() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).if_index) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(if_index) + ) + ); + } + test_field_if_index(); + fn test_field_min_mtu() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).min_mtu) as usize - ptr as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(min_mtu) + ) + ); + } + test_field_min_mtu(); + fn test_field_max_mtu() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).max_mtu) as usize - ptr as usize + }, + 22usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(max_mtu) + ) + ); + } + test_field_max_mtu(); + fn test_field_dev_flags() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dev_flags) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(dev_flags) + ) + ); + } + test_field_dev_flags(); + fn test_field_min_rx_bufsize() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).min_rx_bufsize) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(min_rx_bufsize) + ) + ); + } + test_field_min_rx_bufsize(); + fn test_field_max_rx_pktlen() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).max_rx_pktlen) as usize - ptr as usize + }, + 36usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(max_rx_pktlen) + ) + ); + } + test_field_max_rx_pktlen(); + fn test_field_max_lro_pkt_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).max_lro_pkt_size) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(max_lro_pkt_size) + ) + ); + } + test_field_max_lro_pkt_size(); + fn test_field_max_rx_queues() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).max_rx_queues) as usize - ptr as usize + }, + 44usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(max_rx_queues) + ) + ); + } + test_field_max_rx_queues(); + fn test_field_max_tx_queues() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).max_tx_queues) as usize - ptr as usize + }, + 46usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(max_tx_queues) + ) + ); + } + test_field_max_tx_queues(); + fn test_field_max_mac_addrs() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).max_mac_addrs) as usize - ptr as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(max_mac_addrs) + ) + ); + } + test_field_max_mac_addrs(); + fn test_field_max_hash_mac_addrs() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).max_hash_mac_addrs) as usize - ptr as usize + }, + 52usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(max_hash_mac_addrs) + ) + ); + } + test_field_max_hash_mac_addrs(); + fn test_field_max_vfs() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).max_vfs) as usize - ptr as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(max_vfs) + ) + ); + } + test_field_max_vfs(); + fn test_field_max_vmdq_pools() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).max_vmdq_pools) as usize - ptr as usize + }, + 58usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(max_vmdq_pools) + ) + ); + } + test_field_max_vmdq_pools(); + fn test_field_rx_offload_capa() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_offload_capa) as usize - ptr as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(rx_offload_capa) + ) + ); + } + test_field_rx_offload_capa(); + fn test_field_tx_offload_capa() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tx_offload_capa) as usize - ptr as usize + }, + 72usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(tx_offload_capa) + ) + ); + } + test_field_tx_offload_capa(); + fn test_field_rx_queue_offload_capa() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_queue_offload_capa) as usize - ptr as usize + }, + 80usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(rx_queue_offload_capa) + ) + ); + } + test_field_rx_queue_offload_capa(); + fn test_field_tx_queue_offload_capa() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tx_queue_offload_capa) as usize - ptr as usize + }, + 88usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(tx_queue_offload_capa) + ) + ); + } + test_field_tx_queue_offload_capa(); + fn test_field_reta_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).reta_size) as usize - ptr as usize + }, + 96usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(reta_size) + ) + ); + } + test_field_reta_size(); + fn test_field_hash_key_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).hash_key_size) as usize - ptr as usize + }, + 98usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(hash_key_size) + ) + ); + } + test_field_hash_key_size(); + fn test_field_flow_type_rss_offloads() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flow_type_rss_offloads) as usize - ptr as usize + }, + 104usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(flow_type_rss_offloads) + ) + ); + } + test_field_flow_type_rss_offloads(); + fn test_field_default_rxconf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).default_rxconf) as usize - ptr as usize + }, + 112usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(default_rxconf) + ) + ); + } + test_field_default_rxconf(); + fn test_field_default_txconf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).default_txconf) as usize - ptr as usize + }, + 160usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(default_txconf) + ) + ); + } + test_field_default_txconf(); + fn test_field_vmdq_queue_base() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vmdq_queue_base) as usize - ptr as usize + }, + 216usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(vmdq_queue_base) + ) + ); + } + test_field_vmdq_queue_base(); + fn test_field_vmdq_queue_num() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vmdq_queue_num) as usize - ptr as usize + }, + 218usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(vmdq_queue_num) + ) + ); + } + test_field_vmdq_queue_num(); + fn test_field_vmdq_pool_base() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vmdq_pool_base) as usize - ptr as usize + }, + 220usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(vmdq_pool_base) + ) + ); + } + test_field_vmdq_pool_base(); + fn test_field_rx_desc_lim() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_desc_lim) as usize - ptr as usize + }, + 222usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(rx_desc_lim) + ) + ); + } + test_field_rx_desc_lim(); + fn test_field_tx_desc_lim() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tx_desc_lim) as usize - ptr as usize + }, + 232usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(tx_desc_lim) + ) + ); + } + test_field_tx_desc_lim(); + fn test_field_speed_capa() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).speed_capa) as usize - ptr as usize + }, + 244usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(speed_capa) + ) + ); + } + test_field_speed_capa(); + fn test_field_nb_rx_queues() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_rx_queues) as usize - ptr as usize + }, + 248usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(nb_rx_queues) + ) + ); + } + test_field_nb_rx_queues(); + fn test_field_nb_tx_queues() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_tx_queues) as usize - ptr as usize + }, + 250usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(nb_tx_queues) + ) + ); + } + test_field_nb_tx_queues(); + fn test_field_default_rxportconf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).default_rxportconf) as usize - ptr as usize + }, + 252usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(default_rxportconf) + ) + ); + } + test_field_default_rxportconf(); + fn test_field_default_txportconf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).default_txportconf) as usize - ptr as usize + }, + 258usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(default_txportconf) + ) + ); + } + test_field_default_txportconf(); + fn test_field_dev_capa() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dev_capa) as usize - ptr as usize + }, + 264usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(dev_capa) + ) + ); + } + test_field_dev_capa(); + fn test_field_switch_info() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).switch_info) as usize - ptr as usize + }, + 272usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(switch_info) + ) + ); + } + test_field_switch_info(); + fn test_field_reserved_64s() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).reserved_64s) as usize - ptr as usize + }, + 288usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(reserved_64s) + ) + ); + } + test_field_reserved_64s(); + fn test_field_reserved_ptrs() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).reserved_ptrs) as usize - ptr as usize + }, + 304usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_info), + "::", + stringify!(reserved_ptrs) + ) + ); + } + test_field_reserved_ptrs(); +} +impl Default for rte_eth_dev_info { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[repr(align(64))] +#[derive(Debug, Copy, Clone, PartialEq)] +pub struct rte_eth_rxq_info { + pub mp: *mut rte_mempool, + pub conf: rte_eth_rxconf, + pub scattered_rx: u8, + pub nb_desc: u16, +} +#[test] +fn bindgen_test_layout_rte_eth_rxq_info() { assert_eq!( - unsafe { &(*(::std::ptr::null::())).device as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(device) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).driver_name as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(driver_name) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).if_index as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(if_index) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).min_mtu as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(min_mtu) - ) + ::std::mem::size_of::(), + 64usize, + concat!("Size of: ", stringify!(rte_eth_rxq_info)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).max_mtu as *const _ as usize }, - 22usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(max_mtu) - ) + ::std::mem::align_of::(), + 64usize, + concat!("Alignment of ", stringify!(rte_eth_rxq_info)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dev_flags as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(dev_flags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).min_rx_bufsize as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(min_rx_bufsize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).max_rx_pktlen as *const _ as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(max_rx_pktlen) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).max_lro_pkt_size as *const _ as usize - }, - 40usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(max_lro_pkt_size) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).max_rx_queues as *const _ as usize }, - 44usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(max_rx_queues) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).max_tx_queues as *const _ as usize }, - 46usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(max_tx_queues) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).max_mac_addrs as *const _ as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(max_mac_addrs) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).max_hash_mac_addrs as *const _ as usize - }, - 52usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(max_hash_mac_addrs) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).max_vfs as *const _ as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(max_vfs) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).max_vmdq_pools as *const _ as usize }, - 58usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(max_vmdq_pools) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).rx_offload_capa as *const _ as usize - }, - 64usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(rx_offload_capa) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).tx_offload_capa as *const _ as usize - }, - 72usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(tx_offload_capa) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).rx_queue_offload_capa as *const _ as usize - }, - 80usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(rx_queue_offload_capa) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).tx_queue_offload_capa as *const _ as usize - }, - 88usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(tx_queue_offload_capa) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).reta_size as *const _ as usize }, - 96usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(reta_size) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).hash_key_size as *const _ as usize }, - 98usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(hash_key_size) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).flow_type_rss_offloads as *const _ as usize - }, - 104usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(flow_type_rss_offloads) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).default_rxconf as *const _ as usize }, - 112usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(default_rxconf) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).default_txconf as *const _ as usize }, - 160usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(default_txconf) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).vmdq_queue_base as *const _ as usize - }, - 216usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(vmdq_queue_base) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).vmdq_queue_num as *const _ as usize }, - 218usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(vmdq_queue_num) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).vmdq_pool_base as *const _ as usize }, - 220usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(vmdq_pool_base) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rx_desc_lim as *const _ as usize }, - 222usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(rx_desc_lim) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tx_desc_lim as *const _ as usize }, - 232usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(tx_desc_lim) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).speed_capa as *const _ as usize }, - 244usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(speed_capa) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).nb_rx_queues as *const _ as usize }, - 248usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(nb_rx_queues) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).nb_tx_queues as *const _ as usize }, - 250usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(nb_tx_queues) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).default_rxportconf as *const _ as usize - }, - 252usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(default_rxportconf) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).default_txportconf as *const _ as usize - }, - 258usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(default_txportconf) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dev_capa as *const _ as usize }, - 264usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(dev_capa) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).switch_info as *const _ as usize }, - 272usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(switch_info) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved_64s as *const _ as usize }, - 288usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(reserved_64s) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved_ptrs as *const _ as usize }, - 304usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_info), - "::", - stringify!(reserved_ptrs) - ) - ); -} -impl Default for rte_eth_dev_info { - fn default() -> Self { - unsafe { ::std::mem::zeroed() } + fn test_field_mp() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mp) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_rxq_info), + "::", + stringify!(mp) + ) + ); + } + test_field_mp(); + fn test_field_conf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).conf) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_rxq_info), + "::", + stringify!(conf) + ) + ); + } + test_field_conf(); + fn test_field_scattered_rx() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).scattered_rx) as usize - ptr as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_rxq_info), + "::", + stringify!(scattered_rx) + ) + ); + } + test_field_scattered_rx(); + fn test_field_nb_desc() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_desc) as usize - ptr as usize + }, + 58usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_rxq_info), + "::", + stringify!(nb_desc) + ) + ); } -} -#[repr(C)] -#[repr(align(64))] -#[derive(Copy, Clone)] -pub struct rte_eth_rxq_info { - pub mp: *mut rte_mempool, - pub conf: rte_eth_rxconf, - pub scattered_rx: u8, - pub nb_desc: u16, -} -#[test] -fn bindgen_test_layout_rte_eth_rxq_info() { - assert_eq!( - ::std::mem::size_of::(), - 64usize, - concat!("Size of: ", stringify!(rte_eth_rxq_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 64usize, - concat!("Alignment of ", stringify!(rte_eth_rxq_info)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mp as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_rxq_info), - "::", - stringify!(mp) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).conf as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_rxq_info), - "::", - stringify!(conf) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).scattered_rx as *const _ as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_rxq_info), - "::", - stringify!(scattered_rx) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).nb_desc as *const _ as usize }, - 58usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_rxq_info), - "::", - stringify!(nb_desc) - ) - ); + test_field_nb_desc(); } impl Default for rte_eth_rxq_info { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] #[repr(align(64))] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct rte_eth_txq_info { pub conf: rte_eth_txconf, pub nb_desc: u16, @@ -20302,34 +26514,52 @@ fn bindgen_test_layout_rte_eth_txq_info() { 64usize, concat!("Alignment of ", stringify!(rte_eth_txq_info)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).conf as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_txq_info), - "::", - stringify!(conf) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).nb_desc as *const _ as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_txq_info), - "::", - stringify!(nb_desc) - ) - ); + fn test_field_conf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).conf) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_txq_info), + "::", + stringify!(conf) + ) + ); + } + test_field_conf(); + fn test_field_nb_desc() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_desc) as usize - ptr as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_txq_info), + "::", + stringify!(nb_desc) + ) + ); + } + test_field_nb_desc(); } impl Default for rte_eth_txq_info { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct rte_eth_burst_mode { pub flags: u64, pub info: [::std::os::raw::c_char; 1024usize], @@ -20346,30 +26576,48 @@ fn bindgen_test_layout_rte_eth_burst_mode() { 8usize, concat!("Alignment of ", stringify!(rte_eth_burst_mode)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_burst_mode), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).info as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_burst_mode), - "::", - stringify!(info) - ) - ); + fn test_field_flags() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_burst_mode), + "::", + stringify!(flags) + ) + ); + } + test_field_flags(); + fn test_field_info() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).info) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_burst_mode), + "::", + stringify!(info) + ) + ); + } + test_field_info(); } impl Default for rte_eth_burst_mode { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -20390,29 +26638,43 @@ fn bindgen_test_layout_rte_eth_xstat() { 8usize, concat!("Alignment of ", stringify!(rte_eth_xstat)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).id as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_xstat), - "::", - stringify!(id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).value as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_xstat), - "::", - stringify!(value) - ) - ); + fn test_field_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_xstat), + "::", + stringify!(id) + ) + ); + } + test_field_id(); + fn test_field_value() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).value) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_xstat), + "::", + stringify!(value) + ) + ); + } + test_field_value(); } #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct rte_eth_xstat_name { pub name: [::std::os::raw::c_char; 64usize], } @@ -20428,24 +26690,35 @@ fn bindgen_test_layout_rte_eth_xstat_name() { 1usize, concat!("Alignment of ", stringify!(rte_eth_xstat_name)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).name as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_xstat_name), - "::", - stringify!(name) - ) - ); + fn test_field_name() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_xstat_name), + "::", + stringify!(name) + ) + ); + } + test_field_name(); } impl Default for rte_eth_xstat_name { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct rte_eth_dcb_tc_queue_mapping { pub tc_rxq: [[rte_eth_dcb_tc_queue_mapping__bindgen_ty_1; 8usize]; 64usize], pub tc_txq: [[rte_eth_dcb_tc_queue_mapping__bindgen_ty_2; 8usize]; 64usize], @@ -20474,32 +26747,42 @@ fn bindgen_test_layout_rte_eth_dcb_tc_queue_mapping__bindgen_ty_1() { stringify!(rte_eth_dcb_tc_queue_mapping__bindgen_ty_1) ) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).base as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dcb_tc_queue_mapping__bindgen_ty_1), - "::", - stringify!(base) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).nb_queue - as *const _ as usize - }, - 1usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dcb_tc_queue_mapping__bindgen_ty_1), - "::", - stringify!(nb_queue) - ) - ); + fn test_field_base() { + assert_eq!( + unsafe { + let uninit = + ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).base) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dcb_tc_queue_mapping__bindgen_ty_1), + "::", + stringify!(base) + ) + ); + } + test_field_base(); + fn test_field_nb_queue() { + assert_eq!( + unsafe { + let uninit = + ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_queue) as usize - ptr as usize + }, + 1usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dcb_tc_queue_mapping__bindgen_ty_1), + "::", + stringify!(nb_queue) + ) + ); + } + test_field_nb_queue(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -20525,32 +26808,42 @@ fn bindgen_test_layout_rte_eth_dcb_tc_queue_mapping__bindgen_ty_2() { stringify!(rte_eth_dcb_tc_queue_mapping__bindgen_ty_2) ) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).base as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dcb_tc_queue_mapping__bindgen_ty_2), - "::", - stringify!(base) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).nb_queue - as *const _ as usize - }, - 1usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dcb_tc_queue_mapping__bindgen_ty_2), - "::", - stringify!(nb_queue) - ) - ); + fn test_field_base() { + assert_eq!( + unsafe { + let uninit = + ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).base) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dcb_tc_queue_mapping__bindgen_ty_2), + "::", + stringify!(base) + ) + ); + } + test_field_base(); + fn test_field_nb_queue() { + assert_eq!( + unsafe { + let uninit = + ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_queue) as usize - ptr as usize + }, + 1usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dcb_tc_queue_mapping__bindgen_ty_2), + "::", + stringify!(nb_queue) + ) + ); + } + test_field_nb_queue(); } #[test] fn bindgen_test_layout_rte_eth_dcb_tc_queue_mapping() { @@ -20564,38 +26857,52 @@ fn bindgen_test_layout_rte_eth_dcb_tc_queue_mapping() { 1usize, concat!("Alignment of ", stringify!(rte_eth_dcb_tc_queue_mapping)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).tc_rxq as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dcb_tc_queue_mapping), - "::", - stringify!(tc_rxq) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).tc_txq as *const _ as usize - }, - 1024usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dcb_tc_queue_mapping), - "::", - stringify!(tc_txq) - ) - ); + fn test_field_tc_rxq() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tc_rxq) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dcb_tc_queue_mapping), + "::", + stringify!(tc_rxq) + ) + ); + } + test_field_tc_rxq(); + fn test_field_tc_txq() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tc_txq) as usize - ptr as usize + }, + 1024usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dcb_tc_queue_mapping), + "::", + stringify!(tc_txq) + ) + ); + } + test_field_tc_txq(); } impl Default for rte_eth_dcb_tc_queue_mapping { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct rte_eth_dcb_info { pub nb_tcs: u8, pub prio_tc: [u8; 8usize], @@ -20614,50 +26921,82 @@ fn bindgen_test_layout_rte_eth_dcb_info() { 1usize, concat!("Alignment of ", stringify!(rte_eth_dcb_info)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).nb_tcs as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dcb_info), - "::", - stringify!(nb_tcs) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).prio_tc as *const _ as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dcb_info), - "::", - stringify!(prio_tc) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tc_bws as *const _ as usize }, - 9usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dcb_info), - "::", - stringify!(tc_bws) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tc_queue as *const _ as usize }, - 17usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dcb_info), - "::", - stringify!(tc_queue) - ) - ); + fn test_field_nb_tcs() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_tcs) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dcb_info), + "::", + stringify!(nb_tcs) + ) + ); + } + test_field_nb_tcs(); + fn test_field_prio_tc() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).prio_tc) as usize - ptr as usize + }, + 1usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dcb_info), + "::", + stringify!(prio_tc) + ) + ); + } + test_field_prio_tc(); + fn test_field_tc_bws() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tc_bws) as usize - ptr as usize + }, + 9usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dcb_info), + "::", + stringify!(tc_bws) + ) + ); + } + test_field_tc_bws(); + fn test_field_tc_queue() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tc_queue) as usize - ptr as usize + }, + 17usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dcb_info), + "::", + stringify!(tc_queue) + ) + ); + } + test_field_tc_queue(); } impl Default for rte_eth_dcb_info { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type rte_rx_callback_fn = ::std::option::Option< @@ -20705,51 +27044,77 @@ fn bindgen_test_layout_rte_eth_dev_sriov() { 2usize, concat!("Alignment of ", stringify!(rte_eth_dev_sriov)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).active as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_sriov), - "::", - stringify!(active) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).nb_q_per_pool as *const _ as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_sriov), - "::", - stringify!(nb_q_per_pool) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).def_vmdq_idx as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_sriov), - "::", - stringify!(def_vmdq_idx) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).def_pool_q_idx as *const _ as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_sriov), - "::", - stringify!(def_pool_q_idx) - ) - ); + fn test_field_active() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).active) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_sriov), + "::", + stringify!(active) + ) + ); + } + test_field_active(); + fn test_field_nb_q_per_pool() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_q_per_pool) as usize - ptr as usize + }, + 1usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_sriov), + "::", + stringify!(nb_q_per_pool) + ) + ); + } + test_field_nb_q_per_pool(); + fn test_field_def_vmdq_idx() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).def_vmdq_idx) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_sriov), + "::", + stringify!(def_vmdq_idx) + ) + ); + } + test_field_def_vmdq_idx(); + fn test_field_def_pool_q_idx() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).def_pool_q_idx) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_sriov), + "::", + stringify!(def_pool_q_idx) + ) + ); + } + test_field_def_pool_q_idx(); } #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct rte_eth_dev_owner { pub id: u64, pub name: [::std::os::raw::c_char; 64usize], @@ -20766,30 +27131,48 @@ fn bindgen_test_layout_rte_eth_dev_owner() { 8usize, concat!("Alignment of ", stringify!(rte_eth_dev_owner)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).id as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_owner), - "::", - stringify!(id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).name as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_owner), - "::", - stringify!(name) - ) - ); + fn test_field_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_owner), + "::", + stringify!(id) + ) + ); + } + test_field_id(); + fn test_field_name() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_owner), + "::", + stringify!(name) + ) + ); + } + test_field_name(); } impl Default for rte_eth_dev_owner { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } extern "C" { @@ -21115,7 +27498,11 @@ fn bindgen_test_layout_rte_eth_dev_tx_buffer() { } impl Default for rte_eth_dev_tx_buffer { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } extern "C" { @@ -21178,34 +27565,48 @@ fn bindgen_test_layout_rte_eth_event_ipsec_desc() { 8usize, concat!("Alignment of ", stringify!(rte_eth_event_ipsec_desc)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).subtype as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_event_ipsec_desc), - "::", - stringify!(subtype) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).metadata as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_event_ipsec_desc), - "::", - stringify!(metadata) - ) - ); + fn test_field_subtype() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).subtype) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_event_ipsec_desc), + "::", + stringify!(subtype) + ) + ); + } + test_field_subtype(); + fn test_field_metadata() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).metadata) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_event_ipsec_desc), + "::", + stringify!(metadata) + ) + ); + } + test_field_metadata(); } impl Default for rte_eth_event_ipsec_desc { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub mod rte_eth_event_type { @@ -21612,30 +28013,48 @@ fn bindgen_test_layout_rte_eth_dev_cb_list() { 8usize, concat!("Alignment of ", stringify!(rte_eth_dev_cb_list)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tqh_first as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_cb_list), - "::", - stringify!(tqh_first) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tqh_last as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_cb_list), - "::", - stringify!(tqh_last) - ) - ); + fn test_field_tqh_first() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tqh_first) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_cb_list), + "::", + stringify!(tqh_first) + ) + ); + } + test_field_tqh_first(); + fn test_field_tqh_last() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tqh_last) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_cb_list), + "::", + stringify!(tqh_last) + ) + ); + } + test_field_tqh_last(); } impl Default for rte_eth_dev_cb_list { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type eth_dev_configure_t = @@ -22196,984 +28615,1604 @@ fn bindgen_test_layout_eth_dev_ops() { 8usize, concat!("Alignment of ", stringify!(eth_dev_ops)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dev_configure as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(dev_configure) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dev_start as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(dev_start) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dev_stop as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(dev_stop) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dev_set_link_up as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(dev_set_link_up) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dev_set_link_down as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(dev_set_link_down) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dev_close as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(dev_close) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dev_reset as *const _ as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(dev_reset) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).link_update as *const _ as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(link_update) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).is_removed as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(is_removed) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).promiscuous_enable as *const _ as usize }, - 72usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(promiscuous_enable) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).promiscuous_disable as *const _ as usize }, - 80usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(promiscuous_disable) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).allmulticast_enable as *const _ as usize }, - 88usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(allmulticast_enable) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).allmulticast_disable as *const _ as usize - }, - 96usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(allmulticast_disable) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mac_addr_remove as *const _ as usize }, - 104usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(mac_addr_remove) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mac_addr_add as *const _ as usize }, - 112usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(mac_addr_add) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mac_addr_set as *const _ as usize }, - 120usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(mac_addr_set) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).set_mc_addr_list as *const _ as usize }, - 128usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(set_mc_addr_list) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mtu_set as *const _ as usize }, - 136usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(mtu_set) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).stats_get as *const _ as usize }, - 144usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(stats_get) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).stats_reset as *const _ as usize }, - 152usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(stats_reset) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).xstats_get as *const _ as usize }, - 160usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(xstats_get) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).xstats_reset as *const _ as usize }, - 168usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(xstats_reset) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).xstats_get_names as *const _ as usize }, - 176usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(xstats_get_names) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).queue_stats_mapping_set as *const _ as usize - }, - 184usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(queue_stats_mapping_set) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dev_infos_get as *const _ as usize }, - 192usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(dev_infos_get) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rxq_info_get as *const _ as usize }, - 200usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(rxq_info_get) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).txq_info_get as *const _ as usize }, - 208usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(txq_info_get) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rx_burst_mode_get as *const _ as usize }, - 216usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(rx_burst_mode_get) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tx_burst_mode_get as *const _ as usize }, - 224usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(tx_burst_mode_get) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).fw_version_get as *const _ as usize }, - 232usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(fw_version_get) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).dev_supported_ptypes_get as *const _ as usize - }, - 240usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(dev_supported_ptypes_get) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dev_ptypes_set as *const _ as usize }, - 248usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(dev_ptypes_set) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).vlan_filter_set as *const _ as usize }, - 256usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(vlan_filter_set) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).vlan_tpid_set as *const _ as usize }, - 264usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(vlan_tpid_set) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).vlan_strip_queue_set as *const _ as usize - }, - 272usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(vlan_strip_queue_set) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).vlan_offload_set as *const _ as usize }, - 280usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(vlan_offload_set) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).vlan_pvid_set as *const _ as usize }, - 288usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(vlan_pvid_set) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rx_queue_start as *const _ as usize }, - 296usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(rx_queue_start) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rx_queue_stop as *const _ as usize }, - 304usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(rx_queue_stop) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tx_queue_start as *const _ as usize }, - 312usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(tx_queue_start) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tx_queue_stop as *const _ as usize }, - 320usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(tx_queue_stop) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rx_queue_setup as *const _ as usize }, - 328usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(rx_queue_setup) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rx_queue_release as *const _ as usize }, - 336usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(rx_queue_release) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rx_queue_count as *const _ as usize }, - 344usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(rx_queue_count) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rx_descriptor_done as *const _ as usize }, - 352usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(rx_descriptor_done) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).rx_descriptor_status as *const _ as usize - }, - 360usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(rx_descriptor_status) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).tx_descriptor_status as *const _ as usize - }, - 368usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(tx_descriptor_status) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).rx_queue_intr_enable as *const _ as usize - }, - 376usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(rx_queue_intr_enable) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).rx_queue_intr_disable as *const _ as usize - }, - 384usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(rx_queue_intr_disable) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tx_queue_setup as *const _ as usize }, - 392usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(tx_queue_setup) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tx_queue_release as *const _ as usize }, - 400usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(tx_queue_release) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tx_done_cleanup as *const _ as usize }, - 408usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(tx_done_cleanup) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dev_led_on as *const _ as usize }, - 416usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(dev_led_on) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dev_led_off as *const _ as usize }, - 424usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(dev_led_off) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flow_ctrl_get as *const _ as usize }, - 432usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(flow_ctrl_get) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flow_ctrl_set as *const _ as usize }, - 440usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(flow_ctrl_set) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).priority_flow_ctrl_set as *const _ as usize - }, - 448usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(priority_flow_ctrl_set) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).uc_hash_table_set as *const _ as usize }, - 456usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(uc_hash_table_set) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).uc_all_hash_table_set as *const _ as usize - }, - 464usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(uc_all_hash_table_set) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mirror_rule_set as *const _ as usize }, - 472usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(mirror_rule_set) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mirror_rule_reset as *const _ as usize }, - 480usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(mirror_rule_reset) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).udp_tunnel_port_add as *const _ as usize }, - 488usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(udp_tunnel_port_add) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).udp_tunnel_port_del as *const _ as usize }, - 496usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(udp_tunnel_port_del) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).l2_tunnel_eth_type_conf as *const _ as usize - }, - 504usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(l2_tunnel_eth_type_conf) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).l2_tunnel_offload_set as *const _ as usize - }, - 512usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(l2_tunnel_offload_set) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).set_queue_rate_limit as *const _ as usize - }, - 520usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(set_queue_rate_limit) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rss_hash_update as *const _ as usize }, - 528usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(rss_hash_update) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rss_hash_conf_get as *const _ as usize }, - 536usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(rss_hash_conf_get) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).reta_update as *const _ as usize }, - 544usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(reta_update) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).reta_query as *const _ as usize }, - 552usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(reta_query) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).get_reg as *const _ as usize }, - 560usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(get_reg) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).get_eeprom_length as *const _ as usize }, - 568usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(get_eeprom_length) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).get_eeprom as *const _ as usize }, - 576usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(get_eeprom) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).set_eeprom as *const _ as usize }, - 584usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(set_eeprom) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).get_module_info as *const _ as usize }, - 592usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(get_module_info) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).get_module_eeprom as *const _ as usize }, - 600usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(get_module_eeprom) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).filter_ctrl as *const _ as usize }, - 608usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(filter_ctrl) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).get_dcb_info as *const _ as usize }, - 616usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(get_dcb_info) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).timesync_enable as *const _ as usize }, - 624usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(timesync_enable) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).timesync_disable as *const _ as usize }, - 632usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(timesync_disable) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).timesync_read_rx_timestamp as *const _ as usize - }, - 640usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(timesync_read_rx_timestamp) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).timesync_read_tx_timestamp as *const _ as usize - }, - 648usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(timesync_read_tx_timestamp) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).timesync_adjust_time as *const _ as usize - }, - 656usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(timesync_adjust_time) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).timesync_read_time as *const _ as usize }, - 664usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(timesync_read_time) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).timesync_write_time as *const _ as usize }, - 672usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(timesync_write_time) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).read_clock as *const _ as usize }, - 680usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(read_clock) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).xstats_get_by_id as *const _ as usize }, - 688usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(xstats_get_by_id) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).xstats_get_names_by_id as *const _ as usize - }, - 696usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(xstats_get_names_by_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tm_ops_get as *const _ as usize }, - 704usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(tm_ops_get) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mtr_ops_get as *const _ as usize }, - 712usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(mtr_ops_get) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pool_ops_supported as *const _ as usize }, - 720usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(pool_ops_supported) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).hairpin_cap_get as *const _ as usize }, - 728usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(hairpin_cap_get) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).rx_hairpin_queue_setup as *const _ as usize - }, - 736usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(rx_hairpin_queue_setup) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).tx_hairpin_queue_setup as *const _ as usize - }, - 744usize, - concat!( - "Offset of field: ", - stringify!(eth_dev_ops), - "::", - stringify!(tx_hairpin_queue_setup) - ) - ); + fn test_field_dev_configure() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dev_configure) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(dev_configure) + ) + ); + } + test_field_dev_configure(); + fn test_field_dev_start() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dev_start) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(dev_start) + ) + ); + } + test_field_dev_start(); + fn test_field_dev_stop() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dev_stop) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(dev_stop) + ) + ); + } + test_field_dev_stop(); + fn test_field_dev_set_link_up() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dev_set_link_up) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(dev_set_link_up) + ) + ); + } + test_field_dev_set_link_up(); + fn test_field_dev_set_link_down() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dev_set_link_down) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(dev_set_link_down) + ) + ); + } + test_field_dev_set_link_down(); + fn test_field_dev_close() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dev_close) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(dev_close) + ) + ); + } + test_field_dev_close(); + fn test_field_dev_reset() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dev_reset) as usize - ptr as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(dev_reset) + ) + ); + } + test_field_dev_reset(); + fn test_field_link_update() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).link_update) as usize - ptr as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(link_update) + ) + ); + } + test_field_link_update(); + fn test_field_is_removed() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).is_removed) as usize - ptr as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(is_removed) + ) + ); + } + test_field_is_removed(); + fn test_field_promiscuous_enable() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).promiscuous_enable) as usize - ptr as usize + }, + 72usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(promiscuous_enable) + ) + ); + } + test_field_promiscuous_enable(); + fn test_field_promiscuous_disable() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).promiscuous_disable) as usize - ptr as usize + }, + 80usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(promiscuous_disable) + ) + ); + } + test_field_promiscuous_disable(); + fn test_field_allmulticast_enable() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).allmulticast_enable) as usize - ptr as usize + }, + 88usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(allmulticast_enable) + ) + ); + } + test_field_allmulticast_enable(); + fn test_field_allmulticast_disable() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).allmulticast_disable) as usize - ptr as usize + }, + 96usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(allmulticast_disable) + ) + ); + } + test_field_allmulticast_disable(); + fn test_field_mac_addr_remove() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mac_addr_remove) as usize - ptr as usize + }, + 104usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(mac_addr_remove) + ) + ); + } + test_field_mac_addr_remove(); + fn test_field_mac_addr_add() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mac_addr_add) as usize - ptr as usize + }, + 112usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(mac_addr_add) + ) + ); + } + test_field_mac_addr_add(); + fn test_field_mac_addr_set() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mac_addr_set) as usize - ptr as usize + }, + 120usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(mac_addr_set) + ) + ); + } + test_field_mac_addr_set(); + fn test_field_set_mc_addr_list() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).set_mc_addr_list) as usize - ptr as usize + }, + 128usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(set_mc_addr_list) + ) + ); + } + test_field_set_mc_addr_list(); + fn test_field_mtu_set() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mtu_set) as usize - ptr as usize + }, + 136usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(mtu_set) + ) + ); + } + test_field_mtu_set(); + fn test_field_stats_get() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).stats_get) as usize - ptr as usize + }, + 144usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(stats_get) + ) + ); + } + test_field_stats_get(); + fn test_field_stats_reset() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).stats_reset) as usize - ptr as usize + }, + 152usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(stats_reset) + ) + ); + } + test_field_stats_reset(); + fn test_field_xstats_get() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).xstats_get) as usize - ptr as usize + }, + 160usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(xstats_get) + ) + ); + } + test_field_xstats_get(); + fn test_field_xstats_reset() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).xstats_reset) as usize - ptr as usize + }, + 168usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(xstats_reset) + ) + ); + } + test_field_xstats_reset(); + fn test_field_xstats_get_names() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).xstats_get_names) as usize - ptr as usize + }, + 176usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(xstats_get_names) + ) + ); + } + test_field_xstats_get_names(); + fn test_field_queue_stats_mapping_set() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).queue_stats_mapping_set) as usize - ptr as usize + }, + 184usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(queue_stats_mapping_set) + ) + ); + } + test_field_queue_stats_mapping_set(); + fn test_field_dev_infos_get() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dev_infos_get) as usize - ptr as usize + }, + 192usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(dev_infos_get) + ) + ); + } + test_field_dev_infos_get(); + fn test_field_rxq_info_get() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rxq_info_get) as usize - ptr as usize + }, + 200usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(rxq_info_get) + ) + ); + } + test_field_rxq_info_get(); + fn test_field_txq_info_get() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).txq_info_get) as usize - ptr as usize + }, + 208usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(txq_info_get) + ) + ); + } + test_field_txq_info_get(); + fn test_field_rx_burst_mode_get() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_burst_mode_get) as usize - ptr as usize + }, + 216usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(rx_burst_mode_get) + ) + ); + } + test_field_rx_burst_mode_get(); + fn test_field_tx_burst_mode_get() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tx_burst_mode_get) as usize - ptr as usize + }, + 224usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(tx_burst_mode_get) + ) + ); + } + test_field_tx_burst_mode_get(); + fn test_field_fw_version_get() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).fw_version_get) as usize - ptr as usize + }, + 232usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(fw_version_get) + ) + ); + } + test_field_fw_version_get(); + fn test_field_dev_supported_ptypes_get() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dev_supported_ptypes_get) as usize - ptr as usize + }, + 240usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(dev_supported_ptypes_get) + ) + ); + } + test_field_dev_supported_ptypes_get(); + fn test_field_dev_ptypes_set() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dev_ptypes_set) as usize - ptr as usize + }, + 248usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(dev_ptypes_set) + ) + ); + } + test_field_dev_ptypes_set(); + fn test_field_vlan_filter_set() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vlan_filter_set) as usize - ptr as usize + }, + 256usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(vlan_filter_set) + ) + ); + } + test_field_vlan_filter_set(); + fn test_field_vlan_tpid_set() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vlan_tpid_set) as usize - ptr as usize + }, + 264usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(vlan_tpid_set) + ) + ); + } + test_field_vlan_tpid_set(); + fn test_field_vlan_strip_queue_set() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vlan_strip_queue_set) as usize - ptr as usize + }, + 272usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(vlan_strip_queue_set) + ) + ); + } + test_field_vlan_strip_queue_set(); + fn test_field_vlan_offload_set() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vlan_offload_set) as usize - ptr as usize + }, + 280usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(vlan_offload_set) + ) + ); + } + test_field_vlan_offload_set(); + fn test_field_vlan_pvid_set() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vlan_pvid_set) as usize - ptr as usize + }, + 288usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(vlan_pvid_set) + ) + ); + } + test_field_vlan_pvid_set(); + fn test_field_rx_queue_start() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_queue_start) as usize - ptr as usize + }, + 296usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(rx_queue_start) + ) + ); + } + test_field_rx_queue_start(); + fn test_field_rx_queue_stop() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_queue_stop) as usize - ptr as usize + }, + 304usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(rx_queue_stop) + ) + ); + } + test_field_rx_queue_stop(); + fn test_field_tx_queue_start() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tx_queue_start) as usize - ptr as usize + }, + 312usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(tx_queue_start) + ) + ); + } + test_field_tx_queue_start(); + fn test_field_tx_queue_stop() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tx_queue_stop) as usize - ptr as usize + }, + 320usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(tx_queue_stop) + ) + ); + } + test_field_tx_queue_stop(); + fn test_field_rx_queue_setup() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_queue_setup) as usize - ptr as usize + }, + 328usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(rx_queue_setup) + ) + ); + } + test_field_rx_queue_setup(); + fn test_field_rx_queue_release() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_queue_release) as usize - ptr as usize + }, + 336usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(rx_queue_release) + ) + ); + } + test_field_rx_queue_release(); + fn test_field_rx_queue_count() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_queue_count) as usize - ptr as usize + }, + 344usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(rx_queue_count) + ) + ); + } + test_field_rx_queue_count(); + fn test_field_rx_descriptor_done() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_descriptor_done) as usize - ptr as usize + }, + 352usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(rx_descriptor_done) + ) + ); + } + test_field_rx_descriptor_done(); + fn test_field_rx_descriptor_status() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_descriptor_status) as usize - ptr as usize + }, + 360usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(rx_descriptor_status) + ) + ); + } + test_field_rx_descriptor_status(); + fn test_field_tx_descriptor_status() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tx_descriptor_status) as usize - ptr as usize + }, + 368usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(tx_descriptor_status) + ) + ); + } + test_field_tx_descriptor_status(); + fn test_field_rx_queue_intr_enable() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_queue_intr_enable) as usize - ptr as usize + }, + 376usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(rx_queue_intr_enable) + ) + ); + } + test_field_rx_queue_intr_enable(); + fn test_field_rx_queue_intr_disable() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_queue_intr_disable) as usize - ptr as usize + }, + 384usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(rx_queue_intr_disable) + ) + ); + } + test_field_rx_queue_intr_disable(); + fn test_field_tx_queue_setup() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tx_queue_setup) as usize - ptr as usize + }, + 392usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(tx_queue_setup) + ) + ); + } + test_field_tx_queue_setup(); + fn test_field_tx_queue_release() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tx_queue_release) as usize - ptr as usize + }, + 400usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(tx_queue_release) + ) + ); + } + test_field_tx_queue_release(); + fn test_field_tx_done_cleanup() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tx_done_cleanup) as usize - ptr as usize + }, + 408usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(tx_done_cleanup) + ) + ); + } + test_field_tx_done_cleanup(); + fn test_field_dev_led_on() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dev_led_on) as usize - ptr as usize + }, + 416usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(dev_led_on) + ) + ); + } + test_field_dev_led_on(); + fn test_field_dev_led_off() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dev_led_off) as usize - ptr as usize + }, + 424usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(dev_led_off) + ) + ); + } + test_field_dev_led_off(); + fn test_field_flow_ctrl_get() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flow_ctrl_get) as usize - ptr as usize + }, + 432usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(flow_ctrl_get) + ) + ); + } + test_field_flow_ctrl_get(); + fn test_field_flow_ctrl_set() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flow_ctrl_set) as usize - ptr as usize + }, + 440usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(flow_ctrl_set) + ) + ); + } + test_field_flow_ctrl_set(); + fn test_field_priority_flow_ctrl_set() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).priority_flow_ctrl_set) as usize - ptr as usize + }, + 448usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(priority_flow_ctrl_set) + ) + ); + } + test_field_priority_flow_ctrl_set(); + fn test_field_uc_hash_table_set() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).uc_hash_table_set) as usize - ptr as usize + }, + 456usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(uc_hash_table_set) + ) + ); + } + test_field_uc_hash_table_set(); + fn test_field_uc_all_hash_table_set() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).uc_all_hash_table_set) as usize - ptr as usize + }, + 464usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(uc_all_hash_table_set) + ) + ); + } + test_field_uc_all_hash_table_set(); + fn test_field_mirror_rule_set() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mirror_rule_set) as usize - ptr as usize + }, + 472usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(mirror_rule_set) + ) + ); + } + test_field_mirror_rule_set(); + fn test_field_mirror_rule_reset() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mirror_rule_reset) as usize - ptr as usize + }, + 480usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(mirror_rule_reset) + ) + ); + } + test_field_mirror_rule_reset(); + fn test_field_udp_tunnel_port_add() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).udp_tunnel_port_add) as usize - ptr as usize + }, + 488usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(udp_tunnel_port_add) + ) + ); + } + test_field_udp_tunnel_port_add(); + fn test_field_udp_tunnel_port_del() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).udp_tunnel_port_del) as usize - ptr as usize + }, + 496usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(udp_tunnel_port_del) + ) + ); + } + test_field_udp_tunnel_port_del(); + fn test_field_l2_tunnel_eth_type_conf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).l2_tunnel_eth_type_conf) as usize - ptr as usize + }, + 504usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(l2_tunnel_eth_type_conf) + ) + ); + } + test_field_l2_tunnel_eth_type_conf(); + fn test_field_l2_tunnel_offload_set() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).l2_tunnel_offload_set) as usize - ptr as usize + }, + 512usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(l2_tunnel_offload_set) + ) + ); + } + test_field_l2_tunnel_offload_set(); + fn test_field_set_queue_rate_limit() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).set_queue_rate_limit) as usize - ptr as usize + }, + 520usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(set_queue_rate_limit) + ) + ); + } + test_field_set_queue_rate_limit(); + fn test_field_rss_hash_update() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rss_hash_update) as usize - ptr as usize + }, + 528usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(rss_hash_update) + ) + ); + } + test_field_rss_hash_update(); + fn test_field_rss_hash_conf_get() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rss_hash_conf_get) as usize - ptr as usize + }, + 536usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(rss_hash_conf_get) + ) + ); + } + test_field_rss_hash_conf_get(); + fn test_field_reta_update() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).reta_update) as usize - ptr as usize + }, + 544usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(reta_update) + ) + ); + } + test_field_reta_update(); + fn test_field_reta_query() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).reta_query) as usize - ptr as usize + }, + 552usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(reta_query) + ) + ); + } + test_field_reta_query(); + fn test_field_get_reg() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).get_reg) as usize - ptr as usize + }, + 560usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(get_reg) + ) + ); + } + test_field_get_reg(); + fn test_field_get_eeprom_length() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).get_eeprom_length) as usize - ptr as usize + }, + 568usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(get_eeprom_length) + ) + ); + } + test_field_get_eeprom_length(); + fn test_field_get_eeprom() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).get_eeprom) as usize - ptr as usize + }, + 576usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(get_eeprom) + ) + ); + } + test_field_get_eeprom(); + fn test_field_set_eeprom() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).set_eeprom) as usize - ptr as usize + }, + 584usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(set_eeprom) + ) + ); + } + test_field_set_eeprom(); + fn test_field_get_module_info() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).get_module_info) as usize - ptr as usize + }, + 592usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(get_module_info) + ) + ); + } + test_field_get_module_info(); + fn test_field_get_module_eeprom() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).get_module_eeprom) as usize - ptr as usize + }, + 600usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(get_module_eeprom) + ) + ); + } + test_field_get_module_eeprom(); + fn test_field_filter_ctrl() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).filter_ctrl) as usize - ptr as usize + }, + 608usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(filter_ctrl) + ) + ); + } + test_field_filter_ctrl(); + fn test_field_get_dcb_info() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).get_dcb_info) as usize - ptr as usize + }, + 616usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(get_dcb_info) + ) + ); + } + test_field_get_dcb_info(); + fn test_field_timesync_enable() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).timesync_enable) as usize - ptr as usize + }, + 624usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(timesync_enable) + ) + ); + } + test_field_timesync_enable(); + fn test_field_timesync_disable() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).timesync_disable) as usize - ptr as usize + }, + 632usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(timesync_disable) + ) + ); + } + test_field_timesync_disable(); + fn test_field_timesync_read_rx_timestamp() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).timesync_read_rx_timestamp) as usize - ptr as usize + }, + 640usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(timesync_read_rx_timestamp) + ) + ); + } + test_field_timesync_read_rx_timestamp(); + fn test_field_timesync_read_tx_timestamp() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).timesync_read_tx_timestamp) as usize - ptr as usize + }, + 648usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(timesync_read_tx_timestamp) + ) + ); + } + test_field_timesync_read_tx_timestamp(); + fn test_field_timesync_adjust_time() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).timesync_adjust_time) as usize - ptr as usize + }, + 656usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(timesync_adjust_time) + ) + ); + } + test_field_timesync_adjust_time(); + fn test_field_timesync_read_time() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).timesync_read_time) as usize - ptr as usize + }, + 664usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(timesync_read_time) + ) + ); + } + test_field_timesync_read_time(); + fn test_field_timesync_write_time() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).timesync_write_time) as usize - ptr as usize + }, + 672usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(timesync_write_time) + ) + ); + } + test_field_timesync_write_time(); + fn test_field_read_clock() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).read_clock) as usize - ptr as usize + }, + 680usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(read_clock) + ) + ); + } + test_field_read_clock(); + fn test_field_xstats_get_by_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).xstats_get_by_id) as usize - ptr as usize + }, + 688usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(xstats_get_by_id) + ) + ); + } + test_field_xstats_get_by_id(); + fn test_field_xstats_get_names_by_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).xstats_get_names_by_id) as usize - ptr as usize + }, + 696usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(xstats_get_names_by_id) + ) + ); + } + test_field_xstats_get_names_by_id(); + fn test_field_tm_ops_get() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tm_ops_get) as usize - ptr as usize + }, + 704usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(tm_ops_get) + ) + ); + } + test_field_tm_ops_get(); + fn test_field_mtr_ops_get() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mtr_ops_get) as usize - ptr as usize + }, + 712usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(mtr_ops_get) + ) + ); + } + test_field_mtr_ops_get(); + fn test_field_pool_ops_supported() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pool_ops_supported) as usize - ptr as usize + }, + 720usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(pool_ops_supported) + ) + ); + } + test_field_pool_ops_supported(); + fn test_field_hairpin_cap_get() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).hairpin_cap_get) as usize - ptr as usize + }, + 728usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(hairpin_cap_get) + ) + ); + } + test_field_hairpin_cap_get(); + fn test_field_rx_hairpin_queue_setup() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_hairpin_queue_setup) as usize - ptr as usize + }, + 736usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(rx_hairpin_queue_setup) + ) + ); + } + test_field_rx_hairpin_queue_setup(); + fn test_field_tx_hairpin_queue_setup() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tx_hairpin_queue_setup) as usize - ptr as usize + }, + 744usize, + concat!( + "Offset of field: ", + stringify!(eth_dev_ops), + "::", + stringify!(tx_hairpin_queue_setup) + ) + ); + } + test_field_tx_hairpin_queue_setup(); } #[repr(C)] #[derive(Copy, Clone)] @@ -23187,7 +30226,6 @@ pub struct rte_eth_rxtx_callback { pub union rte_eth_rxtx_callback__bindgen_ty_1 { pub rx: rte_rx_callback_fn, pub tx: rte_tx_callback_fn, - _bindgen_union_align: u64, } #[test] fn bindgen_test_layout_rte_eth_rxtx_callback__bindgen_ty_1() { @@ -23204,34 +30242,50 @@ fn bindgen_test_layout_rte_eth_rxtx_callback__bindgen_ty_1() { stringify!(rte_eth_rxtx_callback__bindgen_ty_1) ) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).rx as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_rxtx_callback__bindgen_ty_1), - "::", - stringify!(rx) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).tx as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_rxtx_callback__bindgen_ty_1), - "::", - stringify!(tx) - ) - ); + fn test_field_rx() { + assert_eq!( + unsafe { + let uninit = + ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_rxtx_callback__bindgen_ty_1), + "::", + stringify!(rx) + ) + ); + } + test_field_rx(); + fn test_field_tx() { + assert_eq!( + unsafe { + let uninit = + ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tx) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_rxtx_callback__bindgen_ty_1), + "::", + stringify!(tx) + ) + ); + } + test_field_tx(); } impl Default for rte_eth_rxtx_callback__bindgen_ty_1 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[test] @@ -23246,45 +30300,70 @@ fn bindgen_test_layout_rte_eth_rxtx_callback() { 8usize, concat!("Alignment of ", stringify!(rte_eth_rxtx_callback)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).next as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_rxtx_callback), - "::", - stringify!(next) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).fn_ as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_rxtx_callback), - "::", - stringify!(fn_) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).param as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_rxtx_callback), - "::", - stringify!(param) - ) - ); + fn test_field_next() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).next) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_rxtx_callback), + "::", + stringify!(next) + ) + ); + } + test_field_next(); + fn test_field_fn() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).fn_) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_rxtx_callback), + "::", + stringify!(fn_) + ) + ); + } + test_field_fn(); + fn test_field_param() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).param) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_rxtx_callback), + "::", + stringify!(param) + ) + ); + } + test_field_param(); } impl Default for rte_eth_rxtx_callback { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] #[repr(align(64))] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct rte_eth_dev { pub rx_pkt_burst: eth_rx_burst_t, pub tx_pkt_burst: eth_tx_burst_t, @@ -23314,477 +30393,766 @@ fn bindgen_test_layout_rte_eth_dev() { 64usize, concat!("Alignment of ", stringify!(rte_eth_dev)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rx_pkt_burst as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev), - "::", - stringify!(rx_pkt_burst) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tx_pkt_burst as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev), - "::", - stringify!(tx_pkt_burst) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tx_pkt_prepare as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev), - "::", - stringify!(tx_pkt_prepare) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev), - "::", - stringify!(data) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).process_private as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev), - "::", - stringify!(process_private) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dev_ops as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev), - "::", - stringify!(dev_ops) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).device as *const _ as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev), - "::", - stringify!(device) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).intr_handle as *const _ as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev), - "::", - stringify!(intr_handle) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).link_intr_cbs as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev), - "::", - stringify!(link_intr_cbs) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).post_rx_burst_cbs as *const _ as usize }, - 80usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev), - "::", - stringify!(post_rx_burst_cbs) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pre_tx_burst_cbs as *const _ as usize }, - 8272usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev), - "::", - stringify!(pre_tx_burst_cbs) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).state as *const _ as usize }, - 16464usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev), - "::", - stringify!(state) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).security_ctx as *const _ as usize }, - 16472usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev), - "::", - stringify!(security_ctx) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved_64s as *const _ as usize }, - 16480usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev), - "::", - stringify!(reserved_64s) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved_ptrs as *const _ as usize }, - 16512usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev), - "::", - stringify!(reserved_ptrs) - ) - ); -} -impl Default for rte_eth_dev { - fn default() -> Self { - unsafe { ::std::mem::zeroed() } + fn test_field_rx_pkt_burst() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_pkt_burst) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev), + "::", + stringify!(rx_pkt_burst) + ) + ); + } + test_field_rx_pkt_burst(); + fn test_field_tx_pkt_burst() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tx_pkt_burst) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev), + "::", + stringify!(tx_pkt_burst) + ) + ); + } + test_field_tx_pkt_burst(); + fn test_field_tx_pkt_prepare() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tx_pkt_prepare) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev), + "::", + stringify!(tx_pkt_prepare) + ) + ); + } + test_field_tx_pkt_prepare(); + fn test_field_data() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev), + "::", + stringify!(data) + ) + ); + } + test_field_data(); + fn test_field_process_private() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).process_private) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev), + "::", + stringify!(process_private) + ) + ); + } + test_field_process_private(); + fn test_field_dev_ops() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dev_ops) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev), + "::", + stringify!(dev_ops) + ) + ); + } + test_field_dev_ops(); + fn test_field_device() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).device) as usize - ptr as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev), + "::", + stringify!(device) + ) + ); + } + test_field_device(); + fn test_field_intr_handle() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).intr_handle) as usize - ptr as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev), + "::", + stringify!(intr_handle) + ) + ); + } + test_field_intr_handle(); + fn test_field_link_intr_cbs() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).link_intr_cbs) as usize - ptr as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev), + "::", + stringify!(link_intr_cbs) + ) + ); + } + test_field_link_intr_cbs(); + fn test_field_post_rx_burst_cbs() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).post_rx_burst_cbs) as usize - ptr as usize + }, + 80usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev), + "::", + stringify!(post_rx_burst_cbs) + ) + ); + } + test_field_post_rx_burst_cbs(); + fn test_field_pre_tx_burst_cbs() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pre_tx_burst_cbs) as usize - ptr as usize + }, + 8272usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev), + "::", + stringify!(pre_tx_burst_cbs) + ) + ); + } + test_field_pre_tx_burst_cbs(); + fn test_field_state() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).state) as usize - ptr as usize + }, + 16464usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev), + "::", + stringify!(state) + ) + ); + } + test_field_state(); + fn test_field_security_ctx() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).security_ctx) as usize - ptr as usize + }, + 16472usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev), + "::", + stringify!(security_ctx) + ) + ); + } + test_field_security_ctx(); + fn test_field_reserved_64s() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).reserved_64s) as usize - ptr as usize + }, + 16480usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev), + "::", + stringify!(reserved_64s) + ) + ); + } + test_field_reserved_64s(); + fn test_field_reserved_ptrs() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).reserved_ptrs) as usize - ptr as usize + }, + 16512usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev), + "::", + stringify!(reserved_ptrs) + ) + ); } -} -#[repr(C)] -#[repr(align(64))] -#[derive(Copy, Clone)] -pub struct rte_eth_dev_data { - pub name: [::std::os::raw::c_char; 64usize], - pub rx_queues: *mut *mut ::std::os::raw::c_void, - pub tx_queues: *mut *mut ::std::os::raw::c_void, - pub nb_rx_queues: u16, - pub nb_tx_queues: u16, - pub sriov: rte_eth_dev_sriov, - pub dev_private: *mut ::std::os::raw::c_void, - pub dev_link: rte_eth_link, - pub dev_conf: rte_eth_conf, - pub mtu: u16, - pub min_rx_buf_size: u32, - pub rx_mbuf_alloc_failed: u64, - pub mac_addrs: *mut rte_ether_addr, - pub mac_pool_sel: [u64; 128usize], - pub hash_mac_addrs: *mut rte_ether_addr, - pub port_id: u16, - pub _bitfield_align_1: [u8; 0], - pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, - pub rx_queue_state: [u8; 1024usize], - pub tx_queue_state: [u8; 1024usize], - pub dev_flags: u32, - pub kdrv: rte_kernel_driver::Type, - pub numa_node: ::std::os::raw::c_int, - pub vlan_filter_conf: rte_vlan_filter_conf, - pub owner: rte_eth_dev_owner, - pub representor_id: u16, - pub reserved_64s: [u64; 4usize], - pub reserved_ptrs: [*mut ::std::os::raw::c_void; 4usize], -} -#[test] -fn bindgen_test_layout_rte_eth_dev_data() { - assert_eq!( - ::std::mem::size_of::(), - 6976usize, - concat!("Size of: ", stringify!(rte_eth_dev_data)) - ); - assert_eq!( - ::std::mem::align_of::(), - 64usize, - concat!("Alignment of ", stringify!(rte_eth_dev_data)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).name as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_data), - "::", - stringify!(name) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rx_queues as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_data), - "::", - stringify!(rx_queues) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tx_queues as *const _ as usize }, - 72usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_data), - "::", - stringify!(tx_queues) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).nb_rx_queues as *const _ as usize }, - 80usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_data), - "::", - stringify!(nb_rx_queues) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).nb_tx_queues as *const _ as usize }, - 82usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_data), - "::", - stringify!(nb_tx_queues) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).sriov as *const _ as usize }, - 84usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_data), - "::", - stringify!(sriov) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dev_private as *const _ as usize }, - 96usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_data), - "::", - stringify!(dev_private) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dev_link as *const _ as usize }, - 104usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_data), - "::", - stringify!(dev_link) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dev_conf as *const _ as usize }, - 112usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_data), - "::", - stringify!(dev_conf) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mtu as *const _ as usize }, - 3192usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_data), - "::", - stringify!(mtu) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).min_rx_buf_size as *const _ as usize - }, - 3196usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_data), - "::", - stringify!(min_rx_buf_size) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).rx_mbuf_alloc_failed as *const _ as usize - }, - 3200usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_data), - "::", - stringify!(rx_mbuf_alloc_failed) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mac_addrs as *const _ as usize }, - 3208usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_data), - "::", - stringify!(mac_addrs) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mac_pool_sel as *const _ as usize }, - 3216usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_data), - "::", - stringify!(mac_pool_sel) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).hash_mac_addrs as *const _ as usize }, - 4240usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_data), - "::", - stringify!(hash_mac_addrs) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).port_id as *const _ as usize }, - 4248usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_data), - "::", - stringify!(port_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rx_queue_state as *const _ as usize }, - 4251usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_data), - "::", - stringify!(rx_queue_state) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tx_queue_state as *const _ as usize }, - 5275usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_data), - "::", - stringify!(tx_queue_state) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dev_flags as *const _ as usize }, - 6300usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_data), - "::", - stringify!(dev_flags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).kdrv as *const _ as usize }, - 6304usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_data), - "::", - stringify!(kdrv) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).numa_node as *const _ as usize }, - 6308usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_data), - "::", - stringify!(numa_node) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).vlan_filter_conf as *const _ as usize - }, - 6312usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_data), - "::", - stringify!(vlan_filter_conf) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).owner as *const _ as usize }, - 6824usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_data), - "::", - stringify!(owner) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).representor_id as *const _ as usize }, - 6896usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_data), - "::", - stringify!(representor_id) - ) - ); + test_field_reserved_ptrs(); +} +impl Default for rte_eth_dev { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[repr(align(64))] +#[derive(Copy, Clone)] +pub struct rte_eth_dev_data { + pub name: [::std::os::raw::c_char; 64usize], + pub rx_queues: *mut *mut ::std::os::raw::c_void, + pub tx_queues: *mut *mut ::std::os::raw::c_void, + pub nb_rx_queues: u16, + pub nb_tx_queues: u16, + pub sriov: rte_eth_dev_sriov, + pub dev_private: *mut ::std::os::raw::c_void, + pub dev_link: rte_eth_link, + pub dev_conf: rte_eth_conf, + pub mtu: u16, + pub min_rx_buf_size: u32, + pub rx_mbuf_alloc_failed: u64, + pub mac_addrs: *mut rte_ether_addr, + pub mac_pool_sel: [u64; 128usize], + pub hash_mac_addrs: *mut rte_ether_addr, + pub port_id: u16, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub rx_queue_state: [u8; 1024usize], + pub tx_queue_state: [u8; 1024usize], + pub dev_flags: u32, + pub kdrv: rte_kernel_driver::Type, + pub numa_node: ::std::os::raw::c_int, + pub vlan_filter_conf: rte_vlan_filter_conf, + pub owner: rte_eth_dev_owner, + pub representor_id: u16, + pub reserved_64s: [u64; 4usize], + pub reserved_ptrs: [*mut ::std::os::raw::c_void; 4usize], +} +#[test] +fn bindgen_test_layout_rte_eth_dev_data() { assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved_64s as *const _ as usize }, - 6904usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_data), - "::", - stringify!(reserved_64s) - ) + ::std::mem::size_of::(), + 6976usize, + concat!("Size of: ", stringify!(rte_eth_dev_data)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved_ptrs as *const _ as usize }, - 6936usize, - concat!( - "Offset of field: ", - stringify!(rte_eth_dev_data), - "::", - stringify!(reserved_ptrs) - ) + ::std::mem::align_of::(), + 64usize, + concat!("Alignment of ", stringify!(rte_eth_dev_data)) ); + fn test_field_name() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_data), + "::", + stringify!(name) + ) + ); + } + test_field_name(); + fn test_field_rx_queues() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_queues) as usize - ptr as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_data), + "::", + stringify!(rx_queues) + ) + ); + } + test_field_rx_queues(); + fn test_field_tx_queues() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tx_queues) as usize - ptr as usize + }, + 72usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_data), + "::", + stringify!(tx_queues) + ) + ); + } + test_field_tx_queues(); + fn test_field_nb_rx_queues() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_rx_queues) as usize - ptr as usize + }, + 80usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_data), + "::", + stringify!(nb_rx_queues) + ) + ); + } + test_field_nb_rx_queues(); + fn test_field_nb_tx_queues() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_tx_queues) as usize - ptr as usize + }, + 82usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_data), + "::", + stringify!(nb_tx_queues) + ) + ); + } + test_field_nb_tx_queues(); + fn test_field_sriov() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).sriov) as usize - ptr as usize + }, + 84usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_data), + "::", + stringify!(sriov) + ) + ); + } + test_field_sriov(); + fn test_field_dev_private() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dev_private) as usize - ptr as usize + }, + 96usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_data), + "::", + stringify!(dev_private) + ) + ); + } + test_field_dev_private(); + fn test_field_dev_link() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dev_link) as usize - ptr as usize + }, + 104usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_data), + "::", + stringify!(dev_link) + ) + ); + } + test_field_dev_link(); + fn test_field_dev_conf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dev_conf) as usize - ptr as usize + }, + 112usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_data), + "::", + stringify!(dev_conf) + ) + ); + } + test_field_dev_conf(); + fn test_field_mtu() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mtu) as usize - ptr as usize + }, + 3192usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_data), + "::", + stringify!(mtu) + ) + ); + } + test_field_mtu(); + fn test_field_min_rx_buf_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).min_rx_buf_size) as usize - ptr as usize + }, + 3196usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_data), + "::", + stringify!(min_rx_buf_size) + ) + ); + } + test_field_min_rx_buf_size(); + fn test_field_rx_mbuf_alloc_failed() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_mbuf_alloc_failed) as usize - ptr as usize + }, + 3200usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_data), + "::", + stringify!(rx_mbuf_alloc_failed) + ) + ); + } + test_field_rx_mbuf_alloc_failed(); + fn test_field_mac_addrs() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mac_addrs) as usize - ptr as usize + }, + 3208usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_data), + "::", + stringify!(mac_addrs) + ) + ); + } + test_field_mac_addrs(); + fn test_field_mac_pool_sel() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mac_pool_sel) as usize - ptr as usize + }, + 3216usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_data), + "::", + stringify!(mac_pool_sel) + ) + ); + } + test_field_mac_pool_sel(); + fn test_field_hash_mac_addrs() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).hash_mac_addrs) as usize - ptr as usize + }, + 4240usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_data), + "::", + stringify!(hash_mac_addrs) + ) + ); + } + test_field_hash_mac_addrs(); + fn test_field_port_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).port_id) as usize - ptr as usize + }, + 4248usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_data), + "::", + stringify!(port_id) + ) + ); + } + test_field_port_id(); + fn test_field_rx_queue_state() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_queue_state) as usize - ptr as usize + }, + 4251usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_data), + "::", + stringify!(rx_queue_state) + ) + ); + } + test_field_rx_queue_state(); + fn test_field_tx_queue_state() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tx_queue_state) as usize - ptr as usize + }, + 5275usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_data), + "::", + stringify!(tx_queue_state) + ) + ); + } + test_field_tx_queue_state(); + fn test_field_dev_flags() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dev_flags) as usize - ptr as usize + }, + 6300usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_data), + "::", + stringify!(dev_flags) + ) + ); + } + test_field_dev_flags(); + fn test_field_kdrv() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).kdrv) as usize - ptr as usize + }, + 6304usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_data), + "::", + stringify!(kdrv) + ) + ); + } + test_field_kdrv(); + fn test_field_numa_node() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).numa_node) as usize - ptr as usize + }, + 6308usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_data), + "::", + stringify!(numa_node) + ) + ); + } + test_field_numa_node(); + fn test_field_vlan_filter_conf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vlan_filter_conf) as usize - ptr as usize + }, + 6312usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_data), + "::", + stringify!(vlan_filter_conf) + ) + ); + } + test_field_vlan_filter_conf(); + fn test_field_owner() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).owner) as usize - ptr as usize + }, + 6824usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_data), + "::", + stringify!(owner) + ) + ); + } + test_field_owner(); + fn test_field_representor_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).representor_id) as usize - ptr as usize + }, + 6896usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_data), + "::", + stringify!(representor_id) + ) + ); + } + test_field_representor_id(); + fn test_field_reserved_64s() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).reserved_64s) as usize - ptr as usize + }, + 6904usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_data), + "::", + stringify!(reserved_64s) + ) + ); + } + test_field_reserved_64s(); + fn test_field_reserved_ptrs() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).reserved_ptrs) as usize - ptr as usize + }, + 6936usize, + concat!( + "Offset of field: ", + stringify!(rte_eth_dev_data), + "::", + stringify!(reserved_ptrs) + ) + ); + } + test_field_reserved_ptrs(); } impl Default for rte_eth_dev_data { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } impl rte_eth_dev_data { @@ -23899,56 +31267,91 @@ fn bindgen_test_layout_rte_pci_id() { 4usize, concat!("Alignment of ", stringify!(rte_pci_id)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).class_id as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_pci_id), - "::", - stringify!(class_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).vendor_id as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_pci_id), - "::", - stringify!(vendor_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).device_id as *const _ as usize }, - 6usize, - concat!( - "Offset of field: ", - stringify!(rte_pci_id), - "::", - stringify!(device_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).subsystem_vendor_id as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_pci_id), - "::", - stringify!(subsystem_vendor_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).subsystem_device_id as *const _ as usize }, - 10usize, - concat!( - "Offset of field: ", - stringify!(rte_pci_id), - "::", - stringify!(subsystem_device_id) - ) - ); + fn test_field_class_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).class_id) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_pci_id), + "::", + stringify!(class_id) + ) + ); + } + test_field_class_id(); + fn test_field_vendor_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).vendor_id) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_pci_id), + "::", + stringify!(vendor_id) + ) + ); + } + test_field_vendor_id(); + fn test_field_device_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).device_id) as usize - ptr as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(rte_pci_id), + "::", + stringify!(device_id) + ) + ); + } + test_field_device_id(); + fn test_field_subsystem_vendor_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).subsystem_vendor_id) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_pci_id), + "::", + stringify!(subsystem_vendor_id) + ) + ); + } + test_field_subsystem_vendor_id(); + fn test_field_subsystem_device_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).subsystem_device_id) as usize - ptr as usize + }, + 10usize, + concat!( + "Offset of field: ", + stringify!(rte_pci_id), + "::", + stringify!(subsystem_device_id) + ) + ); + } + test_field_subsystem_device_id(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -23970,46 +31373,74 @@ fn bindgen_test_layout_rte_pci_addr() { 4usize, concat!("Alignment of ", stringify!(rte_pci_addr)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).domain as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_pci_addr), - "::", - stringify!(domain) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).bus as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(rte_pci_addr), - "::", - stringify!(bus) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).devid as *const _ as usize }, - 5usize, - concat!( - "Offset of field: ", - stringify!(rte_pci_addr), - "::", - stringify!(devid) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).function as *const _ as usize }, - 6usize, - concat!( - "Offset of field: ", - stringify!(rte_pci_addr), - "::", - stringify!(function) - ) - ); + fn test_field_domain() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).domain) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_pci_addr), + "::", + stringify!(domain) + ) + ); + } + test_field_domain(); + fn test_field_bus() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).bus) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rte_pci_addr), + "::", + stringify!(bus) + ) + ); + } + test_field_bus(); + fn test_field_devid() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).devid) as usize - ptr as usize + }, + 5usize, + concat!( + "Offset of field: ", + stringify!(rte_pci_addr), + "::", + stringify!(devid) + ) + ); + } + test_field_devid(); + fn test_field_function() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).function) as usize - ptr as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(rte_pci_addr), + "::", + stringify!(function) + ) + ); + } + test_field_function(); } extern "C" { pub fn rte_pci_device_name( @@ -24055,7 +31486,6 @@ pub union rte_kni_request__bindgen_ty_1 { pub mac_addr: [u8; 6usize], pub promiscusity: u8, pub allmulti: u8, - _bindgen_union_align: [u32; 2usize], } #[test] fn bindgen_test_layout_rte_kni_request__bindgen_ty_1() { @@ -24069,71 +31499,99 @@ fn bindgen_test_layout_rte_kni_request__bindgen_ty_1() { 4usize, concat!("Alignment of ", stringify!(rte_kni_request__bindgen_ty_1)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).new_mtu as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_request__bindgen_ty_1), - "::", - stringify!(new_mtu) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).if_up as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_request__bindgen_ty_1), - "::", - stringify!(if_up) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mac_addr as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_request__bindgen_ty_1), - "::", - stringify!(mac_addr) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).promiscusity as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_request__bindgen_ty_1), - "::", - stringify!(promiscusity) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).allmulti as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_request__bindgen_ty_1), - "::", - stringify!(allmulti) - ) - ); + fn test_field_new_mtu() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).new_mtu) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_request__bindgen_ty_1), + "::", + stringify!(new_mtu) + ) + ); + } + test_field_new_mtu(); + fn test_field_if_up() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).if_up) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_request__bindgen_ty_1), + "::", + stringify!(if_up) + ) + ); + } + test_field_if_up(); + fn test_field_mac_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mac_addr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_request__bindgen_ty_1), + "::", + stringify!(mac_addr) + ) + ); + } + test_field_mac_addr(); + fn test_field_promiscusity() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).promiscusity) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_request__bindgen_ty_1), + "::", + stringify!(promiscusity) + ) + ); + } + test_field_promiscusity(); + fn test_field_allmulti() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).allmulti) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_request__bindgen_ty_1), + "::", + stringify!(allmulti) + ) + ); + } + test_field_allmulti(); } impl Default for rte_kni_request__bindgen_ty_1 { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[test] @@ -24148,30 +31606,48 @@ fn bindgen_test_layout_rte_kni_request() { 1usize, concat!("Alignment of ", stringify!(rte_kni_request)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).req_id as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_request), - "::", - stringify!(req_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).result as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_request), - "::", - stringify!(result) - ) - ); + fn test_field_req_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).req_id) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_request), + "::", + stringify!(req_id) + ) + ); + } + test_field_req_id(); + fn test_field_result() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).result) as usize - ptr as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_request), + "::", + stringify!(result) + ) + ); + } + test_field_result(); } impl Default for rte_kni_request { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -24198,174 +31674,273 @@ fn bindgen_test_layout_rte_kni_fifo() { } impl Default for rte_kni_fifo { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] #[repr(align(64))] -#[derive(Copy, Clone)] -pub struct rte_kni_mbuf { - pub buf_addr: *mut ::std::os::raw::c_void, - pub buf_physaddr: u64, - pub data_off: u16, - pub pad1: [::std::os::raw::c_char; 2usize], - pub nb_segs: u16, - pub pad4: [::std::os::raw::c_char; 2usize], - pub ol_flags: u64, - pub pad2: [::std::os::raw::c_char; 4usize], - pub pkt_len: u32, - pub data_len: u16, - pub __bindgen_padding_0: [u8; 22usize], - pub pad3: [::std::os::raw::c_char; 8usize], - pub pool: *mut ::std::os::raw::c_void, - pub next: *mut ::std::os::raw::c_void, -} -#[test] -fn bindgen_test_layout_rte_kni_mbuf() { - assert_eq!( - ::std::mem::size_of::(), - 128usize, - concat!("Size of: ", stringify!(rte_kni_mbuf)) - ); - assert_eq!( - ::std::mem::align_of::(), - 64usize, - concat!("Alignment of ", stringify!(rte_kni_mbuf)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).buf_addr as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_mbuf), - "::", - stringify!(buf_addr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).buf_physaddr as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_mbuf), - "::", - stringify!(buf_physaddr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).data_off as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_mbuf), - "::", - stringify!(data_off) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad1 as *const _ as usize }, - 18usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_mbuf), - "::", - stringify!(pad1) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).nb_segs as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_mbuf), - "::", - stringify!(nb_segs) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad4 as *const _ as usize }, - 22usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_mbuf), - "::", - stringify!(pad4) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ol_flags as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_mbuf), - "::", - stringify!(ol_flags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad2 as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_mbuf), - "::", - stringify!(pad2) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pkt_len as *const _ as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_mbuf), - "::", - stringify!(pkt_len) - ) - ); +#[derive(Debug, Copy, Clone, PartialEq)] +pub struct rte_kni_mbuf { + pub buf_addr: *mut ::std::os::raw::c_void, + pub buf_physaddr: u64, + pub data_off: u16, + pub pad1: [::std::os::raw::c_char; 2usize], + pub nb_segs: u16, + pub pad4: [::std::os::raw::c_char; 2usize], + pub ol_flags: u64, + pub pad2: [::std::os::raw::c_char; 4usize], + pub pkt_len: u32, + pub data_len: u16, + pub __bindgen_padding_0: [u8; 22usize], + pub pad3: [::std::os::raw::c_char; 8usize], + pub pool: *mut ::std::os::raw::c_void, + pub next: *mut ::std::os::raw::c_void, +} +#[test] +fn bindgen_test_layout_rte_kni_mbuf() { assert_eq!( - unsafe { &(*(::std::ptr::null::())).data_len as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_mbuf), - "::", - stringify!(data_len) - ) + ::std::mem::size_of::(), + 128usize, + concat!("Size of: ", stringify!(rte_kni_mbuf)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad3 as *const _ as usize }, + ::std::mem::align_of::(), 64usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_mbuf), - "::", - stringify!(pad3) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pool as *const _ as usize }, - 72usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_mbuf), - "::", - stringify!(pool) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).next as *const _ as usize }, - 80usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_mbuf), - "::", - stringify!(next) - ) + concat!("Alignment of ", stringify!(rte_kni_mbuf)) ); + fn test_field_buf_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).buf_addr) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_mbuf), + "::", + stringify!(buf_addr) + ) + ); + } + test_field_buf_addr(); + fn test_field_buf_physaddr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).buf_physaddr) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_mbuf), + "::", + stringify!(buf_physaddr) + ) + ); + } + test_field_buf_physaddr(); + fn test_field_data_off() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).data_off) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_mbuf), + "::", + stringify!(data_off) + ) + ); + } + test_field_data_off(); + fn test_field_pad1() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pad1) as usize - ptr as usize + }, + 18usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_mbuf), + "::", + stringify!(pad1) + ) + ); + } + test_field_pad1(); + fn test_field_nb_segs() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).nb_segs) as usize - ptr as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_mbuf), + "::", + stringify!(nb_segs) + ) + ); + } + test_field_nb_segs(); + fn test_field_pad4() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pad4) as usize - ptr as usize + }, + 22usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_mbuf), + "::", + stringify!(pad4) + ) + ); + } + test_field_pad4(); + fn test_field_ol_flags() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ol_flags) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_mbuf), + "::", + stringify!(ol_flags) + ) + ); + } + test_field_ol_flags(); + fn test_field_pad2() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pad2) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_mbuf), + "::", + stringify!(pad2) + ) + ); + } + test_field_pad2(); + fn test_field_pkt_len() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pkt_len) as usize - ptr as usize + }, + 36usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_mbuf), + "::", + stringify!(pkt_len) + ) + ); + } + test_field_pkt_len(); + fn test_field_data_len() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).data_len) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_mbuf), + "::", + stringify!(data_len) + ) + ); + } + test_field_data_len(); + fn test_field_pad3() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pad3) as usize - ptr as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_mbuf), + "::", + stringify!(pad3) + ) + ); + } + test_field_pad3(); + fn test_field_pool() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).pool) as usize - ptr as usize + }, + 72usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_mbuf), + "::", + stringify!(pool) + ) + ); + } + test_field_pool(); + fn test_field_next() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).next) as usize - ptr as usize + }, + 80usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_mbuf), + "::", + stringify!(next) + ) + ); + } + test_field_next(); } impl Default for rte_kni_mbuf { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -24405,200 +31980,337 @@ fn bindgen_test_layout_rte_kni_device_info() { 8usize, concat!("Alignment of ", stringify!(rte_kni_device_info)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).name as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_device_info), - "::", - stringify!(name) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tx_phys as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_device_info), - "::", - stringify!(tx_phys) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rx_phys as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_device_info), - "::", - stringify!(rx_phys) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).alloc_phys as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_device_info), - "::", - stringify!(alloc_phys) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).free_phys as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_device_info), - "::", - stringify!(free_phys) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).req_phys as *const _ as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_device_info), - "::", - stringify!(req_phys) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).resp_phys as *const _ as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_device_info), - "::", - stringify!(resp_phys) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).sync_phys as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_device_info), - "::", - stringify!(sync_phys) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).sync_va as *const _ as usize }, - 72usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_device_info), - "::", - stringify!(sync_va) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mbuf_va as *const _ as usize }, - 80usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_device_info), - "::", - stringify!(mbuf_va) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mbuf_phys as *const _ as usize }, - 88usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_device_info), - "::", - stringify!(mbuf_phys) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).group_id as *const _ as usize }, - 96usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_device_info), - "::", - stringify!(group_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).core_id as *const _ as usize }, - 100usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_device_info), - "::", - stringify!(core_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mbuf_size as *const _ as usize }, - 108usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_device_info), - "::", - stringify!(mbuf_size) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mtu as *const _ as usize }, - 112usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_device_info), - "::", - stringify!(mtu) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).min_mtu as *const _ as usize }, - 116usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_device_info), - "::", - stringify!(min_mtu) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).max_mtu as *const _ as usize }, - 120usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_device_info), - "::", - stringify!(max_mtu) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mac_addr as *const _ as usize }, - 124usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_device_info), - "::", - stringify!(mac_addr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).iova_mode as *const _ as usize }, - 130usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_device_info), - "::", - stringify!(iova_mode) - ) - ); + fn test_field_name() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_device_info), + "::", + stringify!(name) + ) + ); + } + test_field_name(); + fn test_field_tx_phys() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).tx_phys) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_device_info), + "::", + stringify!(tx_phys) + ) + ); + } + test_field_tx_phys(); + fn test_field_rx_phys() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rx_phys) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_device_info), + "::", + stringify!(rx_phys) + ) + ); + } + test_field_rx_phys(); + fn test_field_alloc_phys() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).alloc_phys) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_device_info), + "::", + stringify!(alloc_phys) + ) + ); + } + test_field_alloc_phys(); + fn test_field_free_phys() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).free_phys) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_device_info), + "::", + stringify!(free_phys) + ) + ); + } + test_field_free_phys(); + fn test_field_req_phys() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).req_phys) as usize - ptr as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_device_info), + "::", + stringify!(req_phys) + ) + ); + } + test_field_req_phys(); + fn test_field_resp_phys() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).resp_phys) as usize - ptr as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_device_info), + "::", + stringify!(resp_phys) + ) + ); + } + test_field_resp_phys(); + fn test_field_sync_phys() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).sync_phys) as usize - ptr as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_device_info), + "::", + stringify!(sync_phys) + ) + ); + } + test_field_sync_phys(); + fn test_field_sync_va() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).sync_va) as usize - ptr as usize + }, + 72usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_device_info), + "::", + stringify!(sync_va) + ) + ); + } + test_field_sync_va(); + fn test_field_mbuf_va() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mbuf_va) as usize - ptr as usize + }, + 80usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_device_info), + "::", + stringify!(mbuf_va) + ) + ); + } + test_field_mbuf_va(); + fn test_field_mbuf_phys() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mbuf_phys) as usize - ptr as usize + }, + 88usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_device_info), + "::", + stringify!(mbuf_phys) + ) + ); + } + test_field_mbuf_phys(); + fn test_field_group_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).group_id) as usize - ptr as usize + }, + 96usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_device_info), + "::", + stringify!(group_id) + ) + ); + } + test_field_group_id(); + fn test_field_core_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).core_id) as usize - ptr as usize + }, + 100usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_device_info), + "::", + stringify!(core_id) + ) + ); + } + test_field_core_id(); + fn test_field_mbuf_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mbuf_size) as usize - ptr as usize + }, + 108usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_device_info), + "::", + stringify!(mbuf_size) + ) + ); + } + test_field_mbuf_size(); + fn test_field_mtu() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mtu) as usize - ptr as usize + }, + 112usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_device_info), + "::", + stringify!(mtu) + ) + ); + } + test_field_mtu(); + fn test_field_min_mtu() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).min_mtu) as usize - ptr as usize + }, + 116usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_device_info), + "::", + stringify!(min_mtu) + ) + ); + } + test_field_min_mtu(); + fn test_field_max_mtu() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).max_mtu) as usize - ptr as usize + }, + 120usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_device_info), + "::", + stringify!(max_mtu) + ) + ); + } + test_field_max_mtu(); + fn test_field_mac_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mac_addr) as usize - ptr as usize + }, + 124usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_device_info), + "::", + stringify!(mac_addr) + ) + ); + } + test_field_mac_addr(); + fn test_field_iova_mode() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).iova_mode) as usize - ptr as usize + }, + 130usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_device_info), + "::", + stringify!(iova_mode) + ) + ); + } + test_field_iova_mode(); } impl Default for rte_kni_device_info { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } impl rte_kni_device_info { @@ -24663,66 +32375,108 @@ fn bindgen_test_layout_rte_kni_ops() { 8usize, concat!("Alignment of ", stringify!(rte_kni_ops)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).port_id as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_ops), - "::", - stringify!(port_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).change_mtu as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_ops), - "::", - stringify!(change_mtu) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).config_network_if as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_ops), - "::", - stringify!(config_network_if) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).config_mac_address as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_ops), - "::", - stringify!(config_mac_address) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).config_promiscusity as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_ops), - "::", - stringify!(config_promiscusity) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).config_allmulticast as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_ops), - "::", - stringify!(config_allmulticast) - ) - ); + fn test_field_port_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).port_id) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_ops), + "::", + stringify!(port_id) + ) + ); + } + test_field_port_id(); + fn test_field_change_mtu() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).change_mtu) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_ops), + "::", + stringify!(change_mtu) + ) + ); + } + test_field_change_mtu(); + fn test_field_config_network_if() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).config_network_if) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_ops), + "::", + stringify!(config_network_if) + ) + ); + } + test_field_config_network_if(); + fn test_field_config_mac_address() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).config_mac_address) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_ops), + "::", + stringify!(config_mac_address) + ) + ); + } + test_field_config_mac_address(); + fn test_field_config_promiscusity() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).config_promiscusity) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_ops), + "::", + stringify!(config_promiscusity) + ) + ); + } + test_field_config_promiscusity(); + fn test_field_config_allmulticast() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).config_allmulticast) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_ops), + "::", + stringify!(config_allmulticast) + ) + ); + } + test_field_config_allmulticast(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -24733,125 +32487,195 @@ pub struct rte_kni_conf { pub mbuf_size: ::std::os::raw::c_uint, pub addr: rte_pci_addr, pub id: rte_pci_id, - pub _bitfield_align_1: [u8; 0], - pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, - pub mac_addr: [u8; 6usize], - pub mtu: u16, - pub min_mtu: u16, - pub max_mtu: u16, -} -#[test] -fn bindgen_test_layout_rte_kni_conf() { - assert_eq!( - ::std::mem::size_of::(), - 64usize, - concat!("Size of: ", stringify!(rte_kni_conf)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(rte_kni_conf)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).name as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_conf), - "::", - stringify!(name) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).core_id as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_conf), - "::", - stringify!(core_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).group_id as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_conf), - "::", - stringify!(group_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mbuf_size as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_conf), - "::", - stringify!(mbuf_size) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, - 28usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_conf), - "::", - stringify!(addr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).id as *const _ as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_conf), - "::", - stringify!(id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mac_addr as *const _ as usize }, - 49usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_conf), - "::", - stringify!(mac_addr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mtu as *const _ as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_conf), - "::", - stringify!(mtu) - ) - ); + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub mac_addr: [u8; 6usize], + pub mtu: u16, + pub min_mtu: u16, + pub max_mtu: u16, +} +#[test] +fn bindgen_test_layout_rte_kni_conf() { assert_eq!( - unsafe { &(*(::std::ptr::null::())).min_mtu as *const _ as usize }, - 58usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_conf), - "::", - stringify!(min_mtu) - ) + ::std::mem::size_of::(), + 64usize, + concat!("Size of: ", stringify!(rte_kni_conf)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).max_mtu as *const _ as usize }, - 60usize, - concat!( - "Offset of field: ", - stringify!(rte_kni_conf), - "::", - stringify!(max_mtu) - ) + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(rte_kni_conf)) ); + fn test_field_name() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_conf), + "::", + stringify!(name) + ) + ); + } + test_field_name(); + fn test_field_core_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).core_id) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_conf), + "::", + stringify!(core_id) + ) + ); + } + test_field_core_id(); + fn test_field_group_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).group_id) as usize - ptr as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_conf), + "::", + stringify!(group_id) + ) + ); + } + test_field_group_id(); + fn test_field_mbuf_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mbuf_size) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_conf), + "::", + stringify!(mbuf_size) + ) + ); + } + test_field_mbuf_size(); + fn test_field_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize + }, + 28usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_conf), + "::", + stringify!(addr) + ) + ); + } + test_field_addr(); + fn test_field_id() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize + }, + 36usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_conf), + "::", + stringify!(id) + ) + ); + } + test_field_id(); + fn test_field_mac_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mac_addr) as usize - ptr as usize + }, + 49usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_conf), + "::", + stringify!(mac_addr) + ) + ); + } + test_field_mac_addr(); + fn test_field_mtu() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mtu) as usize - ptr as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_conf), + "::", + stringify!(mtu) + ) + ); + } + test_field_mtu(); + fn test_field_min_mtu() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).min_mtu) as usize - ptr as usize + }, + 58usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_conf), + "::", + stringify!(min_mtu) + ) + ); + } + test_field_min_mtu(); + fn test_field_max_mtu() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).max_mtu) as usize - ptr as usize + }, + 60usize, + concat!( + "Offset of field: ", + stringify!(rte_kni_conf), + "::", + stringify!(max_mtu) + ) + ); + } + test_field_max_mtu(); } impl rte_kni_conf { #[inline] @@ -24946,16 +32770,23 @@ fn bindgen_test_layout_nodemask_t() { 8usize, concat!("Alignment of ", stringify!(nodemask_t)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).n as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(nodemask_t), - "::", - stringify!(n) - ) - ); + fn test_field_n() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).n) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(nodemask_t), + "::", + stringify!(n) + ) + ); + } + test_field_n(); } #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq)] @@ -24975,30 +32806,48 @@ fn bindgen_test_layout_bitmask() { 8usize, concat!("Alignment of ", stringify!(bitmask)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).size as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(bitmask), - "::", - stringify!(size) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).maskp as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(bitmask), - "::", - stringify!(maskp) - ) - ); + fn test_field_size() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(bitmask), + "::", + stringify!(size) + ) + ); + } + test_field_size(); + fn test_field_maskp() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).maskp) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(bitmask), + "::", + stringify!(maskp) + ) + ); + } + test_field_maskp(); } impl Default for bitmask { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } extern "C" { @@ -25270,30 +33119,48 @@ fn bindgen_test_layout_bpf_program() { 8usize, concat!("Alignment of ", stringify!(bpf_program)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).bf_len as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(bpf_program), - "::", - stringify!(bf_len) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).bf_insns as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(bpf_program), - "::", - stringify!(bf_insns) - ) - ); + fn test_field_bf_len() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).bf_len) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(bpf_program), + "::", + stringify!(bf_len) + ) + ); + } + test_field_bf_len(); + fn test_field_bf_insns() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).bf_insns) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(bpf_program), + "::", + stringify!(bf_insns) + ) + ); + } + test_field_bf_insns(); } impl Default for bpf_program { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -25316,46 +33183,74 @@ fn bindgen_test_layout_bpf_insn() { 4usize, concat!("Alignment of ", stringify!(bpf_insn)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).code as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(bpf_insn), - "::", - stringify!(code) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).jt as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(bpf_insn), - "::", - stringify!(jt) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).jf as *const _ as usize }, - 3usize, - concat!( - "Offset of field: ", - stringify!(bpf_insn), - "::", - stringify!(jf) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).k as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(bpf_insn), - "::", - stringify!(k) - ) - ); + fn test_field_code() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).code) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(bpf_insn), + "::", + stringify!(code) + ) + ); + } + test_field_code(); + fn test_field_jt() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).jt) as usize - ptr as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(bpf_insn), + "::", + stringify!(jt) + ) + ); + } + test_field_jt(); + fn test_field_jf() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).jf) as usize - ptr as usize + }, + 3usize, + concat!( + "Offset of field: ", + stringify!(bpf_insn), + "::", + stringify!(jf) + ) + ); + } + test_field_jf(); + fn test_field_k() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).k) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(bpf_insn), + "::", + stringify!(k) + ) + ); + } + test_field_k(); } #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -25394,76 +33289,125 @@ fn bindgen_test_layout_pcap_file_header() { 4usize, concat!("Alignment of ", stringify!(pcap_file_header)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).magic as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(pcap_file_header), - "::", - stringify!(magic) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).version_major as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(pcap_file_header), - "::", - stringify!(version_major) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).version_minor as *const _ as usize }, - 6usize, - concat!( - "Offset of field: ", - stringify!(pcap_file_header), - "::", - stringify!(version_minor) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).thiszone as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(pcap_file_header), - "::", - stringify!(thiszone) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).sigfigs as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(pcap_file_header), - "::", - stringify!(sigfigs) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).snaplen as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(pcap_file_header), - "::", - stringify!(snaplen) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).linktype as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(pcap_file_header), - "::", - stringify!(linktype) - ) - ); + fn test_field_magic() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).magic) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pcap_file_header), + "::", + stringify!(magic) + ) + ); + } + test_field_magic(); + fn test_field_version_major() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).version_major) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(pcap_file_header), + "::", + stringify!(version_major) + ) + ); + } + test_field_version_major(); + fn test_field_version_minor() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).version_minor) as usize - ptr as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(pcap_file_header), + "::", + stringify!(version_minor) + ) + ); + } + test_field_version_minor(); + fn test_field_thiszone() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).thiszone) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pcap_file_header), + "::", + stringify!(thiszone) + ) + ); + } + test_field_thiszone(); + fn test_field_sigfigs() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).sigfigs) as usize - ptr as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(pcap_file_header), + "::", + stringify!(sigfigs) + ) + ); + } + test_field_sigfigs(); + fn test_field_snaplen() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).snaplen) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pcap_file_header), + "::", + stringify!(snaplen) + ) + ); + } + test_field_snaplen(); + fn test_field_linktype() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).linktype) as usize - ptr as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(pcap_file_header), + "::", + stringify!(linktype) + ) + ); + } + test_field_linktype(); } pub mod pcap_direction_t { pub type Type = ::std::os::raw::c_uint; @@ -25490,36 +33434,57 @@ fn bindgen_test_layout_pcap_pkthdr() { 8usize, concat!("Alignment of ", stringify!(pcap_pkthdr)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ts as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(pcap_pkthdr), - "::", - stringify!(ts) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).caplen as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(pcap_pkthdr), - "::", - stringify!(caplen) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).len as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(pcap_pkthdr), - "::", - stringify!(len) - ) - ); + fn test_field_ts() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ts) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pcap_pkthdr), + "::", + stringify!(ts) + ) + ); + } + test_field_ts(); + fn test_field_caplen() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).caplen) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pcap_pkthdr), + "::", + stringify!(caplen) + ) + ); + } + test_field_caplen(); + fn test_field_len() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(pcap_pkthdr), + "::", + stringify!(len) + ) + ); + } + test_field_len(); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] @@ -25540,36 +33505,57 @@ fn bindgen_test_layout_pcap_stat() { 4usize, concat!("Alignment of ", stringify!(pcap_stat)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ps_recv as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(pcap_stat), - "::", - stringify!(ps_recv) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ps_drop as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(pcap_stat), - "::", - stringify!(ps_drop) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ps_ifdrop as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(pcap_stat), - "::", - stringify!(ps_ifdrop) - ) - ); + fn test_field_ps_recv() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ps_recv) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pcap_stat), + "::", + stringify!(ps_recv) + ) + ); + } + test_field_ps_recv(); + fn test_field_ps_drop() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ps_drop) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(pcap_stat), + "::", + stringify!(ps_drop) + ) + ); + } + test_field_ps_drop(); + fn test_field_ps_ifdrop() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).ps_ifdrop) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pcap_stat), + "::", + stringify!(ps_ifdrop) + ) + ); + } + test_field_ps_ifdrop(); } #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq)] @@ -25592,60 +33578,99 @@ fn bindgen_test_layout_pcap_if() { 8usize, concat!("Alignment of ", stringify!(pcap_if)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).next as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(pcap_if), - "::", - stringify!(next) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).name as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(pcap_if), - "::", - stringify!(name) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).description as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(pcap_if), - "::", - stringify!(description) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).addresses as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(pcap_if), - "::", - stringify!(addresses) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(pcap_if), - "::", - stringify!(flags) - ) - ); + fn test_field_next() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).next) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pcap_if), + "::", + stringify!(next) + ) + ); + } + test_field_next(); + fn test_field_name() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pcap_if), + "::", + stringify!(name) + ) + ); + } + test_field_name(); + fn test_field_description() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).description) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pcap_if), + "::", + stringify!(description) + ) + ); + } + test_field_description(); + fn test_field_addresses() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).addresses) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(pcap_if), + "::", + stringify!(addresses) + ) + ); + } + test_field_addresses(); + fn test_field_flags() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(pcap_if), + "::", + stringify!(flags) + ) + ); + } + test_field_flags(); } impl Default for pcap_if { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -25669,60 +33694,99 @@ fn bindgen_test_layout_pcap_addr() { 8usize, concat!("Alignment of ", stringify!(pcap_addr)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).next as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(pcap_addr), - "::", - stringify!(next) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(pcap_addr), - "::", - stringify!(addr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).netmask as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(pcap_addr), - "::", - stringify!(netmask) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).broadaddr as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(pcap_addr), - "::", - stringify!(broadaddr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dstaddr as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(pcap_addr), - "::", - stringify!(dstaddr) - ) - ); + fn test_field_next() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).next) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pcap_addr), + "::", + stringify!(next) + ) + ); + } + test_field_next(); + fn test_field_addr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pcap_addr), + "::", + stringify!(addr) + ) + ); + } + test_field_addr(); + fn test_field_netmask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).netmask) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pcap_addr), + "::", + stringify!(netmask) + ) + ); + } + test_field_netmask(); + fn test_field_broadaddr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).broadaddr) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(pcap_addr), + "::", + stringify!(broadaddr) + ) + ); + } + test_field_broadaddr(); + fn test_field_dstaddr() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).dstaddr) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(pcap_addr), + "::", + stringify!(dstaddr) + ) + ); + } + test_field_dstaddr(); } impl Default for pcap_addr { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type pcap_handler = ::std::option::Option< @@ -26147,50 +34211,82 @@ fn bindgen_test_layout___va_list_tag() { 8usize, concat!("Alignment of ", stringify!(__va_list_tag)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<__va_list_tag>())).gp_offset as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(__va_list_tag), - "::", - stringify!(gp_offset) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<__va_list_tag>())).fp_offset as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(__va_list_tag), - "::", - stringify!(fp_offset) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<__va_list_tag>())).overflow_arg_area as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(__va_list_tag), - "::", - stringify!(overflow_arg_area) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<__va_list_tag>())).reg_save_area as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(__va_list_tag), - "::", - stringify!(reg_save_area) - ) - ); + fn test_field_gp_offset() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<__va_list_tag>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).gp_offset) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__va_list_tag), + "::", + stringify!(gp_offset) + ) + ); + } + test_field_gp_offset(); + fn test_field_fp_offset() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<__va_list_tag>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).fp_offset) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(__va_list_tag), + "::", + stringify!(fp_offset) + ) + ); + } + test_field_fp_offset(); + fn test_field_overflow_arg_area() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<__va_list_tag>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).overflow_arg_area) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(__va_list_tag), + "::", + stringify!(overflow_arg_area) + ) + ); + } + test_field_overflow_arg_area(); + fn test_field_reg_save_area() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::<__va_list_tag>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).reg_save_area) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(__va_list_tag), + "::", + stringify!(reg_save_area) + ) + ); + } + test_field_reg_save_area(); } impl Default for __va_list_tag { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] diff --git a/macros/Cargo.toml b/macros/Cargo.toml index 99267022..99562296 100644 --- a/macros/Cargo.toml +++ b/macros/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "capsule-macros" -version = "0.1.5" +version = "0.2.0" authors = ["Capsule Developers "] license = "Apache-2.0" edition = "2018" diff --git a/macros/src/derive_packet.rs b/macros/src/derive_packet.rs index 76baf650..5e7de693 100644 --- a/macros/src/derive_packet.rs +++ b/macros/src/derive_packet.rs @@ -82,6 +82,7 @@ pub fn gen_icmpv6(input: syn::DeriveInput) -> TokenStream { fn try_push(mut envelope: Self::Envelope, internal: Internal) -> ::anyhow::Result { use ::capsule::packets::icmp::v6::{Icmpv6, Icmpv6Header, Icmpv6Message}; use ::capsule::packets::ip::{IpPacket, ProtocolNumbers}; + use ::capsule::packets::SizeOf; let offset = envelope.payload_offset(); let mbuf = envelope.mbuf_mut(); @@ -180,6 +181,7 @@ pub fn gen_icmpv4(input: syn::DeriveInput) -> TokenStream { fn try_push(mut envelope: Self::Envelope, internal: ::capsule::packets::Internal) -> ::anyhow::Result { use ::capsule::packets::icmp::v4::{Icmpv4, Icmpv4Header, Icmpv4Message}; use ::capsule::packets::ip::{IpPacket, ProtocolNumbers}; + use ::capsule::packets::SizeOf; let offset = envelope.payload_offset(); let mbuf = envelope.mbuf_mut(); diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 0cfca412..23b816ec 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -40,7 +40,7 @@ pub fn derive_size_of(input: TokenStream) -> TokenStream { let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); let expanded = quote! { - impl #impl_generics SizeOf for #name #ty_generics #where_clause { + impl #impl_generics ::capsule::packets::SizeOf for #name #ty_generics #where_clause { fn size_of() -> usize { std::mem::size_of::() }