diff options
author | Nathan Ringo <nathan@remexre.com> | 2024-08-31 00:46:17 -0500 |
---|---|---|
committer | Nathan Ringo <nathan@remexre.com> | 2024-08-31 00:46:17 -0500 |
commit | 4617f96a99c0e5dfac1b45b3cff037306e4edc63 (patch) | |
tree | 45bf1ae799bbaa1d24bb9970c2c052419b3cec42 | |
parent | 15fd8115739da57c6aa64da9a2ac6e0f0b7ba088 (diff) |
Adds a static assertion.
-rw-r--r-- | kernel/Cargo.lock | 7 | ||||
-rw-r--r-- | kernel/Cargo.toml | 1 | ||||
-rw-r--r-- | kernel/src/allocators/buddy/mod.rs | 3 |
3 files changed, 11 insertions, 0 deletions
diff --git a/kernel/Cargo.lock b/kernel/Cargo.lock index ca8ef0e..71a1b88 100644 --- a/kernel/Cargo.lock +++ b/kernel/Cargo.lock @@ -51,6 +51,7 @@ dependencies = [ "either", "log", "spin", + "static_assertions", "void", ] @@ -91,6 +92,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] name = "syn" version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/kernel/Cargo.toml b/kernel/Cargo.toml index 87a2443..f2bb9ff 100644 --- a/kernel/Cargo.toml +++ b/kernel/Cargo.toml @@ -14,6 +14,7 @@ contracts = { version = "0.6.3", default-features = false } either = { version = "1.13.0", default-features = false } log = { version = "0.4.20", default-features = false } spin = { version = "0.9.8", default-features = false, features = ["mutex", "use_ticket_mutex"] } +static_assertions = { version = "1.1.0", default-features = false } void = { version = "1.0.2", default-features = false } [profile.release] diff --git a/kernel/src/allocators/buddy/mod.rs b/kernel/src/allocators/buddy/mod.rs index 261d076..08b30a7 100644 --- a/kernel/src/allocators/buddy/mod.rs +++ b/kernel/src/allocators/buddy/mod.rs @@ -47,3 +47,6 @@ mod tree; /// The index of the largest size class; i.e., one less than the number of size classes. const MAX_ORDER: usize = 18; + +// The max order comes out to a largest size class of 1GiB pages. +static_assertions::const_assert_eq!(4096 << MAX_ORDER, 1024 * 1024 * 1024); |