Remove custom TLS implementation for Trusty targets
This commit is contained in:
parent
5b941136f1
commit
0b1a7ab339
2 changed files with 2 additions and 39 deletions
|
@ -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) {}
|
|
@ -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};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue