Skip to content

Commit f2ac4ef

Browse files
committed
std::thread::LocalKeyState: Add state Initializing
1 parent a209539 commit f2ac4ef

File tree

4 files changed

+319
-160
lines changed

4 files changed

+319
-160
lines changed

src/libstd/io/stdio.rs

+1
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ fn print_to<T>(args: fmt::Arguments,
676676
label: &str) where T: Write {
677677
let result = match local_s.state() {
678678
LocalKeyState::Uninitialized |
679+
LocalKeyState::Initializing |
679680
LocalKeyState::Destroyed => global_s().write_fmt(args),
680681
LocalKeyState::Valid => {
681682
local_s.with(|s| {

src/libstd/sys/unix/fast_thread_local.rs

-16
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,3 @@ pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern fn(*mut u8)) {
5959
// a more direct implementation.
6060
#[cfg(target_os = "fuchsia")]
6161
pub use sys_common::thread_local::register_dtor_fallback as register_dtor;
62-
63-
pub fn requires_move_before_drop() -> bool {
64-
// The macOS implementation of TLS apparently had an odd aspect to it
65-
// where the pointer we have may be overwritten while this destructor
66-
// is running. Specifically if a TLS destructor re-accesses TLS it may
67-
// trigger a re-initialization of all TLS variables, paving over at
68-
// least some destroyed ones with initial values.
69-
//
70-
// This means that if we drop a TLS value in place on macOS that we could
71-
// revert the value to its original state halfway through the
72-
// destructor, which would be bad!
73-
//
74-
// Hence, we use `ptr::read` on macOS (to move to a "safe" location)
75-
// instead of drop_in_place.
76-
cfg!(target_os = "macos")
77-
}

0 commit comments

Comments
 (0)