Skip to content

Commit

Permalink
Fixing safety declarations in the userspace module
Browse files Browse the repository at this point in the history
  • Loading branch information
jzbor committed Jun 13, 2024
1 parent be9b1c0 commit 14d53e8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/userspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ use std::process::exit;
use std::slice;

/// Write error message to stderr
///
/// # Safety
/// This function should only be called by the library, which should ensure that the `buffer`
/// contains exactly `nbytes` bytes.
#[no_mangle]
pub unsafe extern "C" fn zan_write(buffer: *const u8, nbytes: usize) {
let buf = slice::from_raw_parts(buffer, nbytes);
Expand All @@ -14,10 +18,10 @@ pub unsafe extern "C" fn zan_write(buffer: *const u8, nbytes: usize) {

/// Abort the program by exiting with error code
#[no_mangle]
pub unsafe extern "C" fn zan_abort() {
pub extern "C" fn zan_abort() {
exit(1);
}

/// Right now this does nothing, but it would be great to disable UNIX signals for example
#[no_mangle]
pub unsafe fn zan_disable_interrupts() {}
pub fn zan_disable_interrupts() {}

0 comments on commit 14d53e8

Please sign in to comment.