diff --git a/benches/context_new.rs b/benches/context_new.rs index 4eec654..6ac9f51 100644 --- a/benches/context_new.rs +++ b/benches/context_new.rs @@ -3,7 +3,7 @@ extern crate test; extern crate lwkt; use lwkt::{Context, StackSource}; -static mut ctx_slot: *mut Context = 0 as *mut Context; +static mut ctx_slot: *mut Context = 0 as *mut Context<_>; #[bench] fn context_new(b: &mut test::Bencher) { diff --git a/benches/swap.rs b/benches/swap.rs index b6eb363..7d3c4ea 100644 --- a/benches/swap.rs +++ b/benches/swap.rs @@ -3,7 +3,7 @@ extern crate test; extern crate lwkt; use lwkt::{Context, StackSource}; -static mut ctx_slot: *mut Context = 0 as *mut Context; +static mut ctx_slot: *mut Context = 0 as *mut Context<_>; #[bench] fn swap(b: &mut test::Bencher) { diff --git a/examples/basic.rs b/examples/basic.rs index a421f13..435cbdd 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -3,7 +3,7 @@ extern crate lwkt; use lwkt::{Context, StackSource}; #[thread_local] -static mut ctx_slot: *mut Context = 0 as *mut Context; +static mut ctx_slot: *mut Context = 0 as *mut Context<_>; fn main() { unsafe { diff --git a/src/context.rs b/src/context.rs index 8ffcb30..d322ba8 100644 --- a/src/context.rs +++ b/src/context.rs @@ -1,15 +1,16 @@ use core::prelude::*; use arch::Registers; -use os; +use stack; -pub struct Context { +pub struct Context { regs: Registers, - _stack: os::Stack + _stack: Stack } -impl Context { +impl Context where Stack: stack::Stack { #[inline] - pub unsafe fn new(mut stack: os::Stack, f: F) -> Context where F: FnOnce() + Send + 'static { + pub unsafe fn new(mut stack: Stack, f: F) -> Context + where F: FnOnce() + Send + 'static { let regs = Registers::new(&mut stack, f); Context { regs: regs,