From 1d9c56ddf40fd43231c3caa167465167738ebfda Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Wed, 30 May 2018 15:59:04 +0200 Subject: [PATCH] TlsKey is messy because it changes types between systems --- src/fn_call.rs | 9 +++------ src/lib.rs | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/fn_call.rs b/src/fn_call.rs index 6a2255e5777..d1a483d2e80 100644 --- a/src/fn_call.rs +++ b/src/fn_call.rs @@ -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)?; diff --git a/src/lib.rs b/src/lib.rs index 079560c0ca9..6d7c0b05f80 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -277,7 +277,7 @@ pub struct Evaluator<'tcx> { pub(crate) suspended: HashMap>>, } -pub type TlsKey = usize; +pub type TlsKey = u128; #[derive(Copy, Clone, Debug)] pub struct TlsEntry<'tcx> {