Merge branch 'as/serf-guard' into msl/guard

This commit is contained in:
Matthew LeVan 2024-02-19 13:11:19 -05:00
commit 6479459204
3 changed files with 8 additions and 10 deletions

View File

@ -7,7 +7,6 @@ use std::marker::PhantomData;
#[derive(Debug)]
pub enum GuardError {
InvalidSignal,
MemoryProtection,
NullPointer,
OutOfMemory,
@ -19,7 +18,6 @@ impl From<u32> for GuardError {
fn from(value: u32) -> Self {
match value {
GUARD_NULL => Self::NullPointer,
GUARD_SIGNAL => Self::InvalidSignal,
GUARD_OOM => Self::OutOfMemory,
x if (x & GUARD_MPROTECT) != 0 => Self::MemoryProtection,
x if (x & (GUARD_MALLOC | GUARD_SIGACTION)) != 0 => Self::Setup,
@ -91,7 +89,7 @@ pub fn call_with_guard<F: FnMut() -> Result>(
match err {
GuardError::OutOfMemory => Err(Error::NonDeterministic(Mote::Meme, D(0))),
_ => {
panic!("serf: guard: unexpected error {:?}", err);
panic!("serf: guard: unexpected error {:?} {}", err, res);
}
}
}

View File

@ -60,7 +60,6 @@ _focus_guard()
fprintf(stderr, "guard: focus: stack or alloc pointer is null\r\n");
return guard_null;
} else if (stack_p == alloc_p) {
fprintf(stderr, "guard: focus: stack and alloc pointers equal\r\n");
return guard_oom;
}

View File

@ -4,9 +4,10 @@
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
pub const GUARD_NULL: u32 = guard_result_guard_null;
pub const GUARD_SIGNAL: u32 = guard_result_guard_signal;
pub const GUARD_OOM: u32 = guard_result_guard_oom;
pub const GUARD_MALLOC: u32 = guard_result_guard_malloc;
pub const GUARD_MPROTECT: u32 = guard_result_guard_mprotect;
pub const GUARD_SIGACTION: u32 = guard_result_guard_sigaction;
pub const GUARD_SUCCESS: u32 = guard_result_guard_success;
pub const GUARD_NULL: u32 = guard_result_guard_null;
pub const GUARD_SIGNAL: u32 = guard_result_guard_signal;
pub const GUARD_OOM: u32 = guard_result_guard_oom;
pub const GUARD_MALLOC: u32 = guard_result_guard_malloc;
pub const GUARD_MPROTECT: u32 = guard_result_guard_mprotect;
pub const GUARD_SIGACTION: u32 = guard_result_guard_sigaction;