#[allow(unused_macros)]
macro_rules! layout {
($t:ty, size = $size:expr, align = $align:expr) => {
const _: () = assert!(
::core::mem::size_of::<$t>() == $size && ::core::mem::align_of::<$t>() == $align,
concat!(
"layout of ",
stringify!($t),
" differs from the platform headers"
),
);
};
}
#[cfg(test)]
#[allow(unused_macros)]
macro_rules! same_layout {
($ours:ty, $theirs:ty $(, $a:ident $(. $an:ident)* => $b:ident $(. $bn:ident)*)* $(,)?) => {
const _: () = {
assert!(::core::mem::size_of::<$ours>() == ::core::mem::size_of::<$theirs>(),
concat!("size of ", stringify!($ours)));
assert!(::core::mem::align_of::<$ours>() == ::core::mem::align_of::<$theirs>(),
concat!("alignment of ", stringify!($ours)));
$(assert!(
::core::mem::offset_of!($ours, $a $(. $an)*)
== ::core::mem::offset_of!($theirs, $b $(. $bn)*),
concat!("offset of ", stringify!($ours), ".", stringify!($a $(. $an)*))
);)*
};
};
(prefix $ours:ty, $theirs:ty $(, $a:ident => $b:ident)* $(,)?) => {
const _: () = {
assert!(::core::mem::size_of::<$ours>() <= ::core::mem::size_of::<$theirs>(),
concat!("size of ", stringify!($ours)));
$(assert!(
::core::mem::offset_of!($ours, $a) == ::core::mem::offset_of!($theirs, $b),
concat!("offset of ", stringify!($ours), ".", stringify!($a))
);)*
};
};
}
mod pending;
#[cfg(all(
any(target_os = "linux", target_os = "android"),
target_pointer_width = "64"
))]
#[allow(unsafe_code)]
mod linux;
#[cfg(all(
any(target_os = "linux", target_os = "android"),
target_pointer_width = "64"
))]
pub(crate) use linux::*;
#[cfg(all(
any(target_os = "macos", target_os = "ios"),
target_pointer_width = "64"
))]
#[allow(unsafe_code)]
mod apple;
#[cfg(all(
any(target_os = "macos", target_os = "ios"),
target_pointer_width = "64"
))]
pub(crate) use apple::*;
#[cfg(windows)]
#[allow(unsafe_code)]
mod windows;
#[cfg(windows)]
pub(crate) use windows::*;
#[cfg(not(any(
all(
any(target_os = "linux", target_os = "android"),
target_pointer_width = "64"
),
all(
any(target_os = "macos", target_os = "ios"),
target_pointer_width = "64"
),
windows
)))]
mod unsupported;
#[cfg(not(any(
all(
any(target_os = "linux", target_os = "android"),
target_pointer_width = "64"
),
all(
any(target_os = "macos", target_os = "ios"),
target_pointer_width = "64"
),
windows
)))]
pub(crate) use unsupported::*;
use crate::{cpu::Vendor, os::Source};
#[derive(Clone, Debug, PartialEq, Eq)]
pub(crate) struct OsFacts {
pub(crate) name: String,
pub(crate) version: Option<String>,
pub(crate) kernel: String,
pub(crate) distro: String,
pub(crate) distro_id: String,
pub(crate) release: Option<ReleaseFacts>,
pub(crate) name_source: Source,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub(crate) struct ReleaseFacts {
pub(crate) id: Option<String>,
pub(crate) id_like: Vec<String>,
pub(crate) name: Option<String>,
pub(crate) pretty_name: Option<String>,
pub(crate) version: Option<String>,
pub(crate) version_id: Option<String>,
pub(crate) codename: Option<String>,
pub(crate) variant_id: Option<String>,
pub(crate) build_id: Option<String>,
pub(crate) source: Source,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub(crate) struct CpuFacts {
pub(crate) logical: usize,
pub(crate) physical: Option<usize>,
pub(crate) packages: Option<usize>,
pub(crate) raw_name: Option<String>,
pub(crate) name: Option<String>,
pub(crate) vendor: Vendor,
}
#[cfg(feature = "guard")]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) struct FsKind {
pub(crate) name: &'static str,
pub(crate) network: bool,
}