mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
Renames pv crate to s390_pv and pv_core to s390_pv_core. pv was already taken on crates.io. Bump the versions of all crates to 0.10.0. From now on we follow Semver compatibility rules when it comes to updates. patch-level updates will not introduce any backwards incompatible changes. For now all crates in this directory will have the same version number. A version update may, therefore, not add any new things. Library users in this repository still use the non prefixed names and rename the crate in the Cargo.toml. Doc-tests have to use the new name however. Add some Cargo metadata to the Cargo.toml. Acked-by: Marc Hartmayer <mhartmay@linux.ibm.com> Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
56 lines
1.3 KiB
Rust
56 lines
1.3 KiB
Rust
// SPDX-License-Identifier: MIT
|
|
//
|
|
// Copyright IBM Corp. 2023, 2024
|
|
|
|
macro_rules! file_error {
|
|
($ty: tt, $ctx: expr, $path:expr, $src: expr) => {
|
|
$crate::Error::FileIo {
|
|
ty: $crate::FileIoErrorType::$ty,
|
|
ctx: $ctx.to_string(),
|
|
path: $path.as_ref().to_path_buf(),
|
|
source: $src,
|
|
}
|
|
};
|
|
}
|
|
pub(crate) use file_error;
|
|
|
|
macro_rules! bail_spec {
|
|
($str: expr) => {
|
|
return Err($crate::Error::Specification($str.to_string()))
|
|
};
|
|
}
|
|
pub(crate) use bail_spec;
|
|
|
|
/// Asserts a constant expression evaluates to `true`.
|
|
///
|
|
/// If the expression is not evaluated to `true` the compilation will fail.
|
|
#[macro_export]
|
|
macro_rules! static_assert {
|
|
($condition:expr) => {
|
|
const _: () = core::assert!($condition);
|
|
};
|
|
}
|
|
|
|
/// Asserts that a type has a specific size.
|
|
///
|
|
/// Useful to validate structs that are passed to C code.
|
|
/// If the size has not the expected value the compilation will fail.
|
|
///
|
|
/// # Example
|
|
/// ```rust
|
|
/// # use s390_pv_core::assert_size;
|
|
/// # fn main() {}
|
|
/// #[repr(C)]
|
|
/// struct c_struct {
|
|
/// v: u64,
|
|
/// }
|
|
/// assert_size!(c_struct, 8);
|
|
/// // assert_size!(c_struct, 7);//won't compile
|
|
/// ```
|
|
#[macro_export]
|
|
macro_rules! assert_size {
|
|
($t:ty, $sz:expr ) => {
|
|
$crate::static_assert!(::std::mem::size_of::<$t>() == $sz);
|
|
};
|
|
}
|