Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove pre 1.36 backwards compatibility code #189

Merged
merged 1 commit into from
Nov 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions build.rs

This file was deleted.

9 changes: 0 additions & 9 deletions core/build.rs

This file was deleted.

1 change: 0 additions & 1 deletion core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
feature(thread_local, checked_duration_since)
)]

mod maybe_uninit;
mod parking_lot;
mod spinwait;
mod thread_parker;
Expand Down
41 changes: 0 additions & 41 deletions core/src/maybe_uninit.rs

This file was deleted.

3 changes: 1 addition & 2 deletions core/src/thread_parker/cloudabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.

use crate::maybe_uninit::MaybeUninit;
use cloudabi as abi;
use core::{
cell::Cell,
mem,
mem::{self, MaybeUninit},
sync::atomic::{AtomicU32, Ordering},
};
use std::{convert::TryFrom, thread, time::Instant};
Expand Down
4 changes: 2 additions & 2 deletions core/src/thread_parker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub trait UnparkHandleT {
}

cfg_if! {
if #[cfg(all(has_sized_atomics, any(target_os = "linux", target_os = "android")))] {
if #[cfg(any(target_os = "linux", target_os = "android"))] {
#[path = "linux.rs"]
mod imp;
} else if #[cfg(unix)] {
Expand All @@ -60,7 +60,7 @@ cfg_if! {
} else if #[cfg(windows)] {
#[path = "windows/mod.rs"]
mod imp;
} else if #[cfg(all(has_sized_atomics, target_os = "redox"))] {
} else if #[cfg(target_os = "redox")] {
#[path = "redox.rs"]
mod imp;
} else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] {
Expand Down
6 changes: 4 additions & 2 deletions core/src/thread_parker/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.

use crate::maybe_uninit::MaybeUninit;
use core::cell::{Cell, UnsafeCell};
#[cfg(any(target_os = "macos", target_os = "ios"))]
use core::ptr;
use core::{
cell::{Cell, UnsafeCell},
mem::MaybeUninit,
};
use libc;
use std::{
thread,
Expand Down
6 changes: 4 additions & 2 deletions core/src/thread_parker/windows/keyed_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.

use crate::maybe_uninit::MaybeUninit;
use core::{mem, ptr};
use core::{
mem::{self, MaybeUninit},
ptr,
};
use std::{
sync::atomic::{AtomicUsize, Ordering},
time::Instant,
Expand Down
19 changes: 5 additions & 14 deletions src/once.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,16 @@
// copied, modified, or distributed except according to those terms.

use crate::util::UncheckedOptionExt;
#[cfg(has_sized_atomics)]
use core::sync::atomic::AtomicU8;
#[cfg(not(has_sized_atomics))]
use core::sync::atomic::AtomicUsize as AtomicU8;
use core::{
fmt, mem,
sync::atomic::{fence, Ordering},
sync::atomic::{fence, AtomicU8, Ordering},
};
use parking_lot_core::{self, SpinWait, DEFAULT_PARK_TOKEN, DEFAULT_UNPARK_TOKEN};

#[cfg(has_sized_atomics)]
type U8 = u8;
#[cfg(not(has_sized_atomics))]
type U8 = usize;

const DONE_BIT: U8 = 1;
const POISON_BIT: U8 = 2;
const LOCKED_BIT: U8 = 4;
const PARKED_BIT: U8 = 8;
const DONE_BIT: u8 = 1;
const POISON_BIT: u8 = 2;
const LOCKED_BIT: u8 = 4;
const PARKED_BIT: u8 = 8;

/// Current state of a `Once`.
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
Expand Down
18 changes: 6 additions & 12 deletions src/raw_mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,14 @@
// copied, modified, or distributed except according to those terms.

use crate::{deadlock, util};
#[cfg(has_sized_atomics)]
use core::sync::atomic::AtomicU8;
#[cfg(not(has_sized_atomics))]
use core::sync::atomic::AtomicUsize as AtomicU8;
use core::{sync::atomic::Ordering, time::Duration};
use core::{
sync::atomic::{AtomicU8, Ordering},
time::Duration,
};
use lock_api::{GuardNoSend, RawMutex as RawMutex_};
use parking_lot_core::{self, ParkResult, SpinWait, UnparkResult, UnparkToken, DEFAULT_PARK_TOKEN};
use std::time::Instant;

#[cfg(has_sized_atomics)]
type U8 = u8;
#[cfg(not(has_sized_atomics))]
type U8 = usize;

// UnparkToken used to indicate that that the target thread should attempt to
// lock the mutex again as soon as it is unparked.
pub(crate) const TOKEN_NORMAL: UnparkToken = UnparkToken(0);
Expand All @@ -29,10 +23,10 @@ pub(crate) const TOKEN_NORMAL: UnparkToken = UnparkToken(0);
pub(crate) const TOKEN_HANDOFF: UnparkToken = UnparkToken(1);

/// This bit is set in the `state` of a `RawMutex` when that mutex is locked by some thread.
const LOCKED_BIT: U8 = 0b01;
const LOCKED_BIT: u8 = 0b01;
/// This bit is set in the `state` of a `RawMutex` just before parking a thread. A thread is being
/// parked if it wants to lock the mutex, but it is currently being held by some other thread.
const PARKED_BIT: U8 = 0b10;
const PARKED_BIT: u8 = 0b10;

/// Raw mutex type backed by the parking lot.
pub struct RawMutex {
Expand Down
7 changes: 1 addition & 6 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,5 @@ unsafe fn unreachable() -> ! {

#[inline]
pub fn to_deadline(timeout: Duration) -> Option<Instant> {
#[cfg(has_checked_instant)]
let deadline = Instant::now().checked_add(timeout);
#[cfg(not(has_checked_instant))]
let deadline = Some(Instant::now() + timeout);

deadline
Instant::now().checked_add(timeout)
}