ableos_userland/libraries/std/src/entry.rs

36 lines
866 B
Rust
Raw Normal View History

2023-03-30 05:21:18 -05:00
use crate::exit::{exit, GenericError};
2023-03-09 06:36:35 -06:00
#[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
2023-03-30 02:35:02 -05:00
let ret = main(0, core::ptr::null());
2023-03-09 06:36:35 -06:00
2023-03-30 02:35:02 -05:00
// 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
2023-03-30 05:21:18 -05:00
Some(GenericError {
2023-03-30 02:35:02 -05:00
error_id: 123456789,
2023-03-30 05:21:18 -05:00
// location: None,
// a_lil_message_as_a_treat: "Unknown Cause",
2023-03-30 02:35:02 -05:00
})
}
_ => panic!("Program returned an invalid isize"),
};
exit(err_obj);
2023-03-09 06:36:35 -06:00
}
#[lang = "start"]
fn lang_start<T>(main: fn() -> T, _: isize, _: *const *const u8, _: u8) -> isize {
main();
0
}