Skip to content

Commit

Permalink
📝 fix latest nightly build issue (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xudong-Huang committed Jun 10, 2020
1 parent a414fbe commit d4cd3ee
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/detail/x86_64_unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/detail/x86_64_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions src/gen_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))]
Expand Down
1 change: 1 addition & 0 deletions src/rt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![allow(deprecated)]
#![allow(unused_assignments)]

extern crate generator;

Expand Down

0 comments on commit d4cd3ee

Please sign in to comment.