yay, Rust beta…

This commit is contained in:
edef 2015-01-13 08:38:52 +01:00
parent fec3f2eaef
commit 0729ca8648
5 changed files with 15 additions and 15 deletions

View File

@ -90,13 +90,13 @@ pub unsafe fn set_sp_limit(limit: *const u8) {
} }
#[inline] #[inline]
fn align_down_mut<T>(sp: *mut T, n: uint) -> *mut T { fn align_down_mut<T>(sp: *mut T, n: usize) -> *mut T {
let sp = (sp as uint) & !(n - 1); let sp = (sp as usize) & !(n - 1);
sp as *mut T sp as *mut T
} }
// ptr::offset_mut is positive ints only // ptr::offset_mut is positive ints only
#[inline] #[inline]
pub fn offset_mut<T>(ptr: *mut T, count: int) -> *mut T { pub fn offset_mut<T>(ptr: *mut T, count: isize) -> *mut T {
(ptr as int + count * (size_of::<T>() as int)) as *mut T (ptr as isize + count * (size_of::<T>() as isize)) as *mut T
} }

View File

@ -1,4 +1,4 @@
#![feature(phase, asm)] #![feature(asm)]
#![no_std] #![no_std]
#[macro_use] #[macro_use]

View File

@ -7,9 +7,9 @@ use lwkt::Context;
use fn_box::FnBox; use fn_box::FnBox;
fn main() { fn main() {
let f = box move |:| { let f = Box::new(move |:| {
println!("Hello, world!") println!("Hello, world!")
}; });
let mut native = unsafe { Context::native() }; 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); let mut green = Context::new(init, &mut *ctx as *mut _, f);
ctx.1 = &mut green as *mut Context; ctx.1 = &mut green as *mut Context;

View File

@ -22,20 +22,20 @@ const STACK_FLAGS: libc::c_int = libc::MAP_STACK
| libc::MAP_ANON; | libc::MAP_ANON;
impl Stack { impl Stack {
pub fn new(size: uint) -> Stack { pub fn new(size: usize) -> Stack {
let buf = match MemoryMap::new(size, &[MapReadable, MapWritable, let buf = match MemoryMap::new(size, &[MapReadable, MapWritable,
MapNonStandardFlags(STACK_FLAGS)]) { MapNonStandardFlags(STACK_FLAGS)]) {
Ok(map) => map, 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) { 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()); buf.data(), errno());
} }
let valgrind_id = unsafe { 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 _) buf.data() as *const _)
}; };
@ -65,13 +65,13 @@ impl Drop for Stack {
impl Stack { impl Stack {
pub fn top(&mut self) -> *mut u8 { pub fn top(&mut self) -> *mut u8 {
unsafe { 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 { pub fn limit(&self) -> *const u8 {
unsafe { unsafe {
self.buf.data().offset(page_size() as int) as *const _ self.buf.data().offset(page_size() as isize) as *const _
} }
} }
} }

View File

@ -9,7 +9,7 @@ pub enum Stack {
} }
impl Stack { impl Stack {
pub fn new(size: uint) -> Stack { pub fn new(size: usize) -> Stack {
Stack::Managed(platform::Stack::new(size)) Stack::Managed(platform::Stack::new(size))
} }