diff options
Diffstat (limited to 'library/std/src/thread')
| -rw-r--r-- | library/std/src/thread/current.rs | 13 | ||||
| -rw-r--r-- | library/std/src/thread/local.rs | 8 | ||||
| -rw-r--r-- | library/std/src/thread/mod.rs | 14 |
3 files changed, 20 insertions, 15 deletions
diff --git a/library/std/src/thread/current.rs b/library/std/src/thread/current.rs index 5c879903526..7da1621da45 100644 --- a/library/std/src/thread/current.rs +++ b/library/std/src/thread/current.rs @@ -18,8 +18,8 @@ local_pointer! { pub(super) mod id { use super::*; - cfg_if::cfg_if! { - if #[cfg(target_thread_local)] { + cfg_select! { + target_thread_local => { use crate::cell::Cell; #[thread_local] @@ -34,7 +34,8 @@ pub(super) mod id { pub(super) fn set(id: ThreadId) { ID.set(Some(id)) } - } else if #[cfg(target_pointer_width = "16")] { + } + target_pointer_width = "16" => { local_pointer! { static ID0; static ID16; @@ -59,7 +60,8 @@ pub(super) mod id { ID32.set(ptr::without_provenance_mut((val >> 32) as usize)); ID48.set(ptr::without_provenance_mut((val >> 48) as usize)); } - } else if #[cfg(target_pointer_width = "32")] { + } + target_pointer_width = "32" => { local_pointer! { static ID0; static ID32; @@ -78,7 +80,8 @@ pub(super) mod id { ID0.set(ptr::without_provenance_mut(val as usize)); ID32.set(ptr::without_provenance_mut((val >> 32) as usize)); } - } else { + } + _ => { local_pointer! { static ID; } diff --git a/library/std/src/thread/local.rs b/library/std/src/thread/local.rs index 0ad014ccd3e..797feeb2bbb 100644 --- a/library/std/src/thread/local.rs +++ b/library/std/src/thread/local.rs @@ -8,8 +8,8 @@ use crate::fmt; /// A thread local storage (TLS) key which owns its contents. /// -/// This key uses the fastest possible implementation available to it for the -/// target platform. It is instantiated with the [`thread_local!`] macro and the +/// This key uses the fastest implementation available on the target platform. +/// It is instantiated with the [`thread_local!`] macro and the /// primary method is the [`with`] method, though there are helpers to make /// working with [`Cell`] types easier. /// @@ -24,10 +24,10 @@ use crate::fmt; /// [`with`]) within a thread, and values that implement [`Drop`] get /// destructed when a thread exits. Some platform-specific caveats apply, which /// are explained below. -/// Note that, should the destructor panics, the whole process will be [aborted]. +/// Note that if the destructor panics, the whole process will be [aborted]. /// /// A `LocalKey`'s initializer cannot recursively depend on itself. Using a -/// `LocalKey` in this way may cause panics, aborts or infinite recursion on +/// `LocalKey` in this way may cause panics, aborts, or infinite recursion on /// the first call to `with`. /// /// [aborted]: crate::process::abort diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index 292323d0118..b6059c28cec 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -1212,8 +1212,8 @@ impl ThreadId { panic!("failed to generate unique thread ID: bitspace exhausted") } - cfg_if::cfg_if! { - if #[cfg(target_has_atomic = "64")] { + cfg_select! { + target_has_atomic = "64" => { use crate::sync::atomic::{Atomic, AtomicU64}; static COUNTER: Atomic<u64> = AtomicU64::new(0); @@ -1229,7 +1229,8 @@ impl ThreadId { Err(id) => last = id, } } - } else { + } + _ => { use crate::sync::{Mutex, PoisonError}; static COUNTER: Mutex<u64> = Mutex::new(0); @@ -1318,8 +1319,8 @@ use thread_name_string::ThreadNameString; /// Note however that this also means that the name reported in pre-main functions /// will be incorrect, but that's just something we have to live with. pub(crate) mod main_thread { - cfg_if::cfg_if! { - if #[cfg(target_has_atomic = "64")] { + cfg_select! { + target_has_atomic = "64" => { use super::ThreadId; use crate::sync::atomic::{Atomic, AtomicU64}; use crate::sync::atomic::Ordering::Relaxed; @@ -1335,7 +1336,8 @@ pub(crate) mod main_thread { pub(crate) unsafe fn set(id: ThreadId) { MAIN.store(id.as_u64().get(), Relaxed) } - } else { + } + _ => { use super::ThreadId; use crate::mem::MaybeUninit; use crate::sync::atomic::{Atomic, AtomicBool}; |
