diff --git a/src/detail/x86_64_unix.rs b/src/detail/x86_64_unix.rs index 9182e2f..47b5060 100644 --- a/src/detail/x86_64_unix.rs +++ b/src/detail/x86_64_unix.rs @@ -16,7 +16,7 @@ mod asm_impl { /// prefetch data #[inline] pub unsafe extern "C" fn prefetch(data: *const usize) { - asm!( + llvm_asm!( "prefetcht1 $0" : // no output : "m"(*data) @@ -28,7 +28,7 @@ mod asm_impl { #[naked] #[inline(never)] pub unsafe extern "C" fn bootstrap_green_task() { - asm!( + llvm_asm!( " mov %r12, %rdi // setup the function arg mov %r13, %rsi // setup the function arg @@ -46,7 +46,7 @@ mod asm_impl { #[inline(never)] pub unsafe extern "C" fn swap_registers(out_regs: *mut Registers, in_regs: *const Registers) { // The first argument is in %rdi, and the second one is in %rsi - asm!( + llvm_asm!( "" : : "{rdi}"(out_regs), "{rsi}"(in_regs) @@ -58,7 +58,7 @@ mod asm_impl { #[naked] unsafe extern "C" fn _swap_reg() { // Save registers - asm!( + llvm_asm!( " mov %rbx, (0*8)(%rdi) mov %rsp, (1*8)(%rdi) diff --git a/src/detail/x86_64_windows.rs b/src/detail/x86_64_windows.rs index 96d49fe..1a27855 100644 --- a/src/detail/x86_64_windows.rs +++ b/src/detail/x86_64_windows.rs @@ -22,7 +22,7 @@ mod asm_impl { /// prefetch data #[inline] pub unsafe extern "C" fn prefetch_asm(data: *const usize) { - asm!( + llvm_asm!( "prefetcht1 $0" : // no output : "m"(*data) @@ -34,7 +34,7 @@ mod asm_impl { #[naked] #[inline(never)] pub unsafe extern "C" fn bootstrap_green_task() { - asm!( + llvm_asm!( " mov %r12, %rcx // setup the function arg mov %r13, %rdx // setup the function arg @@ -52,7 +52,7 @@ mod asm_impl { #[inline(never)] pub unsafe extern "C" fn swap_registers(out_regs: *mut Registers, in_regs: *const Registers) { // The first argument is in %rcx, and the second one is in %rdx - asm!( + llvm_asm!( "" : : "{rcx}"(out_regs), "{rdx}"(in_regs) @@ -64,7 +64,7 @@ mod asm_impl { #[naked] unsafe extern "C" fn _swap_reg() { // Save registers - asm!( + llvm_asm!( " mov %rbx, (0*8)(%rcx) mov %rsp, (1*8)(%rcx) diff --git a/src/gen_impl.rs b/src/gen_impl.rs index 952a440..332f584 100644 --- a/src/gen_impl.rs +++ b/src/gen_impl.rs @@ -115,8 +115,11 @@ impl<'a, A, T> Generator<'a, A, T> { self.gen.send(para) } - /// cancel the generator - /// this will trigger a Cancel panic, it's unsafe in that you must care about the resource + /// cancel the generator [TODO: change to safe?] + /// this will trigger a Cancel panic + /// # Safety + /// it's unsafe that cancel may have side effect when unwind stack + /// all the resources would be dropped before the normal completion pub unsafe fn cancel(&mut self) { self.gen.cancel() } diff --git a/src/lib.rs b/src/lib.rs index 6d3afde..475f835 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,7 @@ //! Rust generator library //! -#![cfg_attr(nightly, feature(asm))] +#![cfg_attr(nightly, feature(llvm_asm))] #![cfg_attr(nightly, feature(repr_simd))] #![cfg_attr(nightly, feature(core_intrinsics))] #![cfg_attr(nightly, feature(naked_functions))] diff --git a/src/rt.rs b/src/rt.rs index 4132ffd..887d228 100644 --- a/src/rt.rs +++ b/src/rt.rs @@ -24,6 +24,7 @@ thread_local!( // to a different place, be careful about that. #[cfg(nightly)] #[thread_local] +#[no_mangle] static mut ROOT_CONTEXT_P: *mut Context = ptr::null_mut(); /// yield panic error types diff --git a/tests/lib.rs b/tests/lib.rs index bd0bff8..38a5f58 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -1,4 +1,5 @@ #![allow(deprecated)] +#![allow(unused_assignments)] extern crate generator;