diff --git a/crates/private/support/sel4-simple-task/runtime/src/lib.rs b/crates/private/support/sel4-simple-task/runtime/src/lib.rs index 4c7a6b051..e893590c0 100644 --- a/crates/private/support/sel4-simple-task/runtime/src/lib.rs +++ b/crates/private/support/sel4-simple-task/runtime/src/lib.rs @@ -12,7 +12,6 @@ #[cfg(feature = "alloc")] extern crate alloc; -use core::ffi::c_char; use core::ptr; use core::slice; @@ -122,11 +121,7 @@ fn abort_hook(info: Option<&AbortInfo>) { sel4_panicking_env::register_abort_hook!(abort_hook); -fn debug_put_char(c: u8) { - sel4::debug_put_char(c as c_char) -} - -sel4_panicking_env::register_debug_put_char!(debug_put_char); +sel4_panicking_env::register_debug_put_char!(sel4::debug_put_char); fn panic_hook(info: &ExternalPanicInfo<'_>) { debug_println!("{}", info); diff --git a/crates/sel4-microkit/src/panicking.rs b/crates/sel4-microkit/src/panicking.rs index 24efb1d9e..5b9156ac0 100644 --- a/crates/sel4-microkit/src/panicking.rs +++ b/crates/sel4-microkit/src/panicking.rs @@ -43,7 +43,7 @@ pub(crate) fn init_panicking() { fn debug_put_char(c: u8) { sel4::sel4_cfg_if! { if #[cfg(PRINTING)] { - sel4::debug_put_char(c as core::ffi::c_char) + sel4::debug_put_char(c) } } } diff --git a/crates/sel4-newlib/src/lib.rs b/crates/sel4-newlib/src/lib.rs index 4e85e0681..c2502dc03 100644 --- a/crates/sel4-newlib/src/lib.rs +++ b/crates/sel4-newlib/src/lib.rs @@ -53,8 +53,8 @@ mod impl_write { 1 | 2 => { let bytes = unsafe { slice::from_raw_parts(ptr.cast::(), len.try_into().unwrap()) }; - for b in bytes { - debug_put_char(*b); + for &b in bytes { + debug_put_char(b); } len } diff --git a/crates/sel4-root-task/src/lib.rs b/crates/sel4-root-task/src/lib.rs index db3d80b68..622fade34 100644 --- a/crates/sel4-root-task/src/lib.rs +++ b/crates/sel4-root-task/src/lib.rs @@ -8,7 +8,6 @@ #![feature(cfg_target_thread_local)] #![feature(never_type)] -use core::ffi::c_char; use core::fmt; pub use sel4_panicking_env::{abort, debug_print, debug_println}; @@ -83,11 +82,7 @@ where } } -fn debug_put_char(c: u8) { - sel4::debug_put_char(c as c_char) -} - -sel4_panicking_env::register_debug_put_char!(debug_put_char); +sel4_panicking_env::register_debug_put_char!(sel4::debug_put_char); #[macro_export] macro_rules! declare_root_task { diff --git a/crates/sel4/src/debug.rs b/crates/sel4/src/debug.rs index ba8eb5070..b846ad597 100644 --- a/crates/sel4/src/debug.rs +++ b/crates/sel4/src/debug.rs @@ -5,12 +5,10 @@ // SPDX-License-Identifier: MIT // -use core::ffi::c_char; - use crate::{sys, InvocationContext, CapType, TCB, LocalCPtr}; /// Corresponds to `seL4_DebugPutChar`. -pub fn debug_put_char(c: c_char) { +pub fn debug_put_char(c: u8) { sys::seL4_DebugPutChar(c) } diff --git a/crates/sel4/src/fmt.rs b/crates/sel4/src/fmt.rs index 98d47ed0d..a4ca4e708 100644 --- a/crates/sel4/src/fmt.rs +++ b/crates/sel4/src/fmt.rs @@ -5,7 +5,6 @@ // SPDX-License-Identifier: MIT // -use core::ffi::c_char; use core::fmt; use crate::debug_put_char; @@ -21,7 +20,7 @@ pub struct DebugWrite; impl fmt::Write for DebugWrite { fn write_str(&mut self, s: &str) -> fmt::Result { for &c in s.as_bytes() { - debug_put_char(c as c_char) + debug_put_char(c) } Ok(()) } diff --git a/crates/sel4/sys/src/syscalls/calls.rs b/crates/sel4/sys/src/syscalls/calls.rs index c19aa4a38..728bf4206 100644 --- a/crates/sel4/sys/src/syscalls/calls.rs +++ b/crates/sel4/sys/src/syscalls/calls.rs @@ -4,7 +4,7 @@ // SPDX-License-Identifier: BSD-2-Clause // -use core::ffi::{c_char, c_int}; +use core::ffi::c_int; use core::sync::atomic::{compiler_fence, Ordering}; use sel4_config::{sel4_cfg, sel4_cfg_if}; @@ -631,7 +631,7 @@ pub fn seL4_Yield() { sel4_cfg_if! { if #[cfg(DEBUG_BUILD)] { - pub fn seL4_DebugPutChar(c: c_char) { + pub fn seL4_DebugPutChar(c: u8) { sys_send_recv_simple(syscall_id::DebugPutChar, c as seL4_Word); } diff --git a/crates/sel4/sys/src/wrappers/syscalls.rs b/crates/sel4/sys/src/wrappers/syscalls.rs index f1565fcc8..cf450463f 100644 --- a/crates/sel4/sys/src/wrappers/syscalls.rs +++ b/crates/sel4/sys/src/wrappers/syscalls.rs @@ -385,9 +385,11 @@ pub unsafe extern "C" fn seL4_Poll(src: seL4_CPtr, sender: *mut seL4_Word) -> se sel4_cfg_if! { if #[cfg(DEBUG_BUILD)] { + // Doesn't actually matter, but libsel4 uses char, which may be signed. Use c_char here and + // cast to u8 for the sake of principles. #[no_mangle] pub unsafe extern "C" fn seL4_DebugPutChar(c: c_char) { - crate::seL4_DebugPutChar(c) + crate::seL4_DebugPutChar(c as u8) } #[no_mangle] diff --git a/crates/sel4/sys/wrappers/src/panic_handler.rs b/crates/sel4/sys/wrappers/src/panic_handler.rs index 1bc0ba3fc..ec9a04d70 100644 --- a/crates/sel4/sys/wrappers/src/panic_handler.rs +++ b/crates/sel4/sys/wrappers/src/panic_handler.rs @@ -4,7 +4,6 @@ // SPDX-License-Identifier: BSD-2-Clause // -use core::ffi::c_char; use core::fmt::{self, Write}; use core::panic::PanicInfo; @@ -21,7 +20,7 @@ struct Debug; impl Write for Debug { fn write_str(&mut self, s: &str) -> fmt::Result { for &c in s.as_bytes() { - seL4_DebugPutChar(c as c_char) + seL4_DebugPutChar(c) } Ok(()) }