libfringe/src/debug/mod.rs

29 lines
612 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.
2015-04-16 18:08:44 +08:00
// Copyright (c) 2015, edef <edef@edef.eu>
// See the LICENSE file included in this distribution.
use core::prelude::*;
use stack;
mod valgrind;
#[derive(Debug)]
pub struct StackId(valgrind::stack_id_t);
impl StackId {
#[inline(always)]
pub fn register<Stack: stack::Stack>(stack: &mut Stack) -> StackId {
StackId(unsafe {
valgrind::stack_register(stack.limit(), stack.top())
})
}
}
impl Drop for StackId {
#[inline(always)]
fn drop(&mut self) {
unsafe {
valgrind::stack_deregister(self.0)
}
}
}