diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 37093c294d..bb73df0cf8 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "nightly-2021-10-20" +channel = "nightly-2021-11-01" components = [ "rust-src", "llvm-tools-preview", diff --git a/src/arch/mod.rs b/src/arch/mod.rs index d9c5496b98..8d6d741739 100644 --- a/src/arch/mod.rs +++ b/src/arch/mod.rs @@ -44,7 +44,11 @@ pub use crate::arch::x86_64::*; #[cfg(target_arch = "x86_64")] pub use crate::arch::x86_64::kernel::apic::{set_oneshot_timer, wakeup_core}; -#[cfg(all(target_arch = "x86_64", target_os = "hermit", feature = "smp"))] +#[cfg(all( + target_arch = "x86_64", + any(target_os = "none", target_os = "hermit"), + feature = "smp" +))] pub use crate::arch::x86_64::kernel::application_processor_init; #[cfg(target_arch = "x86_64")] pub use crate::arch::x86_64::kernel::gdt::set_current_kernel_stack; @@ -60,7 +64,7 @@ pub use crate::arch::x86_64::kernel::scheduler; pub use crate::arch::x86_64::kernel::switch; #[cfg(target_arch = "x86_64")] pub use crate::arch::x86_64::kernel::systemtime::get_boot_time; -#[cfg(all(target_arch = "x86_64", target_os = "hermit"))] +#[cfg(all(target_arch = "x86_64", any(target_os = "none", target_os = "hermit")))] pub use crate::arch::x86_64::kernel::{boot_application_processors, boot_processor_init}; #[cfg(target_arch = "x86_64")] pub use crate::arch::x86_64::kernel::{ diff --git a/src/arch/x86_64/kernel/apic.rs b/src/arch/x86_64/kernel/apic.rs index 688e87ad50..8b222ecec6 100644 --- a/src/arch/x86_64/kernel/apic.rs +++ b/src/arch/x86_64/kernel/apic.rs @@ -2,7 +2,7 @@ use crate::arch; #[cfg(feature = "acpi")] use crate::arch::x86_64::kernel::acpi; use crate::arch::x86_64::kernel::irq::IrqStatistics; -#[cfg(all(target_os = "hermit", feature = "smp"))] +#[cfg(all(any(target_os = "none", target_os = "hermit"), feature = "smp"))] use crate::arch::x86_64::kernel::smp_boot_code::SMP_BOOT_CODE; use crate::arch::x86_64::kernel::IRQ_COUNTERS; use crate::arch::x86_64::mm::paging::{BasePageSize, PageSize, PageTableEntryFlags}; @@ -568,7 +568,7 @@ extern "C" { /// This algorithm is derived from Intel MultiProcessor Specification 1.4, B.4, but testing has shown /// that a second STARTUP IPI and setting the BIOS Reset Vector are no longer necessary. /// This is partly confirmed by https://wiki.osdev.org/Symmetric_Multiprocessing -#[cfg(all(target_os = "hermit", feature = "smp"))] +#[cfg(all(any(target_os = "none", target_os = "hermit"), feature = "smp"))] pub fn boot_application_processors() { // We shouldn't have any problems fitting the boot code into a single page, but let's better be sure. assert!( diff --git a/src/arch/x86_64/kernel/irq.rs b/src/arch/x86_64/kernel/irq.rs index 6d9e0ec3ac..b8e96d03bc 100644 --- a/src/arch/x86_64/kernel/irq.rs +++ b/src/arch/x86_64/kernel/irq.rs @@ -90,7 +90,7 @@ pub fn disable() { /// were not activated before calling this function. #[inline] pub fn nested_disable() -> bool { - cfg!(target_os = "hermit") && { + cfg!(any(target_os = "none", target_os = "hermit")) && { let ret = rflags::read().contains(RFlags::FLAGS_IF); disable(); ret diff --git a/src/arch/x86_64/kernel/mod.rs b/src/arch/x86_64/kernel/mod.rs index cc57b123b6..7f95415aa0 100644 --- a/src/arch/x86_64/kernel/mod.rs +++ b/src/arch/x86_64/kernel/mod.rs @@ -119,14 +119,14 @@ impl BootInfo { } /// Kernel header to announce machine features -#[cfg(not(target_os = "hermit"))] +#[cfg(not(any(target_os = "none", target_os = "hermit")))] static mut BOOT_INFO: *mut BootInfo = ptr::null_mut(); -#[cfg(all(target_os = "hermit", not(feature = "newlib")))] +#[cfg(all(any(target_os = "none", target_os = "hermit"), not(feature = "newlib")))] #[link_section = ".data"] static mut BOOT_INFO: *mut BootInfo = ptr::null_mut(); -#[cfg(all(target_os = "hermit", feature = "newlib"))] +#[cfg(all(any(target_os = "none", target_os = "hermit"), feature = "newlib"))] #[link_section = ".mboot"] static mut BOOT_INFO: *mut BootInfo = ptr::null_mut(); @@ -298,7 +298,10 @@ pub fn message_output_init() { } } -#[cfg(all(not(target_os = "hermit"), not(target_os = "windows")))] +#[cfg(all( + not(any(target_os = "none", target_os = "hermit")), + not(target_os = "windows") +))] pub fn output_message_byte(byte: u8) { extern "C" { fn write(fd: i32, buf: *const u8, count: usize) -> isize; @@ -320,7 +323,7 @@ pub fn output_message_byte(byte: u8) { } } -#[cfg(not(target_os = "hermit"))] +#[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn test_output() { output_message_byte('t' as u8); @@ -330,7 +333,7 @@ fn test_output() { output_message_byte('\n' as u8); } -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] pub fn output_message_byte(byte: u8) { if environment::is_single_kernel() { // Output messages to the serial port and VGA screen in unikernel mode. @@ -348,7 +351,7 @@ pub fn output_message_byte(byte: u8) { } } -//#[cfg(target_os = "hermit")] +//#[cfg(any(target_os = "none", target_os = "hermit"))] pub fn output_message_buf(buf: &[u8]) { for byte in buf { output_message_byte(*byte); @@ -356,7 +359,7 @@ pub fn output_message_buf(buf: &[u8]) { } /// Real Boot Processor initialization as soon as we have put the first Welcome message on the screen. -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] pub fn boot_processor_init() { processor::detect_features(); processor::configure(); @@ -403,7 +406,7 @@ pub fn boot_processor_init() { /// Boots all available Application Processors on bare-metal or QEMU. /// Called after the Boot Processor has been fully initialized along with its scheduler. -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] pub fn boot_application_processors() { #[cfg(feature = "smp")] apic::boot_application_processors(); @@ -411,7 +414,7 @@ pub fn boot_application_processors() { } /// Application Processor initialization -#[cfg(all(target_os = "hermit", feature = "smp"))] +#[cfg(all(any(target_os = "none", target_os = "hermit"), feature = "smp"))] pub fn application_processor_init() { percore::init(); processor::configure(); @@ -466,7 +469,7 @@ pub fn print_statistics() { } } -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] #[inline(never)] #[no_mangle] unsafe fn pre_init(boot_info: &'static mut BootInfo) -> ! { diff --git a/src/arch/x86_64/kernel/percore.rs b/src/arch/x86_64/kernel/percore.rs index aa3324faad..7bee11e01e 100644 --- a/src/arch/x86_64/kernel/percore.rs +++ b/src/arch/x86_64/kernel/percore.rs @@ -137,13 +137,13 @@ impl PerCoreVariableMethods for PerCoreVariable { } } -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] #[inline] pub fn core_id() -> CoreId { unsafe { PERCORE.core_id.get() } } -#[cfg(not(target_os = "hermit"))] +#[cfg(not(any(target_os = "none", target_os = "hermit")))] pub fn core_id() -> CoreId { 0 } diff --git a/src/arch/x86_64/kernel/processor.rs b/src/arch/x86_64/kernel/processor.rs index 13bc22e4bd..936d0d4a07 100644 --- a/src/arch/x86_64/kernel/processor.rs +++ b/src/arch/x86_64/kernel/processor.rs @@ -337,14 +337,14 @@ impl CpuFrequency { pic::eoi(pit::PIT_INTERRUPT_NUMBER); } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] fn measure_frequency(&mut self) -> Result<(), ()> { // return just Ok because the real implementation must run in ring 0 self.source = CpuFrequencySources::Measurement; Ok(()) } - #[cfg(target_os = "hermit")] + #[cfg(any(target_os = "none", target_os = "hermit"))] fn measure_frequency(&mut self) -> Result<(), ()> { // The PIC is not initialized for uhyve, so we cannot measure anything. if environment::is_uhyve() { @@ -865,7 +865,7 @@ pub fn print_information() { infofooter!(); } -/*#[cfg(not(target_os = "hermit"))] +/*#[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn print_cpu_information() { ::logging::init(); diff --git a/src/arch/x86_64/kernel/scheduler.rs b/src/arch/x86_64/kernel/scheduler.rs index 2aabfe14d8..bfcfa8bda4 100644 --- a/src/arch/x86_64/kernel/scheduler.rs +++ b/src/arch/x86_64/kernel/scheduler.rs @@ -305,12 +305,12 @@ impl Clone for TaskTLS { } } -#[cfg(not(target_os = "hermit"))] +#[cfg(not(any(target_os = "none", target_os = "hermit")))] extern "C" fn task_start(_f: extern "C" fn(usize), _arg: usize, _user_stack: u64) -> ! { unimplemented!() } -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] #[naked] extern "C" fn task_start(_f: extern "C" fn(usize), _arg: usize, _user_stack: u64) -> ! { // `f` is in the `rdi` register diff --git a/src/console.rs b/src/console.rs index 0682612aa4..d9155c703c 100644 --- a/src/console.rs +++ b/src/console.rs @@ -31,7 +31,7 @@ impl Console { pub static CONSOLE: SpinlockIrqSave = SpinlockIrqSave::new(Console(())); -#[cfg(not(target_os = "hermit"))] +#[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn test_console() { println!("HelloWorld"); diff --git a/src/lib.rs b/src/lib.rs index 897f28dc48..ae5f6d6e6f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -30,13 +30,19 @@ #![feature(llvm_asm)] #![feature(global_asm)] #![no_std] -#![cfg_attr(target_os = "hermit", feature(custom_test_frameworks))] -#![cfg_attr(target_os = "hermit", cfg_attr(test, test_runner(crate::test_runner)))] #![cfg_attr( - target_os = "hermit", + any(target_os = "none", target_os = "hermit"), + feature(custom_test_frameworks) +)] +#![cfg_attr( + any(target_os = "none", target_os = "hermit"), + cfg_attr(test, test_runner(crate::test_runner)) +)] +#![cfg_attr( + any(target_os = "none", target_os = "hermit"), cfg_attr(test, reexport_test_harness_main = "test_main") )] -#![cfg_attr(target_os = "hermit", cfg_attr(test, no_main))] +#![cfg_attr(any(target_os = "none", target_os = "hermit"), cfg_attr(test, no_main))] // EXTERNAL CRATES #[macro_use] @@ -47,7 +53,7 @@ extern crate bitflags; extern crate log; #[macro_use] extern crate num_derive; -#[cfg(not(target_os = "hermit"))] +#[cfg(not(any(target_os = "none", target_os = "hermit")))] #[macro_use] extern crate std; #[cfg(target_arch = "aarch64")] @@ -88,7 +94,7 @@ mod errno; mod ffi; mod kernel_message_buffer; mod mm; -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] mod runtime_glue; mod scheduler; mod synch; @@ -102,7 +108,7 @@ pub fn _print(args: ::core::fmt::Arguments<'_>) { } #[cfg(test)] -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] #[no_mangle] extern "C" fn runtime_entry(_argc: i32, _argv: *const *const u8, _env: *const *const u8) -> ! { println!("Executing hermit unittests. Any arguments are dropped"); @@ -120,14 +126,14 @@ pub fn test_runner(tests: &[&dyn Fn()]) { sys_exit(0); } -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] #[test_case] fn trivial_test() { println!("Test test test"); panic!("Test called"); } -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] #[global_allocator] static ALLOCATOR: LockedHeap = LockedHeap::empty(); @@ -137,7 +143,7 @@ static ALLOCATOR: LockedHeap = LockedHeap::empty(); /// Returning a null pointer indicates that either memory is exhausted or /// `size` and `align` do not meet this allocator's size or alignment constraints. /// -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] pub extern "C" fn __sys_malloc(size: usize, align: usize) -> *mut u8 { let layout_res = Layout::from_size_align(size, align); if layout_res.is_err() || size == 0 { @@ -179,7 +185,7 @@ pub extern "C" fn __sys_malloc(size: usize, align: usize) -> *mut u8 { /// # Errors /// Returns null if the new layout does not meet the size and alignment constraints of the /// allocator, or if reallocation otherwise fails. -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] pub extern "C" fn __sys_realloc( ptr: *mut u8, size: usize, @@ -224,7 +230,7 @@ pub extern "C" fn __sys_realloc( /// /// # Errors /// May panic if debug assertions are enabled and invalid parameters `size` or `align` where passed. -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] pub extern "C" fn __sys_free(ptr: *mut u8, size: usize, align: usize) { unsafe { let layout_res = Layout::from_size_align(size, align); @@ -247,7 +253,7 @@ pub extern "C" fn __sys_free(ptr: *mut u8, size: usize, align: usize) { } } -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] extern "C" { static mut __bss_start: usize; } @@ -259,7 +265,7 @@ fn has_ipdevice() -> bool { } /// Entry point of a kernel thread, which initialize the libos -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] extern "C" fn initd(_arg: usize) { extern "C" { #[cfg(not(test))] @@ -319,7 +325,7 @@ fn synch_all_cores() { } /// Entry Point of HermitCore for the Boot Processor -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] fn boot_processor_main() -> ! { // Initialize the kernel and hardware. arch::message_output_init(); @@ -372,7 +378,7 @@ fn boot_processor_main() -> ! { } /// Entry Point of HermitCore for an Application Processor -#[cfg(all(target_os = "hermit", feature = "smp"))] +#[cfg(all(any(target_os = "none", target_os = "hermit"), feature = "smp"))] fn application_processor_main() -> ! { arch::application_processor_init(); scheduler::add_current_core(); diff --git a/src/mm/allocator.rs b/src/mm/allocator.rs index 6a31d99e27..ce2c14e2a7 100644 --- a/src/mm/allocator.rs +++ b/src/mm/allocator.rs @@ -31,9 +31,9 @@ pub struct Heap { index: usize, bottom: usize, size: usize, - #[cfg(target_os = "hermit")] + #[cfg(any(target_os = "none", target_os = "hermit"))] holes: HoleList, - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] pub holes: HoleList, } diff --git a/src/mm/freelist.rs b/src/mm/freelist.rs index 5dd5b2576e..7db3bd02fc 100644 --- a/src/mm/freelist.rs +++ b/src/mm/freelist.rs @@ -190,7 +190,7 @@ impl FreeList { } } -#[cfg(not(target_os = "hermit"))] +#[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn add_element() { let mut freelist = FreeList::new(); @@ -208,7 +208,7 @@ fn add_element() { } } -#[cfg(not(target_os = "hermit"))] +#[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn allocate() { let mut freelist = FreeList::new(); @@ -241,7 +241,7 @@ fn allocate() { } } -#[cfg(not(target_os = "hermit"))] +#[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn deallocate() { let mut freelist = FreeList::new(); diff --git a/src/mm/hole.rs b/src/mm/hole.rs index 86a9337221..c1fa95c422 100644 --- a/src/mm/hole.rs +++ b/src/mm/hole.rs @@ -80,7 +80,7 @@ impl HoleList { } /// Returns information about the first hole for test purposes. - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[cfg(test)] pub fn first_hole(&self) -> Option<(usize, usize)> { self.first @@ -91,13 +91,13 @@ impl HoleList { } /// A block containing free memory. It points to the next hole and thus forms a linked list. -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] pub struct Hole { size: usize, next: Option<&'static mut Hole>, } -#[cfg(not(target_os = "hermit"))] +#[cfg(not(any(target_os = "none", target_os = "hermit")))] pub struct Hole { pub size: usize, pub next: Option<&'static mut Hole>, diff --git a/src/mm/mod.rs b/src/mm/mod.rs index 97a04f9627..4299bec47e 100644 --- a/src/mm/mod.rs +++ b/src/mm/mod.rs @@ -71,7 +71,7 @@ fn map_heap(virt_addr: VirtAddr, size: usize) -> usize { i } -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] pub fn init() { // Calculate the start and end addresses of the 2 MiB page(s) that map the kernel. unsafe { diff --git a/src/mm/test.rs b/src/mm/test.rs index a17d6ab2fb..dda0e90562 100644 --- a/src/mm/test.rs +++ b/src/mm/test.rs @@ -5,7 +5,7 @@ // To avoid false sharing, our version allocate as smallest block 64 byte (= cache line). // In addition, for pre -#[cfg(not(target_os = "hermit"))] +#[cfg(not(any(target_os = "none", target_os = "hermit")))] #[cfg(test)] mod tests { use super::*; @@ -42,7 +42,7 @@ mod tests { heap } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn empty() { let mut heap = Heap::empty(); @@ -55,7 +55,7 @@ mod tests { assert!(addr.is_err()); } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn oom() { let mut heap = new_heap(); @@ -64,7 +64,7 @@ mod tests { assert!(addr.is_err()); } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn allocate_double_usize() { let mut heap = new_heap(); @@ -86,7 +86,7 @@ mod tests { } } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn allocate_and_free_double_usize() { let mut heap = new_heap(); @@ -102,7 +102,7 @@ mod tests { } } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn deallocate_right_before() { let mut heap = new_heap(); @@ -129,7 +129,7 @@ mod tests { } } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn deallocate_right_behind() { let mut heap = new_heap(); @@ -151,7 +151,7 @@ mod tests { } } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn deallocate_middle() { let mut heap = new_heap(); @@ -178,7 +178,7 @@ mod tests { } } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn reallocate_double_usize() { let mut heap = new_heap(); @@ -198,7 +198,7 @@ mod tests { assert_eq!(x, y); } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn allocate_usize() { let mut heap = new_heap(); @@ -208,7 +208,7 @@ mod tests { assert!(heap.allocate_first_fit(layout.clone()).is_ok()); } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn allocate_usize_in_bigger_block() { let mut heap = new_heap(); @@ -233,7 +233,7 @@ mod tests { } } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] // see https://github.com/phil-opp/blog_os/issues/160 fn align_from_small_to_big() { @@ -248,7 +248,7 @@ mod tests { assert!(heap.allocate_first_fit(layout_2.clone()).is_ok()); } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn extend_empty_heap() { let mut heap = new_max_heap(); @@ -262,7 +262,7 @@ mod tests { assert!(heap.allocate_first_fit(layout.clone()).is_ok()); } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn extend_full_heap() { let mut heap = new_max_heap(); @@ -277,7 +277,7 @@ mod tests { assert!(heap.allocate_first_fit(layout.clone()).is_ok()); } - #[cfg(not(target_os = "hermit"))] + #[cfg(not(any(target_os = "none", target_os = "hermit")))] #[test] fn extend_fragmented_heap() { let mut heap = new_max_heap(); diff --git a/src/runtime_glue.rs b/src/runtime_glue.rs index 8a9e65271d..c81cbcd2f3 100644 --- a/src/runtime_glue.rs +++ b/src/runtime_glue.rs @@ -7,7 +7,7 @@ use alloc::alloc::Layout; use core::panic::PanicInfo; // see https://users.rust-lang.org/t/psa-breaking-change-panic-fmt-language-item-removed-in-favor-of-panic-implementation/17875 -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] #[panic_handler] fn panic(info: &PanicInfo<'_>) -> ! { print!("[{}][!!!PANIC!!!] ", arch::percore::core_id()); @@ -44,6 +44,7 @@ fn rust_oom(layout: Layout) -> ! { } } +#[cfg(target_os = "hermit")] #[no_mangle] pub unsafe extern "C" fn __rg_oom(size: usize, align: usize) -> ! { let layout = Layout::from_size_align_unchecked(size, align); diff --git a/src/syscalls/interfaces/uhyve.rs b/src/syscalls/interfaces/uhyve.rs index a13bcc74d9..bad7c4df05 100644 --- a/src/syscalls/interfaces/uhyve.rs +++ b/src/syscalls/interfaces/uhyve.rs @@ -207,7 +207,7 @@ impl SyscallInterface for Uhyve { /// /// ToDo: Add Safety section under which circumctances this is safe/unsafe to use /// ToDo: Add an Errors section - What happens when e.g. malloc fails, how is that handled (currently it isn't) - #[cfg(target_os = "hermit")] + #[cfg(any(target_os = "none", target_os = "hermit"))] fn get_application_parameters(&self) -> (i32, *const *const u8, *const *const u8) { // determine the number of arguments and environment variables let mut syscmdsize = SysCmdsize::new(); diff --git a/src/syscalls/mod.rs b/src/syscalls/mod.rs index 2ba403ce44..b61ee7f251 100644 --- a/src/syscalls/mod.rs +++ b/src/syscalls/mod.rs @@ -6,7 +6,7 @@ use crate::environment; #[cfg(feature = "newlib")] use crate::synch::spinlock::SpinlockIrqSave; use crate::syscalls::interfaces::SyscallInterface; -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] use crate::{__sys_free, __sys_malloc, __sys_realloc}; pub use self::condvar::*; @@ -60,19 +60,19 @@ pub fn init() { sbrk_init(); } -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] #[no_mangle] pub extern "C" fn sys_malloc(size: usize, align: usize) -> *mut u8 { __sys_malloc(size, align) } -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] #[no_mangle] pub extern "C" fn sys_realloc(ptr: *mut u8, size: usize, align: usize, new_size: usize) -> *mut u8 { __sys_realloc(ptr, size, align, new_size) } -#[cfg(target_os = "hermit")] +#[cfg(any(target_os = "none", target_os = "hermit"))] #[no_mangle] pub extern "C" fn sys_free(ptr: *mut u8, size: usize, align: usize) { __sys_free(ptr, size, align)