Tell std to use statics for TLS given mikros is single-threaded
This commit is contained in:
parent
9690e01be2
commit
c0c4a87103
@ -1,32 +1,21 @@
|
|||||||
use crate::{
|
|
||||||
ptr,
|
|
||||||
sync::atomic::{AtomicUsize, Ordering}
|
|
||||||
};
|
|
||||||
|
|
||||||
pub type Key = usize;
|
pub type Key = usize;
|
||||||
|
|
||||||
static mut TLS_SLOTS: [*mut u8; 64] = [ptr::null_mut(); 64];
|
|
||||||
static NEXT_TLS: AtomicUsize = AtomicUsize::new(1);
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn create(_dtor: Option<unsafe extern "C" fn(*mut u8)>) -> Key {
|
pub unsafe fn create(_dtor: Option<unsafe extern "C" fn(*mut u8)>) -> Key {
|
||||||
if NEXT_TLS.load(Ordering::Relaxed) == 65 {
|
panic!("should not be used on this target");
|
||||||
panic!("Out of TLS slots");
|
|
||||||
}
|
|
||||||
NEXT_TLS.fetch_add(1, Ordering::Relaxed)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn set(key: Key, value: *mut u8) {
|
pub unsafe fn set(_key: Key, _value: *mut u8) {
|
||||||
unsafe { TLS_SLOTS[key - 1] = value }
|
panic!("should not be used on this target");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn get(key: Key) -> *mut u8 {
|
pub unsafe fn get(_key: Key) -> *mut u8 {
|
||||||
unsafe { TLS_SLOTS[key - 1]}
|
panic!("should not be used on this target");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn destroy(_key: Key) {
|
pub unsafe fn destroy(_key: Key) {
|
||||||
// Ignore destructors for now
|
panic!("should not be used on this target");
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
// "static" is for single-threaded platforms where a global static is sufficient.
|
// "static" is for single-threaded platforms where a global static is sufficient.
|
||||||
|
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(any(all(target_family = "wasm", not(target_feature = "atomics")), target_os = "uefi"))] {
|
if #[cfg(any(all(target_family = "wasm", not(target_feature = "atomics")), target_os = "uefi", target_os = "mikros"))] {
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
mod static_local;
|
mod static_local;
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
|
Loading…
Reference in New Issue
Block a user