Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cortex-m-semihosting/src/hio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ pub fn hstdout() -> Result<HostStream, ()> {
open(":tt\0", nr::open::W_TRUNC)
}

fn open(name: &str, mode: usize) -> Result<HostStream, ()> {
/// Open a file on the host. The filename must be zero-terminated.
pub fn open(name: &str, mode: usize) -> Result<HostStream, ()> {
debug_assert_eq!(name.bytes().last(), Some(0), "the filename must be zero-terminated");

let name = name.as_bytes();
match unsafe { syscall!(OPEN, name.as_ptr(), mode, name.len() - 1) } as isize {
-1 => Err(()),
Expand Down