From 319a9b0f71d21409858297357bc047fb7a6ba27f Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 6 Apr 2022 22:12:47 +0200 Subject: [PATCH] Move current_thread_unique_ptr to the only module that uses it. --- library/std/src/sys/unix/locks/futex.rs | 10 +++++++++- library/std/src/sys_common/thread_info.rs | 9 --------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/library/std/src/sys/unix/locks/futex.rs b/library/std/src/sys/unix/locks/futex.rs index f49fbda0d82..1df7b532546 100644 --- a/library/std/src/sys/unix/locks/futex.rs +++ b/library/std/src/sys/unix/locks/futex.rs @@ -4,7 +4,6 @@ use crate::sync::atomic::{ Ordering::{Acquire, Relaxed, Release}, }; use crate::sys::futex::{futex_wait, futex_wake, futex_wake_all}; -use crate::sys_common::thread_info::current_thread_unique_ptr; use crate::time::Duration; pub type MovableMutex = Mutex; @@ -248,3 +247,12 @@ impl ReentrantMutex { } } } + +/// Get an address that is unique per running thread. +/// +/// This can be used as a non-null usize-sized ID. +pub fn current_thread_unique_ptr() -> usize { + // Use a non-drop type to make sure it's still available during thread destruction. + thread_local! { static X: u8 = 0 } + X.with(|x| <*const _>::addr(x)) +} diff --git a/library/std/src/sys_common/thread_info.rs b/library/std/src/sys_common/thread_info.rs index b8f2e658214..38c9e50009a 100644 --- a/library/std/src/sys_common/thread_info.rs +++ b/library/std/src/sys_common/thread_info.rs @@ -30,15 +30,6 @@ impl ThreadInfo { } } -/// Get an address that is unique per running thread. -/// -/// This can be used as a non-null usize-sized ID. -pub fn current_thread_unique_ptr() -> usize { - // Use a non-drop type to make sure it's still available during thread destruction. - thread_local! { static X: u8 = 0 } - X.with(|x| <*const _>::addr(x)) -} - pub fn current_thread() -> Option { ThreadInfo::with(|info| info.thread.clone()) }