2018-08-28 04:40:08 +00:00
|
|
|
use super::abi::tls::{Key as AbiKey, Tls};
|
2018-08-28 04:33:26 +00:00
|
|
|
|
|
|
|
pub type Key = usize;
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
pub unsafe fn create(dtor: Option<unsafe extern "C" fn(*mut u8)>) -> Key {
|
2018-08-28 04:40:08 +00:00
|
|
|
Tls::create(dtor).as_usize()
|
2018-08-28 04:33:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
pub unsafe fn set(key: Key, value: *mut u8) {
|
2018-08-28 04:40:08 +00:00
|
|
|
Tls::set(AbiKey::from_usize(key), value)
|
2018-08-28 04:33:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
pub unsafe fn get(key: Key) -> *mut u8 {
|
2018-08-28 04:40:08 +00:00
|
|
|
Tls::get(AbiKey::from_usize(key))
|
2018-08-28 04:33:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
pub unsafe fn destroy(key: Key) {
|
2018-08-28 04:40:08 +00:00
|
|
|
Tls::destroy(AbiKey::from_usize(key))
|
2018-08-28 04:33:26 +00:00
|
|
|
}
|