mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-22 00:43:24 +00:00
Remove static_assertions
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
0c028a7d8c
commit
9e1c939a3f
11
Cargo.lock
generated
11
Cargo.lock
generated
@ -85,7 +85,6 @@ dependencies = [
|
|||||||
"ostd",
|
"ostd",
|
||||||
"smoltcp",
|
"smoltcp",
|
||||||
"spin",
|
"spin",
|
||||||
"static_assertions",
|
|
||||||
"takeable",
|
"takeable",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -100,7 +99,6 @@ dependencies = [
|
|||||||
"log",
|
"log",
|
||||||
"ostd",
|
"ostd",
|
||||||
"spin",
|
"spin",
|
||||||
"static_assertions",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -162,7 +160,6 @@ dependencies = [
|
|||||||
"ostd-pod",
|
"ostd-pod",
|
||||||
"postcard",
|
"postcard",
|
||||||
"serde",
|
"serde",
|
||||||
"static_assertions",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -219,7 +216,6 @@ dependencies = [
|
|||||||
"rand",
|
"rand",
|
||||||
"riscv",
|
"riscv",
|
||||||
"spin",
|
"spin",
|
||||||
"static_assertions",
|
|
||||||
"takeable",
|
"takeable",
|
||||||
"tdx-guest",
|
"tdx-guest",
|
||||||
"time",
|
"time",
|
||||||
@ -1296,7 +1292,6 @@ dependencies = [
|
|||||||
"sbi-rt",
|
"sbi-rt",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"spin",
|
"spin",
|
||||||
"static_assertions",
|
|
||||||
"tdx-guest",
|
"tdx-guest",
|
||||||
"unwinding",
|
"unwinding",
|
||||||
"volatile 0.6.1",
|
"volatile 0.6.1",
|
||||||
@ -1632,12 +1627,6 @@ version = "1.2.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "static_assertions"
|
|
||||||
version = "1.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "strsim"
|
name = "strsim"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
|
@ -52,7 +52,6 @@ rand = { version = "0.8.5", default-features = false, features = [
|
|||||||
"small_rng",
|
"small_rng",
|
||||||
"std_rng",
|
"std_rng",
|
||||||
] }
|
] }
|
||||||
static_assertions = "1.1.0"
|
|
||||||
inherit-methods-macro = { git = "https://github.com/asterinas/inherit-methods-macro", rev = "98f7e3e" }
|
inherit-methods-macro = { git = "https://github.com/asterinas/inherit-methods-macro", rev = "98f7e3e" }
|
||||||
getset = "0.1.2"
|
getset = "0.1.2"
|
||||||
takeable = "0.2.2"
|
takeable = "0.2.2"
|
||||||
|
@ -12,7 +12,6 @@ align_ext = { path = "../../../ostd/libs/align_ext" }
|
|||||||
int-to-c-enum = { path = "../../libs/int-to-c-enum" }
|
int-to-c-enum = { path = "../../libs/int-to-c-enum" }
|
||||||
component = { path = "../../libs/comp-sys/component" }
|
component = { path = "../../libs/comp-sys/component" }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
static_assertions = "1.1.0"
|
|
||||||
bitvec = { version = "1.0.1", default-features = false, features = ["alloc"] }
|
bitvec = { version = "1.0.1", default-features = false, features = ["alloc"] }
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
|
@ -5,8 +5,7 @@ use core::{
|
|||||||
ops::{Add, Sub},
|
ops::{Add, Sub},
|
||||||
};
|
};
|
||||||
|
|
||||||
use ostd::Pod;
|
use ostd::{const_assert, Pod};
|
||||||
use static_assertions::const_assert;
|
|
||||||
|
|
||||||
/// The block index used in the filesystem.
|
/// The block index used in the filesystem.
|
||||||
pub type Bid = BlockId<BLOCK_SIZE>;
|
pub type Bid = BlockId<BLOCK_SIZE>;
|
||||||
|
@ -26,7 +26,6 @@ log = "0.4"
|
|||||||
lru = "0.12.3"
|
lru = "0.12.3"
|
||||||
postcard = "1.0.6"
|
postcard = "1.0.6"
|
||||||
serde = { version = "1.0.192", default-features = false, features = ["alloc", "derive"] }
|
serde = { version = "1.0.192", default-features = false, features = ["alloc", "derive"] }
|
||||||
static_assertions = "1.1.0"
|
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
//! The layer of untrusted block I/O.
|
//! The layer of untrusted block I/O.
|
||||||
|
|
||||||
use static_assertions::assert_eq_size;
|
|
||||||
|
|
||||||
mod block_buf;
|
mod block_buf;
|
||||||
mod block_log;
|
mod block_log;
|
||||||
mod block_ring;
|
mod block_ring;
|
||||||
mod block_set;
|
mod block_set;
|
||||||
|
|
||||||
|
use ostd::const_assert;
|
||||||
|
|
||||||
pub use self::{
|
pub use self::{
|
||||||
block_buf::{Buf, BufMut, BufRef},
|
block_buf::{Buf, BufMut, BufRef},
|
||||||
block_log::{BlockLog, MemLog},
|
block_log::{BlockLog, MemLog},
|
||||||
@ -20,5 +20,5 @@ pub type BlockId = usize;
|
|||||||
pub const BLOCK_SIZE: usize = 0x1000;
|
pub const BLOCK_SIZE: usize = 0x1000;
|
||||||
pub const BID_SIZE: usize = core::mem::size_of::<BlockId>();
|
pub const BID_SIZE: usize = core::mem::size_of::<BlockId>();
|
||||||
|
|
||||||
// This definition of BlockId assumes the target architecture is 64-bit
|
// This definition of `BlockId` assumes the target architecture is 64-bit.
|
||||||
assert_eq_size!(usize, u64);
|
const_assert!(BID_SIZE == 8);
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
use alloc::vec;
|
use alloc::vec;
|
||||||
use core::{any::Any, mem::size_of};
|
use core::{any::Any, mem::size_of};
|
||||||
|
|
||||||
|
use ostd::const_assert;
|
||||||
use ostd_pod::Pod;
|
use ostd_pod::Pod;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use static_assertions::const_assert;
|
|
||||||
|
|
||||||
use super::{Iv, Key, Mac};
|
use super::{Iv, Key, Mac};
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -19,7 +19,6 @@ smoltcp = { git = "https://github.com/asterinas/smoltcp", tag = "r_2024-11-08_f0
|
|||||||
"socket-tcp",
|
"socket-tcp",
|
||||||
] }
|
] }
|
||||||
spin = "0.9.4"
|
spin = "0.9.4"
|
||||||
static_assertions = "1.1.0"
|
|
||||||
takeable = "0.2.2"
|
takeable = "0.2.2"
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
|
@ -7,8 +7,8 @@ use alloc::{boxed::Box, sync::Arc, vec::Vec};
|
|||||||
use core::net::Ipv4Addr;
|
use core::net::Ipv4Addr;
|
||||||
|
|
||||||
use jhash::{jhash_1vals, jhash_3vals};
|
use jhash::{jhash_1vals, jhash_3vals};
|
||||||
|
use ostd::const_assert;
|
||||||
use smoltcp::wire::{IpAddress, IpEndpoint, IpListenEndpoint};
|
use smoltcp::wire::{IpAddress, IpEndpoint, IpListenEndpoint};
|
||||||
use static_assertions::const_assert;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ext::Ext,
|
ext::Ext,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
use id_alloc::IdAlloc;
|
use id_alloc::IdAlloc;
|
||||||
use ostd::mm::UntypedMem;
|
use ostd::{const_assert, mm::UntypedMem};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
block_ptr::Ext2Bid,
|
block_ptr::Ext2Bid,
|
||||||
|
@ -7,7 +7,7 @@ use alloc::{borrow::ToOwned, rc::Rc};
|
|||||||
use core::sync::atomic::{AtomicUsize, Ordering};
|
use core::sync::atomic::{AtomicUsize, Ordering};
|
||||||
|
|
||||||
use inherit_methods_macro::inherit_methods;
|
use inherit_methods_macro::inherit_methods;
|
||||||
use ostd::mm::UntypedMem;
|
use ostd::{const_assert, mm::UntypedMem};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
block_ptr::{BidPath, BlockPtrs, Ext2Bid, BID_SIZE, MAX_BLOCK_PTRS},
|
block_ptr::{BidPath, BlockPtrs, Ext2Bid, BID_SIZE, MAX_BLOCK_PTRS},
|
||||||
|
@ -16,7 +16,6 @@ pub(super) use ostd::{
|
|||||||
mm::{Frame, FrameAllocOptions, Segment, USegment, VmIo},
|
mm::{Frame, FrameAllocOptions, Segment, USegment, VmIo},
|
||||||
sync::{RwMutex, RwMutexReadGuard, RwMutexWriteGuard},
|
sync::{RwMutex, RwMutexReadGuard, RwMutexWriteGuard},
|
||||||
};
|
};
|
||||||
pub(super) use static_assertions::const_assert;
|
|
||||||
|
|
||||||
pub(super) use super::utils::{Dirty, IsPowerOf};
|
pub(super) use super::utils::{Dirty, IsPowerOf};
|
||||||
pub(super) use crate::{
|
pub(super) use crate::{
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
|
use ostd::const_assert;
|
||||||
|
|
||||||
use super::{inode::RawInode, prelude::*};
|
use super::{inode::RawInode, prelude::*};
|
||||||
|
|
||||||
/// The magic number of Ext2.
|
/// The magic number of Ext2.
|
||||||
|
@ -35,7 +35,6 @@ ostd-test = { version = "0.11.3", path = "libs/ostd-test" }
|
|||||||
ostd-pod = { git = "https://github.com/asterinas/ostd-pod", rev = "c4644be", version = "0.1.1" }
|
ostd-pod = { git = "https://github.com/asterinas/ostd-pod", rev = "c4644be", version = "0.1.1" }
|
||||||
spin = "0.9.4"
|
spin = "0.9.4"
|
||||||
smallvec = "1.13.2"
|
smallvec = "1.13.2"
|
||||||
static_assertions = "1.1.0"
|
|
||||||
unwinding = { version = "0.2.5", default-features = false, features = ["fde-gnu-eh-frame-hdr", "hide-trace", "panic", "personality", "unwinder"] }
|
unwinding = { version = "0.2.5", default-features = false, features = ["fde-gnu-eh-frame-hdr", "hide-trace", "panic", "personality", "unwinder"] }
|
||||||
volatile = "0.6.1"
|
volatile = "0.6.1"
|
||||||
xarray = { git = "https://github.com/asterinas/xarray", version = "0.1.0" }
|
xarray = { git = "https://github.com/asterinas/xarray", version = "0.1.0" }
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
use core::sync::atomic::{AtomicU64, Ordering};
|
use core::sync::atomic::{AtomicU64, Ordering};
|
||||||
|
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use static_assertions::const_assert_eq;
|
|
||||||
|
|
||||||
use super::{num_cpus, CpuId};
|
use super::{num_cpus, CpuId};
|
||||||
|
use crate::const_assert;
|
||||||
|
|
||||||
/// A subset of all CPUs in the system.
|
/// A subset of all CPUs in the system.
|
||||||
#[derive(Clone, Debug, Default)]
|
#[derive(Clone, Debug, Default)]
|
||||||
@ -159,7 +159,7 @@ pub struct AtomicCpuSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type AtomicInnerPart = AtomicU64;
|
type AtomicInnerPart = AtomicU64;
|
||||||
const_assert_eq!(core::mem::size_of::<AtomicInnerPart>() * 8, BITS_PER_PART);
|
const_assert!(core::mem::size_of::<AtomicInnerPart>() * 8 == BITS_PER_PART);
|
||||||
|
|
||||||
impl AtomicCpuSet {
|
impl AtomicCpuSet {
|
||||||
/// Creates a new `AtomicCpuSet` with an initial value.
|
/// Creates a new `AtomicCpuSet` with an initial value.
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
extern crate static_assertions;
|
|
||||||
|
|
||||||
pub mod arch;
|
pub mod arch;
|
||||||
pub mod boot;
|
pub mod boot;
|
||||||
|
@ -49,11 +49,11 @@ use core::{
|
|||||||
|
|
||||||
use align_ext::AlignExt;
|
use align_ext::AlignExt;
|
||||||
use log::info;
|
use log::info;
|
||||||
use static_assertions::const_assert_eq;
|
|
||||||
|
|
||||||
use super::{allocator, Segment};
|
use super::{allocator, Segment};
|
||||||
use crate::{
|
use crate::{
|
||||||
arch::mm::PagingConsts,
|
arch::mm::PagingConsts,
|
||||||
|
const_assert,
|
||||||
mm::{
|
mm::{
|
||||||
kspace::LINEAR_MAPPING_BASE_VADDR, paddr_to_vaddr, page_size, page_table::boot_pt,
|
kspace::LINEAR_MAPPING_BASE_VADDR, paddr_to_vaddr, page_size, page_table::boot_pt,
|
||||||
CachePolicy, Infallible, Paddr, PageFlags, PageProperty, PrivilegedPageFlags, Vaddr,
|
CachePolicy, Infallible, Paddr, PageFlags, PageProperty, PrivilegedPageFlags, Vaddr,
|
||||||
@ -124,8 +124,8 @@ pub(super) const REF_COUNT_MAX: u64 = i64::MAX as u64;
|
|||||||
|
|
||||||
type FrameMetaVtablePtr = core::ptr::DynMetadata<dyn AnyFrameMeta>;
|
type FrameMetaVtablePtr = core::ptr::DynMetadata<dyn AnyFrameMeta>;
|
||||||
|
|
||||||
const_assert_eq!(PAGE_SIZE % META_SLOT_SIZE, 0);
|
const_assert!(PAGE_SIZE % META_SLOT_SIZE == 0);
|
||||||
const_assert_eq!(size_of::<MetaSlot>(), META_SLOT_SIZE);
|
const_assert!(size_of::<MetaSlot>() == META_SLOT_SIZE);
|
||||||
|
|
||||||
/// All frame metadata types must implement this trait.
|
/// All frame metadata types must implement this trait.
|
||||||
///
|
///
|
||||||
|
@ -1,5 +1,20 @@
|
|||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
|
/// Asserts that a boolean expression is `true` at compile-time.
|
||||||
|
///
|
||||||
|
/// Rust provides [`const` blocks], which can be used flexibly within methods, but cannot be used
|
||||||
|
/// directly at the top level. This macro serves as a helper to perform compile-time assertions
|
||||||
|
/// outside of methods.
|
||||||
|
///
|
||||||
|
/// [`const` blocks]: https://doc.rust-lang.org/reference/expressions/block-expr.html#const-blocks
|
||||||
|
//
|
||||||
|
// TODO: Introduce `const_assert_eq!()` once `assert_eq!()` can be used in the `const` context.
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! const_assert {
|
||||||
|
($cond:expr $(,)?) => { const _: () = assert!($cond); };
|
||||||
|
($cond:expr, $($arg:tt)+) => { const _: () = assert!($cond, $($arg)*); };
|
||||||
|
}
|
||||||
|
|
||||||
/// A marker trait that represents a type has the same size as `T`.
|
/// A marker trait that represents a type has the same size as `T`.
|
||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
|
Reference in New Issue
Block a user