diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-18 02:49:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-18 02:49:50 +0000 |
commit | 9835e2ae736235810b4ea1c162ca5e65c547e770 (patch) | |
tree | 3fcebf40ed70e581d776a8a4c65923e8ec20e026 /library/std/src/sys/common/thread_local/mod.rs | |
parent | Releasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff) | |
download | rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip |
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/std/src/sys/common/thread_local/mod.rs')
-rw-r--r-- | library/std/src/sys/common/thread_local/mod.rs | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/library/std/src/sys/common/thread_local/mod.rs b/library/std/src/sys/common/thread_local/mod.rs index 1fee84a04..77f645883 100644 --- a/library/std/src/sys/common/thread_local/mod.rs +++ b/library/std/src/sys/common/thread_local/mod.rs @@ -1,35 +1,29 @@ -//! The following module declarations are outside cfg_if because the internal -//! `__thread_local_internal` macro does not seem to be exported properly when using cfg_if #![unstable(feature = "thread_local_internals", reason = "should not be necessary", issue = "none")] -#[cfg(all(target_thread_local, not(all(target_family = "wasm", not(target_feature = "atomics")))))] -mod fast_local; -#[cfg(all( - not(target_thread_local), - not(all(target_family = "wasm", not(target_feature = "atomics"))) -))] -mod os_local; -#[cfg(all(target_family = "wasm", not(target_feature = "atomics")))] -mod static_local; +// There are three thread-local implementations: "static", "fast", "OS". +// The "OS" thread local key type is accessed via platform-specific API calls and is slow, while the +// "fast" key type is accessed via code generated via LLVM, where TLS keys are set up by the linker. +// "static" is for single-threaded platforms where a global static is sufficient. -#[cfg(not(test))] cfg_if::cfg_if! { if #[cfg(all(target_family = "wasm", not(target_feature = "atomics")))] { #[doc(hidden)] - pub use static_local::statik::Key; - } else if #[cfg(all(target_thread_local, not(all(target_family = "wasm", not(target_feature = "atomics")))))] { + mod static_local; #[doc(hidden)] - pub use fast_local::fast::Key; - } else if #[cfg(all(not(target_thread_local), not(all(target_family = "wasm", not(target_feature = "atomics")))))] { + pub use static_local::{Key, thread_local_inner}; + } else if #[cfg(target_thread_local)] { #[doc(hidden)] - pub use os_local::os::Key; + mod fast_local; + #[doc(hidden)] + pub use fast_local::{Key, thread_local_inner}; + } else { + #[doc(hidden)] + mod os_local; + #[doc(hidden)] + pub use os_local::{Key, thread_local_inner}; } } -#[doc(hidden)] -#[cfg(test)] -pub use realstd::thread::__LocalKeyInner as Key; - mod lazy { use crate::cell::UnsafeCell; use crate::hint; |