libfringe/src/stack.rs

23 lines
845 B
Rust
Raw Normal View History

2015-04-16 20:06:57 +08:00
// This file is part of libfringe, a low-level green threading library.
// Copyright (c) edef <edef@edef.eu>
2015-04-16 18:08:44 +08:00
// See the LICENSE file included in this distribution.
2015-04-16 11:37:17 +08:00
//! Traits for stacks.
/// A trait for objects that hold ownership of a stack.
pub trait Stack {
/// Returns the base of the stack.
2015-04-16 11:37:17 +08:00
/// On all modern architectures, the stack grows downwards,
/// so this is the highest address.
fn base(&self) -> *mut u8;
2015-04-16 11:37:17 +08:00
/// Returns the bottom of the stack.
/// On all modern architectures, the stack grows downwards,
/// so this is the lowest address.
fn limit(&self) -> *mut u8;
2014-12-23 11:24:40 +08:00
}
/// A marker trait for `Stack` objects with a guard page.
///
/// A guarded stack must guarantee that any access of data at addresses `limit()` to
/// `limit().offset(4096)` will abnormally terminate the program.
pub unsafe trait GuardedStack {}