From 63ce236432c4970034a367dd5552d063762b5844 Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Sun, 11 Feb 2024 10:45:15 +0000 Subject: [PATCH] Require sel4_cfg attr in sel4_cfg_if macro Signed-off-by: Nick Spinale --- .../sel4-simple-task/runtime/src/lib.rs | 2 +- .../tests/root-task/config/src/main.rs | 2 +- .../core/src/arch/mod.rs | 6 +- crates/sel4-capdl-initializer/core/src/lib.rs | 10 +-- .../types/src/when_sel4.rs | 6 +- crates/sel4-kernel-loader/build.rs | 16 ++-- .../src/arch/arm/arch/mod.rs | 4 +- crates/sel4-kernel-loader/src/arch/mod.rs | 4 +- .../sel4-kernel-loader/src/arch/riscv/mod.rs | 4 +- crates/sel4-kernel-loader/src/plat/mod.rs | 6 +- crates/sel4-microkit/src/lib.rs | 2 +- crates/sel4-microkit/src/panicking.rs | 2 +- crates/sel4-runtime-common/src/phdrs/tls.rs | 2 +- crates/sel4/config/generic/src/cfg_if.rs | 81 +++++++++++-------- crates/sel4/src/arch/arm/arch/aarch32/mod.rs | 2 +- crates/sel4/src/arch/arm/arch/aarch64/mod.rs | 2 +- crates/sel4/src/arch/arm/arch/mod.rs | 4 +- crates/sel4/src/arch/arm/fault.rs | 2 +- crates/sel4/src/arch/mod.rs | 6 +- crates/sel4/src/arch/x86/arch/mod.rs | 2 +- crates/sel4/src/benchmark.rs | 4 +- crates/sel4/src/cptr.rs | 4 +- crates/sel4/src/invocations.rs | 4 +- crates/sel4/src/lib.rs | 8 +- crates/sel4/src/reply_authority.rs | 2 +- crates/sel4/src/syscalls.rs | 2 +- crates/sel4/sys/src/fault/arch/mod.rs | 8 +- crates/sel4/sys/src/lib.rs | 4 +- crates/sel4/sys/src/syscalls/calls.rs | 14 ++-- .../sel4/sys/src/syscalls/helpers/arch/mod.rs | 8 +- 30 files changed, 119 insertions(+), 104 deletions(-) diff --git a/crates/private/support/sel4-simple-task/runtime/src/lib.rs b/crates/private/support/sel4-simple-task/runtime/src/lib.rs index 05484b11c..91b80b20c 100644 --- a/crates/private/support/sel4-simple-task/runtime/src/lib.rs +++ b/crates/private/support/sel4-simple-task/runtime/src/lib.rs @@ -87,7 +87,7 @@ pub unsafe extern "C" fn cont_fn(cont_arg: *mut sel4_runtime_common::ContArg) -> let endpoint = Endpoint::from_bits(thread_config.endpoint().unwrap()); let reply_authority = { sel4::sel4_cfg_if! { - if #[cfg(KERNEL_MCS)] { + if #[sel4_cfg(KERNEL_MCS)] { sel4::Reply::from_bits(thread_config.reply_authority().unwrap()) } else { assert!(thread_config.reply_authority().is_none()); diff --git a/crates/private/tests/root-task/config/src/main.rs b/crates/private/tests/root-task/config/src/main.rs index 8ab4fc200..869d8eff1 100644 --- a/crates/private/tests/root-task/config/src/main.rs +++ b/crates/private/tests/root-task/config/src/main.rs @@ -17,7 +17,7 @@ fn main(_: &sel4::BootInfoPtr) -> ! { sel4::sel4_cfg_usize!(RETYPE_FAN_OUT_LIMIT), ); sel4::sel4_cfg_if! { - if #[cfg(NUM_PRIORITIES = "0")] { + if #[sel4_cfg(NUM_PRIORITIES = "0")] { compile_error!("uh oh"); } else { debug_println!("NUM_PRIORITIES: {}", sel4::sel4_cfg_usize!(NUM_PRIORITIES)); diff --git a/crates/sel4-capdl-initializer/core/src/arch/mod.rs b/crates/sel4-capdl-initializer/core/src/arch/mod.rs index 2f63d3509..cdcfac909 100644 --- a/crates/sel4-capdl-initializer/core/src/arch/mod.rs +++ b/crates/sel4-capdl-initializer/core/src/arch/mod.rs @@ -135,13 +135,13 @@ pub(crate) mod frame_types { } sel4::sel4_cfg_if! { - if #[cfg(ARCH_AARCH64)] { + if #[sel4_cfg(ARCH_AARCH64)] { const CACHED: VmAttributes = VmAttributes::PAGE_CACHEABLE; const UNCACHED: VmAttributes = VmAttributes::DEFAULT; - } else if #[cfg(ARCH_RISCV64)] { + } else if #[sel4_cfg(ARCH_RISCV64)] { const CACHED: VmAttributes = VmAttributes::DEFAULT; const UNCACHED: VmAttributes = VmAttributes::NONE; - } else if #[cfg(ARCH_X86_64)] { + } else if #[sel4_cfg(ARCH_X86_64)] { const CACHED: VmAttributes = VmAttributes::DEFAULT; const UNCACHED: VmAttributes = VmAttributes::CACHE_DISABLED; } diff --git a/crates/sel4-capdl-initializer/core/src/lib.rs b/crates/sel4-capdl-initializer/core/src/lib.rs index f84ac58ce..183785769 100644 --- a/crates/sel4-capdl-initializer/core/src/lib.rs +++ b/crates/sel4-capdl-initializer/core/src/lib.rs @@ -108,7 +108,7 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject self.init_vspaces()?; sel4::sel4_cfg_if! { - if #[cfg(KERNEL_MCS)] { + if #[sel4_cfg(KERNEL_MCS)] { self.init_sched_contexts()?; } } @@ -343,7 +343,7 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject #[sel4_cfg(any(ARCH_AARCH32, ARCH_AARCH64))] Object::ArmIrq(obj) => { sel4::sel4_cfg_if! { - if #[cfg(MAX_NUM_NODES = "1")] { + if #[sel4_cfg(MAX_NUM_NODES = "1")] { init_thread::slot::IRQ_CONTROL.cap().irq_control_get_trigger( *irq, obj.extra.trigger, @@ -581,7 +581,7 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject } sel4::sel4_cfg_if! { - if #[cfg(all(ARCH_AARCH64, ARM_HYPERVISOR_SUPPORT))] { + if #[sel4_cfg(all(ARCH_AARCH64, ARM_HYPERVISOR_SUPPORT))] { if let Some(vcpu) = obj.vcpu() { let vcpu = self.orig_cap::(vcpu.object); vcpu.vcpu_set_tcb(tcb)?; @@ -607,7 +607,7 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject let affinity: usize = obj.extra.affinity.try_into()?; sel4::sel4_cfg_if! { - if #[cfg(KERNEL_MCS)] { + if #[sel4_cfg(KERNEL_MCS)] { if let Some(sched_context_cap) = obj.sc() { self.init_sched_context(sched_context_cap.object, affinity)?; } @@ -679,7 +679,7 @@ impl<'a, N: ObjectName, D: Content, M: GetEmbeddedFrame, B: BorrowMut<[PerObject )?; sel4::sel4_cfg_if! { - if #[cfg(not(MAX_NUM_NODES = "1"))] { + if #[sel4_cfg(not(MAX_NUM_NODES = "1"))] { tcb.tcb_set_affinity(affinity.try_into().unwrap())?; } } diff --git a/crates/sel4-capdl-initializer/types/src/when_sel4.rs b/crates/sel4-capdl-initializer/types/src/when_sel4.rs index 3720042db..4069aff8c 100644 --- a/crates/sel4-capdl-initializer/types/src/when_sel4.rs +++ b/crates/sel4-capdl-initializer/types/src/when_sel4.rs @@ -134,13 +134,13 @@ impl HasVmAttributes for cap::PageTable { } sel4::sel4_cfg_if! { - if #[cfg(ARCH_AARCH64)] { + if #[sel4_cfg(ARCH_AARCH64)] { const CACHED: VmAttributes = VmAttributes::PAGE_CACHEABLE; const UNCACHED: VmAttributes = VmAttributes::DEFAULT; - } else if #[cfg(any(ARCH_RISCV64, ARCH_RISCV32))] { + } else if #[sel4_cfg(any(ARCH_RISCV64, ARCH_RISCV32))] { const CACHED: VmAttributes = VmAttributes::DEFAULT; const UNCACHED: VmAttributes = VmAttributes::NONE; - } else if #[cfg(ARCH_X86_64)] { + } else if #[sel4_cfg(ARCH_X86_64)] { const CACHED: VmAttributes = VmAttributes::DEFAULT; const UNCACHED: VmAttributes = VmAttributes::CACHE_DISABLED; } diff --git a/crates/sel4-kernel-loader/build.rs b/crates/sel4-kernel-loader/build.rs index d568ceab0..b58d5bcd9 100644 --- a/crates/sel4-kernel-loader/build.rs +++ b/crates/sel4-kernel-loader/build.rs @@ -30,27 +30,27 @@ use sel4_rustfmt_helper::Rustfmt; pub const SEL4_KERNEL_ENV: &str = "SEL4_KERNEL"; sel4_cfg_if! { - if #[cfg(WORD_SIZE = "64")] { + if #[sel4_cfg(WORD_SIZE = "64")] { type FileHeader = object::elf::FileHeader64; - } else if #[cfg(WORD_SIZE = "32")] { + } else if #[sel4_cfg(WORD_SIZE = "32")] { type FileHeader = object::elf::FileHeader32; } } sel4_cfg_if! { - if #[cfg(SEL4_ARCH = "aarch64")] { + if #[sel4_cfg(SEL4_ARCH = "aarch64")] { type SchemeImpl = schemes::AArch64; - } else if #[cfg(SEL4_ARCH = "aarch32")] { + } else if #[sel4_cfg(SEL4_ARCH = "aarch32")] { type SchemeImpl = schemes::AArch32; - } else if #[cfg(SEL4_ARCH = "riscv64")] { + } else if #[sel4_cfg(SEL4_ARCH = "riscv64")] { sel4_cfg_if! { - if #[cfg(PT_LEVELS = "3")] { + if #[sel4_cfg(PT_LEVELS = "3")] { type SchemeImpl = schemes::RiscV64Sv39; } } - } else if #[cfg(SEL4_ARCH = "riscv32")] { + } else if #[sel4_cfg(SEL4_ARCH = "riscv32")] { sel4_cfg_if! { - if #[cfg(PT_LEVELS = "2")] { + if #[sel4_cfg(PT_LEVELS = "2")] { type SchemeImpl = schemes::RiscV32Sv32; } } diff --git a/crates/sel4-kernel-loader/src/arch/arm/arch/mod.rs b/crates/sel4-kernel-loader/src/arch/arm/arch/mod.rs index b47649e69..d2005305b 100644 --- a/crates/sel4-kernel-loader/src/arch/arm/arch/mod.rs +++ b/crates/sel4-kernel-loader/src/arch/arm/arch/mod.rs @@ -5,10 +5,10 @@ // sel4_config::sel4_cfg_if! { - if #[cfg(ARCH_AARCH64)] { + if #[sel4_cfg(ARCH_AARCH64)] { #[path = "aarch64/mod.rs"] mod imp; - } else if #[cfg(ARCH_AARCH32)] { + } else if #[sel4_cfg(ARCH_AARCH32)] { #[path = "aarch32/mod.rs"] mod imp; } diff --git a/crates/sel4-kernel-loader/src/arch/mod.rs b/crates/sel4-kernel-loader/src/arch/mod.rs index 8ab30c1c2..1ce9cf2d0 100644 --- a/crates/sel4-kernel-loader/src/arch/mod.rs +++ b/crates/sel4-kernel-loader/src/arch/mod.rs @@ -8,10 +8,10 @@ use sel4_config::sel4_cfg_if; use sel4_kernel_loader_payload_types::PayloadInfo; sel4_cfg_if! { - if #[cfg(any(ARCH_AARCH64, ARCH_AARCH32))] { + if #[sel4_cfg(any(ARCH_AARCH64, ARCH_AARCH32))] { #[path = "arm/mod.rs"] mod imp; - } else if #[cfg(any(ARCH_RISCV64, ARCH_RISCV32))] { + } else if #[sel4_cfg(any(ARCH_RISCV64, ARCH_RISCV32))] { #[path = "riscv/mod.rs"] mod imp; } diff --git a/crates/sel4-kernel-loader/src/arch/riscv/mod.rs b/crates/sel4-kernel-loader/src/arch/riscv/mod.rs index 44ea4c0cc..c6c7803c0 100644 --- a/crates/sel4-kernel-loader/src/arch/riscv/mod.rs +++ b/crates/sel4-kernel-loader/src/arch/riscv/mod.rs @@ -77,7 +77,7 @@ impl Arch for ArchImpl { switch_page_tables(); sel4_cfg_if! { - if #[cfg(MAX_NUM_NODES = "1")] { + if #[sel4_cfg(MAX_NUM_NODES = "1")] { (kernel_entry)( ui_p_reg_start, ui_p_reg_end, @@ -103,7 +103,7 @@ impl Arch for ArchImpl { } sel4_cfg_if! { - if #[cfg(MAX_NUM_NODES = "1")] { + if #[sel4_cfg(MAX_NUM_NODES = "1")] { type KernelEntry = extern "C" fn( ui_p_reg_start: usize, ui_p_reg_end: usize, diff --git a/crates/sel4-kernel-loader/src/plat/mod.rs b/crates/sel4-kernel-loader/src/plat/mod.rs index 38fd576e0..6ecec223e 100644 --- a/crates/sel4-kernel-loader/src/plat/mod.rs +++ b/crates/sel4-kernel-loader/src/plat/mod.rs @@ -7,13 +7,13 @@ use sel4_config::sel4_cfg_if; sel4_cfg_if! { - if #[cfg(all(any(ARCH_AARCH64, ARCH_AARCH32), PLAT_QEMU_ARM_VIRT))] { + if #[sel4_cfg(all(any(ARCH_AARCH64, ARCH_AARCH32), PLAT_QEMU_ARM_VIRT))] { #[path = "qemu_arm_virt/mod.rs"] mod imp; - } else if #[cfg(all(any(ARCH_AARCH64, ARCH_AARCH32), PLAT_BCM2711))] { + } else if #[sel4_cfg(all(any(ARCH_AARCH64, ARCH_AARCH32), PLAT_BCM2711))] { #[path = "bcm2711/mod.rs"] mod imp; - } else if #[cfg(all(any(ARCH_RISCV64, ARCH_RISCV32), any(PLAT_SPIKE, PLAT_QEMU_RISCV_VIRT)))] { + } else if #[sel4_cfg(all(any(ARCH_RISCV64, ARCH_RISCV32), any(PLAT_SPIKE, PLAT_QEMU_RISCV_VIRT)))] { #[path = "riscv_generic/mod.rs"] mod imp; } diff --git a/crates/sel4-microkit/src/lib.rs b/crates/sel4-microkit/src/lib.rs index 085717de9..84200c415 100644 --- a/crates/sel4-microkit/src/lib.rs +++ b/crates/sel4-microkit/src/lib.rs @@ -111,7 +111,7 @@ pub mod _private { } sel4::config::sel4_cfg_if! { - if #[cfg(PRINTING)] { + if #[sel4_cfg(PRINTING)] { pub use sel4_panicking_env::{debug_print, debug_println}; } else { /// No-op for this configuration. diff --git a/crates/sel4-microkit/src/panicking.rs b/crates/sel4-microkit/src/panicking.rs index 2694eef9d..093d91fad 100644 --- a/crates/sel4-microkit/src/panicking.rs +++ b/crates/sel4-microkit/src/panicking.rs @@ -41,7 +41,7 @@ pub(crate) fn init_panicking() { fn debug_put_char(c: u8) { sel4::sel4_cfg_if! { - if #[cfg(PRINTING)] { + if #[sel4_cfg(PRINTING)] { sel4::debug_put_char(c) } } diff --git a/crates/sel4-runtime-common/src/phdrs/tls.rs b/crates/sel4-runtime-common/src/phdrs/tls.rs index bf772f0d5..44eb06a9d 100644 --- a/crates/sel4-runtime-common/src/phdrs/tls.rs +++ b/crates/sel4-runtime-common/src/phdrs/tls.rs @@ -34,7 +34,7 @@ pub unsafe fn initialize_tls_on_stack_and_continue(cont_fn: ContFn, cont_arg: *m } sel4::sel4_cfg_if! { - if #[cfg(all(ARCH_X86_64, SET_TLS_BASE_SELF))] { + if #[sel4_cfg(all(ARCH_X86_64, SET_TLS_BASE_SELF))] { const CHOSEN_SET_THREAD_POINTER_FN: SetThreadPointerFn = set_thread_pointer_via_syscall; unsafe extern "C" fn set_thread_pointer_via_syscall(val: usize) { diff --git a/crates/sel4/config/generic/src/cfg_if.rs b/crates/sel4/config/generic/src/cfg_if.rs index 8b16d8dff..ff806ed1e 100644 --- a/crates/sel4/config/generic/src/cfg_if.rs +++ b/crates/sel4/config/generic/src/cfg_if.rs @@ -6,13 +6,25 @@ use proc_macro2::TokenStream; use quote::{format_ident, quote}; -use syn::{parse2, spanned::Spanned, Token}; +use syn::{ + parse::{ParseStream, Parser}, + spanned::Spanned, + Token, +}; -use crate::{parse_or_return, MacroImpls}; +use crate::MacroImpls; impl<'a> MacroImpls<'a> { pub fn cfg_if_impl(&self, toks: TokenStream) -> TokenStream { - let input = parse_or_return!(toks as CfgIfInput); + let parser = move |parse_stream: ParseStream| { + parse_cfg_if_input(self.synthetic_attr(), parse_stream) + }; + let input = match parser.parse2(toks) { + Ok(parsed) => parsed, + Err(err) => { + return err.to_compile_error(); + } + }; for branch_with_condition in input.branches_with_conditions.iter() { match self.eval_nested_meta(&branch_with_condition.condition) { Ok(pass) => { @@ -37,27 +49,28 @@ struct CfgIfInput { trailing_branch_without_condition: Option, } -impl syn::parse::Parse for CfgIfInput { - fn parse(input: syn::parse::ParseStream) -> syn::Result { - let mut branches_with_conditions = vec![input.parse()?]; - while input.peek(Token![else]) { - input.parse::()?; - if input.peek(Token![if]) { - branches_with_conditions.push(input.parse()?); - } else { - break; - } - } - let trailing_branch_without_condition = if input.is_empty() { - None +fn parse_cfg_if_input( + synthetic_attr: &str, + input: syn::parse::ParseStream, +) -> syn::Result { + let mut branches_with_conditions = vec![parse_branch_with_condition(synthetic_attr, input)?]; + while input.peek(Token![else]) { + input.parse::()?; + if input.peek(Token![if]) { + branches_with_conditions.push(parse_branch_with_condition(synthetic_attr, input)?); } else { - Some(input.call(parse_branch)?) - }; - Ok(Self { - branches_with_conditions, - trailing_branch_without_condition, - }) + break; + } } + let trailing_branch_without_condition = if input.is_empty() { + None + } else { + Some(input.call(parse_branch)?) + }; + Ok(CfgIfInput { + branches_with_conditions, + trailing_branch_without_condition, + }) } struct BranchWithCondition { @@ -65,19 +78,18 @@ struct BranchWithCondition { branch: TokenStream, } -impl syn::parse::Parse for BranchWithCondition { - fn parse(input: syn::parse::ParseStream) -> syn::Result { - let condition = input.call(parse_condition)?; - let branch = input.call(parse_branch)?; - Ok(Self { condition, branch }) - } +fn parse_branch_with_condition( + synthetic_attr: &str, + input: syn::parse::ParseStream, +) -> syn::Result { + let condition = parse_condition(synthetic_attr, input)?; + let branch = parse_branch(input)?; + Ok(BranchWithCondition { condition, branch }) } type Condition = syn::NestedMeta; -const CFG: &str = "cfg"; - -fn parse_condition(input: syn::parse::ParseStream) -> syn::Result { +fn parse_condition(synthetic_attr: &str, input: syn::parse::ParseStream) -> syn::Result { input.parse::()?; let attrs = syn::Attribute::parse_outer(input)?; let attr = match attrs.len() { @@ -90,8 +102,11 @@ fn parse_condition(input: syn::parse::ParseStream) -> syn::Result { )) } }; - if !attr.path.is_ident(&format_ident!("{}", CFG)) { - return Err(syn::Error::new(attr.span(), format!("expected '{CFG}'"))); + if !attr.path.is_ident(&format_ident!("{}", synthetic_attr)) { + return Err(syn::Error::new( + attr.span(), + format!("expected '{synthetic_attr}'"), + )); } attr.parse_args() } diff --git a/crates/sel4/src/arch/arm/arch/aarch32/mod.rs b/crates/sel4/src/arch/arm/arch/aarch32/mod.rs index 249e20692..556e653f7 100644 --- a/crates/sel4/src/arch/arm/arch/aarch32/mod.rs +++ b/crates/sel4/src/arch/arm/arch/aarch32/mod.rs @@ -9,7 +9,7 @@ mod object; mod user_context; sel4_config::sel4_cfg_if! { - if #[cfg(ARM_HYPERVISOR_SUPPORT)] { + if #[sel4_cfg(ARM_HYPERVISOR_SUPPORT)] { mod vcpu_reg; } } diff --git a/crates/sel4/src/arch/arm/arch/aarch64/mod.rs b/crates/sel4/src/arch/arm/arch/aarch64/mod.rs index 249e20692..556e653f7 100644 --- a/crates/sel4/src/arch/arm/arch/aarch64/mod.rs +++ b/crates/sel4/src/arch/arm/arch/aarch64/mod.rs @@ -9,7 +9,7 @@ mod object; mod user_context; sel4_config::sel4_cfg_if! { - if #[cfg(ARM_HYPERVISOR_SUPPORT)] { + if #[sel4_cfg(ARM_HYPERVISOR_SUPPORT)] { mod vcpu_reg; } } diff --git a/crates/sel4/src/arch/arm/arch/mod.rs b/crates/sel4/src/arch/arm/arch/mod.rs index 32c778934..385aef98a 100644 --- a/crates/sel4/src/arch/arm/arch/mod.rs +++ b/crates/sel4/src/arch/arm/arch/mod.rs @@ -7,10 +7,10 @@ use sel4_config::sel4_cfg_if; sel4_cfg_if! { - if #[cfg(ARCH_AARCH64)] { + if #[sel4_cfg(ARCH_AARCH64)] { #[path = "aarch64/mod.rs"] mod imp; - } else if #[cfg(ARCH_AARCH32)] { + } else if #[sel4_cfg(ARCH_AARCH32)] { #[path = "aarch32/mod.rs"] mod imp; } diff --git a/crates/sel4/src/arch/arm/fault.rs b/crates/sel4/src/arch/arm/fault.rs index 53adf2948..5670d63d8 100644 --- a/crates/sel4/src/arch/arm/fault.rs +++ b/crates/sel4/src/arch/arm/fault.rs @@ -19,7 +19,7 @@ declare_fault_newtype!(VmFault, sys::seL4_Fault_VMFault); declare_fault_newtype!(Timeout, sys::seL4_Fault_Timeout); sel4_cfg_if! { - if #[cfg(ARM_HYPERVISOR_SUPPORT)] { + if #[sel4_cfg(ARM_HYPERVISOR_SUPPORT)] { declare_fault_newtype!(VGicMaintenance, sys::seL4_Fault_VGICMaintenance); declare_fault_newtype!(VCpuFault, sys::seL4_Fault_VCPUFault); declare_fault_newtype!(VPpiEvent, sys::seL4_Fault_VPPIEvent); diff --git a/crates/sel4/src/arch/mod.rs b/crates/sel4/src/arch/mod.rs index 9066b3711..014f9bb71 100644 --- a/crates/sel4/src/arch/mod.rs +++ b/crates/sel4/src/arch/mod.rs @@ -13,13 +13,13 @@ use sel4_config::sel4_cfg_if; // - ARCH_X86 sel4_cfg_if! { - if #[cfg(any(ARCH_AARCH32, ARCH_AARCH64))] { + if #[sel4_cfg(any(ARCH_AARCH32, ARCH_AARCH64))] { #[path = "arm/mod.rs"] mod imp; - } else if #[cfg(any(ARCH_RISCV32, ARCH_RISCV64))] { + } else if #[sel4_cfg(any(ARCH_RISCV32, ARCH_RISCV64))] { #[path = "riscv/mod.rs"] mod imp; - } else if #[cfg(ARCH_X86_64)] { + } else if #[sel4_cfg(ARCH_X86_64)] { #[path = "x86/mod.rs"] mod imp; } diff --git a/crates/sel4/src/arch/x86/arch/mod.rs b/crates/sel4/src/arch/x86/arch/mod.rs index d23ab6033..cf418fb89 100644 --- a/crates/sel4/src/arch/x86/arch/mod.rs +++ b/crates/sel4/src/arch/x86/arch/mod.rs @@ -7,7 +7,7 @@ use sel4_config::sel4_cfg_if; sel4_cfg_if! { - if #[cfg(ARCH_X86_64)] { + if #[sel4_cfg(ARCH_X86_64)] { #[path = "x64/mod.rs"] mod imp; } diff --git a/crates/sel4/src/benchmark.rs b/crates/sel4/src/benchmark.rs index 111435d82..baf072e73 100644 --- a/crates/sel4/src/benchmark.rs +++ b/crates/sel4/src/benchmark.rs @@ -24,7 +24,7 @@ pub fn benchmark_set_log_buffer(frame: LargePage) -> Result<()> { } sel4_cfg_if! { - if #[cfg(BENCHMARK_TRACK_UTILISATION)] { + if #[sel4_cfg(BENCHMARK_TRACK_UTILISATION)] { pub fn benchmark_get_thread_utilisation(tcb: Tcb) { sys::seL4_BenchmarkGetThreadUtilisation(tcb.bits()) } @@ -34,7 +34,7 @@ sel4_cfg_if! { } sel4_cfg_if! { - if #[cfg(DEBUG_BUILD)] { + if #[sel4_cfg(DEBUG_BUILD)] { pub fn benchmark_dump_all_thread_utilisation() { sys::seL4_BenchmarkDumpAllThreadsUtilisation() } diff --git a/crates/sel4/src/cptr.rs b/crates/sel4/src/cptr.rs index ecd8583ec..16ceca68b 100644 --- a/crates/sel4/src/cptr.rs +++ b/crates/sel4/src/cptr.rs @@ -233,7 +233,7 @@ pub mod cap_type { } sel4_cfg_if! { - if #[cfg(KERNEL_MCS)] { + if #[sel4_cfg(KERNEL_MCS)] { declare_cap_type! { /// Corresponds to the reply capability type (MCS only). Reply @@ -282,7 +282,7 @@ pub mod cap { declare_cap_alias!(Granule); sel4_cfg_if! { - if #[cfg(KERNEL_MCS)] { + if #[sel4_cfg(KERNEL_MCS)] { declare_cap_alias!(Reply); declare_cap_alias!(SchedContext); declare_cap_alias!(SchedControl); diff --git a/crates/sel4/src/invocations.rs b/crates/sel4/src/invocations.rs index b490bc226..07de9d48a 100644 --- a/crates/sel4/src/invocations.rs +++ b/crates/sel4/src/invocations.rs @@ -109,7 +109,7 @@ impl Tcb { } sel4_cfg_if! { - if #[cfg(KERNEL_MCS)] { + if #[sel4_cfg(KERNEL_MCS)] { /// Corresponds to `seL4_TCB_Configure`. pub fn tcb_configure( self, @@ -159,7 +159,7 @@ impl Tcb { } sel4_cfg_if! { - if #[cfg(KERNEL_MCS)] { + if #[sel4_cfg(KERNEL_MCS)] { /// Corresponds to `seL4_TCB_SetSchedParams`. pub fn tcb_set_sched_params( self, diff --git a/crates/sel4/src/lib.rs b/crates/sel4/src/lib.rs index a5033c1cc..619192586 100644 --- a/crates/sel4/src/lib.rs +++ b/crates/sel4/src/lib.rs @@ -131,7 +131,7 @@ pub use syscalls::{ pub use vspace::{FrameType, SizedFrameType, GRANULE_SIZE}; sel4_cfg_if! { - if #[cfg(KERNEL_MCS)] { + if #[sel4_cfg(KERNEL_MCS)] { pub use invocations::Time; } else { pub use syscalls::reply; @@ -155,7 +155,7 @@ pub(crate) use helper_macros::{ }; sel4_cfg_if! { - if #[cfg(DEBUG_BUILD)] { + if #[sel4_cfg(DEBUG_BUILD)] { mod debug; mod fmt; @@ -165,7 +165,7 @@ sel4_cfg_if! { } sel4_cfg_if! { - if #[cfg(ENABLE_BENCHMARKS)] { + if #[sel4_cfg(ENABLE_BENCHMARKS)] { mod benchmark; pub use benchmark::{ @@ -175,7 +175,7 @@ sel4_cfg_if! { }; sel4_cfg_if! { - if #[cfg(BENCHMARK_TRACK_UTILISATION)] { + if #[sel4_cfg(BENCHMARK_TRACK_UTILISATION)] { pub use benchmark::{ benchmark_get_thread_utilisation, benchmark_reset_thread_utilisation, diff --git a/crates/sel4/src/reply_authority.rs b/crates/sel4/src/reply_authority.rs index cb34accd0..f67f2a982 100644 --- a/crates/sel4/src/reply_authority.rs +++ b/crates/sel4/src/reply_authority.rs @@ -12,7 +12,7 @@ use crate::sys; use crate::Reply; sel4_cfg_if! { - if #[cfg(KERNEL_MCS)] { + if #[sel4_cfg(KERNEL_MCS)] { pub type ReplyAuthority = Reply; impl ReplyAuthority { diff --git a/crates/sel4/src/syscalls.rs b/crates/sel4/src/syscalls.rs index 159f658e1..748c7a185 100644 --- a/crates/sel4/src/syscalls.rs +++ b/crates/sel4/src/syscalls.rs @@ -32,7 +32,7 @@ impl IpcCapType for cap_type::Endpoint {} impl IpcCapType for cap_type::Unspecified {} sel4_cfg_if! { - if #[cfg(KERNEL_MCS)] { + if #[sel4_cfg(KERNEL_MCS)] { pub type WaitMessageInfo = MessageInfo; fn wait_message_info_from_sys(info: sys::WaitMessageInfo) -> WaitMessageInfo { diff --git a/crates/sel4/sys/src/fault/arch/mod.rs b/crates/sel4/sys/src/fault/arch/mod.rs index 602de9d3e..1d4b5882d 100644 --- a/crates/sel4/sys/src/fault/arch/mod.rs +++ b/crates/sel4/sys/src/fault/arch/mod.rs @@ -7,16 +7,16 @@ use sel4_config::sel4_cfg_if; sel4_cfg_if! { - if #[cfg(ARCH_AARCH64)] { + if #[sel4_cfg(ARCH_AARCH64)] { #[path = "aarch64.rs"] mod imp; - } else if #[cfg(ARCH_AARCH32)] { + } else if #[sel4_cfg(ARCH_AARCH32)] { #[path = "aarch32.rs"] mod imp; - } else if #[cfg(any(ARCH_RISCV64, ARCH_RISCV32))] { + } else if #[sel4_cfg(any(ARCH_RISCV64, ARCH_RISCV32))] { #[path = "riscv.rs"] mod imp; - } else if #[cfg(ARCH_X86_64)] { + } else if #[sel4_cfg(ARCH_X86_64)] { #[path = "x86_64.rs"] mod imp; } diff --git a/crates/sel4/sys/src/lib.rs b/crates/sel4/sys/src/lib.rs index 1a2aabb76..3f1a316b4 100644 --- a/crates/sel4/sys/src/lib.rs +++ b/crates/sel4/sys/src/lib.rs @@ -25,7 +25,7 @@ pub use invocations::*; pub use syscalls::*; pub type ReplyAuthority = sel4_config::sel4_cfg_if! { - if #[cfg(KERNEL_MCS)] { + if #[sel4_cfg(KERNEL_MCS)] { seL4_CPtr } else { () @@ -33,7 +33,7 @@ pub type ReplyAuthority = sel4_config::sel4_cfg_if! { }; pub type WaitMessageInfo = sel4_config::sel4_cfg_if! { - if #[cfg(KERNEL_MCS)] { + if #[sel4_cfg(KERNEL_MCS)] { seL4_MessageInfo } else { () diff --git a/crates/sel4/sys/src/syscalls/calls.rs b/crates/sel4/sys/src/syscalls/calls.rs index 9d9f0ce48..6b4f0e828 100644 --- a/crates/sel4/sys/src/syscalls/calls.rs +++ b/crates/sel4/sys/src/syscalls/calls.rs @@ -23,7 +23,7 @@ const UNUSED_REPLY_ARG: seL4_Word = 0; fn reply_authority_to_sys_arg(#[allow(unused_variables)] authority: ReplyAuthority) -> seL4_Word { sel4_cfg_if! { - if #[cfg(KERNEL_MCS)] { + if #[sel4_cfg(KERNEL_MCS)] { authority } else { UNUSED_REPLY_ARG @@ -347,7 +347,7 @@ impl seL4_IPCBuffer { } sel4_cfg_if! { - if #[cfg(KERNEL_MCS)] { + if #[sel4_cfg(KERNEL_MCS)] { pub fn seL4_NBSendRecv( &mut self, dest: seL4_CPtr, @@ -474,7 +474,7 @@ impl seL4_IPCBuffer { pub fn seL4_Poll(&mut self, src: seL4_CPtr) -> (seL4_MessageInfo, seL4_Word) { sel4_cfg_if! { - if #[cfg(KERNEL_MCS)] { + if #[sel4_cfg(KERNEL_MCS)] { self.seL4_NBWait(src) } else { self.seL4_NBRecv(src, ()) @@ -630,7 +630,7 @@ pub fn seL4_Yield() { } sel4_cfg_if! { - if #[cfg(DEBUG_BUILD)] { + if #[sel4_cfg(DEBUG_BUILD)] { pub fn seL4_DebugPutChar(c: u8) { sys_send_recv_simple(syscall_id::DebugPutChar, c as seL4_Word); } @@ -674,7 +674,7 @@ sel4_cfg_if! { } sel4_cfg_if! { - if #[cfg(ENABLE_BENCHMARKS)] { + if #[sel4_cfg(ENABLE_BENCHMARKS)] { pub fn seL4_BenchmarkResetLog() -> seL4_Error::Type { sys_send_recv_simple( syscall_id::BenchmarkResetLog, @@ -697,7 +697,7 @@ sel4_cfg_if! { } sel4_cfg_if! { - if #[cfg(BENCHMARK_TRACK_UTILISATION)] { + if #[sel4_cfg(BENCHMARK_TRACK_UTILISATION)] { pub fn seL4_BenchmarkGetThreadUtilisation(tcb: seL4_CPtr) { sys_send_recv_simple( syscall_id::BenchmarkGetThreadUtilisation, @@ -713,7 +713,7 @@ sel4_cfg_if! { } sel4_cfg_if! { - if #[cfg(DEBUG_BUILD)] { + if #[sel4_cfg(DEBUG_BUILD)] { pub fn seL4_BenchmarkDumpAllThreadsUtilisation() { sys_send_recv_simple( syscall_id::BenchmarkDumpAllThreadsUtilisation, diff --git a/crates/sel4/sys/src/syscalls/helpers/arch/mod.rs b/crates/sel4/sys/src/syscalls/helpers/arch/mod.rs index 82000853f..404823ae1 100644 --- a/crates/sel4/sys/src/syscalls/helpers/arch/mod.rs +++ b/crates/sel4/sys/src/syscalls/helpers/arch/mod.rs @@ -11,16 +11,16 @@ use sel4_config::sel4_cfg_if; use crate::seL4_Word; sel4_cfg_if! { - if #[cfg(ARCH_AARCH64)] { + if #[sel4_cfg(ARCH_AARCH64)] { #[path = "aarch64.rs"] mod imp; - } else if #[cfg(ARCH_AARCH32)] { + } else if #[sel4_cfg(ARCH_AARCH32)] { #[path = "aarch32.rs"] mod imp; - } else if #[cfg(any(ARCH_RISCV64, ARCH_RISCV32))] { + } else if #[sel4_cfg(any(ARCH_RISCV64, ARCH_RISCV32))] { #[path = "riscv.rs"] mod imp; - } else if #[cfg(ARCH_X86_64)] { + } else if #[sel4_cfg(ARCH_X86_64)] { #[path = "x86_64.rs"] mod imp; }