ableos_userland/libraries/std/src/entry.rs
2023-03-30 05:21:18 -05:00

36 lines
866 B
Rust

use crate::exit::{exit, GenericError};
#[no_mangle]
unsafe extern "C" fn _start() -> ! {
extern "C" {
fn main(argc: isize, argv: *const *const u8) -> isize;
}
// TODO: grab and pass arguments to main
let ret = main(0, core::ptr::null());
// TODO: implement exiting properly and provide a public exit function
let err_obj = match ret {
0 => None,
1 => {
// TODO: Get errorID location and error message
Some(GenericError {
error_id: 123456789,
// location: None,
// a_lil_message_as_a_treat: "Unknown Cause",
})
}
_ => panic!("Program returned an invalid isize"),
};
exit(err_obj);
}
#[lang = "start"]
fn lang_start<T>(main: fn() -> T, _: isize, _: *const *const u8, _: u8) -> isize {
main();
0
}