Skip to content

Commit

Permalink
Update for latest nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
Amanieu committed May 29, 2018
1 parent 121eade commit a63c120
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 22 deletions.
6 changes: 3 additions & 3 deletions src/arch/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ pub unsafe fn swap_link(arg: usize, new_sp: StackPointer,
: "={x0}" (ret)
"={x1}" (ret_sp)
: "{x0}" (arg)
"{x2}" (*new_sp.0)
"{x2}" (new_sp.offset(0))
"{x3}" (new_stack_base)
:/*"x0", "x1",*/"x2", "x3", "x4", "x5", "x6", "x7",
"x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15",
Expand Down Expand Up @@ -260,7 +260,7 @@ pub unsafe fn swap(arg: usize, new_sp: StackPointer) -> (usize, StackPointer) {
: "={x0}" (ret)
"={x1}" (ret_sp)
: "{x0}" (arg)
"{x2}" (*new_sp.0)
"{x2}" (new_sp.offset(0))
:/*"x0", "x1",*/"x2", "x3", "x4", "x5", "x6", "x7",
"x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15",
"x16", "x17", "x18", "x19", "x20", "x21", "x22", "x23",
Expand Down Expand Up @@ -299,7 +299,7 @@ pub unsafe fn unwind(new_sp: StackPointer, new_stack_base: *mut u8) {
:
: "s" (unwind::start_unwind as usize)
"{x0}" (arg)
"{x2}" (*new_sp.0)
"{x2}" (new_sp.offset(0))
"{x3}" (new_stack_base)
: "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7",
"x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15",
Expand Down
6 changes: 3 additions & 3 deletions src/arch/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ pub unsafe fn swap_link(arg: usize, new_sp: StackPointer,
: "={r0}" (ret)
"={r1}" (ret_sp)
: "{r0}" (arg)
"{r2}" (*new_sp.0)
"{r2}" (new_sp.offset(0))
"{r3}" (new_stack_base)
:/*r0, r1,*/ "r2", "r3", "r4", "r5", "r6", "r7",
"r8", "r9", "r10",/*r11,*/"r12",/*sp,*/ "lr", /*pc,*/
Expand Down Expand Up @@ -239,7 +239,7 @@ pub unsafe fn swap(arg: usize, new_sp: StackPointer) -> (usize, StackPointer) {
: "={r0}" (ret)
"={r1}" (ret_sp)
: "{r0}" (arg)
"{r2}" (*new_sp.0)
"{r2}" (new_sp.offset(0))
:/*r0, r1,*/ "r2", "r3", "r4", "r5", "r6", "r7",
"r8", "r9", "r10",/*r11,*/"r12",/*sp,*/ "lr", /*pc,*/
"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
Expand Down Expand Up @@ -279,7 +279,7 @@ pub unsafe fn unwind(new_sp: StackPointer, new_stack_base: *mut u8) {
:
: "s" (unwind::start_unwind as usize)
"{r0}" (arg)
"{r2}" (*new_sp.0)
"{r2}" (new_sp.offset(0))
"{r3}" (new_stack_base)
: "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
"r8", "r9", "r10",/*r11,*/"r12",/*sp,*/ "lr", /*pc,*/
Expand Down
12 changes: 6 additions & 6 deletions src/arch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// copied, modified, or distributed except according to those terms.

pub use self::imp::*;
use core::nonzero::NonZero;
use core::ptr::NonNull;

#[allow(unused_attributes)] // rust-lang/rust#35584
#[cfg_attr(target_arch = "x86", path = "x86.rs")]
Expand All @@ -18,23 +18,23 @@ use core::nonzero::NonZero;
mod imp;

#[derive(Debug, Clone, Copy)]
pub struct StackPointer(NonZero<*mut usize>);
pub struct StackPointer(NonNull<usize>);

impl StackPointer {
#[inline(always)]
pub unsafe fn push(&mut self, val: usize) {
self.0 = NonZero::new(self.0.offset(-1));
**self.0 = val;
self.0 = NonNull::new_unchecked(self.0.as_ptr().offset(-1));
*self.0.as_mut() = val;
}

#[inline(always)]
pub unsafe fn new(sp: *mut u8) -> StackPointer {
StackPointer(NonZero::new(sp as *mut usize))
StackPointer(NonNull::new_unchecked(sp as *mut usize))
}

#[inline(always)]
pub unsafe fn offset(&self, count: isize) -> *mut usize {
self.0.offset(count)
self.0.as_ptr().offset(count)
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/arch/or1k.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ pub unsafe fn swap_link(arg: usize, new_sp: StackPointer,
"={r4}" (ret_sp)
: "s" (trampoline as usize)
"{r3}" (arg)
"{r5}" (*new_sp.0)
"{r5}" (new_sp.offset(0))
"{r6}" (new_stack_base)
:/*"r0", "r1", "r2", "r3", "r4",*/"r5", "r6", "r7",
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
Expand Down Expand Up @@ -255,7 +255,7 @@ pub unsafe fn swap(arg: usize, new_sp: StackPointer) -> (usize, StackPointer) {
"={r4}" (ret_sp)
: "s" (trampoline as usize)
"{r3}" (arg)
"{r5}" (*new_sp.0)
"{r5}" (new_sp.offset(0))
:/*"r0", "r1", "r2", "r3", "r4",*/"r5", "r6", "r7",
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
"r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
Expand Down Expand Up @@ -306,7 +306,7 @@ pub unsafe fn unwind(new_sp: StackPointer, new_stack_base: *mut u8) {
:
: "s" (trampoline as usize)
"{r3}" (arg)
"{r5}" (*new_sp.0)
"{r5}" (new_sp.offset(0))
"{r6}" (new_stack_base)
:/*"r0", "r1", "r2",*/"r3", "r4", "r5", "r6", "r7",
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
Expand Down
6 changes: 3 additions & 3 deletions src/arch/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ pub unsafe fn swap_link(arg: usize, new_sp: StackPointer,
"={esi}" (ret_sp)
: "s" (trampoline as usize)
"{edi}" (arg)
"{edx}" (*new_sp.0)
"{edx}" (new_sp.offset(0))
"{ecx}" (new_stack_base)
: "eax", "ebx", "ecx", "edx",/*"esi", "edi", "ebp", "esp",*/
"mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7",
Expand Down Expand Up @@ -299,7 +299,7 @@ pub unsafe fn swap(arg: usize, new_sp: StackPointer) -> (usize, StackPointer) {
"={esi}" (ret_sp)
: "s" (trampoline as usize)
"{edi}" (arg)
"{edx}" (*new_sp.0)
"{edx}" (new_sp.offset(0))
: "eax", "ebx", "ecx", "edx",/*"esi", "edi", "ebp", "esp",*/
"mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7",
"xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7",
Expand Down Expand Up @@ -348,7 +348,7 @@ pub unsafe fn unwind(new_sp: StackPointer, new_stack_base: *mut u8) {
:
: "s" (trampoline as usize)
"{edi}" (arg)
"{edx}" (*new_sp.0)
"{edx}" (new_sp.offset(0))
"{ecx}" (new_stack_base)
: "eax", "ebx", "ecx", "edx", "esi", "edi",/*"ebp", "esp",*/
"mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7",
Expand Down
6 changes: 3 additions & 3 deletions src/arch/x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ pub unsafe fn swap_link(arg: usize, new_sp: StackPointer,
: "={rdi}" (ret)
"={rsi}" (ret_sp)
: "{rdi}" (arg)
"{rdx}" (*new_sp.0)
"{rdx}" (new_sp.offset(0))
"{rcx}" (new_stack_base)
: "rax", "rbx", "rcx", "rdx", /*"rsi", "rdi", "rbp", "rsp",*/
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
Expand Down Expand Up @@ -269,7 +269,7 @@ pub unsafe fn swap(arg: usize, new_sp: StackPointer) -> (usize, StackPointer) {
: "={rdi}" (ret)
"={rsi}" (ret_sp)
: "{rdi}" (arg)
"{rdx}" (*new_sp.0)
"{rdx}" (new_sp.offset(0))
: "rax", "rbx", "rcx", "rdx", /*"rsi", "rdi", "rbp", "rsp",*/
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
"mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7",
Expand Down Expand Up @@ -307,7 +307,7 @@ pub unsafe fn unwind(new_sp: StackPointer, new_stack_base: *mut u8) {
:
: "s" (unwind::start_unwind as usize)
"{rdi}" (arg)
"{rdx}" (*new_sp.0)
"{rdx}" (new_sp.offset(0))
"{rcx}" (new_stack_base)
: "rax", "rbx", "rcx", "rdx", "rsi", "rdi", /*"rbp", "rsp",*/
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.

#![feature(asm, naked_functions, cfg_target_vendor, nonzero, untagged_unions)]
#![feature(asm, naked_functions, cfg_target_vendor, untagged_unions, unwind_attributes)]
#![cfg_attr(feature = "alloc", feature(alloc, heap_api, allocator_api))]
#![cfg_attr(test, feature(test))]
#![no_std]
Expand Down
2 changes: 2 additions & 0 deletions src/unwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ fn have_cross_stack_unwind() -> bool {
}

// Wrapper around the root function of a generator which handles unwinding.
#[unwind(allowed)]
pub unsafe extern "C" fn unwind_wrapper(arg: usize, sp: StackPointer, stack_base: *mut u8,
f: unsafe fn(usize, StackPointer)) -> Option<Box<Box<Any + Send>>> {
// Catch any attempts to unwind out of the context.
Expand Down Expand Up @@ -63,6 +64,7 @@ pub unsafe extern "C" fn unwind_wrapper(arg: usize, sp: StackPointer, stack_base

// Called by asm to start unwinding in the current context with the given
// exception object.
#[unwind(allowed)]
pub unsafe extern "C" fn start_unwind(panic: Box<Box<Any + Send>>) -> ! {
// Use resume_unwind instead of panic! to avoid printing a message.
panic::resume_unwind(*panic)
Expand Down

0 comments on commit a63c120

Please sign in to comment.