This commit is contained in:
2026-02-25 14:08:27 +01:00
parent 8a8034bd11
commit 4dc05c4151
23 changed files with 554 additions and 66 deletions

View File

@@ -1,12 +1,34 @@
#![no_std]
mod prelude;
extern crate alloc;
pub mod prelude;
pub use shared::syscall;
#[macro_export]
macro_rules! custom_std_setup {
() => {
use $crate::prelude::*;
extern crate alloc;
struct GlobalAllocator;
#[global_allocator]
static GLOBAL_ALLOCATOR: GlobalAllocator = GlobalAllocator;
unsafe impl core::alloc::GlobalAlloc for GlobalAllocator {
unsafe fn alloc(&self, layout: core::alloc::Layout) -> *mut u8 {
syscall::write_string_temp("Alloc user called");
$crate::syscall::alloc(layout)
}
unsafe fn dealloc(&self, ptr: *mut u8, layout: core::alloc::Layout) {
$crate::syscall::dealloc(ptr, layout)
}
}
#[panic_handler]
fn panic(_panic_info: &core::panic::PanicInfo) -> ! {
// TODO print
@@ -19,3 +41,21 @@ macro_rules! custom_std_setup {
}
};
}
#[macro_export]
macro_rules! print {
($($args:expr),*) => {
$crate::syscall::write_string_temp(&format!($($args),*))
};
}
#[macro_export]
macro_rules! println {
() => {
// $crate::print!("");
$crate::print!("\n\r");
};
($($args:expr),*) => {
$crate::print!($($args),*);
$crate::println!();
};
}

View File

@@ -1 +1,5 @@
pub use crate::print;
pub use crate::println;
pub use alloc::format;
pub use alloc::string::String;
pub use alloc::vec;