yay, Rust beta…
This commit is contained in:
parent
fec3f2eaef
commit
0729ca8648
@ -90,13 +90,13 @@ pub unsafe fn set_sp_limit(limit: *const u8) {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn align_down_mut<T>(sp: *mut T, n: uint) -> *mut T {
|
||||
let sp = (sp as uint) & !(n - 1);
|
||||
fn align_down_mut<T>(sp: *mut T, n: usize) -> *mut T {
|
||||
let sp = (sp as usize) & !(n - 1);
|
||||
sp as *mut T
|
||||
}
|
||||
|
||||
// ptr::offset_mut is positive ints only
|
||||
#[inline]
|
||||
pub fn offset_mut<T>(ptr: *mut T, count: int) -> *mut T {
|
||||
(ptr as int + count * (size_of::<T>() as int)) as *mut T
|
||||
pub fn offset_mut<T>(ptr: *mut T, count: isize) -> *mut T {
|
||||
(ptr as isize + count * (size_of::<T>() as isize)) as *mut T
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#![feature(phase, asm)]
|
||||
#![feature(asm)]
|
||||
#![no_std]
|
||||
|
||||
#[macro_use]
|
||||
|
@ -7,9 +7,9 @@ use lwkt::Context;
|
||||
use fn_box::FnBox;
|
||||
|
||||
fn main() {
|
||||
let f = box move |:| {
|
||||
let f = Box::new(move |:| {
|
||||
println!("Hello, world!")
|
||||
};
|
||||
});
|
||||
|
||||
let mut native = unsafe { Context::native() };
|
||||
|
||||
@ -24,7 +24,7 @@ fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
let mut ctx = box { (&mut native as *mut Context, null_mut()) };
|
||||
let mut ctx = Box::new((&mut native as *mut Context, null_mut()));
|
||||
let mut green = Context::new(init, &mut *ctx as *mut _, f);
|
||||
ctx.1 = &mut green as *mut Context;
|
||||
|
||||
|
@ -22,20 +22,20 @@ const STACK_FLAGS: libc::c_int = libc::MAP_STACK
|
||||
| libc::MAP_ANON;
|
||||
|
||||
impl Stack {
|
||||
pub fn new(size: uint) -> Stack {
|
||||
pub fn new(size: usize) -> Stack {
|
||||
let buf = match MemoryMap::new(size, &[MapReadable, MapWritable,
|
||||
MapNonStandardFlags(STACK_FLAGS)]) {
|
||||
Ok(map) => map,
|
||||
Err(e) => panic!("mmap for stack of size {} failed: {}", size, e)
|
||||
Err(e) => panic!("mmap for stack of size {} failed: {:?}", size, e)
|
||||
};
|
||||
|
||||
if !protect_last_page(&buf) {
|
||||
panic!("Could not memory-protect guard page. stack={}, errno={}",
|
||||
panic!("Could not memory-protect guard page. stack={:p}, errno={}",
|
||||
buf.data(), errno());
|
||||
}
|
||||
|
||||
let valgrind_id = unsafe {
|
||||
stack_register(buf.data().offset(buf.len() as int) as *const _,
|
||||
stack_register(buf.data().offset(buf.len() as isize) as *const _,
|
||||
buf.data() as *const _)
|
||||
};
|
||||
|
||||
@ -65,13 +65,13 @@ impl Drop for Stack {
|
||||
impl Stack {
|
||||
pub fn top(&mut self) -> *mut u8 {
|
||||
unsafe {
|
||||
self.buf.data().offset(self.buf.len() as int)
|
||||
self.buf.data().offset(self.buf.len() as isize)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn limit(&self) -> *const u8 {
|
||||
unsafe {
|
||||
self.buf.data().offset(page_size() as int) as *const _
|
||||
self.buf.data().offset(page_size() as isize) as *const _
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ pub enum Stack {
|
||||
}
|
||||
|
||||
impl Stack {
|
||||
pub fn new(size: uint) -> Stack {
|
||||
pub fn new(size: usize) -> Stack {
|
||||
Stack::Managed(platform::Stack::new(size))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user