about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicole LeGare <legaren@immunant.com>2025-02-19 11:55:28 -0800
committerNicole L <dlegare.1001@gmail.com>2025-03-10 10:00:25 -0700
commit0b1a7ab3393e59f59a0d53e66cccb195dadc378e (patch)
treee44aaf5717e98f556337c3884a256601f210a973
parent5b941136f1dbceca775b8770014783dc98998e45 (diff)
downloadrust-0b1a7ab3393e59f59a0d53e66cccb195dadc378e.tar.gz
rust-0b1a7ab3393e59f59a0d53e66cccb195dadc378e.zip
Remove custom TLS implementation for Trusty targets
-rw-r--r--library/std/src/sys/thread_local/key/trusty.rs30
-rw-r--r--library/std/src/sys/thread_local/mod.rs11
2 files changed, 2 insertions, 39 deletions
diff --git a/library/std/src/sys/thread_local/key/trusty.rs b/library/std/src/sys/thread_local/key/trusty.rs
deleted file mode 100644
index 894091d2d81..00000000000
--- a/library/std/src/sys/thread_local/key/trusty.rs
+++ /dev/null
@@ -1,30 +0,0 @@
-use crate::ptr;
-
-pub type Key = usize;
-type Dtor = unsafe extern "C" fn(*mut u8);
-
-static mut STORAGE: crate::vec::Vec<(*mut u8, Option<Dtor>)> = Vec::new();
-
-#[inline]
-pub fn create(dtor: Option<Dtor>) -> Key {
-    unsafe {
-        #[allow(static_mut_refs)]
-        let key = STORAGE.len();
-        #[allow(static_mut_refs)]
-        STORAGE.push((ptr::null_mut(), dtor));
-        key
-    }
-}
-
-#[inline]
-pub unsafe fn set(key: Key, value: *mut u8) {
-    unsafe { STORAGE[key].0 = value };
-}
-
-#[inline]
-pub unsafe fn get(key: Key) -> *mut u8 {
-    unsafe { STORAGE[key].0 }
-}
-
-#[inline]
-pub fn destroy(_key: Key) {}
diff --git a/library/std/src/sys/thread_local/mod.rs b/library/std/src/sys/thread_local/mod.rs
index 827f464e860..1ff13154b7b 100644
--- a/library/std/src/sys/thread_local/mod.rs
+++ b/library/std/src/sys/thread_local/mod.rs
@@ -28,6 +28,7 @@ cfg_if::cfg_if! {
         all(target_family = "wasm", not(target_feature = "atomics")),
         target_os = "uefi",
         target_os = "zkvm",
+        target_os = "trusty",
     ))] {
         mod statik;
         pub use statik::{EagerStorage, LazyStorage, thread_local_inner};
@@ -91,6 +92,7 @@ pub(crate) mod guard {
             )),
             target_os = "uefi",
             target_os = "zkvm",
+            target_os = "trusty",
         ))] {
             pub(crate) fn enable() {
                 // FIXME: Right now there is no concept of "thread exit" on
@@ -170,15 +172,6 @@ pub(crate) mod key {
             pub(crate) use xous::destroy_tls;
             pub(super) use xous::{Key, get, set};
             use xous::{create, destroy};
-        } else if #[cfg(target_os = "trusty")] {
-            #[allow(unused_unsafe)]
-            mod racy;
-            #[cfg(test)]
-            mod tests;
-            mod trusty;
-            pub(super) use racy::LazyKey;
-            pub(super) use trusty::{Key, get, set};
-            use trusty::{create, destroy};
         }
     }
 }