Skip to content

Commit

Permalink
fix: mark extern blocks as unsafe
Browse files Browse the repository at this point in the history
  • Loading branch information
mkroening committed Jan 2, 2025
1 parent d01f93c commit 7e29caa
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/arch/aarch64/kernel/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use hermit_entry::Entry;
use crate::arch::aarch64::kernel::scheduler::TaskStacks;
use crate::{env, KERNEL_STACK_SIZE};

extern "C" {
unsafe extern "C" {
static vector_table: u8;
}

Expand Down
2 changes: 1 addition & 1 deletion src/arch/riscv64/kernel/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ impl TaskFrame for Task {
}
}

extern "C" {
unsafe extern "C" {
fn task_start(func: extern "C" fn(usize), arg: usize, user_stack: u64);
}

Expand Down
2 changes: 1 addition & 1 deletion src/arch/riscv64/kernel/switch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ use core::arch::global_asm;

global_asm!(include_str!("switch.s"));

extern "C" {
unsafe extern "C" {
pub fn switch_to_task(old_stack: *mut usize, new_stack: usize);
}
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ fn trivial_test() {
/// Entry point of a kernel thread, which initialize the libos
#[cfg(target_os = "none")]
extern "C" fn initd(_arg: usize) {
extern "C" {
unsafe extern "C" {
#[cfg(all(not(test), not(any(feature = "nostd", feature = "common-os"))))]
fn runtime_entry(argc: i32, argv: *const *const u8, env: *const *const u8) -> !;
#[cfg(all(not(test), any(feature = "nostd", feature = "common-os")))]
Expand Down Expand Up @@ -190,7 +190,7 @@ fn boot_processor_main() -> ! {
info!("FDT:\n{fdt:#?}");
}

extern "C" {
unsafe extern "C" {
static mut __bss_start: u8;
}
let bss_ptr = core::ptr::addr_of_mut!(__bss_start);
Expand Down
2 changes: 1 addition & 1 deletion tests/basic_mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ where
T: core::fmt::Debug,
T: num_traits::int::PrimInt,
{
extern "C" {
unsafe extern "C" {
fn memcpy(dest: *mut u8, src: *const u8, n: usize) -> *mut u8;
fn memcmp(s1: *const u8, s2: *const u8, n: usize) -> i32;
}
Expand Down

0 comments on commit 7e29caa

Please sign in to comment.