Bump Rust version to nightly-2025-02-18(2024 Edition)

This commit is contained in:
Yifan Wu 2025-02-19 21:27:17 +08:00
parent 123595601d
commit 5b846fce6a
44 changed files with 118 additions and 105 deletions

View file

@ -5,9 +5,9 @@
extern crate user_lib;
extern crate alloc;
use user_lib::{close, open, read, OpenFlags};
use user_lib::{OpenFlags, close, open, read};
#[no_mangle]
#[unsafe(no_mangle)]
pub fn main() -> i32 {
let fd = open("filea\0", OpenFlags::RDONLY);
if fd == -1 {

View file

@ -7,7 +7,7 @@ use user_lib::{exit, fork, wait, waitpid, yield_};
const MAGIC: i32 = -0x10384;
#[no_mangle]
#[unsafe(no_mangle)]
pub fn main() -> i32 {
println!("I am the parent. Forking the child...");
let pid = fork();

View file

@ -5,12 +5,12 @@
extern crate user_lib;
macro_rules! color_text {
($text:expr, $color:expr) => {{
($text:expr, $color:expr) => {
format_args!("\x1b[{}m{}\x1b[0m", $color, $text)
}};
};
}
#[no_mangle]
#[unsafe(no_mangle)]
pub fn main() -> i32 {
println!(
"{}{}{}{}{} {}{}{}{} {}{}{}{}{}{}",

View file

@ -4,9 +4,9 @@
#[macro_use]
extern crate user_lib;
use user_lib::{close, open, read, write, OpenFlags};
use user_lib::{OpenFlags, close, open, read, write};
#[no_mangle]
#[unsafe(no_mangle)]
pub fn main() -> i32 {
let test_str = "Hello, world!";
let filea = "filea\0";

View file

@ -8,7 +8,7 @@ use user_lib::{exit, fork, wait};
const MAX_CHILD: usize = 30;
#[no_mangle]
#[unsafe(no_mangle)]
pub fn main() -> i32 {
for i in 0..MAX_CHILD {
let pid = fork();

View file

@ -8,7 +8,7 @@ use user_lib::{exit, fork, get_time, getpid, sleep, wait};
static NUM: usize = 30;
#[no_mangle]
#[unsafe(no_mangle)]
pub fn main() -> i32 {
for _ in 0..NUM {
let pid = fork();

View file

@ -6,7 +6,7 @@ extern crate user_lib;
use user_lib::{fork, getpid, wait};
#[no_mangle]
#[unsafe(no_mangle)]
pub fn main() -> i32 {
assert_eq!(wait(&mut 0i32), -1);
println!("sys_wait without child process test passed!");

View file

@ -29,7 +29,7 @@ fn fork_tree(cur: &str) {
fork_child(cur, '1');
}
#[no_mangle]
#[unsafe(no_mangle)]
pub fn main() -> i32 {
fork_tree("");
sleep(3000);

View file

@ -4,7 +4,7 @@
#[macro_use]
extern crate user_lib;
#[no_mangle]
#[unsafe(no_mangle)]
pub fn main() -> i32 {
println!("Hello world from user mode program!");
0

View file

@ -4,9 +4,9 @@
#[macro_use]
extern crate user_lib;
use user_lib::{close, get_time, open, write, OpenFlags};
use user_lib::{OpenFlags, close, get_time, open, write};
#[no_mangle]
#[unsafe(no_mangle)]
pub fn main() -> i32 {
let mut buffer = [0u8; 1024]; // 1KiB
for (i, ch) in buffer.iter_mut().enumerate() {

View file

@ -6,7 +6,7 @@ extern crate user_lib;
use user_lib::{exec, fork, wait, yield_};
#[no_mangle]
#[unsafe(no_mangle)]
fn main() -> i32 {
if fork() == 0 {
exec("user_shell\0");

View file

@ -44,7 +44,7 @@ fn work(times: isize) {
exit(0);
}
#[no_mangle]
#[unsafe(no_mangle)]
pub fn main() -> i32 {
for _ in 0..NUM {
let pid = fork();

View file

@ -15,7 +15,7 @@ fn sleepy() {
exit(0);
}
#[no_mangle]
#[unsafe(no_mangle)]
pub fn main() -> i32 {
let current_time = get_time();
let pid = fork();

View file

@ -6,7 +6,7 @@ extern crate user_lib;
use user_lib::{get_time, sleep};
#[no_mangle]
#[unsafe(no_mangle)]
pub fn main() -> i32 {
println!("into sleep test!");
let start = get_time();

View file

@ -12,7 +12,7 @@ fn f(depth: usize) {
f(depth + 1);
}
#[no_mangle]
#[unsafe(no_mangle)]
pub fn main() -> i32 {
println!("It should trigger segmentation fault!");
f(0);

View file

@ -16,7 +16,7 @@ use alloc::string::String;
use user_lib::console::getchar;
use user_lib::{exec, fork, waitpid};
#[no_mangle]
#[unsafe(no_mangle)]
pub fn main() -> i32 {
println!("Rust user shell");
let mut line: String = String::new();

View file

@ -84,7 +84,7 @@ fn run_tests(tests: &[(&str, &str, &str, &str, i32)]) -> i32 {
pass_num
}
#[no_mangle]
#[unsafe(no_mangle)]
pub fn main() -> i32 {
let succ_num = run_tests(SUCC_TESTS);
let err_num = run_tests(FAIL_TESTS);

View file

@ -20,7 +20,7 @@ static TESTS: &[&str] = &[
use user_lib::{exec, fork, waitpid};
#[no_mangle]
#[unsafe(no_mangle)]
pub fn main() -> i32 {
for test in TESTS {
println!("Usertests: Running {}", test);

View file

@ -5,7 +5,7 @@
extern crate user_lib;
use user_lib::{getpid, yield_};
#[no_mangle]
#[unsafe(no_mangle)]
pub fn main() -> i32 {
println!("Hello, I am process {}.", getpid());
for i in 0..5 {

View file

@ -2,7 +2,7 @@ use super::exit;
#[panic_handler]
fn panic_handler(panic_info: &core::panic::PanicInfo) -> ! {
let err = panic_info.message().unwrap();
let err = panic_info.message();
if let Some(location) = panic_info.location() {
println!(
"Panicked at {}:{}, {}",

View file

@ -1,6 +1,5 @@
#![no_std]
#![feature(linkage)]
#![feature(panic_info_message)]
#![feature(alloc_error_handler)]
#[macro_use]
@ -13,6 +12,7 @@ extern crate alloc;
extern crate bitflags;
use buddy_system_allocator::LockedHeap;
use core::ptr::addr_of_mut;
use syscall::*;
const USER_HEAP_SIZE: usize = 32768;
@ -27,18 +27,18 @@ pub fn handle_alloc_error(layout: core::alloc::Layout) -> ! {
panic!("Heap allocation error, layout = {:?}", layout);
}
#[no_mangle]
#[link_section = ".text.entry"]
#[unsafe(no_mangle)]
#[unsafe(link_section = ".text.entry")]
pub extern "C" fn _start() -> ! {
unsafe {
HEAP.lock()
.init(HEAP_SPACE.as_ptr() as usize, USER_HEAP_SIZE);
.init(addr_of_mut!(HEAP_SPACE) as usize, USER_HEAP_SIZE);
}
exit(main());
}
#[linkage = "weak"]
#[no_mangle]
#[unsafe(no_mangle)]
fn main() -> i32 {
panic!("Cannot find main!");
}