Skip to content

Commit

Permalink
fix mips stack alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
crabtw committed May 21, 2013
1 parent 6c0a469 commit d86a32b
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
Expand Up @@ -183,7 +183,9 @@ fn new_regs() -> ~Registers { ~([0, .. 32]) }

#[cfg(target_arch = "mips")]
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 mips o32 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/mips/context.cpp
Expand Up @@ -34,9 +34,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 mips o32 is 8-byte aligned
sp -= 2;
*sp = 0;

regs.data[4] = (uint32_t)arg;
regs.data[29] = (uint32_t)sp;
Expand Down

5 comments on commit d86a32b

@bors
Copy link
Contributor

@bors bors commented on d86a32b May 21, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from sanxiyn
at crabtw@d86a32b

@bors
Copy link
Contributor

@bors bors commented on d86a32b May 21, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging crabtw/rust/mips-rt = d86a32b into auto

@bors
Copy link
Contributor

@bors bors commented on d86a32b May 21, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crabtw/rust/mips-rt = d86a32b merged ok, testing candidate = dc7b83d

@bors
Copy link
Contributor

@bors bors commented on d86a32b May 21, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on d86a32b May 21, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding incoming to auto = dc7b83d

Please sign in to comment.