Expand description
os_abi_sentinel is a small, dependency-free crate for OS development focused on ABI
contracts.
In operating systems you often share #[repr(C)] structures across boundaries:
- bootloader ↔ kernel
- kernel ↔ drivers
- kernel ↔ user-space runtimes / services
- firmware tables ↔ parsers
A single layout mismatch (size, alignment, or field offset) can silently corrupt memory. This crate provides tiny compile-time assertions and a minimal ABI version type so those mismatches become build failures.
§Design goals
- No external dependencies
no_std-first (enable thestdfeature only for host-side tests/examples)- Compile-time verification where possible
- Clear docs suitable for
docs.rs
§Quick example
use os_abi_sentinel::{const_assert_align, const_assert_offset, const_assert_size};
#[repr(C)]
pub struct BootInfo {
pub magic: u32,
pub version: u32,
pub mem_map_ptr: u64,
pub mem_map_len: u32,
pub _reserved: u32,
}
const_assert_size!(BootInfo, 24);
const_assert_align!(BootInfo, 8);
const_assert_offset!(BootInfo, mem_map_ptr, 8);
const_assert_offset!(BootInfo, mem_map_len, 16);Modules§
- version
- ABI version helpers.
Macros§
- const_
assert - Compile-time assertion.
- const_
assert_ align - Compile-time type alignment assertion (in bytes).
- const_
assert_ eq - Compile-time equality assertion.
- const_
assert_ ne - Compile-time non-equality assertion.
- const_
assert_ offset - Compile-time field offset assertion (in bytes).
- const_
assert_ size - Compile-time type size assertion (in bytes).