byteor_abi/
lib.rs

1#![cfg_attr(not(feature = "std"), no_std)]
2#![deny(missing_docs)]
3#![deny(unreachable_pub, rust_2018_idioms)]
4#![forbid(unsafe_code)]
5
6//! ByteOr ABI surface (v1).
7//!
8//! This crate holds versioned `repr(C)` layouts and constants shared across
9//! processes. Layouts are designed to be compatible with [spec/byteor_v1.h](../../spec/byteor_v1.h).
10
11pub mod header;
12pub mod layouts;
13
14pub use header::caps::{
15    BYTEOR_CAP_SUPPORTS_EVENTS_CHAIN, BYTEOR_CAP_SUPPORTS_EVENTS_CHAIN_MPSC,
16    BYTEOR_CAP_SUPPORTS_SEQUENCED_SLOTS,
17};
18pub use header::flags::{BYTEOR_REGION_KIND_EVENTS_CHAIN, BYTEOR_REGION_KIND_SEQUENCED_SLOTS};
19pub use header::{caps, flags};
20
21#[cfg(test)]
22mod abi_tests {
23    use core::mem;
24
25    use crate::layouts::{EventsChainLayout4, SequencedSlotsLayout4};
26
27    #[test]
28    fn abi_events_chain_layout4() {
29        assert_eq!(mem::align_of::<EventsChainLayout4>(), 64);
30        assert_eq!(mem::size_of::<EventsChainLayout4>() % 64, 0);
31        assert_eq!(mem::offset_of!(EventsChainLayout4, slot_pool), 64);
32        assert_eq!(mem::offset_of!(EventsChainLayout4, queues), 278656);
33        assert_eq!(mem::offset_of!(EventsChainLayout4, mpsc_queues), 295296);
34    }
35
36    #[test]
37    fn abi_sequenced_slots_layout4() {
38        assert_eq!(mem::align_of::<SequencedSlotsLayout4>(), 64);
39        assert_eq!(mem::size_of::<SequencedSlotsLayout4>() % 64, 0);
40        assert_eq!(mem::offset_of!(SequencedSlotsLayout4, cursor), 64);
41        assert_eq!(mem::offset_of!(SequencedSlotsLayout4, gating), 128);
42    }
43}