TlsKey is messy because it changes types between systems

This commit is contained in:
Oliver Schneider 2018-05-30 15:59:04 +02:00
parent 062be7c047
commit 1d9c56ddf4
2 changed files with 4 additions and 7 deletions

View File

@ -512,21 +512,18 @@ fn call_c_abi(
self.write_null(dest, dest_ty)?;
}
"pthread_key_delete" => {
// The conversion into TlsKey here is a little fishy, but should work as long as usize >= libc::pthread_key_t
let key = self.value_to_scalar(args[0])?.to_u64()? as TlsKey;
let key = self.value_to_scalar(args[0])?.to_bytes()?;
self.memory.delete_tls_key(key)?;
// Return success (0)
self.write_null(dest, dest_ty)?;
}
"pthread_getspecific" => {
// The conversion into TlsKey here is a little fishy, but should work as long as usize >= libc::pthread_key_t
let key = self.value_to_scalar(args[0])?.to_u64()? as TlsKey;
let key = self.value_to_scalar(args[0])?.to_bytes()?;
let ptr = self.memory.load_tls(key)?;
self.write_ptr(dest, ptr, dest_ty)?;
}
"pthread_setspecific" => {
// The conversion into TlsKey here is a little fishy, but should work as long as usize >= libc::pthread_key_t
let key = self.value_to_scalar(args[0])?.to_u64()? as TlsKey;
let key = self.value_to_scalar(args[0])?.to_bytes()?;
let new_ptr = self.into_ptr(args[1].value)?;
self.memory.store_tls(key, new_ptr)?;

View File

@ -277,7 +277,7 @@ pub struct Evaluator<'tcx> {
pub(crate) suspended: HashMap<DynamicLifetime, Vec<ValidationQuery<'tcx>>>,
}
pub type TlsKey = usize;
pub type TlsKey = u128;
#[derive(Copy, Clone, Debug)]
pub struct TlsEntry<'tcx> {