2016-01-04 22:32:03 +08:00
|
|
|
// This file is part of libfringe, a low-level green threading library.
|
2016-03-22 15:25:23 +08:00
|
|
|
// Copyright (c) edef <edef@edef.eu>
|
2016-01-04 22:32:03 +08:00
|
|
|
// See the LICENSE file included in this distribution.
|
|
|
|
extern crate valgrind;
|
|
|
|
|
|
|
|
use stack;
|
|
|
|
use self::valgrind::{stack_register, stack_deregister};
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct StackId(self::valgrind::Value);
|
|
|
|
|
|
|
|
impl StackId {
|
|
|
|
#[inline(always)]
|
2016-07-16 09:22:41 +08:00
|
|
|
pub fn register<Stack: stack::Stack>(stack: &Stack) -> StackId {
|
2016-08-12 07:18:36 +08:00
|
|
|
StackId(stack_register(stack.limit(), stack.base()))
|
2016-01-04 22:32:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Drop for StackId {
|
|
|
|
#[inline(always)]
|
|
|
|
fn drop(&mut self) {
|
|
|
|
stack_deregister(self.0)
|
|
|
|
}
|
|
|
|
}
|