Skip to content

Commit

Permalink
auto merge of rust-lang#6667 : crabtw/rust/arm-rt, r=brson
Browse files Browse the repository at this point in the history
This fixes segmentation fault of new rt tests.
For example
```
use core::rt::test::*;
use core::rt::comm::*;
use core::cell::Cell;

fn main() {
    do run_in_newsched_task {
        let (port, chan) = oneshot::<~int>();
        let port_cell = Cell(port);
        do spawntask_immediately {
            assert!(port_cell.take().recv() == ~10);
        }
        chan.send(~10);
    }
}
```
  • Loading branch information
bors committed May 22, 2013
2 parents 15e4438 + 499b022 commit 8a4bffc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/libcore/rt/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ fn new_regs() -> ~Registers { ~([0, .. 32]) }

#[cfg(target_arch = "arm")]
fn initialize_call_frame(regs: &mut Registers, fptr: *c_void, arg: *c_void, sp: *mut uint) {
let sp = mut_offset(sp, -1);
let sp = align_down(sp);
// sp of arm eabi is 8-byte aligned
let sp = mut_offset(sp, -2);

// The final return address. 0 indicates the bottom of the stack
unsafe { *sp = 0; }
Expand Down
6 changes: 4 additions & 2 deletions src/rt/arch/arm/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ void context::call(void *f, void *arg, void *stack)

// set up the stack
uint32_t *sp = ( uint32_t *)stack;
//sp = align_down(sp);
sp = align_down(sp);
// The final return address. 0 indicates the bottom of the stack
*--sp = 0;
// sp of arm eabi is 8-byte aligned
sp -= 2;
*sp = 0;

regs.data[0] = ( uint32_t )arg; // r0
regs.data[13] = ( uint32_t )sp; //#52 sp, r13
Expand Down

0 comments on commit 8a4bffc

Please sign in to comment.