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-08-21 05:45:01 +08:00
|
|
|
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
|
|
|
|
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
|
|
|
|
// http://opensource.org/licenses/MIT>, at your option. This file may not be
|
|
|
|
// copied, modified, or distributed except according to those terms.
|
2016-01-04 22:32:03 +08:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|