Remove the linkage feature usage for `ostd::main`

This commit is contained in:
Zhang Junyang 2024-10-04 23:16:19 +08:00 committed by Tate, Hongliang Tian
parent 131a25c15c
commit a716763772
6 changed files with 5 additions and 14 deletions

View File

@ -15,7 +15,6 @@
#![feature(format_args_nl)]
#![feature(int_roundings)]
#![feature(let_chains)]
#![feature(linkage)]
#![feature(linked_list_remove)]
#![feature(negative_impls)]
#![feature(register_tool)]

View File

@ -1,6 +1,4 @@
#![no_std]
// The feature `linkage` is required for `ostd::main` to work.
#![feature(linkage)]
#![deny(unsafe_code)]
use ostd::prelude::*;

View File

@ -1,7 +1,6 @@
// SPDX-License-Identifier: MPL-2.0
#![no_std]
#![feature(linkage)]
#![deny(unsafe_code)]
use ostd::prelude::*;

View File

@ -1,8 +1,7 @@
// SPDX-License-Identifier: MPL-2.0
#![no_std]
// The feature `linkage` is required for `ostd::main` to work.
#![feature(linkage)]
#![deny(unsafe_code)]
extern crate alloc;

View File

@ -13,7 +13,6 @@ use syn::{parse_macro_input, Expr, Ident, ItemFn};
///
/// ```ignore
/// #![no_std]
/// #![feature(linkage)]
///
/// use ostd::prelude::*;
///
@ -28,13 +27,14 @@ pub fn main(_attr: TokenStream, item: TokenStream) -> TokenStream {
let main_fn_name = &main_fn.sig.ident;
quote!(
#[cfg(not(ktest))]
#[no_mangle]
#[linkage = "weak"]
extern "Rust" fn __ostd_main() -> ! {
#main_fn_name();
ostd::prelude::abort();
}
#[allow(unused)]
#main_fn
)
.into()
@ -44,10 +44,6 @@ pub fn main(_attr: TokenStream, item: TokenStream) -> TokenStream {
///
/// This macro is used for internal OSDK implementation. Do not use it
/// directly.
///
/// It is a strong version of the `main` macro attribute. So if it exists (
/// which means the unit test kernel is linked to perform testing), the actual
/// kernel entry point will be replaced by this one.
#[proc_macro_attribute]
pub fn test_main(_attr: TokenStream, item: TokenStream) -> TokenStream {
let main_fn = parse_macro_input!(item as ItemFn);
@ -82,7 +78,7 @@ pub fn panic_handler(_attr: TokenStream, item: TokenStream) -> TokenStream {
#handler_fn_name(info);
}
#[cfg(not(ktest))]
#[allow(unused)]
#handler_fn
)
.into()

View File

@ -25,7 +25,7 @@ use unwinding::abi::{
///
/// The user can override it by defining their own panic handler with the macro
/// `#[ostd::panic_handler]`.
#[cfg(not(ktest))]
#[linkage = "weak"]
#[no_mangle]
pub fn __ostd_panic_handler(info: &core::panic::PanicInfo) -> ! {
let _irq_guard = crate::trap::disable_local();