Skip to content

Commit

Permalink
fix rust-analyzer warning
Browse files Browse the repository at this point in the history
  • Loading branch information
chyyuu committed Dec 31, 2022
1 parent 07c6cb3 commit e4e089f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// For Rust Analyzer plugin users:
"rust-analyzer.cargo.target": "riscv64gc-unknown-none-elf",
"rust-analyzer.checkOnSave.allTargets": false,
"rust-analyzer.cargo.features": [
"board_qemu"
]
// "rust-analyzer.cargo.features": [
// "board_qemu"
// ]
}
6 changes: 3 additions & 3 deletions easy-fs-fuse/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ clap = "2.33.3"
easy-fs = { path = "../easy-fs" }
rand = "0.8.0"

[features]
board_qemu = []
board_k210 = []
# [features]
# board_qemu = []
# board_k210 = []
6 changes: 3 additions & 3 deletions user/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ riscv = { git = "https://github.com/rcore-os/riscv", features = ["inline-asm"] }
[profile.release]
debug = true

[features]
board_qemu = []
board_k210 = []
# [features]
# board_qemu = []
# board_k210 = []
9 changes: 5 additions & 4 deletions user/src/bin/stackful_coroutine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
#![no_std]
#![no_main]
#![feature(naked_functions)]
#![feature(asm)]
//#![feature(asm)]

extern crate alloc;
#[macro_use]
extern crate user_lib;

use core::arch::asm;

#[macro_use]
//#[macro_use]
use alloc::vec;
use alloc::vec::Vec;

Expand Down Expand Up @@ -69,7 +69,7 @@ impl Task {
// we can allocate memory for it later, but it keeps complexity down and lets us focus on more interesting parts
// to do it here. The important part is that once allocated it MUST NOT move in memory.
Task {
id,
id:id,
stack: vec![0_u8; DEFAULT_STACK_SIZE],
ctx: TaskContext::default(),
state: State::Available,
Expand Down Expand Up @@ -185,6 +185,7 @@ impl Runtime {
.find(|t| t.state == State::Available)
.expect("no available task.");

println!("RUNTIME: spawning task {}\n", available.id);
let size = available.stack.len();
unsafe {
let s_ptr = available.stack.as_mut_ptr().offset(size as isize);
Expand Down Expand Up @@ -259,7 +260,7 @@ pub fn yield_task() {
/// see: https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html
#[naked]
#[no_mangle]
unsafe fn switch(old: *mut TaskContext, new: *const TaskContext) {
unsafe extern "C" fn switch(old: *mut TaskContext, new: *const TaskContext) {
// a0: _old, a1: _new
asm!(
"
Expand Down

0 comments on commit e4e089f

Please sign in to comment.