summaryrefslogtreecommitdiffstats
path: root/library/std/src/thread/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'library/std/src/thread/mod.rs')
-rw-r--r--library/std/src/thread/mod.rs35
1 files changed, 19 insertions, 16 deletions
diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs
index 13b845b25..f712c8727 100644
--- a/library/std/src/thread/mod.rs
+++ b/library/std/src/thread/mod.rs
@@ -193,20 +193,23 @@ pub use scoped::{scope, Scope, ScopedJoinHandle};
#[macro_use]
mod local;
-#[stable(feature = "rust1", since = "1.0.0")]
-pub use self::local::{AccessError, LocalKey};
-
-// Provide the type used by the thread_local! macro to access TLS keys. This
-// needs to be kept in sync with the macro itself (in `local.rs`).
-// There are three types: "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 elf linker. "static" is for single-threaded platforms where a global
-// static is sufficient.
-
-#[doc(hidden)]
-#[unstable(feature = "libstd_thread_internals", issue = "none")]
-pub use crate::sys::common::thread_local::Key as __LocalKeyInner;
+cfg_if::cfg_if! {
+ if #[cfg(test)] {
+ // Avoid duplicating the global state assoicated with thread-locals between this crate and
+ // realstd. Miri relies on this.
+ pub use realstd::thread::{local_impl, AccessError, LocalKey};
+ } else {
+ #[stable(feature = "rust1", since = "1.0.0")]
+ pub use self::local::{AccessError, LocalKey};
+
+ // Implementation details used by the thread_local!{} macro.
+ #[doc(hidden)]
+ #[unstable(feature = "thread_local_internals", issue = "none")]
+ pub mod local_impl {
+ pub use crate::sys::common::thread_local::{thread_local_inner, Key};
+ }
+ }
+}
////////////////////////////////////////////////////////////////////////////////
// Builder
@@ -494,7 +497,7 @@ impl Builder {
MaybeDangling(mem::MaybeUninit::new(x))
}
fn into_inner(self) -> T {
- // SAFETY: we are always initiailized.
+ // SAFETY: we are always initialized.
let ret = unsafe { self.0.assume_init_read() };
// Make sure we don't drop.
mem::forget(self);
@@ -503,7 +506,7 @@ impl Builder {
}
impl<T> Drop for MaybeDangling<T> {
fn drop(&mut self) {
- // SAFETY: we are always initiailized.
+ // SAFETY: we are always initialized.
unsafe { self.0.assume_init_drop() };
}
}